-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* sequence check function and test cases * re-organise files and formatting
- Loading branch information
1 parent
7617542
commit 723373b
Showing
14 changed files
with
507 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
synphage/assets/ncbi_connect/sequence_quality_assessment.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
from dagster import ( | ||
asset, | ||
EnvVar, | ||
Field, | ||
) | ||
|
||
import os | ||
import shutil | ||
|
||
from pathlib import Path | ||
from datetime import datetime | ||
from typing import List | ||
|
||
|
||
sqc_folder_config = { | ||
"sqc_download_dir": Field( | ||
str, | ||
description="Path to folder containing the downloaded genbank sequences", | ||
default_value="download", | ||
), | ||
"genbank_dir": Field( | ||
str, | ||
description="Path to folder containing the genbank files", | ||
default_value="genbank", | ||
), | ||
"fasta_dir": Field( | ||
str, | ||
description="Path to folder containing the fasta sequence files", | ||
default_value="gene_identity/fasta", | ||
), | ||
} | ||
|
||
|
||
@asset( | ||
config_schema={**sqc_folder_config}, | ||
description="Checks for sequence quality and accuracy", | ||
compute_kind="Biopython", | ||
metadata={"owner": "Virginie Grosboillot"}, | ||
) | ||
def sequence_check(context, fetch_genome) -> List[str]: | ||
context.log.info(f"Number of genomes in download folder: {len(fetch_genome)}") | ||
|
||
_gb_path = "/".join( | ||
[os.getenv(EnvVar("PHAGY_DIRECTORY")), context.op_config["genbank_dir"]] | ||
) | ||
os.makedirs(_gb_path, exist_ok=True) | ||
|
||
# add check to assess the quality of the query | ||
|
||
for _file in fetch_genome: | ||
shutil.copy2( | ||
_file, | ||
f"{_gb_path}/{Path(_file).stem.replace('.', '_')}.gb", | ||
) | ||
|
||
_downloaded_files = list( | ||
map( | ||
lambda x: Path(x).stem, | ||
os.listdir(_gb_path), | ||
) | ||
) | ||
|
||
_time = datetime.now() | ||
context.add_output_metadata( | ||
metadata={ | ||
"text_metadata": f"List of downloaded sequences{_time.isoformat()} (UTC).", | ||
"path": _gb_path, | ||
"num_files": len(_downloaded_files), | ||
"preview": _downloaded_files, | ||
} | ||
) | ||
|
||
return _downloaded_files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.