User Tools

Site Tools


findbestfromcogs.pl

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

findbestfromcogs.pl [2018/01/06 09:22] (current)
hyjeong created
Line 1: Line 1:
 +====== 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