File: classificationQualityFilter.pl

package info (click to toggle)
rtax 0.984-8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 316 kB
  • sloc: perl: 1,123; sh: 203; makefile: 2
file content (51 lines) | stat: -rwxr-xr-x 1,675 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/perl

my $countThreshold               = $ARGV[0];
my $localMinProportionThreshold  = $ARGV[1];
my $globalMinProportionThreshold = $ARGV[2];

while (<STDIN>) {
    chomp;
    my ( $id, $bestPcid, @taxonomyEntries ) = split /\t/;

    if ( $taxonomyEntries[0] eq "NOPRIMER" ) {
        print "$id\t\tNOPRIMER\n";
    }
    elsif ( $taxonomyEntries[0] eq "NOHIT" ) {
        print "$id\t\tNOHIT\n";
    }
    elsif ( $taxonomyEntries[0] eq "NOMATEPAIR" ) {
        print "$id\t\tNOMATEPAIR\n";
    }
	elsif ( $taxonomyEntries[0] =~ /TOOMANYHITS/ ) {
	    print "$id\t\tTOOMANYHITS\n";
	}
    else {
        my @newTaxonomyEntries = ();
        for my $entry (@taxonomyEntries) {

            my (
                $label,               $numChildren,              $count,
                $localMinProportion,  $localMaxProportion,       $globalMinProportion,
                $globalMaxProportion, $alternateLocalProportion, $alternateGlobalProportion
            ) = split /;/, $entry;

            if (   $count >= $countThreshold
                && $localMinProportion >= $localMinProportionThreshold
                && $globalMinProportion >= $globalMinProportionThreshold )
            {
                push @newTaxonomyEntries, $entry;
            }
            else { last; }
        }
        #if ( @newTaxonomyEntries == 0 ) {
        #    push @newTaxonomyEntries, "Root";
        #}

		# if the trailing entries of the filtered taxonomy string are "SKIP", strip them
		while(substr(@newTaxonomyEntries[$#newTaxonomyEntries],0,4) eq "SKIP") { pop @newTaxonomyEntries; }

        print "$id\t$bestPcid\t" . ( join "\t", @newTaxonomyEntries ) . "\n";
    }

}