comparison gomwu_b.pl @ 1:f7287f82602f draft

"planemo upload commit 486235d6560c9e95bd42152ad19bf7c3941cdc1b"
author cristian
date Tue, 19 Apr 2022 08:28:43 +0000
parents 91261b42c07e
children
comparison
equal deleted inserted replaced
0:91261b42c07e 1:f7287f82602f
1 #!/usr/bin/env perl 1 #!/usr/bin/env perl
2
3 use File::Basename;
2 4
3 my $usage= " 5 my $usage= "
4 6
5 gomwu_b.pl (v. Feb 2015): 7 gomwu_b.pl (v. Feb 2015):
6 8
13 15
14 "; 16 ";
15 17
16 my $gen2go=shift; 18 my $gen2go=shift;
17 my $measure=shift; 19 my $measure=shift;
20 ($mname,$mdir,$mext) = fileparse($measure,'\..*');
21 ($aname,$adir,$aext) = fileparse($gen2go,'\..*');
18 my $div=shift or die "$usage\nNot enough arguments for gomwu_b.pl\n"; 22 my $div=shift or die "$usage\nNot enough arguments for gomwu_b.pl\n";
19 23
20 my $clfile="cl_dissim0_".$div."_".$gen2go; 24 my $clfile=$mdir."cl_dissim0_".$div."_".$aname.$aext;
21 open CLF, $clfile or die "cannot locate primary clustering file $clfile\n"; 25 open CLF, $clfile or die "cannot locate primary clustering file $clfile\n";
22 my %clgo={}; 26 my %clgo={};
23 my $go; 27 my $go;
24 my $cl; 28 my $cl;
25 29
29 push @{$clgo{$cl}},$go; 33 push @{$clgo{$cl}},$go;
30 } 34 }
31 close CLF; 35 close CLF;
32 36
33 unlink $clfile; 37 unlink $clfile;
34 unlink "dissim0_".$div."_".$gen2go; 38 unlink $mdir."dissim0_".$div."_".$aname.$aext;
35 39
36 opendir THISDIR, "."; 40 opendir THISDIR, $mdir;
37 my @donealready=grep /$gen2go/, readdir THISDIR; 41 my @donealready=grep /$gen2go/, readdir THISDIR;
38 my $dones=" "."@donealready"." "; 42 my $dones=" "."@donealready"." ";
39 #print "DONE: $dones\n"; 43 #print "DONE: $dones\n";
40 44
41 my $inname2=$measure.".".$div.".tmp"; 45 my $inname2=$mdir.$mname.".".$div.".tmp";
42 open TAB, $inname2 or die "go_nrify: cannot open input table $inname2\n"; 46 open TAB, $inname2 or die "go_nrify: cannot open input table $inname2\n";
43 <TAB>; 47 <TAB>;
44 my %level={}; 48 my %level={};
45 my %desc={}; 49 my %desc={};
46 my %value={}; 50 my %value={};
117 @{$nrgenes{$goos}}=@nrgens; 121 @{$nrgenes{$goos}}=@nrgens;
118 $gcount+=$#nrgens+1; 122 $gcount+=$#nrgens+1;
119 } 123 }
120 124
121 print $#nrgos+1," non-redundant GO categories of good size\n-------------\n"; 125 print $#nrgos+1," non-redundant GO categories of good size\n-------------\n";
122 $outname=$div."_".$measure; 126 $outname=$mdir.$mname."_".$div.".tsv";
127 print("creating $outname");
123 open OUT, ">$outname" or die "gomwu_b: cannot create output $outname\n"; 128 open OUT, ">$outname" or die "gomwu_b: cannot create output $outname\n";
124 print {OUT} "name\tterm\tlev\tseq\tvalue\n"; 129 print {OUT} "name\tterm\tlev\tseq\tvalue\n";
125 130
126 foreach $go (@nrgos) { 131 foreach $go (@nrgos) {
127 foreach $gene (@{$nrgenes{$go}}){ 132 foreach $gene (@{$nrgenes{$go}}){
148 my %dnds; 153 my %dnds;
149 154
150 #################### 155 ####################
151 # building dissimilarity matrix 156 # building dissimilarity matrix
152 157
153 my $inname4="dissim_".$div."_".$measure."_".$gen2go; 158 my $inname4=$mdir."dissim_".$div."_".$mname."_".$aname.$aext;
154 my $inname3=$div."_".$measure; 159 my $inname3=$mdir.$mname."_".$div.".tsv";
155 160
156 #if($dones!~/ $inname4 /) { 161 #if($dones!~/ $inname4 /) {
157 162
158 use List::Util qw[min max]; 163 use List::Util qw[min max];
159 open TAB, $inname3 or die "go_cluster: cannot open input table $inname3\n"; 164 open TAB, $inname3 or die "go_cluster: cannot open input table $inname3\n";
160 <TAB>; 165 <TAB>;
161 166
162 my $des; 167 # my $des;
163 my $go; 168 # my $go;
164 my $l; 169 # my $l;
165 my $gn; 170 # my $gn;
166 my $val; 171 # my $val;
167 my @gos=(); 172 # my @gos=();
168 my %genes={}; 173 # my %genes={};
169 my %gosi={}; 174 my %gosi={};
170 175
171 print"\nSecondary clustering:\ncalculating similarities....\n"; 176 print"\nSecondary clustering:\ncalculating similarities....\n";
172 while (<TAB>){ 177 while (<TAB>){
173 chomp; 178 chomp;