-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcog_matchup.pl
More file actions
63 lines (63 loc) · 2.01 KB
/
Copy pathcog_matchup.pl
File metadata and controls
63 lines (63 loc) · 2.01 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/perl -w
#################################
### Jennifer Meneghin ###
### March 31, 2009 ###
### Updated August 4, 2010 ###
#################################
#---------------------------------------------------------------------------------------------------------------------------
#Deal with passed parameters
#---------------------------------------------------------------------------------------------------------------------------
#If no arguments are passed, show usage message and exit program.
if ($#ARGV == -1) {
print "COG MATCHUP\n";
print "Jennifer Meneghin\n";
print "March 31, 2009\n";
print "Updated August 4, 2010\n\n";
print "Usage: cog_matchup.pl <blast best file> <matchup file>\n\n";
exit;
}
$in_file = $ARGV[0];
if (@ARGV > 1) {
$cog_file = $ARGV[1];
}
unless ( open(IN, "$in_file") ) {
print "Got a bad input file: $in_file\n";
exit;
}
unless ( open(COG, "$cog_file") ) {
print "Got a bad COG matchup file: $cog_file\n";
exit;
}
$out_file = "cog_matchup.txt";
if (-e $out_file) {
print "Couldn't create output file because it already exists: $out_file\n";
exit;
}
unless ( open(OUT, ">$out_file") ) {
print "Couldn't create output file: $out_file\n";
exit;
}
print "Parameters:\nsummary file = $in_file\nCOG matchup file = $cog_file\n\n";
#---------------------------------------------------------------------------------------------------------------------------
#The main event
#---------------------------------------------------------------------------------------------------------------------------
%lines = ();
while(<IN>) {
chomp;
@fields = split(/\t/);
$lines{$fields[1]} = $_;
}
close(IN);
while(<COG>) {
chomp;
@cog_fields = split(/\t/);
$cog_id = $cog_fields[0];
$cog_num = $cog_fields[3];
$cog_annot = $cog_fields[4];
if ($lines{$cog_id}) {
print "$lines{$cog_id}\t$cog_id\t$cog_num\t$cog_annot\n";
print OUT "$lines{$cog_id}\t$cog_id\t$cog_num\t$cog_annot\n";
}
}
close(COG);
close(OUT);