Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: simple perl script to trim a FASTA file

by BrowserUk (Pope)
on Apr 08, 2010 at 23:01 UTC ( #833659=note: print w/ replies, xml ) Need Help??


in reply to simple perl script to trim a FASTA file

Generally, FASTA files contain multiple sequence lines (wrapped at n? chars), per header line, which means your example could be misleading. If that is the case, then something like this may be needed:

#! perl -slw use strict; my( $x, $y ) = ( 3, 5 ); while( <DATA> ) { chomp; print ">$_"; local $/ = '>'; $_ = <DATA>; chomp; tr[\n][]d; print for unpack '(A36)*', substr $_, $x, length() - $x - $y; } __DATA__ >HWI-EAS158_40_3_1_46_535 GTGAATGCGTGATACAGGAATGTTCGTTGTGACCAT >HWI-EAS158_40_3_1_47_579 AAAGTGAATGCGTGATACAGGAATGTTCGTTGTGAC AAAGTGAATGCGTGATACAGGAATGTTCGTTGTGAC AAAGTGAATGCGTGATACAGGAATGTTCGTTGTGAC AAAGTGAATGCGTGATACAGGAATGTTCGTTGTGAC >HWI-EAS158_40_3_1_46_731 GTGTCATGCGTGATACAGGAATGTTCGTTGTGAAAA GTGTCATGCGTGATACAGGAATGTTCGTTGTGAAAA GTGTCATGCGTGATACAGGAATGTTCGTTGTGAAAA

Produces:

c:\test>junk46 >>HWI-EAS158_40_3_1_46_535 AATGCGTGATACAGGAATGTTCGTTGTG >HWI-EAS158_40_3_1_47_579 GTGAATGCGTGATACAGGAATGTTCGTTGTGACAAA GTGAATGCGTGATACAGGAATGTTCGTTGTGACAAA GTGAATGCGTGATACAGGAATGTTCGTTGTGACAAA GTGAATGCGTGATACAGGAATGTTCGTT >HWI-EAS158_40_3_1_46_731 TCATGCGTGATACAGGAATGTTCGTTGTGAAAAGTG TCATGCGTGATACAGGAATGTTCGTTGTGAAAAGTG TCATGCGTGATACAGGAATGTTCGTTGT

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re: simple perl script to trim a FASTA file
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (11)
As of 2014-07-30 03:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (229 votes), past polls