Mercurial > repos > iss > eurl_vtec_wgs_pt
comparison scripts/patho_typing.pl @ 0:c6bab5103a14 draft
"planemo upload commit 6abf3e299d82d07e6c3cf8642bdea80e96df64c3-dirty"
author | iss |
---|---|
date | Mon, 21 Mar 2022 15:23:09 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c6bab5103a14 |
---|---|
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 $mode = 0744; | |
24 chmod $mode, "$rematchdir/rematch.py"; | |
25 my $newpath = "PATH=$ENV{PATH}:$rematchdir"; | |
26 `$newpath; $python`; | |
27 return 0; | |
28 } | |
29 | |
30 sub collectOutput{ | |
31 my $patho_type = ""; | |
32 open(my $fh, '<', 'output_dir/rematch/rematchModule_report.txt') || die "Could not open file 'output_dir/rematch/rematchModule_report.txt' $!"; | |
33 my @rematch_lines = <$fh>; | |
34 close($fh); | |
35 my @rematch_table = ""; | |
36 my @rematch_total_table = ""; | |
37 my $highest_coverage = 0; | |
38 foreach(@rematch_lines) { | |
39 if ($_ =~ m/\t/) { # Only table lines | |
40 my @elems = split('\t', $_); | |
41 if ($_ =~ m/#/) { # First line | |
42 s/_/ /g for @elems; | |
43 push(@rematch_table,join("\t", @elems[0,1,2,5])); | |
44 push(@rematch_total_table,join("\t", @elems[0,1,2,5])); | |
45 } | |
46 else { | |
47 push(@rematch_total_table,join("\t", @elems[0,1,2,5])); | |
48 if ($elems[1] > 90.0) { # Only genes with over 90% coverage in report table | |
49 push(@rematch_table,join("\t", @elems[0,1,2,5])); | |
50 } | |
51 } | |
52 } | |
53 } | |
54 open($fh, '>', 'pathotyper_rep_tab') || die "Could not open file 'pathotyper_rep_tab' $!"; | |
55 print $fh @rematch_table; | |
56 close($fh); | |
57 open($fh, '>', 'pathotyper_rep_tot_tab') || die "Could not open file 'pathotyper_rep_tot_tab' $!"; | |
58 print $fh @rematch_total_table; | |
59 close($fh); | |
60 | |
61 return 0; | |
62 } |