Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
gbouras13 committed Mar 3, 2024
1 parent dd39b1e commit 5eaa906
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 95 deletions.
47 changes: 13 additions & 34 deletions bin/pharokka.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,21 @@
from custom_db import run_custom_pyhmmer
from databases import check_db_installation
from hmm import run_pyhmmer
from input_commands import (
check_dependencies,
get_input,
instantiate_dirs,
instantiate_split_output,
validate_and_extract_genbank,
validate_custom_hmm,
validate_fasta,
validate_gene_predictor,
validate_meta,
validate_terminase,
validate_threads,
)
from input_commands import (check_dependencies, get_input, instantiate_dirs,
instantiate_split_output,
validate_and_extract_genbank, validate_custom_hmm,
validate_fasta, validate_gene_predictor,
validate_meta, validate_terminase,
validate_threads)
from loguru import logger
from post_processing import Pharok, remove_post_processing_files
from processes import (
concat_phanotate_meta,
concat_trnascan_meta,
convert_gff_to_gbk,
reorient_terminase,
run_aragorn,
run_dnaapler,
run_mash_dist,
run_mash_sketch,
run_minced,
run_mmseqs,
run_phanotate,
run_phanotate_fasta_meta,
run_phanotate_txt_meta,
run_pyrodigal,
run_pyrodigal_gv,
run_trna_scan,
run_trnascan_meta,
split_input_fasta,
translate_fastas,
)
from processes import (concat_phanotate_meta, concat_trnascan_meta,
convert_gff_to_gbk, reorient_terminase, run_aragorn,
run_dnaapler, run_mash_dist, run_mash_sketch,
run_minced, run_mmseqs, run_phanotate,
run_phanotate_fasta_meta, run_phanotate_txt_meta,
run_pyrodigal, run_pyrodigal_gv, run_trna_scan,
run_trnascan_meta, split_input_fasta, translate_fastas)
from util import count_contigs, get_version

# add this to make sure of deprecation warning with biopython
Expand Down
25 changes: 10 additions & 15 deletions bin/pharokka_multiplotter.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#!/usr/bin/env python3
import argparse
import os
import shutil
import sys
from argparse import RawTextHelpFormatter
from pathlib import Path
import shutil
from pycirclize.parser import Genbank


from loguru import logger
from plot import create_single_plot
from pycirclize.parser import Genbank
from util import get_version


Expand All @@ -29,7 +28,11 @@ def get_input():
help="Input genbank file from Pharokka.",
)
parser.add_argument(
"-o", "--outdir", action="store", help="Pharokka output directory.",required=True
"-o",
"--outdir",
action="store",
help="Pharokka output directory.",
required=True,
)
parser.add_argument(
"-f", "--force", help="Overwrites the output plot file.", action="store_true"
Expand Down Expand Up @@ -139,12 +142,9 @@ def get_input():
f"--annotations {args.annotations} specified is not a float. Please check your input and try again."
)


