annotate scripts/sorting.pl @ 0:05c27700e5ca

initial commit
author biomonika <biomonika@psu.edu>
date Thu, 04 Sep 2014 18:24:19 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
1 #!/usr/bin/perl -w
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
2 use strict;
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
3 #usage: perl sorting.pl A/
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
4
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
5 my @inputs = @ARGV;
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
6 chomp(@inputs);
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
7
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
8 my $dir = $inputs[0];
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
9 my $reference = $inputs[1];
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
10 my $LINKYX_PATH = $inputs[2];
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
11 my $results = "X_results.txt";
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
12 my %hash = (); #contig <-> family member with the maximal number of not uniquely mapped reads
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
13 my $contig; my $count=0; my $iso;
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
14
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
15 open(RESULTS_FILE, $results) or die "(sorting.pl) Impossible to open source file: $!\n";
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
16
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
17 while (<RESULTS_FILE>) {
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
18 $contig = $_; chomp($contig);
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
19 $count = `bash $LINKYX_PATH/scripts/number_of_not_uniq_mapped_reads.sh $dir $contig`;
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
20 $hash{$contig} = $count;
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
21 }
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
22
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
23 foreach (sort {$hash{$a} <=> $hash{$b}} keys %hash) {
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
24 print "$_ $hash{$_}";
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
25
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
26 #get sequence
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
27 print "% of not uniquely mapped reads for contig ".$_.": ".$hash{$_}."\n";
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
28 system("perl $LINKYX_PATH/scripts/get_sequences_based_on_ids.pl $reference $_");
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
29
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
30 $iso = `bash $LINKYX_PATH/scripts/isoform_exists.sh $_ references/reference_contig_names`;
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
31 if ($iso eq '') {
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
32 print "No isoforms.\n";
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
33 } else {
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
34 print "Isoforms exists:\n";
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
35 print $iso;
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
36 }
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
37 print "----------\n";
05c27700e5ca initial commit
biomonika <biomonika@psu.edu>
parents:
diff changeset
38 }