Take input and use it in a function
2 views (last 30 days)
Show older comments
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);
0 Comments
Accepted Answer
Geoff Hayes
on 6 Jan 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?
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);
1 Comment
Stephen23
on 6 Jan 2015
It might be a good time for the OP to read some documentation:
More Answers (1)
See Also
Categories
Find more on Biological and Health Sciences in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!