User Tools

Site Tools


Sidebar

This is the sidebar. Without it, the main text is too wide!

findbestfromcogs.pl

findBestCOGs.pl

written by Haeyoung Jeong

#!/usr/bin/perl
#

while (<>) {
    chomp;
    my @data = split /,/, $_;
    push @{$perQuery{$data[0]}}, $_;
    $query{$data[0]} = '';
}

foreach (sort keys %query) {
    if (scalar @{$perQuery{$_}} == 1) {
        print $perQuery{$_}->[0], ',none', "\n" if $perQuery{$_}->[0] =~ /,\-1$/;
        print $perQuery{$_}->[0], ',sinlge', "\n" if $perQuery{$_}->[0] =~ /COG\d{4}$/;
    } else { # multiple COGs assigned per a single query
        my @sorted = ();
        @sorted = map  { $_->[0] }
                  sort { $b->[5] <=> $a->[5] }
                  map { [ $_, (split /,/) ] }
                  @{$perQuery{$_}};
        print $sorted[0], ',multi', "\n";
    }
}
findbestfromcogs.pl.txt · Last modified: 2018/01/06 09:22 by hyjeong