How void function call input variables from file?
1 view (last 30 days)
Show older comments
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 Comments
Jan
on 2 Jun 2015
I do not understand the question. Please take the time to rephrase it more clearly.
Answers (2)
Walter Roberson
on 2 Jun 2015
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 Comments
See Also
Categories
Find more on Genomics and Next Generation Sequencing 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!