How void function call input variables from file?
조회 수: 1 (최근 30일)
이전 댓글 표시
I'm new to MATLAB and i have some probable simple problem.
I have some matlab script with void function
PredPPI = (Protein1,Protein2) in h1 line.
It use protein sequence (VIKNADMSEEMQQDSVECATQALEKYNIEKDIAAHIKKEFDK- like this) as input in matlab command window, for Protein1 and Protein2 in this format:
PredPPI = ('VIKNADMSEEMQQDSVECATQALEKYNIEKDIAAHIKKEFDK','MDNMSITNTPTSNDACLSIVHSLMCHRQGGESETF')
So I need to put every time this sequences for protein pairs to get some result.
I have 100 000 of this pairs....
So is it possible that Protein1 be read form file where I put every of this sequences in new line like this:
Protein1.txt
AIESLVKKLKEKKDELDSLIT
DMSEEMQQDSVECATQALEKYNIEKDIAAH
SITNTPTSNDACLSIVHSLMCHRQGGE
Protein2.txt
YNPTWHCIVGR
DMSEEMQQDSVECATQALEKYNIEKDIA
DACLSIVHSLMCHRQGGESETFAKRAIESLVKKLKEK
So when i call function input is FIRST line (protein sequence) from file Protein1.txt and first line from Protein2.txt, then when function finish, run next pair in second lines, then third then n-th to end of files. Or some similar solution so i dont need to manual input this long sequences every time...
Thanks in ADVANCE!!!
댓글 수: 2
답변 (2개)
Walter Roberson
2015년 6월 2일
pfid1 = fopen('protein1.txt');
pfid2 = fopen('protein2.txt');
while true
prot1 = fgetl(pfid1);
if ~ischar(prot1); break; end %end of file
prot2 = fgetl(pfid2);
if ~ischar(prot2); break; end %end of file
PredPPI(prot1, prot2);
end
fclose(pfid1);
fclose(pfid2);
Question, though: what do you want to do with the output? Your function does not return any result, but it probably displays something. Do you need the displayed output saved? If you do, then before the "while true" add the line
diary('YourOutputFile.txt'); %use suitable name
and after the "end" of the "while" add
diary off
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Genomics and Next Generation Sequencing에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!