Skip to content

Commit

Permalink
fix version incompatability
Browse files Browse the repository at this point in the history
limit biopython to 1.73
fix overwriting of structures in backup temp file
  • Loading branch information
SchwarzMarek committed Jul 19, 2019
1 parent 6a0cf9c commit 2846e3a
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 25 deletions.
6 changes: 5 additions & 1 deletion rna_blast_analyze/BR_core/repredict_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@ def wrapped_ending_with_prediction(
backup_file = args_inner.blast_in + '.tmp_rboAnalyzer'
backup_base_obj = blastsearchrecompute2dict(analyzed_hits)
with open(backup_file, 'w') as ff:
json.dump([backup_base_obj, {}, {}], ff, indent=2)
json.dump(
[backup_base_obj, {k: [seqrecord2dict(s) for s in v] for k, v in new_structures.items()}, exec_time],
ff,
indent=2
)

# prediction methods present in analyzed_hits
# which might be loaded from intermediate file
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}

setup(
name='rna_blast_analyze',
name='rboAnalyzer',
version=version,
description='Analyze BLAST output for RNA query',
author='Marek Schwarz',
Expand All @@ -28,10 +28,10 @@
},
install_requires=[
'matplotlib',
'numpy',
'numpy>=1.14',
'Jinja2>=2, <3',
'pandas>=0.22',
'biopython>=1.72',
'biopython>=1.72, <1.74',
'argcomplete',
],
packages=['rna_blast_analyze', 'rna_blast_analyze.BR_core', 'rna_blast_analyze.BR_core.output'],
Expand Down
28 changes: 11 additions & 17 deletions setup.py~
Original file line number Diff line number Diff line change
@@ -1,46 +1,40 @@
from setuptools import setup, find_packages
from setuptools import setup

# package_data
# - directly related to code
# - 3rd_party_data as data_files not working to expectations

with open('VERSION', 'r') as o:
with open('rna_blast_analyze/VERSION', 'r') as o:
version = o.read().strip()

package_data = {
'rna_blast_analyze': [
'rboAnalyzer': [
'BR_core/config.txt',
'BR_core/prediction_parameters.json',
'BR_core/output/*.html',
'BR_core/output/style.css',
'BR_core/output/*',
'3rd_party_source/RSEARCH_matrices/*',
'docs/*'
'docs/*',
'VERSION'
]
}

setup(
name='rna_blast_analyze',
name='rboAnalyzer',
version=version,
description='Analyze BLAST output for RNA query',
author='Marek Schwarz',
author_email='[email protected]',
entry_points={
'console_scripts': [
'rna_blast_analyze = rna_blast_analyze.BA:main',
'rboAnalyzer = rna_blast_analyze.BA:main',
'genomes_from_blast = rna_blast_analyze.download_blast_genomes:main'
],
},
install_requires=[
'matplotlib',
'dill',
'numpy',
'numpy>=1.14',
'Jinja2>=2, <3',
'pandas>=0.22',
'PyPDF2',
'biopython',
'biopython>=1.72, <1.74',
'argcomplete',
],
packages=find_packages(),
packages=['rna_blast_analyze', 'rna_blast_analyze.BR_core', 'rna_blast_analyze.BR_core.output'],
package_data=package_data,
include_package_data=True,
)
61 changes: 57 additions & 4 deletions test_func/test_continue.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
import os
import tempfile
import unittest
from copy import copy

from unittest.mock import patch

from rna_blast_analyze.BR_core.BA_support import remove_files_with_try
from rna_blast_analyze.BR_core.convert_classes import blastsearchrecomputefromdict, blastsearchrecompute2dict
from rna_blast_analyze.BR_core.convert_classes import blastsearchrecomputefromdict, blastsearchrecompute2dict, seqrecord2dict
from test_func.pseudoargs_class import Pseudoargs
from test_func.test_execution import tab_output_equal, tab_output_equal_structures
from rna_blast_analyze.BA import lunch_with_args
Expand Down Expand Up @@ -57,17 +58,18 @@ def setUp(self):
os.close(ff)
self.fasta_structures = fasta_structures

@patch('builtins.input', return_value='yes')
def test_continuation(self, mock_input):

with open(blast_output, 'r') as f, open(backup_file, 'w') as ff:
data = blastsearchrecomputefromdict(json.load(f))
data.args.json = None
data.args.blast_in = blast_in
data.args.json = None
for hit in data.hits:
del hit.extension.letter_annotations['rnafold']

json.dump([blastsearchrecompute2dict(data), {}, {}], ff, indent=2)

@patch('builtins.input', return_value='yes')
def test_continuation(self, mock_input):
out = lunch_with_args(self.args)
self.assertEqual(1, 1)

Expand Down Expand Up @@ -105,3 +107,54 @@ def test_continuation(self, mock_input):
],
'failed to delete: '
)

@patch('builtins.input', return_value='yes')
def test_continuation2(self, mock_input):

with open(blast_output, 'r') as f, open(backup_file, 'w') as ff:
data = blastsearchrecomputefromdict(json.load(f))
data.args.blast_in = blast_in
data.args.json = None
data.args.prediction_method += ['centroid']

new_structures = {'rnafold': []}
for h in data.hits:
n = copy(h.extension)
n.letter_annotations['ss0'] = n.letter_annotations['rnafold']
del n.letter_annotations['rnafold']

new_structures['rnafold'].append(n)

json.dump([blastsearchrecompute2dict(data), {k: [seqrecord2dict(s) for s in v] for k, v in new_structures.items()}, {}], ff, indent=2)

out = lunch_with_args(self.args)
self.assertEqual(1, 1)

# test_output
for i in range(len(out)):
out[0].to_csv(self.csv)
j_obj = json.dumps(blastsearchrecompute2dict(out[0]), indent=2)
with open(self.json, 'w') as ff:
ff.write(j_obj)
out[0].write_results_fasta(self.fasta)
out[0].write_results_structures(self.fasta_structures)

t = tab_output_equal(
csvfile=self.csv,
jsonfile=self.json,
fastafile=self.fasta,
fastastructures=self.fasta_structures,
ref_seqs_file=os.path.join(fwd, test_data_dir, 'simple.json')
)
self.assertEqual(t, True)


remove_files_with_try(
[
self.csv,
self.json,
self.fasta_structures,
self.fasta,
],
'failed to delete: '
)

0 comments on commit 2846e3a

Please sign in to comment.