Skip to content

Commit

Permalink
Add option to perform translated alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
lauraluebbert authored Nov 12, 2024
1 parent 99aebe4 commit d221f2e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions gget/gget_diamond.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
def diamond(
query,
reference,
translated=False,
diamond_db=None,
sensitivity="very-sensitive",
threads=1,
Expand All @@ -39,6 +40,9 @@ def diamond(
Args:
- query Sequences (str or list) or path to FASTA file containing sequences to be aligned against the reference.
- reference Reference sequences (str or list) or path to FASTA file containing reference sequences.
Set translated=True if reference sequences are amino acid sequences and query sequences are nucleotide sequences.
- translated True/False whether to perform translated alignment of nucleotide sequences to an amino acid reference.
Default: False.
- diamond_db Path to save DIAMOND database created from reference.
Default: None -> Temporary db file will be deleted after alignment or saved in 'out' if 'out' is provided.
- sensitivity Sensitivity of DIAMOND alignment.
Expand Down Expand Up @@ -117,15 +121,20 @@ def diamond(
reference_file_w = reference_file.replace("/", "\\")
output_w = output.replace("/", "\\")

if translated:
diamond_program = "blastp"
else:
diamond_program = "blastx"

if platform.system() == "Windows":
command = f"{DIAMOND} version \
&& {DIAMOND_w} makedb --quiet --in {reference_file_w} --db {diamond_db_w} --threads {threads} \
&& {DIAMOND_w} blastp --outfmt 6 qseqid sseqid pident qlen slen length mismatch gapopen qstart qend sstart send evalue bitscore \
&& {DIAMOND_w} {diamond_program} --outfmt 6 qseqid sseqid pident qlen slen length mismatch gapopen qstart qend sstart send evalue bitscore \
--quiet --query {input_file_w} --db {reference_file_w} --out {output_w} --{sensitivity} --threads {threads} --ignore-warnings"
else:
command = f"'{DIAMOND}' version \
&& '{DIAMOND}' makedb --quiet --in '{reference_file}' --db '{diamond_db}' --threads {threads} \
&& '{DIAMOND}' blastp --outfmt 6 qseqid sseqid pident qlen slen length mismatch gapopen qstart qend sstart send evalue bitscore \
&& '{DIAMOND}' {diamond_program} --outfmt 6 qseqid sseqid pident qlen slen length mismatch gapopen qstart qend sstart send evalue bitscore \
--quiet --query '{input_file}' --db '{reference_file}' --out '{output}' --{sensitivity} --threads {threads} --ignore-warnings"

# Run DIAMOND
Expand Down

0 comments on commit d221f2e

Please sign in to comment.