This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Perl script for discarding sequences less than 200 nucleotides before running CPC in rnaseq analysis

Ii want the perl script to discard sequences less than 200 nts from fasta file to run CPC

rna-seq perl

1 answer

I hope this below script works...just save and run with script name followed by fasta file and trim_length (integer)

#!/usr/bin/perl
use strict;
use warnings;

my $minlen = shift or die "Error: `minlen` parameter not provided\n";
{
    local $/=">";
    while(<>) {
        chomp;
        next unless /\w/;
        s/>$//gs;
        my @chunk = split /\n/;
        my $header = shift @chunk;
        my $seqlen = length join "", @chunk;
        print ">$_" if($seqlen >= $minlen);
    }
    local $/="\n";
}

Log in to answer this question.