File: annotate_chrysalis_welds_with_iworm_names.pl

package info (click to toggle)
trinityrnaseq 2.11.0%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 417,528 kB
  • sloc: perl: 48,420; cpp: 17,749; java: 12,695; python: 3,124; sh: 1,030; ansic: 983; makefile: 688; xml: 62
file content (48 lines) | stat: -rwxr-xr-x 1,175 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
#!/usr/bin/env perl

use strict;
use warnings;

my $usage = "\n\n\tusage: $0 iworm.fasta iworm_cluster_welds_graph.txt\n\n";

my $iworm_fa = $ARGV[0] or die $usage;
my $iworm_cluster_welds_file = $ARGV[1] or die $usage;

 main: {


     my %counter_to_iworm;
     
     {
         my $counter = 0;
         open(my $fh, $iworm_fa) or die "Error, cannot open $iworm_fa file";
         while (<$fh>) {
             if (/^>(\S+)/) {
                 $counter_to_iworm{$counter} = $1;
                 $counter++;
             }
         }
         close $fh;
     }

     open(my $fh, $iworm_cluster_welds_file) or die "Error, cannot open file: $iworm_cluster_welds_file";
     while(<$fh>) {
         chomp;
         my ($idx_A, $ptr, $idx_B, @rest) = split(/\s+/);
         my $iworm_A = $counter_to_iworm{$idx_A};

         if (! defined $iworm_A) { die "Error, no iworm acc for index: $idx_A"; }
         
         my $iworm_B = $counter_to_iworm{$idx_B};

         if (! defined $iworm_B) { die "Error, no iworm acc for index: $idx_B"; }
         
         print join(" ", $idx_A, $iworm_A, $ptr, $idx_B, $iworm_B, @rest) . "\n";
     }
     close $fh;


}

exit(0);