| |||||||||||
| |||||||||||
problem in do until loop Posted by naveen (naveen), 30 January 2008 ID ACA10_ARATH Reviewed; 1069 AA.AC Q9SZR1; Q9M0D3; suppose the above lines are in a file ID1 .pl we want to write a program for the retrieval of only id number(ID ACA10_ARATH) here what we are trying to do is find the position of id and then we want to run a do until loop which will print the text till a white space is reached but the until loop is not working it is only printing the first letter that is A. here we do $pos=$pos+5 because the id number starts from the 5th position. $swissprotfilename="ID1.pl"; unless(open("filename",$swissprotfilename)) { print "cannot open the file"; exit; } @protein=<filename>; close "filename"; $protein=join(' ',@protein); print $protein; print "enter d motif"; $motif=<STDIN>; chomp $motif; if($protein=~/$motif/){ print "id is present at";} $pos=index($protein,"$motif"); print "$pos\n"; $pos1=$pos+5; @protein1=split('',$protein); print $pos1; #problem in the loop do{ print $protein1[$pos1]; $pos1=$pos1+1; }until ( $protein [$pos1]==' '); Posted by admin (Graham Ellis), 30 January 2008 I think the end of your condition - the vital thing I need to see to answer you - is missing .... can you complete that code for us?Thanks! Posted by KevinAD (KevinAD), 30 January 2008 what is the input $motif?Also: please don't ignore the other thread you started. Feedback from you is important. Posted by naveen (naveen), 31 January 2008 sir input motif is IDPosted by KevinAD (KevinAD), 31 January 2008 on 01/31/08 at 06:55:01, naveen wrote:
You mean to say you literally enter "ID" as the input? Then why are you searching for the position of "ID"? Its at the beginning of the line as far as I can tell from what little data you have posted. Anyway, this is wrong: do{ print $protein1[$pos1]; $pos1=$pos1+1; }until ( $protein [$pos1]==' '); you have $protein instead of $protein1 in the until() condition so it will just loop forever. If you had used "strict" you would have caught this error. Should be: do{ print $protein1[$pos1]; } until ( $protein1[++$pos1] eq ' '); Posted by naveen (naveen), 31 January 2008 thank you sir for your reply.ill try run this code. This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |