Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit b2b37cd

Browse files
authored
Merge pull request #2 from SSchott/master
Small mods. Compilation is OK, checks for external software are now much better!
2 parents 03bbc05 + 90a446d commit b2b37cd

File tree

5 files changed

+31
-7
lines changed

5 files changed

+31
-7
lines changed

bin/compile/compile.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
rm -rf protdist *.o
4+
gcc -o protdist protdist.c -O3 -lm

bin/protdist/compile.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

libwhiscy/access.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ def calculate_accessibility(pdb_file_name, output_file_name):
99
a RSA NACCESS-format like file.
1010
"""
1111
cmd = "freesasa {} -n 20 --format=rsa --radii=naccess -o {}".format(pdb_file_name, output_file_name)
12-
subprocess.run(cmd, shell=True)
12+
try:
13+
subprocess.run(cmd, shell=True)
14+
except:
15+
subprocess.check_call(cmd, shell=True)
1316

1417

1518
class ResidueSASA():

libwhiscy/pam_calc.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import os
2-
from math import exp, isclose
2+
try:
3+
from math import exp, isclose
4+
except:
5+
from math import exp
6+
from numpy import isclose
37
from libwhiscy.pam_data import logpameigval, pameigvec, pameigvecinv, code
48

59

whiscy_setup.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import json
1010
import subprocess
1111
import warnings
12+
import shutil
1213
from Bio import AlignIO, SeqIO
1314
from Bio.Blast import NCBIWWW
1415
from Bio.Align.Applications import MuscleCommandline
@@ -29,6 +30,13 @@
2930
logging.basicConfig(format='%(name)s [%(levelname)s] %(message)s', level=logging.INFO)
3031
logger = logging.getLogger("whiscy_setup")
3132

33+
#Some extra checks...
34+
if 'WHISCY_PATH' not in os.environ:
35+
logger.warning("WHISCY_PATH variable not defined in the environment. Assuming the path of the script...")
36+
os.environ['WHISCY_PATH'] = os.path.abspath(os.path.dirname(__file__))+os.path.sep
37+
if shutil.which("freesasa") is None:
38+
logger.critical("FreeSASA not in PATH. Please set environment correctly.")
39+
raise SystemExit
3240

3341
def load_config(config_file='etc/local.json'):
3442
"""Load Whiscy configuration"""
@@ -41,6 +49,9 @@ def muscle_msa(config, input_sequence_file, output_alignment_file):
4149
"""Calculates a MSA using MUSCLE's Biopython wrapper"""
4250
muscle_bin = config['ALIGN']['MUSCLE_BIN']
4351
muscle_cline = MuscleCommandline(muscle_bin, input=input_sequence_file, out=output_alignment_file)
52+
if not os.path.exists(muscle_bin):
53+
logger.critical("The path defined for the MUSCLE binary is not correct. Check the configuration file!")
54+
raise SystemExit
4455
stdout, stderr = muscle_cline()
4556
MultipleSeqAlignment = AlignIO.read(output_alignment_file, "fasta")
4657
return MultipleSeqAlignment
@@ -76,8 +87,14 @@ def msa_to_phylseq(msa, master_sequence, output_file):
7687
def calculate_protdist(phylip_file, protdist_output_file):
7788
"""Calculates the protdist of the given MSA"""
7889
protdist_bin = os.path.join(os.path.dirname(os.path.realpath(__file__)), "bin", "protdist", "protdist")
90+
if not os.path.exists(protdist_bin):
91+
logger.critical("Protdist was not compiled. Please check the installation instructions")
92+
raise SystemExit
7993
cmd = "{0} {1} {2} > /dev/null 2>&1".format(protdist_bin, phylip_file, protdist_output_file)
80-
subprocess.run(cmd, shell=True)
94+
try:
95+
subprocess.run(cmd, shell=True)
96+
except:
97+
subprocess.check_call(cmd, shell=True)
8198

8299

83100
def write_to_fasta(output_fasta_file, sequence):

0 commit comments

Comments
 (0)