comparison scripts/patho_typing.pl @ 3:0cbed1c0a762 draft default tip

planemo upload commit 15239f1674081ab51ab8dd75a9a40cf1bfaa93e8
author cstrittmatter
date Tue, 28 Jan 2020 10:42:31 -0500
parents
children
comparison
equal deleted inserted replaced
2:6837f733b4aa 3:0cbed1c0a762
1 #!/usr/bin/env perl
2 ## A wrapper script to collect patho_typing.py output
3 use strict;
4 use warnings;
5 use Cwd;
6 use English;
7 use File::Copy;
8 use File::Basename;
9
10 # Parse arguments
11 my ($python) = @ARGV;
12
13 # Run program
14 runPathoTyping();
15 collectOutput();
16 exit 0;
17
18 # Run patho_typing
19 sub runPathoTyping {
20 my $abs_path = Cwd::abs_path($PROGRAM_NAME);
21 my $scriptdir = dirname($abs_path);
22 my $rematchdir = "$scriptdir/ReMatCh";
23 my $newpath = "PATH=$ENV{PATH}:$rematchdir";
24 `$newpath; $python`;
25 return 0;
26 }
27
28 sub collectOutput{
29 my $patho_type = "";
30 open(my $fh, '<', 'output_dir/rematch/rematchModule_report.txt') || die "Could not open file 'output_dir/rematch/rematchModule_report.txt' $!";
31 my @rematch_lines = <$fh>;
32 close($fh);
33 my @rematch_table = "";
34 my @rematch_total_table = "";
35 my $highest_coverage = 0;
36 foreach(@rematch_lines) {
37 if ($_ =~ m/\t/) { # Only table lines
38 my @elems = split('\t', $_);
39 if ($_ =~ m/#/) { # First line
40 s/_/ /g for @elems;
41 push(@rematch_table,join("\t", @elems[0,1,2,5]));
42 push(@rematch_total_table,join("\t", @elems[0,1,2,5]));
43 }
44 else {
45 push(@rematch_total_table,join("\t", @elems[0,1,2,5]));
46 if ($elems[1] > 90.0) { # Only genes with over 90% coverage in report table
47 push(@rematch_table,join("\t", @elems[0,1,2,5]));
48 }
49 }
50 }
51 }
52 open($fh, '>', 'pathotyper_rep_tab') || die "Could not open file 'pathotyper_rep_tab' $!";
53 print $fh @rematch_table;
54 close($fh);
55 open($fh, '>', 'pathotyper_rep_tot_tab') || die "Could not open file 'pathotyper_rep_tot_tab' $!";
56 print $fh @rematch_total_table;
57 close($fh);
58
59 return 0;
60 }