-
Notifications
You must be signed in to change notification settings - Fork 7
/
parse_tr2_results.pl
executable file
·79 lines (68 loc) · 1.88 KB
/
parse_tr2_results.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/perl
## Pombert lab, Illinois Tech, 2021
my $name = 'parse_tr2_results';
my $version = '0.1';
my $updated = '2021-08-04';
use strict;
use warnings;
use Getopt::Long qw(GetOptions);
my $usage =<<"OPTIONS";
NAME ${name}
VERSION ${version}
UDPATED ${updated}
SYNOPSIS Parses the trRosetta2 results and rename the outputs with the protein names.
EXAMPLE ${name} \\
-r trRosetta2_results/ \\
-o Parsed_results \\
-t 1
OPTIONS:
-r (--r2dir) trRosetta2 output directory
-o (--outdir) Parsed output directory
-t (--top) Top X number of pdb files to keep, from best to worst (max 5) [Default: 1]
-v (--verbose) Adds verbosity
OPTIONS
die "\n$usage\n" unless @ARGV;
my $r2dir;
my $outdir;
my $top = 1;
my $verbosity;
GetOptions(
'r|r2dir=s' => \$r2dir,
'o|outdir=s' => \$outdir,
't|top=i' => \$top,
'v|verbosity' => \$verbosity
);
## Checking number of pdb templates requested
if ($top > 5){
die "\nPlease enter a number between 1 and 5. RoseTTAFold generates a total of 5 models.\n\n";
}
## Parsing files
opendir (DIR, $r2dir) or die "Can't open trRosetta2 folder $r2dir: $!\n";
my @results;
if ($verbosity) { print "\n"; }
while (my $subfolder = readdir(DIR)) {
if (-d "$r2dir/$subfolder"){
unless ( ($subfolder eq '.') or ($subfolder eq '..') ){
if ($verbosity) { print "Found subfolder: $subfolder\n"; }
push (@results, $subfolder);
}
}
}
if ($verbosity) { print "\n"; }
## Check output directory
unless (-d $outdir){ mkdir ($outdir, 0755) or die "Can't create $outdir: $!\n" ; }
while (my $result = shift @results){
my $filename = "$r2dir/$result/model/model_1.crderr.pdb";
unless (-f $filename){
print "$result: $filename not found. Check if the folding completed properly\n";
next;
}
else {
for my $num (1..$top){
$filename = "$r2dir/$result/model/model_$num.crderr.pdb";
if (-f $filename) {
system "cp $filename $outdir/$result-m$num.pdb";
}
}
}
}