Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move non-download functionalities out of PODPDownloader - _run_bigscape #143

Merged
merged 48 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
0375fc7
create podp_download_and_extract_antismash_data function which uses a…
gcroci2 Apr 6, 2023
30db87b
add todos
gcroci2 Apr 11, 2023
3278adc
add todo comments
gcroci2 Apr 11, 2023
d5bbee6
rename _resolve_genome_id_data to _resolve_refseq_access_id
gcroci2 Apr 20, 2023
13614b9
improve doc string for _resolve_refseq_access_id
gcroci2 Apr 20, 2023
c717098
rename best_id as raw_genome_id
gcroci2 Apr 20, 2023
300ba41
rename resolved_id as resolved_refseq_id
gcroci2 Apr 20, 2023
80c082d
update doc strings for refactored code
gcroci2 Apr 20, 2023
d3981d8
add download_and_extract_antismash_data to the refactored podp_downlo…
gcroci2 Apr 20, 2023
a8b43e9
add suggestions from review
gcroci2 May 1, 2023
4551724
add type hints in podp_antismash_downloader.py
gcroci2 May 1, 2023
b8bffef
fix prospector errors
gcroci2 May 1, 2023
9b74296
run isort on podp_antismash_downloader.py
gcroci2 May 1, 2023
f5f67ab
run yapf on podp_antismash_downloader.py
gcroci2 May 1, 2023
5084cc5
fix mypy errors on podp_antismash_downloader.py
gcroci2 May 1, 2023
df35373
implement the majority of the suggestions from the review
gcroci2 May 3, 2023
3b7b72d
fix mypy errors
gcroci2 May 4, 2023
903192d
add type hints to GenomeStatus
gcroci2 May 4, 2023
bc8e9fe
improve style and do last checks
gcroci2 May 4, 2023
4dbcc06
Update src/nplinker/pairedomics/podp_antismash_downloader.py
gcroci2 May 12, 2023
0372030
Update src/nplinker/pairedomics/podp_antismash_downloader.py
gcroci2 May 12, 2023
edb1f30
Update src/nplinker/pairedomics/podp_antismash_downloader.py
gcroci2 May 12, 2023
e7b7359
Update src/nplinker/pairedomics/podp_antismash_downloader.py
gcroci2 May 12, 2023
c89a92e
Update src/nplinker/pairedomics/podp_antismash_downloader.py
gcroci2 May 12, 2023
05b5964
Update src/nplinker/pairedomics/__init__.py
gcroci2 May 12, 2023
bab7f77
Update src/nplinker/pairedomics/podp_antismash_downloader.py
gcroci2 May 12, 2023
760dfdc
Update src/nplinker/pairedomics/podp_antismash_downloader.py
gcroci2 May 12, 2023
3420ed7
Update src/nplinker/pairedomics/podp_antismash_downloader.py
gcroci2 May 12, 2023
0987d4e
Update src/nplinker/pairedomics/podp_antismash_downloader.py
gcroci2 May 12, 2023
74416bc
add last suggestions from reviews
gcroci2 May 12, 2023
8267110
add review's suggestions
gcroci2 May 12, 2023
d48d909
add test for GenomeStatus
gcroci2 May 12, 2023
c1c00c5
add doc string to podp_download_and_extract_antismash_data
gcroci2 May 12, 2023
275b6ca
add general test for podp antismash downloader
gcroci2 May 16, 2023
c6aeb68
add tests for exceptions and failures
gcroci2 May 16, 2023
842d398
add tests for different accession ids
gcroci2 May 16, 2023
2c8b381
fix style
gcroci2 May 16, 2023
43b5e00
Update src/nplinker/pairedomics/podp_antismash_downloader.py
gcroci2 May 19, 2023
6098437
Update src/nplinker/pairedomics/podp_antismash_downloader.py
gcroci2 May 19, 2023
e6f3674
implement review's improvements
gcroci2 May 19, 2023
55f85f0
move _run_biscape to runbigscape.py and rename to podp_run_bigscape
gcroci2 Jun 8, 2023
edde34e
delete _run_bigscape and use podp_run_bigscape
gcroci2 Jun 8, 2023
2bf61c3
fix prospector errors
gcroci2 Jun 8, 2023
94db0a7
sort libraries
gcroci2 Jun 8, 2023
9da9312
run yapf
gcroci2 Jun 8, 2023
a8dd375
remove if __name__ statement from runbigscape and add type hint for e…
gcroci2 Jun 20, 2023
1c6b12f
Merge branch 'dev' into move_non_download_func_podpdownloader_gcroci2
gcroci2 Jun 21, 2023
ad553d7
import the correct function's name
gcroci2 Jun 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/nplinker/pairedomics/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
import logging
from .podp_antismash_downloader import download_antismash_data
from .podp_antismash_downloader import podp_download_and_extract_antismash_data

