Trim.pl

From Augix' Wiki

Jump to: navigation, search
#!/usr/bin/perl -w
use strict;
my $adaptor="UCGUAUGCCGUCUUCUGCUUGU";#22nt  
$adaptor=~tr/U/T/;
my $filein=$ARGV[0];
my $fileout="trimed_".$filein;
open OUT,">$fileout";
#my %trimed;
#my @unable_trim;
open IN,$filein;
LABLE:while(<IN>)
{
        chomp $_;#raw sequece 36nt
        my($raw1,$count)=split("\t",$_);
        my $raw=substr($raw1,0,35);
        if($raw=~/^[ATGC]+$/)
        {
            for(my $i=22;$i>=1;$i--)
            {
                my $seq=substr($adaptor,0,$i);
                if($raw=~/$seq/)
                {
                    my $pos=rindex($raw,$seq);
                    my $trimed=substr($raw,0,$pos);
                #$trimed{$trimed}=$count;
                    if(length($trimed)>=14)
                    {
                        print OUT join("\t",$trimed,$count),"\n";
                        goto LABLE;
                    }
                }
 
            }
        }
}
 
#foreach(sort{$trimed{$b}<=>$trimed{$a}}keys %trimed)
#{
 #   print OUT join("\t",$_,$trimed{$_}),"\n";
#}
 
 #print scalar(@unable_trim),"\n";
Personal tools