if args.force == True:
if os.path.exists(args.outdir) == True:
logger.info(
f"Removing {args.outdir} as --force was specified."
)
logger.info(f"Removing {args.outdir} as --force was specified.")
shutil.rmtree(args.outdir)
else:
logger.warning(
Expand All @@ -161,7 +161,6 @@ def get_input():
if Path(args.outdir).exists() is False:
Path(args.outdir).mkdir(parents=True, exist_ok=True)


# check label_ids

# list of all IDs that need to be labelled from file
Expand Down Expand Up @@ -237,15 +236,11 @@ def get_input():
label_force_list = list(ignore_dict)

except FileNotFoundError:
logger.warning(
f"{label_ids} contains no text. No contigs will be ignored"
)

logger.warning(f"{label_ids} contains no text. No contigs will be ignored")

# if there is 1 contig, then all the parameters will apply

for contig_id, contig_sequence in gb_seq_dict.items():

for contig_id, contig_sequence in gb_seq_dict.items():
logger.info(f"Plotting {contig_id}")

create_single_plot(
Expand Down
16 changes: 4 additions & 12 deletions bin/pharokka_proteins.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,12 @@
from pathlib import Path

from databases import check_db_installation
from input_commands import (
check_dependencies,
instantiate_dirs,
validate_fasta,
validate_threads,
)
from input_commands import (check_dependencies, instantiate_dirs,
validate_fasta, validate_threads)
from loguru import logger
from post_processing import remove_directory, remove_file
from proteins import (
Pharok_Prot,
get_input_proteins,
run_mmseqs_proteins,
run_pyhmmer_proteins,
)
from proteins import (Pharok_Prot, get_input_proteins, run_mmseqs_proteins,
run_pyhmmer_proteins)
from util import get_version


Expand Down
17 changes: 11 additions & 6 deletions bin/plot.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from pathlib import Path
from typing import Dict, List

import numpy as np
from Bio import SeqUtils
from Bio.Seq import Seq
from Bio.SeqFeature import SeqFeature
from loguru import logger
from matplotlib.lines import Line2D
from matplotlib.patches import Patch
from pycirclize import Circos
from pycirclize.parser import Genbank, Gff
from Bio.Seq import Seq
from Bio.SeqFeature import SeqFeature
from Bio import SeqUtils
from typing import List, Dict
from pathlib import Path

# Load GFF file

Expand Down Expand Up @@ -596,6 +597,7 @@ def create_plot(

### for multiplotter


def create_single_plot(
contig_id: str,
contig_sequence: Seq,
Expand Down Expand Up @@ -1099,7 +1101,10 @@ def create_single_plot(
Patch(color=data_dict["head"]["col"], label="Head & packaging"),
Patch(color=data_dict["con"]["col"], label="Connector"),
Patch(color=data_dict["tail"]["col"], label="Tail"),
Patch(color=data_dict["acr_defense_vfdb_card"]["col"], label="Virulence Factor/AMR"),
Patch(
color=data_dict["acr_defense_vfdb_card"]["col"],
label="Virulence Factor/AMR",
),
]

fig = circos.plotfig()
Expand Down
10 changes: 4 additions & 6 deletions bin/proteins.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@
from Bio import SeqIO
from external_tools import ExternalTool
from loguru import logger
from post_processing import (
process_card_results,
process_pyhmmer_results,
process_vfdb_results,
)
from post_processing import (process_card_results, process_pyhmmer_results,
process_vfdb_results)
from pyhmmer.easel import SequenceFile
from pyhmmer.plan7 import HMM, HMMFile
from util import count_contigs, get_contig_headers, get_version, remove_directory
from util import (count_contigs, get_contig_headers, get_version,
remove_directory)

Result = collections.namedtuple("Result", ["protein", "phrog", "bitscore", "evalue"])

Expand Down
11 changes: 2 additions & 9 deletions tests/test_external_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,8 @@
import pytest
from loguru import logger

from bin.processes import (
run_aragorn,
run_mash_sketch,
run_minced,
run_phanotate,
run_pyrodigal,
run_pyrodigal_gv,
)

from bin.processes import (run_aragorn, run_mash_sketch, run_minced,
run_phanotate, run_pyrodigal, run_pyrodigal_gv)
# import functions
from bin.util import remove_directory

Expand Down
15 changes: 4 additions & 11 deletions tests/test_input_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"""

import sys

# import
import unittest
from pathlib import Path
Expand All @@ -15,16 +14,10 @@
import pytest
from loguru import logger

from bin.input_commands import (
instantiate_dirs,
validate_fasta,
validate_gene_predictor,
validate_meta,
validate_strand,
validate_terminase,
validate_terminase_start,
validate_threads,
)
from bin.input_commands import (instantiate_dirs, validate_fasta,
validate_gene_predictor, validate_meta,
validate_strand, validate_terminase,
validate_terminase_start, validate_threads)
from bin.util import remove_directory

# test data
Expand Down
1 change: 0 additions & 1 deletion tests/test_overall.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# import
import os
import shutil

# import functions
import subprocess
import sys
Expand Down
1 change: 0 additions & 1 deletion tests/test_proteins.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# import
import os
import shutil

# import functions
import subprocess
import sys
Expand Down

0 comments on commit 5eaa906

Please sign in to comment.