-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_class3d_RELION2.0.pl
More file actions
executable file
·96 lines (90 loc) · 3.19 KB
/
Copy pathplot_class3d_RELION2.0.pl
File metadata and controls
executable file
·96 lines (90 loc) · 3.19 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#! /usr/bin/perl -w
# plots the 3d classification results: Accuracy of rorations, accuracy of translations, class distribution, and resolution
# modifed 4-2-17 for Relion 2.0 directory structures
# wjr
#
my $prefix = "Class3D/run1";
print "\nClass3D directory contents: \n";
my @dir=`ls -1 Class3D`;
print @dir;
print "Enter directory to plot: ";
chomp ($line=<STDIN>);
if ($line) {$prefix = 'Class3D/' . $line . '/run';}; # designed for Relion2 directory structure
my $fileout = $prefix . "Class3d.plt";
my @files = glob("${prefix}_it???_model.star");
die "Cannot find any files matching ${prefix}_???_model.star \n" unless (@files);
open (OUT,">$fileout") or die "cannot write\n";
$filenum = 0;
foreach $file (@files) {
$file =~ m/_it(\d+)_/;
$iteration = $1;
if ($iteration>0) {print OUT "$iteration ";}
open (IN,$file) or die "cannot read $file\n";
my $line = <IN>;
while ($line !~ m/data_model_classes/) {
if ($line =~ m/_rlnCurrentResolution\s+(\d+\.\d+)/) {
$resolution = $1;
}
if ($line =~ m/_rlnNrClasses\s+(\d+)/) {
$num_models=$1;
}
$line = <IN>;
}
# xf ($line =~ m/data_model_classes/) #found the final pieces we want
while ($line !~ m/loop_/) {
$line = <IN>;
}
$line=<IN>;
while ($line =~ m/_rln(\w+)/) {
if ($filenum <1) {push @keys,$1;}
$line = <IN>;
}
@data = split (" ",$line);
while ($#data == $#keys) {
$data[0] =~ s/_/-/g;
push @plotnames, $data[0] unless ($filenum >0);
print OUT "$data[1] $data[2] $data[3] " unless ($iteration <1);
$line=<IN>;
@data = split(" ",$line);
}
close (IN);
if ($resolution) { print OUT " $resolution\n";}
$filenum ++;
}
close (OUT);
for ($j=1; $j <= $#keys; $j++) {
open (OUT2,">plotgnu");
# print OUT2 "set term png\n";
print OUT2 "set term png font '/usr/share/fonts/liberation/LiberationSans-Regular.ttf' 12\n";
print OUT2 "set output \"${prefix}_$keys[$j].png\"\n";
print OUT2 "set xlabel \"Iteration\" \n";
print OUT2 "set ylabel \"$keys[$j]\" \n";
if ($keys[$j] =~ m/otation/) { $yrange = 8;}
elsif ($keys[$j] =~ m/anslation/) {$yrange = 5;}
elsif ($keys[$j] =~ m/istribu/) {$yrange = 1;}
print OUT2 "set yrange [0:$yrange]\n";
for ($i=0; $i < $num_models; $i++) {
$coladd = $i*($#keys);
$col = $coladd+$j+1;
if ($i>0) {print OUT2 ", ";} else {print OUT2 "plot ";}
print OUT2 "\"$fileout\" using 1:$col with linespoints lw 2 ti \"$plotnames[$i]\" ";
}
print OUT2 "\n";
close (OUT2);
`gnuplot plotgnu`;
}
$last_col = $num_models * ($#keys) +2;
open (OUT2,">plotgnu");
#print OUT2 "set term png\n";
print OUT2 "set term png font '/usr/share/fonts/liberation/LiberationSans-Regular.ttf' 12\n";
print OUT2 "set output \"${prefix}_class3d_resolution.png\"\n";
print OUT2 "set xlabel \"Iteration\"\n";
print OUT2 "set ylabel \"Resolution (A)\" \n";
print OUT2 "set yrange [0:] \n";
print OUT2 "plot \"$fileout\" using 1:$last_col with linespoints lw 2 ti \"Class Resolution\" \n";
close OUT2;
`gnuplot plotgnu`;
print "plotted data from $filenum files\n ";
print "To view, copy and paste following line:\n";
print "eog Class3D/$line/*.png\n";
foreach $key (@keys) {print "$key\n";}