Skip to content

Commit

Permalink
Improve typing in fasta_to_csv
Browse files Browse the repository at this point in the history
  • Loading branch information
Donaim committed Dec 7, 2024
1 parent 8b8aaf7 commit 199f3a5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions micall/tests/test_fasta_to_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def DEFAULT_DATABASE():

@pytest.fixture(scope='session', name='hcv_db')
def check_hcv_db(DEFAULT_DATABASE):
db_path = Path(DEFAULT_DATABASE)
db_path = DEFAULT_DATABASE
index_path = db_path.parent / "refs.fasta.nin"
build_needed = not index_path.exists()
if not build_needed:
Expand All @@ -32,7 +32,7 @@ def check_hcv_db(DEFAULT_DATABASE):


def test_make_blast_db_excludes_hivgha(hcv_db, DEFAULT_DATABASE):
fasta_path = Path(DEFAULT_DATABASE)
fasta_path = DEFAULT_DATABASE
with fasta_path.open() as f:
for reference in SeqIO.parse(f, 'fasta'):
# Exclude the Ghana project, because they're recombinant.
Expand Down
2 changes: 1 addition & 1 deletion micall/utils/contig_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def main():
with default_database() as DEFAULT_DATABASE:
stdout = Blastn().genotype(
contigs_fasta=contigs_fasta_path,
database=Path(DEFAULT_DATABASE),
database=DEFAULT_DATABASE,
)
plot_contigs(sample_dir, stdout)
plot_path = contig_plots_path / (sample_dir.name + '.png')
Expand Down
8 changes: 4 additions & 4 deletions micall/utils/fasta_to_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ def reference_dir() -> Iterator[Path]:


@contextlib.contextmanager
def default_database() -> Iterator[str]:
def default_database() -> Iterator[Path]:
with reference_dir() as blast_db:
yield str(blast_db / "refs.fasta")
yield blast_db / "refs.fasta"


def read_assembled_contigs(group_refs: Dict[str, str],
Expand Down Expand Up @@ -134,7 +134,7 @@ def write_contigs(writer: DictWriter,
contig=contig.seq))


def genotype(fasta: str, db: Optional[str] = None,
def genotype(fasta: str, db: Optional[Path] = None,
blast_csv: Optional[TextIO] = None,
group_refs: Optional[Dict[str, str]] = None) -> Dict[str, typing.Tuple[str, float]]:
"""Use Blastn to search for the genotype of a set of reference sequences.
Expand Down Expand Up @@ -166,7 +166,7 @@ def genotype(fasta: str, db: Optional[str] = None,
'sstart',
'send']

def invoke_blast(db: str) -> str:
def invoke_blast(db: Path) -> str:
return Blastn().genotype(
contigs_fasta=Path(fasta),
database=Path(db),
Expand Down

0 comments on commit 199f3a5

Please sign in to comment.