Skip to content

Commit

Permalink
minor fixes, locarna max version set
Browse files Browse the repository at this point in the history
set max major version in readme.
  • Loading branch information
SchwarzMarek committed Aug 5, 2019
1 parent 2575e25 commit 795444a
Show file tree
Hide file tree
Showing 14 changed files with 153 additions and 51 deletions.
16 changes: 8 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,28 +60,28 @@ conda install -c conda-forge -c bioconda -c schwarz.marek rboanalyzer
### Install from source

__Prerequisites__
- python >= 3.4 [link](https://www.python.org/downloads/)
- python >= 3.4, <3.8 [link](https://www.python.org/downloads/)
Verify that you have working up-to date `pip3`.
```
pip3 install --upgrade pip
# or
pip3 install --upgrade pip --user
```
- ncbi-blast+ >= 2.6, < 2.8.1 [link](http://ftp.ncbi.nih.gov/blast/executables/blast+/2.7.1/)
- locarna >= 1.9.2 [link](https://github.com/s-will/LocARNA/releases/tag/v1.9.2.2)
- infernal >= 1.1 [link](http://eddylab.org/infernal/)
- clustalo >= 1.2.4 [link](http://www.clustal.org/omega/)
- muscle >= 3.8.31 [link](https://www.drive5.com/muscle/downloads.htm)
- locarna >= 1.9.2, <2 [link](https://github.com/s-will/LocARNA/releases/tag/v1.9.2.2)
- infernal >= 1.1, <2 [link](http://eddylab.org/infernal/)
- clustalo >= 1.2.4, <2 [link](http://www.clustal.org/omega/)
- muscle >= 3.8.31, <4 [link](https://www.drive5.com/muscle/downloads.htm)

For prediction:
- viennarna >=2.3.5 (with refold.pl in PATH) [link](https://www.tbi.univie.ac.at/RNA/download/sourcecode/2_3_x/ViennaRNA-2.3.5.tar.gz)
- viennarna >=2.3.5, <3 (with refold.pl in PATH) [link](https://www.tbi.univie.ac.at/RNA/download/sourcecode/2_3_x/ViennaRNA-2.3.5.tar.gz)
Don't forget to add `refold.pl` to your `PATH`. The `refold.pl` script is located in the `ViennaRNA-[version]/src/Utils/`.
- centroid_homfold >= 0.0.15 [link](https://github.com/satoken/centroid-rna-package/releases/tag/v0.0.15)
- RNAstructure >= 6.0 (TurboFold - Text (Command Line) Interfaces ) [link](https://rna.urmc.rochester.edu/RNAstructure.html)
- RNAstructure >= 6.0, <7 (TurboFold - Text (Command Line) Interfaces ) [link](https://rna.urmc.rochester.edu/RNAstructure.html)
Don't forget to set the `DATAPATH` environment variable [link](http://rna.urmc.rochester.edu/Text/Thermodynamics.html).

Optional (some prediction methods are not available without):
- UNAFold >= 3.8 [link](http://unafold.rna.albany.edu/?q=DINAMelt/software)
- UNAFold >= 3.8, <4 [link](http://unafold.rna.albany.edu/?q=DINAMelt/software)

Clone or download this repository, unpack it if needed. Go to directory with the source code for the rboAnalyzer and run

Expand Down
2 changes: 2 additions & 0 deletions rna_blast_analyze/BA.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,8 @@ def lunch_with_args(args):
# ========= run =========
blast_fn = os.path.basename(args.blast_in) + '.r-' + hashstring[:10]
blast_dir = os.path.dirname(args.blast_in)
if blast_dir == '':
blast_dir = os.getcwd()
potential_matches = [f for f in os.listdir(blast_dir) if f == blast_fn]
if len(potential_matches) == 0:
with open(args.blast_in + '.r-' + args.sha1[:10], 'w') as f:
Expand Down
4 changes: 2 additions & 2 deletions rna_blast_analyze/BR_core/BA_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def run_muscle(fasta_file, out_file=None, muscle_params='', reorder=True):
]
ml.debug(cmd)

with TemporaryFile(mode='w+') as tmp:
with TemporaryFile(mode='w+', encoding='utf-8') as tmp:
r = call(cmd, stdout=tmp, stderr=tmp)
if r:
msgfail = 'Call to muscle failed.'
Expand Down Expand Up @@ -286,7 +286,7 @@ def run_muscle(fasta_file, out_file=None, muscle_params='', reorder=True):

def RNAfold(sequence):
ml.debug(fname())
with TemporaryFile(mode='w+') as tmp:
with TemporaryFile(mode='w+', encoding='utf-8') as tmp:
r = check_output(
[
'{}RNAfold'.format(CONFIG.viennarna_path),
Expand Down
13 changes: 9 additions & 4 deletions rna_blast_analyze/BR_core/BA_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from rna_blast_analyze.BR_core.tools_versions import blast_minimal_version, locarna_minimal_version, \
infernal_minimal_version, vrna_minimal_version, clustalo_minimal_version, muscle_minimal_version, \
centroid_homfold_minimal_version, turbofold_minimal_version,\
mfold_minimal_version, method_required_tools, blast_maximal_version
mfold_minimal_version, method_required_tools, blast_maximal_version, locarna_maximal_version

ml = logging.getLogger('rboAnalyzer')

Expand Down Expand Up @@ -47,7 +47,7 @@ def verify_blastdbcmd(minimal_version, maximal_version):
return False


def verify_locarna(minimal_version):
def verify_locarna(minimal_version, maximal_version):
msgversion = 'Locarna is not installed in required version, required version is {}.{}.{}'.format(*locarna_minimal_version)
msgpath = '{}LocARNA could not be located (not in PATH).'.format(CONFIG.locarna_path)
msgsuccess = 'Locarna is installed in required version'
Expand All @@ -61,7 +61,12 @@ def verify_locarna(minimal_version):
a = a.decode()
if a.startswith('LocARNA'):
r = [int(m.group()) for m in re.finditer('[0-9]+', a)]
return version_check(r, minimal_version, msgsuccess, msgversion)
bb_min = version_check(r, minimal_version, msgsuccess, msgversion)
bb_max = version_check(r, maximal_version, msgsuccess, msgversion, operator.le)
if bb_min and bb_max:
return True
else:
return False
else:
ml.warning(msgversion)
return False
Expand Down Expand Up @@ -313,7 +318,7 @@ def check_3rd_party_tools():
if verify_blastdbcmd(blast_minimal_version, blast_maximal_version):
installed.add('blastdbcmd')

if verify_locarna(locarna_minimal_version):
if verify_locarna(locarna_minimal_version, locarna_maximal_version):
installed.add('locarna')

if verify_infernal('cmbuild', infernal_minimal_version):
Expand Down
6 changes: 3 additions & 3 deletions rna_blast_analyze/BR_core/alifold4all.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def compute_clustalo_clasic(file, clustalo_params=''):
fd, out_path = mkstemp(prefix='rba_', suffix='_01', dir=CONFIG.tmpdir)
os.close(fd)

with TemporaryFile(mode='w+') as tmp:
with TemporaryFile(mode='w+', encoding='utf-8') as tmp:
parlist = clustalo_params.split()
cmd = [
'{}clustalo'.format(CONFIG.clustal_path),
Expand All @@ -45,7 +45,7 @@ def compute_alifold(msa_file, alifold_params=''):
fd, out_path = mkstemp(prefix='rba_', suffix='_02', dir=CONFIG.tmpdir)
os.close(fd)

with TemporaryFile(mode='w+') as tmp:
with TemporaryFile(mode='w+', encoding='utf-8') as tmp:
cmd = '{} --noPS -f C {} < {} > {}'.format(
shlex.quote('{}RNAalifold'.format(CONFIG.viennarna_path)),
' '.join([shlex.quote(i) for i in shlex.split(alifold_params)]),
Expand Down Expand Up @@ -81,7 +81,7 @@ def compute_refold(alig_file, cons_file):
shlex.quote(out_path)
)
ml.debug(cmd)
with TemporaryFile(mode='w+') as tmp:
with TemporaryFile(mode='w+', encoding='utf-8') as tmp:
r = call(cmd, shell=True, stdout=tmp, stderr=tmp)
if r:
msgfail = 'Call to refold.pl failed.'
Expand Down
2 changes: 1 addition & 1 deletion rna_blast_analyze/BR_core/centroid_homfold.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def run_centroid_homfold(fasta2predict, fasta_homologous_seqs, centroid_homfold_
'-o', ch_outfile,
fasta2predict
]
with TemporaryFile(mode='w+') as tmp:
with TemporaryFile(mode='w+', encoding='utf-8') as tmp:
r = call(cmd, stdout=tmp, stderr=tmp)
if r:
tmp.seek(0)
Expand Down
60 changes: 33 additions & 27 deletions rna_blast_analyze/BR_core/cmalign.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def run_cmscan(fastafile, cmmodels_file=None, params=None, outfile=None, threads
else:
cm_file = os.path.join(rfam.rfam_dir, rfam.rfam_file_name)

with TemporaryFile(mode='w+') as tmp:
with TemporaryFile(mode='w+', encoding='utf-8') as tmp:

# build commandline
cmd = ['{}cmscan'.format(CONFIG.infernal_path)]
Expand Down Expand Up @@ -83,7 +83,7 @@ def run_cmfetch(cmfile, modelid, outfile=None):
fd, out = mkstemp(prefix='rba_', suffix='_11', dir=CONFIG.tmpdir)
os.close(fd)

with TemporaryFile(mode='w+') as tmp:
with TemporaryFile(mode='w+', encoding='utf-8') as tmp:
cmd = [
'{}cmfetch'.format(CONFIG.infernal_path),
'-o', out,
Expand Down Expand Up @@ -116,7 +116,7 @@ def run_cmemit(model, params='', out_file=None):
fd, out = mkstemp(prefix='rba_', suffix='_12', dir=CONFIG.tmpdir)
os.close(fd)

with TemporaryFile(mode='w+') as tmp:
with TemporaryFile(mode='w+', encoding='utf-8') as tmp:
# build commandline
cmd = ['{}cmemit'.format(CONFIG.infernal_path)]
if params != '':
Expand Down Expand Up @@ -266,40 +266,46 @@ def download_cmmodels_file(path=None, url=None):
ml.debug(cmd)

ml.info('Downloading RFAM database (aprox 300Mb). This may take a while...')
with TemporaryFile(mode='w+') as tmp:
r = check_output(cmd, stderr=tmp)
with TemporaryFile(mode='w+', encoding='utf-8') as tmp:
r = call(cmd, stderr=tmp, stdout=tmp)

if not r:
if r:
msgfail = 'Call to wget failed. Please check the internet connection and/or availability of "wget".'
ml.error(msgfail)
ml.debug(cmd)
sys.exit(1)

if 'Remote file no newer than local file ‘Rfam.cm.gz’ -- not retrieving.' in r.decode():
# do not download
ml.info('No new data. Nothing to do.')
else:
# unzip using build in gzip
with gzip.open(os.path.join(path, rfam.gzname), 'rb') as fin:
with open(os.path.join(path, rfam.rfam_file_name), 'wb') as fout:
shutil.copyfileobj(fin, fout)

# run cmpress to create binary files needed to run cmscan
try:
run_cmpress(os.path.join(path, rfam.rfam_file_name))
except exceptions.CmpressException as e:
ml.error(str(e))
ml.error('The Rfam file might be corrupt. Please check following output to get more information.\n')
print(e.errors)
sys.exit(1)
tmp.seek(0)
cmd_output = tmp.read()

if 'Remote file no newer than local file' in cmd_output:
# do not download
msg = 'No new data. Nothing to do.'
ml.info(msg)
if ml.getEffectiveLevel() > 20:
print(msg)
else:
# unzip using build in gzip
with gzip.open(os.path.join(path, rfam.gzname), 'rb') as fin:
with open(os.path.join(path, rfam.rfam_file_name), 'wb') as fout:
shutil.copyfileobj(fin, fout)

# run cmpress to create binary files needed to run cmscan
try:
run_cmpress(os.path.join(path, rfam.rfam_file_name))
except exceptions.CmpressException as e:
ml.error(str(e))
ml.error('The Rfam file might be corrupt. Please check following output to get more information.\n')
print(e.errors)
sys.exit(1)

return os.path.join(path, rfam.rfam_file_name)
return os.path.join(path, rfam.rfam_file_name)


def run_cmpress(file2process):
ml.info('Running cmpress.')
ml.debug(fname())
with TemporaryFile(mode='w+') as tmp:
with TemporaryFile(mode='w+', encoding='utf-8') as tmp:
cmd = ['{}cmpress'.format(CONFIG.infernal_path), '-F', file2process]
ml.debug(cmd)
r = call(cmd, stdout=tmp, stderr=tmp)
Expand Down Expand Up @@ -328,7 +334,7 @@ def run_cmbuild(cmbuild_input_file, cmbuild_params=''):
cm_fd, cm_file = mkstemp(prefix='rba_', suffix='_13', dir=CONFIG.tmpdir)
os.close(cm_fd)

with TemporaryFile(mode='w+') as tmp:
with TemporaryFile(mode='w+', encoding='utf-8') as tmp:
cmd = ['{}cmbuild'.format(CONFIG.infernal_path), '-F']
if cmbuild_params != '':
cmd += cmbuild_params.split()
Expand Down Expand Up @@ -358,7 +364,7 @@ def run_cmalign_on_fasta(fasta_file, model_file, cmalign_params='--notrunc', ali
cma_fd, cma_file = mkstemp(prefix='rba_', suffix='_14', dir=CONFIG.tmpdir)
os.close(cma_fd)

with TemporaryFile(mode='w+') as tmp:
with TemporaryFile(mode='w+', encoding='utf-8') as tmp:
cmd = [
'{}cmalign'.format(CONFIG.infernal_path),
'--informat', 'fasta',
Expand Down
2 changes: 1 addition & 1 deletion rna_blast_analyze/BR_core/expand_by_LOCARNA.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def run_locarna(query_file, subject_file, locarna_params):
shlex.quote(subject_file + '.loc_out'),
)
ml.debug(cmd)
with TemporaryFile(mode='w+') as tmp:
with TemporaryFile(mode='w+', encoding='utf-8') as tmp:
r = call(cmd, shell=True, stdout=tmp, stderr=tmp)
if r:
msgfail = 'Call to locarna failed for files in1:{} in2:{} out:{}'.format(
Expand Down
2 changes: 1 addition & 1 deletion rna_blast_analyze/BR_core/hybrid_ss_min.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def _run_hybrid_ss_min_wrapper(seq, P, W, M):


def _run_hybrid_ss_min_single(file_path, P, W, M):
with TemporaryFile(mode='w') as tmp:
with TemporaryFile(mode='w', encoding='utf-8') as tmp:
cmd3 = [
'{}hybrid-ss-min'.format(CONFIG.mfold_path),
'--suffix=DAT',
Expand Down
2 changes: 1 addition & 1 deletion rna_blast_analyze/BR_core/predict_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ def _try_rescue(profile_file):
c_fd, clustalo_file = mkstemp(prefix='rba_', suffix='_57', dir=CONFIG.tmpdir)
os.close(c_fd)

with TemporaryFile(mode='w+') as tmp:
with TemporaryFile(mode='w+', encoding='utf-8') as tmp:
cmd = [
'{}clustalo'.format(CONFIG.clustal_path),
'--force',
Expand Down
1 change: 1 addition & 0 deletions rna_blast_analyze/BR_core/tools_versions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
blast_minimal_version = [2, 6, 0]
blast_maximal_version = [2, 8, 0]
locarna_minimal_version = [1, 9, 2]
locarna_maximal_version = [1, 999, 999]
infernal_minimal_version = [1, 1, 2]
vrna_minimal_version = [2, 3, 5]
clustalo_minimal_version = [1, 2, 4]
Expand Down
2 changes: 1 addition & 1 deletion rna_blast_analyze/BR_core/turbofold.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def _turbofold_worker(sequences, params):
)

# run without prediction progress reporting output
with TemporaryFile(mode='w+') as tmp:
with TemporaryFile(mode='w+', encoding='utf-8') as tmp:
cmd = [
'{}TurboFold'.format(CONFIG.turbofold_path),
con_file
Expand Down
4 changes: 2 additions & 2 deletions rna_blast_analyze/BR_core/viennaRNA.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def rnafold(fastafile, outfile, parameters=''):
shlex.quote(outfile)
)
ml.debug(cmd)
with TemporaryFile(mode='w+') as tmp:
with TemporaryFile(mode='w+', encoding='utf-8') as tmp:
r = call(cmd, shell=True, stderr=tmp, stdout=tmp)

if r:
Expand Down Expand Up @@ -80,7 +80,7 @@ def run_rnaplot(seq, structure=None, format='svg', outfile=None):
shlex.quote(tmpfile)
)
ml.debug(cmd)
with TemporaryFile(mode='w+') as tmp:
with TemporaryFile(mode='w+', encoding='utf-8') as tmp:
r = call(cmd, shell=True, stdout=tmp, stderr=tmp)
if r:
msgfail = 'Call to RNAplot failed.'
Expand Down
Loading

0 comments on commit 795444a

Please sign in to comment.