Trim multifasta.pl: Difference between revisions
Jump to navigation
Jump to search
Created page with 'Category: Bioinformatics <source lang=perl> #! /usr/bin/perl -w # ************************************************************* # This Programme does the following in seque…' |
No edit summary |
||
| Line 3: | Line 3: | ||
<source lang=perl> | <source lang=perl> | ||
#! /usr/bin/perl -w | #! /usr/bin/perl -w | ||
# ************************************************************* | # ************************************************************* | ||
# This Programme does the following in sequence | # This Programme does the following in sequence | ||
# -> | # -> Parses a multi fasta | ||
# -> | # -> Removes the sequence if they have <50bp and of 'N' | ||
# -> Capured as individual files. | |||
# Author : Rajkumar (itc@rajkumar.in) | # Author : Rajkumar (itc@rajkumar.in) | ||
# Release: JUL 2009 | # Release: JUL 2009 | ||
| Line 16: | Line 16: | ||
use Bio::Perl; | use Bio::Perl; | ||
use Bio::SeqIO; | use Bio::SeqIO; | ||
# Variables | # Variables | ||
my $path | my $path = "/home/raj/bio"; | ||
my $path1 | my $path1 = "$path/user/raja"; | ||
my $path2 | my $path2 = "$path1/blast/BES-NR"; | ||
my $multifasta | my $multifasta = "$path2/BES.fa"; | ||
my $ | my $resdir = "$path2/multifasta"; | ||
# Getting the Grip of folders | # Getting the Grip of folders | ||
if (-e $ | if (-e $resdir) {`rm -fr $resdir`;} | ||
if (! -e $ | if (! -e $resdir) {`mkdir $resdir`;} | ||
# making several Fasta files of GDNA | |||
my $in = Bio::SeqIO->new(-file => "$multifasta", -format => 'Fasta'); | |||
my $identifier; | |||
my $sequence; | |||
my $ | while ( my $seq = $in->next_seq() ) { | ||
$identifier = $seq->id; | |||
$sequence = $seq->seq; | |||
#Trim the identifier | |||
$identifier =~ s/_Size:[0-9]+bp//g; | |||
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; } | |||
open (FASTA, ">".$resdir."/".$identifier.".fa"); | |||
print FASTA $fasta; | |||
close FASTA; | |||
# print "$identifier\t$count_seq\n"; | |||
} | |||
# END | # END | ||
</source> | </source> | ||
Latest revision as of 11:28, 16 July 2010
#! /usr/bin/perl -w
# *************************************************************
# This Programme does the following in sequence
# -> Parses a multi fasta
# -> Removes the sequence if they have <50bp and of 'N'
# -> Capured as individual files.
# Author : Rajkumar (itc@rajkumar.in)
# Release: JUL 2009
# *************************************************************
# Libraries
use strict;
use Bio::Perl;
use Bio::SeqIO;
# Variables
my $path = "/home/raj/bio";
my $path1 = "$path/user/raja";
my $path2 = "$path1/blast/BES-NR";
my $multifasta = "$path2/BES.fa";
my $resdir = "$path2/multifasta";
# Getting the Grip of folders
if (-e $resdir) {`rm -fr $resdir`;}
if (! -e $resdir) {`mkdir $resdir`;}
# 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;
#Trim the identifier
$identifier =~ s/_Size:[0-9]+bp//g;
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; }
open (FASTA, ">".$resdir."/".$identifier.".fa");
print FASTA $fasta;
close FASTA;
# print "$identifier\t$count_seq\n";
}
# END