comparison scripts/get_class.pl @ 0:28d1a6f8143f draft

planemo upload for repository https://github.com/portiahollyoak/Tools commit 132bb96bba8e7aed66a102ed93b7744f36d10d37-dirty
author portiahollyoak
date Mon, 25 Apr 2016 13:08:56 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:28d1a6f8143f
1 #!/share/bin/perl
2
3 # chr2L 19384 20049 FBgn0001283_jockey wXh24,-1;harwich,-8,+5;whXw21,-4,+1;whXw14,-5;wXh14,+2; +- sense chr2L:19562.19645
4
5 my @sample=("$ARGV[1]");
6
7 print "chr\tstart\tend\ttransposonName\tstrand\ttransposonStrand\tbreak\tclass";
8 print "\t$_\_class\t$_\_plus\t$_\_minus" foreach @sample;
9 print "\n";
10 open in,$ARGV[0];
11 while(<in>)
12 {
13 chomp;
14 my($chrom,$start,$end,$transposonName,$class,$strand,$transposonStrand,$break)=split/\t/;
15 my %classCounts;
16 my ($tcplus,$tcminus)=(0,0);
17 foreach $s (split/;/,$class)
18 {
19 my ($name,@counts)=split/,/,$s;
20 foreach my $c (@counts)
21 {
22 my $strand=($c>0)?"+":"-";
23 $classCounts{$name}{$strand}=$c;
24 $tcplus+=$c if $c>0;
25 $tcminus+=$c if $c<0;
26 }
27 }
28 print "$chrom\t$start\t$end\t$transposonName\t$strand\t$transposonStrand\t$break";
29 print "\t1p1" if $tcplus>0 && $tcminus<0;
30 print "\t2p" if ($tcplus>1 && $tcminus==0) || ($tcplus==0 && $tcminus<-1);
31 print "\tsingleton" if ($tcplus<=1 && $tcminus==0 && $tcplus>0) || ($tcplus==0 && $tcminus>=-1 && $tcminus<0);
32 print "\tNone" if ($tcminus==0 && $tcplus==0);
33 foreach my $s (@sample)
34 {
35 $classCounts{$s}{"+"}=0 if not exists $classCounts{$s}{"+"};
36 $classCounts{$s}{"-"}=0 if not exists $classCounts{$s}{"-"};
37 print "\t1p1" if $classCounts{$s}{"+"}>0 && $classCounts{$s}{"-"}<0;
38 print "\t2p" if ($classCounts{$s}{"+"}>1 && $classCounts{$s}{"-"}==0) || ($classCounts{$s}{"+"}==0 && $classCounts{$s}{"-"}<-1);
39 print "\tsingleton" if ($classCounts{$s}{"+"}<=1 && $classCounts{$s}{"-"}==0 && $classCounts{$s}{"+"}>0) || ($classCounts{$s}{"+"}==0 && $classCounts{$s}{"-"}>=-1 && $classCounts{$s}{"-"}<0);
40 print "\tNone" if $classCounts{$s}{"+"}==0 && $classCounts{$s}{"-"}==0;
41 print "\t",$classCounts{$s}{"+"},"\t",$classCounts{$s}{"-"};
42 }
43 print "\n";
44 }
45 close in;