-
Notifications
You must be signed in to change notification settings - Fork 0
/
getCore.pl
55 lines (48 loc) · 1.01 KB
/
getCore.pl
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
use Data::Dumper;
open (GENELST, "<$ARGV[0]");
while ($line= <GENELST>){
chomp $line;
if ($line =~ m/^([^\|]+)\|([^\|]+)/){
$org= $1;
$gene= $2;
$orgGene{$org}{$gene}= 1;
if (!defined($orgHash{$org})){
$orgHash{$org}=1;
}
}
}
close (GENELST);
#print Dumper %orgGene;
open (OMCLGROUP, "<$ARGV[1]");
while ($line= <OMCLGROUP>){
chomp $line;
if ($line=~ m/^(\S+)\: (.+)$/){
%tempHash= %orgHash;
$flag{'notCore'}= 0;
$orthoClust= $1;
$tempString= $2;
@geneArray= ();
while ($tempString=~ m/([^\|\s]+)\|([^\|\s]+)/g){
$org= $1;
$gene= $2;
push (@geneArray, "$org|$gene");
$tempHash{$org}++;
}
# print Dumper %tempHash;$pene=<STDIN>;
foreach $org (keys %tempHash){
# single-copy core
if ($tempHash{$org} != 2){
$flag{'notCore'}= 1;
}
#core
# if ($tempHash{$org} < 2){
# $flag{'notCore'}= 1;
# }
}
if (!$flag{'notCore'}){
# print $line . "\n";
print $orthoClust . ": " . join(" ", (sort {lc($a) cmp lc($b)} @geneArray)) . "\n";
}
}
}
close (OMCLGROUP);