Mercurial > repos > morinlab > calc_cnsegments
annotate calc_cnsegements_titan.pl @ 0:c6e48c6ac606 draft default tip
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
author | morinlab |
---|---|
date | Tue, 11 Oct 2016 14:16:32 -0400 |
parents | |
children |
rev | line source |
---|---|
0
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
1 #!/usr/bin/perl -w |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
2 =head1 NAME |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
3 |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
4 createTITANsegmentfiles.pl |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
5 |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
6 -head1 SYNOPSIS |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
7 |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
8 =head1 OPTIONS |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
9 -id <string> |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
10 -outfile|o <string> |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
11 -symmetric|s <boolean> {1 - true; 0 - false}; Default: 1 |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
12 -outIGV|igv <string> Required: |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
13 -infile|i <string> Required: TITAN *titan.txt file |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
14 |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
15 =head1 DESCRIPTION |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
16 |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
17 =head1 CONTACT |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
18 |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
19 Gavin Ha <gha@bccrc.ca> |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
20 |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
21 =cut |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
22 |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
23 use strict; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
24 use List::Util qw[min max]; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
25 use File::Basename; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
26 use Getopt::Long; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
27 |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
28 |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
29 my $version = '0.1.3'; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
30 |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
31 sub usage () { |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
32 exec('perldoc', $0); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
33 exit; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
34 } |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
35 |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
36 my ($id, $outfile, $symmetric, $outIGV, $infile, $calls, $help); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
37 $id=0; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
38 $calls = 1; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
39 $symmetric = 1; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
40 GetOptions ( |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
41 'id=s' => \$id, |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
42 'infile|i=s' => \$infile, |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
43 'symmetric|s=i' => \$symmetric, |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
44 'outfile|o=s' => \$outfile, |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
45 'outIGV|igv=s' => \$outIGV, |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
46 'help|?' => \$help |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
47 ); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
48 |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
49 if($help) { |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
50 &usage(); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
51 } |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
52 print "Parameters:\nid=$id\ninfile=$infile\noutfile=$outfile\noutIGV=$outIGV\n"; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
53 |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
54 my ($name,$path,$suffix) = fileparse($infile); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
55 #my @jnk; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
56 #($id,@jnk) = split(/\_/,$name) if ~defined($id); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
57 my $nameOut = $id; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
58 |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
59 open OUTFILE, ">$outfile" || die("Cannot write to $outfile\n"); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
60 open IGV, ">$outIGV" || die("Cannot write to $outIGV\n"); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
61 print OUTFILE "Sample\tChromosome\tStart_Position(bp)\tEnd_Position(bp)\tLength(bp)\tMedian_Ratio\tMedian_logR\tTITAN_state\tTITAN_call\tCopy_Number\tMinorCN\tMajorCN\tClonal_Cluster\tClonal_Frequency\n"; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
62 print IGV "sample\tchr\tstart\tend\tnum.mark\tmedian\n"; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
63 open(SEGFILE, $infile) || die("Can't open $infile!\n"); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
64 my $header = <SEGFILE>; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
65 my $line = <SEGFILE>; chomp($line); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
66 my($chr, $start, $ref, $nRef, $N, $ratio, $logR, $cn, $state, $call, $clust, $clustFreq, @rest) = split(/\t/,$line); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
67 my $end = $start; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
68 my @totalRatio=(); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
69 my @totalLogR=(); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
70 push(@totalRatio,max($ratio,1-$ratio)); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
71 push(@totalLogR,$logR); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
72 while($line=<SEGFILE>) { |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
73 chomp($line); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
74 my ($chrS, $startS, $refS, $nRefS, $NS, $ratioS, $logRS, $cnS, $stateS, $callS, $clustS, $clustFreqS, @rest) = split(/\t/,$line); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
75 if ($chrS ne $chr || $callS ne $call || $clustS ne $clust){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
76 my $medianRatio = max($ratio,1-$ratio); #1 position only |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
77 my $medianLogR = $logR; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
78 $medianRatio = median(@totalRatio) if (($end-$start+1)>1); #more than 1 position |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
79 $medianLogR = median(@totalLogR) if (($end-$start+1)>1); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
80 my @majmin; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
81 if ($symmetric == 0){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
82 @majmin = &getMinorMajorCN($state); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
83 }elsif ($symmetric == 1){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
84 @majmin = &getMinorMajorCNSymmetric($state); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
85 } |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
86 my $output = $nameOut . "\t" . $chr . "\t" . $start . "\t" . $end . "\t" . ($end-$start+1). "\t" . sprintf("%.2f",$medianRatio) . "\t" . sprintf("%.2f",$medianLogR); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
87 $output = $output . "\t" . $state . "\t" . $call if ($calls); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
88 $output = $output . "\t" . $cn . "\t" . $majmin[0] . "\t" . $majmin[1] . "\t" . $clust . "\t" . $clustFreq; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
89 print OUTFILE $output . "\n"; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
90 my $output2 = $nameOut . "\t" . $chr . "\t" . $start . "\t" . $end . "\t" . scalar(@totalRatio). "\t" . sprintf("%.2f",$medianLogR); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
91 print IGV $output2 . "\n"; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
92 #reset |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
93 @totalRatio = (); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
94 @totalLogR = (); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
95 $start = $startS; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
96 }else{ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
97 |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
98 #push(@totalRatio,max($ratioS,1-$ratioS)); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
99 #assign current state to previous variables |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
100 #new end, but start still the same |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
101 } |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
102 ($chr, $end, $ref, $nRef, $N, $ratio, $logR, $cn, $state, $call, $clust, $clustFreq) = ($chrS, $startS, $refS, $nRefS, $NS, $ratioS, $logRS, $cnS, $stateS, $callS, $clustS, $clustFreqS); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
103 push(@totalRatio,max($ratioS,1-$ratioS)); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
104 push(@totalLogR,$logRS); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
105 } |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
106 |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
107 #final output |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
108 my $medianRatio = max($ratio,1-$ratio); #1 position only |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
109 $medianRatio = median(@totalRatio) if (($end-$start+1)>1); #more than 1 position |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
110 my $medianLogR = $logR; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
111 $medianLogR = median(@totalLogR) if (($end-$start+1)>1); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
112 my $output = $nameOut . "\t" . $chr . "\t" . $start . "\t" . $end . "\t" . ($end-$start+1). "\t" . sprintf("%.4f",$medianRatio) . "\t" . sprintf("%.2f",$medianLogR); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
113 my @majmin; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
114 if ($symmetric == 0){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
115 @majmin = &getMinorMajorCN($state); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
116 }elsif ($symmetric == 1){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
117 @majmin = &getMinorMajorCNSymmetric($state); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
118 } |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
119 $output = $output . "\t" . $state . "\t" . $call if ($calls); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
120 $output = $output . "\t" . $cn . "\t" . $majmin[0] . "\t" . $majmin[1] . "\t" . $clust . "\t" . $clustFreq; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
121 print OUTFILE $output . "\n"; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
122 my $output2 = $nameOut . "\t" . $chr . "\t" . $start . "\t" . $end . "\t" . scalar(@totalRatio). "\t" . sprintf("%.2f",$medianLogR); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
123 print IGV $output2 . "\n"; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
124 close OUTFILE; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
125 close IGV; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
126 #my $returnCode = `sort -k2,2n -k3,3n $outfile\.tmp > $outfile; rm $outfile\.tmp;`; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
127 close SEGFILE; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
128 |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
129 |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
130 sub median { |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
131 my (@array_ref) = @_; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
132 my $count = scalar @array_ref; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
133 # Sort a COPY of the array, leaving the original untouched |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
134 my @array = sort { $a <=> $b } @array_ref; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
135 if ($count % 2) { |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
136 return $array[int($count/2)]; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
137 } else { |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
138 return ($array[$count/2] + $array[$count/2 - 1]) / 2; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
139 } |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
140 } |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
141 |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
142 |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
143 sub getMinorMajorCN { |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
144 my ($state) = @_; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
145 my @majmin; $majmin[0]="NA"; $majmin[1]="NA"; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
146 if ($state==0){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
147 $majmin[0] = 0; $majmin[1] = 0; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
148 }elsif ($state==1 || $state==2){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
149 $majmin[0] = 0; $majmin[1] = 1; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
150 }elsif($state==4){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
151 $majmin[0] = 1; $majmin[1] = 1; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
152 }elsif ($state==3 || $state==5){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
153 $majmin[0] = 0; $majmin[1] = 2; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
154 }elsif ($state==6 || $state==9){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
155 $majmin[0] = 0; $majmin[1] = 3; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
156 }elsif ($state==10 || $state==14){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
157 $majmin[0] = 0; $majmin[1] = 4; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
158 }elsif ($state==15 || $state==20){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
159 $majmin[0] = 0; $majmin[1] = 5; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
160 }elsif ($state==7 || $state==8){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
161 $majmin[0] = 1; $majmin[1] = 2; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
162 }elsif ($state==11 || $state==13){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
163 $majmin[0] = 1; $majmin[1] = 3; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
164 }elsif ($state==16 || $state==19){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
165 $majmin[0] = 1; $majmin[1] = 4; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
166 }elsif ($state==17 || $state==18){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
167 $majmin[0] = 2; $majmin[1] = 3; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
168 }elsif ($state==12){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
169 $majmin[0] = 2; $majmin[1] = 2; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
170 } |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
171 #my $retVal = ($majmin[0],$majmin[1]); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
172 return @majmin; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
173 } |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
174 |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
175 sub getMinorMajorCNSymmetric { |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
176 my ($state) = @_; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
177 my @majmin; $majmin[0]="NA"; $majmin[1]="NA"; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
178 if ($state==0){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
179 $majmin[0] = 0; $majmin[1] = 0; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
180 }elsif ($state==1){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
181 $majmin[0] = 0; $majmin[1] = 1; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
182 }elsif($state==2){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
183 $majmin[0] = 0; $majmin[1] = 2; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
184 }elsif ($state==3){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
185 $majmin[0] = 1; $majmin[1] = 1; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
186 }elsif ($state==4){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
187 $majmin[0] = 0; $majmin[1] = 3; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
188 }elsif ($state==5){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
189 $majmin[0] = 1; $majmin[1] = 2; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
190 }elsif ($state==6){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
191 $majmin[0] = 0; $majmin[1] = 4; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
192 }elsif ($state==7){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
193 $majmin[0] = 1; $majmin[1] = 3; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
194 }elsif ($state==8){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
195 $majmin[0] = 2; $majmin[1] = 2; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
196 }elsif ($state==9){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
197 $majmin[0] = 0; $majmin[1] = 5; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
198 }elsif ($state==10){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
199 $majmin[0] = 1; $majmin[1] = 4; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
200 }elsif ($state==11){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
201 $majmin[0] = 2; $majmin[1] = 3; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
202 }elsif ($state==12){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
203 $majmin[0] = 0; $majmin[1] = 6; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
204 }elsif ($state==13){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
205 $majmin[0] = 1; $majmin[1] = 5; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
206 }elsif ($state==14){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
207 $majmin[0] = 2; $majmin[1] = 4; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
208 }elsif ($state==15){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
209 $majmin[0] = 3; $majmin[1] = 3; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
210 }elsif ($state==16){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
211 $majmin[0] = 0; $majmin[1] = 7; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
212 }elsif ($state==17){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
213 $majmin[0] = 1; $majmin[1] = 6; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
214 }elsif ($state==18){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
215 $majmin[0] = 2; $majmin[1] = 5; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
216 }elsif ($state==19){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
217 $majmin[0] = 3; $majmin[1] = 4; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
218 }elsif ($state==20){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
219 $majmin[0] = 0; $majmin[1] = 8; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
220 }elsif ($state==21){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
221 $majmin[0] = 1; $majmin[1] = 7; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
222 }elsif ($state==22){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
223 $majmin[0] = 2; $majmin[1] = 6; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
224 }elsif ($state==23){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
225 $majmin[0] = 3; $majmin[1] = 5; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
226 }elsif ($state==24){ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
227 $majmin[0] = 4; $majmin[1] = 4; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
228 } |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
229 #my $retVal = ($majmin[0],$majmin[1]); |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
230 return @majmin; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
231 } |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
232 |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
233 |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
234 #Read more: http://wiki.answers.com/Q/How_can_you_calculate_the_average_and_median_in_perl_by_subroutine#ixzz1LcMWdXEE |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
235 #sub median{ |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
236 # my @a = sort @_; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
237 # return ($a[$#a/2] + $a[@a/2]) / 2; |
c6e48c6ac606
planemo upload for repository https://github.com/morinlab/tools-morinlab/tree/master/tools/calc_cnsegments commit 4ef2d91b7c1686a2696b92fe538d4aec51d05e40-dirty
morinlab
parents:
diff
changeset
|
238 #} |