Trim seq: Difference between revisions

From RAJ INFO
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 4: Line 4:
# This Programme does the following in sequence
# This Programme does the following in sequence
# -> Parses a multi fasta
# -> Parses a multi fasta
# -> Removes the sequences that has less than 250 bases in size
# -> Removes the sequence if they have >20% of N
# -> Removes the sequence if they have >20% of N
# -> Capture the results
# -> Capture the results
Line 37: Line 36:
my $count_N = ($sequence =~ tr/N//);
my $count_N = ($sequence =~ tr/N//);
   my $math = $count_seq * 0.2;
   my $math = $count_seq * 0.2;
 
if ($count_seq > 250){ next; }
if ($count_seq < 300){ next; }
if ($count_N > $math){ next; }
if ($count_N > $math){ next; }


Line 45: Line 44:
}
}


# END




# END
</pre>
</pre>

Revision as of 14:34, 1 November 2009

#! /usr/bin/perl -w
# *************************************************************
# This Programme does the following in sequence
# -> Parses a multi fasta
# -> Removes the sequence if they have >20% of N
# -> Capture the results

# Author: Rajkumar (itc@rajkumar.in)

# *************************************************************

# Libraries
	use strict;
	use Bio::Perl;
	use Bio::SeqIO;

# Variables
	my $path = "/home/raj/bio";
	my $multifasta  = "$path/tobacco/data/singlet.fa";
	
# 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;
		
		if ($count_seq < 300){ next; }
		if ($count_N > $math){ next; }

		print $fasta;
	
	}

# END