Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: Conditionally Substituting multi-line string with single string

by gone2015 (Deacon)
on Jan 15, 2009 at 23:27 UTC ( [id://736705]=note: print w/replies, xml ) Need Help??


in reply to Re: Conditionally Substituting multi-line string with single string
in thread Conditionally Substituting multi-line string with single string

Which might be something along the lines of:

my $flag = 0 ; my $scaffold ; my $enumerator ; while (my $fastaline=<FILE>) { if ($fastaline=~ m/^>(\S*)/) { $scaffold = $1 ; $enumerator = 1 ; $flag = 1 ; } elsif ($fastaline =~ m/[ACGT]/) { if ($flag) { print WORKFILE ">$scaffold.$enumerator\n" ; $enumerator++ ; $flag = 0 ; } ; print WORKFILE $fastaline ; } else { $flag = 1 ; } ; } ;
NB: this is not checking that the input is well formed: (a) it accepts any line that contains at least one [ACGT] as being a line to keep; (b) it does not check that the lines being dropped are all N; (c) it does not check the exact form of >scaffold lines; (d) it does not check that at least one ACGT line follows each >scaffold line; ... If the input is 100% trusted, that's fine... (if 100% trustworthy input isn't an oxymoron).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://736705]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-25 19:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found