Skip to content

Commit e558c2b

Browse files
author
Jan Ludwiczak
committed
Add ploting feature to standalone version and correct plotting internals to correctly handle multiple plots in a row
1 parent 4ad6655 commit e558c2b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

bin/deepcoil

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import os
44
import argparse
55
from Bio import SeqIO
66
from deepcoil import DeepCoil
7-
from deepcoil.utils import is_fasta, sharpen_preds
7+
from deepcoil.utils import is_fasta, sharpen_preds, plot_preds
88

99
parser = argparse.ArgumentParser(description='DeepCoil')
1010
parser.add_argument('-i',
@@ -18,6 +18,9 @@ parser.add_argument('-out_path',
1818
parser.add_argument('--gpu',
1919
help='Use GPU',
2020
action='store_true')
21+
parser.add_argument('--plot',
22+
help='Plot predictions. Images will be stored in the path defined by -out_path',
23+
action='store_true')
2124
args = parser.parse_args()
2225

2326
# Check if input file exists
@@ -64,4 +67,7 @@ for entry in out_keys:
6467
for aa, cc_prob, cc_prob_raw, a_prob, d_prob in zip(data[entry], cc_pred, cc_pred_raw, hept_pred[:, 1], hept_pred[:, 2]):
6568
f.write('{0}\t{1:.3f}\t{2:.3f}\t{3:.3f}\t{4:.3f}\n'.format(aa, float(cc_prob), float(cc_prob_raw), float(a_prob), float(d_prob)))
6669
f.close()
70+
if args.plot:
71+
for entry in out_keys:
72+
plot_preds(preds[entry], out_file=f'{args.out_path}/{entry}.png')
6773
print("Done!")

deepcoil/utils/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,5 @@ def plot_preds(results, beg=0, end=-1, out_file=None):
128128
plt.tight_layout()
129129
plt.subplots_adjust(hspace=0)
130130
if out_file:
131-
plt.savefig(out_file, dpi=300)
131+
plt.savefig(out_file, dpi=300)
132+
plt.close()

0 commit comments

Comments
 (0)