logging.getLogger(__name__).addHandler(logging.NullHandler())

__all__ = [
"download_antismash_data",
"podp_download_and_extract_antismash_data"
]
35 changes: 8 additions & 27 deletions src/nplinker/pairedomics/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
from nplinker.metabolomics.gnps.gnps_extractor import GNPSExtractor
from nplinker.strain_collection import StrainCollection
from nplinker.strains import Strain
from . import download_antismash_data
from .runbigscape import run_bigscape
from . import podp_download_and_extract_antismash_data
from .runbigscape import podp_run_bigscape

logger = LogConfig.getLogger(__name__)

Expand Down Expand Up @@ -143,18 +143,16 @@ def _init_folder_structure(self, local_cache):
self.project_json_file = os.path.join(self.local_cache,
f'{self.gnps_massive_id}.json')


# CG: download function

# download function
def get(self, do_bigscape, extra_bigscape_parameters, use_mibig,
mibig_version):
logger.info('Going to download the metabolomics data file')

self._download_metabolomics_zipfile(self.gnps_task_id)

download_antismash_data(self.project_json['genomes'],
self.project_download_cache,
self.project_file_cache)
podp_download_and_extract_antismash_data(self.project_json['genomes'],
self.project_download_cache,
self.project_file_cache)

# CG: it extracts strain names and later will be used for strains
self._parse_genome_labels(self.project_json['genome_metabolome_links'],
Expand All @@ -167,30 +165,13 @@ def get(self, do_bigscape, extra_bigscape_parameters, use_mibig,

if use_mibig:
self._download_mibig_json(mibig_version)
self._run_bigscape(do_bigscape, extra_bigscape_parameters)
podp_run_bigscape(self.project_file_cache, self.PFAM_PATH, do_bigscape,
extra_bigscape_parameters)

def _is_new_gnps_format(self, directory):
# TODO this should test for existence of quantification table instead
return os.path.exists(os.path.join(directory, 'qiime2_output'))

def _run_bigscape(self, do_bigscape, extra_bigscape_parameters):
# TODO this currently assumes docker environment, allow customisation?
# can check if in container with: https://stackoverflow.com/questions/20010199/how-to-determine-if-a-process-runs-inside-lxc-docker
if not do_bigscape:
logger.info('BiG-SCAPE disabled by configuration, not running it')
return

logger.info('Running BiG-SCAPE! extra_bigscape_parameters="%s"',
extra_bigscape_parameters)
try:
run_bigscape('bigscape.py',
os.path.join(self.project_file_cache, 'antismash'),
os.path.join(self.project_file_cache, 'bigscape'),
self.PFAM_PATH, extra_bigscape_parameters)
except Exception as e:
logger.warning(
'Failed to run BiG-SCAPE on antismash data, error was "%s"', e)

def _download_mibig_json(self, version):
output_path = os.path.join(self.project_file_cache, 'mibig_json')

Expand Down
Loading