Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

rename FASTA

by naka (Initiate)
on Sep 19, 2012 at 14:39 UTC ( #994470=perlquestion: print w/ replies, xml ) Need Help??
naka has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I have never made a script in my life. The ploblem is how to change the fasta names like this input file:

>Glyma04g14800|Glyma04g14800.3

MMLETVAAVPGMVAGMLLHCKSLRRFEHSGGWIKALLEEAENERMHLMTFMEVAKPKWYE

>Glyma05g24460|Glyma05g24460.1

SNVSIDLTKHHVPKNFLDKVAYRTVKLLRIPTDLFFKRRYGCRAMMLETVAAVPGMVGGM

in this output file (change original names to numbers in ascending order, starting with 1):

>1

MMLETVAAVPGMVAGMLLHCKSLRRFEHSGGWIKALLEEAENERMHLMTFMEVAKPKWYE

>2

SNVSIDLTKHHVPKNFLDKVAYRTVKLLRIPTDLFFKRRYGCRAMMLETVAAVPGMVGGM

I'm so grateful for helping. Regards, Naka

Comment on rename FASTA
Re: rename FASTA
by toolic (Bishop) on Sep 19, 2012 at 14:45 UTC
    I have never made a script in my life.
    If you are interested in writing your own script, read perlintro and give it a try. If you have problems, post back here, showing your code and asking specific questions. See also Writeup Formatting Tips
Re: rename FASTA
by Cristoforo (Deacon) on Sep 19, 2012 at 22:10 UTC
    Using Bio::SeqIO, you can do something like this:
    #!/usr/bin/perl use strict; use warnings; use Bio::SeqIO; my $in = Bio::SeqIO->new( -file => "fasta_junk.txt" , -format => 'fasta'); my $out = Bio::SeqIO->new( -file => '>o33.txt',#note the leading '>' -format => 'fasta'); my $i; while ( my $seq = $in->next_seq() ) { $seq->display_id(++$i); # set 'id' equal to 1, 2, ... $out->write_seq($seq); } __END__ *** fasta_junk.txt >GJKKTUG01DYDGC GGGTATTCCTTCTCCACCTTGCAGCTAACATCAGTGTTTCGTCTACTCAAGCACGCCAAC ACGCCCTAGAGCGCCCTGTCCAGGGGATGGCAACCAACTCTGACCCTGCAAGTGCAGCAG ACATGAGGAATACAAACTACAATCTTTTACTTGATGATGCAATGCCGGACAAACTCTAGA >F0Z7V0F01EDB3V AAGGCGAGNGGTATCACGCAGTAAGTTACGGTTTTCGGGTAACGCGTCNGNGGNACTAAC CCACGGNGGGTAACCCGTCNCTACCGGTATAGGACTAAGGTTACCGGAACGTCGTGGGGT ACCCCCCGGACGGGGACCGTCCCCTCATANAGTCAACNGTNTGAGATGGACTAACTCAAA CCTAGTTTCAAGTACTATTTAACTTACTTACGTTACCCGTAATTTCGGCGTTTAGAGGCG *** o33.txt >1 GGGTATTCCTTCTCCACCTTGCAGCTAACATCAGTGTTTCGTCTACTCAAGCACGCCAAC ACGCCCTAGAGCGCCCTGTCCAGGGGATGGCAACCAACTCTGACCCTGCAAGTGCAGCAG ACATGAGGAATACAAACTACAATCTTTTACTTGATGATGCAATGCCGGACAAACTCTAGA >2 AAGGCGAGNGGTATCACGCAGTAAGTTACGGTTTTCGGGTAACGCGTCNGNGGNACTAAC CCACGGNGGGTAACCCGTCNCTACCGGTATAGGACTAAGGTTACCGGAACGTCGTGGGGT ACCCCCCGGACGGGGACCGTCCCCTCATANAGTCAACNGTNTGAGATGGACTAACTCAAA CCTAGTTTCAAGTACTATTTAACTTACTTACGTTACCCGTAATTTCGGCGTTTAGAGGCG
      Thank you very much. I'll try to lerning perl language. Regards

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://994470]
Approved by toolic
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: (5)
As of 2015-07-04 04:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls