Trim fasta.pl

From RAJ INFO
Revision as of 15:25, 25 December 2009 by Raj (talk | contribs)
Jump to navigation Jump to search

<syntax>


  1. ! /usr/bin/perl -w
  2. *************************************************************
  3. This Programme does the following in sequence
  4. -> Parses a multi fasta
  5. -> Removes the sequence if they have <50bp and of 'N'
  6. -> Capture the results
  1. Author : Rajkumar (itc@rajkumar.in)
  2. Release: DEC 2009
  3. *************************************************************
  1. Libraries

use strict; use Bio::Perl; use Bio::SeqIO;

  1. Variables

my $path = "/home/raj/bio"; my $multifasta = "$path/euca/data/globulus/globulus_est.fa";

  1. making several Fasta files of GDNA

my $in = Bio::SeqIO->new(-file => "$multifasta", -format => 'Fasta'); my $identifier; my $sequence;

while ( my $seq = $in->next_seq() ) { $identifier = $seq->id;

 		$sequence = $seq->seq;

my ($fasta) = $_; $fasta = ">$identifier\n$sequence\n";

my $count_seq = length($sequence); my $count_N = ($sequence =~ tr/N//);

 		my $math = $count_seq * 0.2;
 		

$sequence =~ s/-/N/; if ($count_seq < 50){ next; } if ($count_N > $math){ next; }

print $identifier."\n";

}

  1. END

</syntax>