Take input and use it in a function

1 visualización (últimos 30 días)
Ahmad
Ahmad el 5 de En. de 2015
Respondida: Ahmad el 6 de En. de 2015
I''m trying to write a program that can analyze protein relationship. I'm trying to make the user input the accession number of the protein, then save it in a variable, then load the sequence using the getgenpept function, but it doesn't seem to work! (Input AAA69808, NP_989750)
protein1=input('NCBI accession number of the first protein: ', 's');
protein2=input('NCBI accession number of the second protein: ', 's');
seq1 = getgenpept('protein1','SequenceOnly',true);
seq2 = getgenpept('protein2','SequenceOnly',true);
However, doing the folloiwng in MATLAB works fine:
human = getgenpept('AAA69808','SequenceOnly',true);
chicken = getgenpept('NP_989750','SequenceOnly',true);

Respuesta aceptada

Geoff Hayes
Geoff Hayes el 6 de En. de 2015
Ahmad - please clarify what you mean by it doesn't seem to work. Are you observing an error or are you not getting the correct/desired results?
If I look at the documentation for getgenpept, one of the examples is
Seq = getgenpept('AAA59174')
and it produces some result. You have even shown that something like
human = getgenpept('AAA69808','SequenceOnly',true);
chicken = getgenpept('NP_989750','SequenceOnly',true);
works too. So what is different between the above two statements and your code that gets the input from the user? Note what you are doing
protein1=input('NCBI accession number of the first protein: ', 's');
protein2=input('NCBI accession number of the second protein: ', 's');
protein1 and protein2 are variables of data type char (so are string variables). With your input example this means that
protein1 == 'AAA69808'
protein2 == 'NP_989750'
Now since these are string variables and the first input to the getgenpept is a string variable, there is no need to wrap these variables in quotes like
seq1 = getgenpept('protein1','SequenceOnly',true);
seq2 = getgenpept('protein2','SequenceOnly',true);
because if you do, then what you are really passing this function are strings representing the variable name of protein1 or protein2 and not the value of the variable.
Remove the single quotes and change these two lines to
seq1 = getgenpept(protein1,'SequenceOnly',true);
seq2 = getgenpept(protein2,'SequenceOnly',true);

Más respuestas (1)

Ahmad
Ahmad el 6 de En. de 2015
Thank you so much

Categorías

Más información sobre Genomics and Next Generation Sequencing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by