Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • entomology
    Member
    • May 2011
    • 34

    #1

    how to get specific length sequence from a fasta file

    I'm not so familiar with perl, is there script can fetch specific length of sequence from a fasta file? many thanks!
  • maubp
    Peter (Biopython etc)
    • Jul 2009
    • 1544

    #2
    You mean loop over the records, outputting just those of a certain length? That should just be a couple of lines using BioPerl, Biopython, etc.

    If you're not familiar with Perl, what can you program in?

    Comment

    • entomology
      Member
      • May 2011
      • 34

      #3
      thanks, I'll try to learn basic perl first, parse with fasta is first step, maybe bioperl is more easy to handle.

      Comment

      • rexxi
        Member
        • Jun 2012
        • 20

        #4
        its name is bp_aacomp.pl, this script can count the aminoacids of a FASTA format file. This doesn't work good with multifasta file, because it takes count of all the aminoacids of the file. If you want to count the aminoacids of 1 sequence I would recomend you. the usage is really simple

        perl bp_aacomp.pl yourfile.fasta

        if you need to bp, you can try this LINK where the is another script.

        #!perl
        use strict;
        use warnings;
        use Carp;

        use Bio::SeqIO;
        use Getopt::Long;
        use Bio::SeqUtils;
        use Bio::Tools::IUPAC;

        my $table = new Bio::SeqUtils;
        my @BASES = $table->valid_aa(0);
        my %all = $table->valid_aa(2);
        my ($file,$format,$help) = ( undef, 'fasta');
        GetOptions(
        'i|in:s' => \$file,
        'f|format:s' => \$format,
        'h|help|?' => \$help,
        );

        my $USAGE = "usage: aacomp [-f format] filename\n\tdefault format is fasta\n";
        $file = shift unless $file;

        die $USAGE if $help;

        my $seqin;
        if( defined $file ) {
        print "Could not open file [$file]\n$USAGE" and exit unless -e $file;
        $seqin = new Bio::SeqIO(-format => $format,
        -file => $file);
        } else {
        $seqin = new Bio::SeqIO(-format => $format,
        -fh => \*STDIN);
        }

        my %composition;
        my $total;
        foreach my $base ( @BASES ) {
        $composition{$base} = 0;
        }
        while ( my $seq = $seqin->next_seq ) {
        if( $seq->alphabet ne 'protein' ) {
        confess("Must only provide amino acid sequences to aacomp...skipping this seq");
        next;
        }
        foreach my $base ( split(//,$seq->seq()) ) {
        $composition{uc $base}++;
        $total++;
        }
        }

        printf("%d aa\n",$total);
        printf("%5s %4s\n", 'aa', '#' );
        my $ct = 0;
        foreach my $base ( @BASES ) {
        printf(" %s %s %3d\n", $base, $all{$base}, $composition{$base} );
        $ct += $composition{$base};
        }
        printf( "%6s %s\n", '','-'x5);
        printf( "%6s %3d\n", '',$ct);


        __END__


        =head1 NAME

        bp_aacomp - amino acid composition of protein sequences

        =head1 SYNOPSIS

        bp_aacomp [-f/--format FORMAT] [-h/--help] filename
        or
        bp_aacomp [-f/--format FORMAT] < filename
        or
        bp_aacomp [-f/--format FORMAT] -i filename

        =head1 DESCRIPTION

        This scripts prints out the count of amino acids over all protein
        sequences from the input file.

        =head1 OPTIONS

        The default sequence format is fasta.

        The sequence input can be provided using any of the three methods:

        =over 3

        =item unnamed argument

        bp_aacomp filename

        =item named argument

        bp_aacomp -i filename

        =item standard input

        bp_aacomp < filename

        =back

        =head1 FEEDBACK

        =head2 Mailing Lists

        User feedback is an integral part of the evolution of this and other
        Bioperl modules. Send your comments and suggestions preferably to
        the Bioperl mailing list. Your participation is much appreciated.

        [email protected] - General discussion
        http://bioperl.org/wiki/Mailing_lists - About the mailing lists

        =head2 Reporting Bugs

        Report bugs to the Bioperl bug tracking system to help us keep track
        of the bugs and their resolution. Bug reports can be submitted via the
        web:



        =head1 AUTHOR - Jason Stajich

        Email [email protected]

        =head1 HISTORY

        Based on aacomp.c from an old version of EMBOSS

        =cut

        Comment

        • adaptivegenome
          Super Moderator
          • Nov 2009
          • 436

          #5
          Samtools will do this if you just want a specific sequence from a Fasta file.

          Comment

          • entomology
            Member
            • May 2011
            • 34

            #6
            Thank you all the same!

            Comment

            Latest Articles

            Collapse

            • SEQadmin2
              Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
              by SEQadmin2



              Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

              Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
              ...
              10-14-2026, 09:55 AM
            • SEQadmin2
              New Genomics Technologies Take Aim at Long-Standing Limits
              by SEQadmin2


              Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.

              We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing
              ...
              09-28-2026, 10:25 AM

            ad_right_rmr

            Collapse

            News

            Collapse

            Topics Statistics Last Post
            Started by SEQadmin2, Yesterday, 11:13 AM
            0 responses
            19 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, Yesterday, 10:48 AM
            0 responses
            18 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 10-15-2026, 10:52 AM
            0 responses
            36 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 10-14-2026, 05:39 AM
            0 responses
            42 views
            0 reactions
            Last Post SEQadmin2  
            Working...