Take input and use it in a function
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
Geoff Hayes
2015년 1월 6일
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
Stephen23
2015년 1월 6일
It might be a good time for the OP to read some documentation:
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Biological and Health Sciences에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!