Skip to content

1.7.3 PR #169

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

Merged
merged 6 commits into from
Jun 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 6 additions & 2 deletions artic/fasta_header.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
from Bio import SeqIO
from importlib.metadata import version


def fasta_header(args):
with open(args.filename) as fh:
rec = list(SeqIO.parse(fh, "fasta"))

fasta_format = "fasta-2line" if args.linearise_fasta else "fasta"
artic_version = version("artic")

with open(args.filename, "w") as fh:
for record in rec:
chrom = record.id
record.id = f"{args.samplename}/{chrom}/ARTIC/{args.caller}"
record.id = f"{args.samplename}"
record.description = (
f"{chrom}_artic-network/fieldbioinformatics_{artic_version}"
)

SeqIO.write(record, fh, fasta_format)

Expand All @@ -23,7 +28,6 @@ def main():
)
parser.add_argument("filename")
parser.add_argument("samplename")
parser.add_argument("caller")
parser.add_argument("--linearise-fasta", action="store_true")

args = parser.parse_args()
Expand Down
25 changes: 12 additions & 13 deletions artic/minion.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def run(parser, args):
raise SystemExit(1)

## collect the primer pools
pools = set([row["PoolName"] for row in read_bed_file(bed)])
pools = set([row["PoolName"] for row in read_bed_file(bed)] + ["unmatched"])

## create a holder to keep the pipeline commands in
cmds = []
Expand Down Expand Up @@ -171,20 +171,19 @@ def run(parser, args):
os.remove("%s.%s.hdf" % (args.sample, p))

# Split the BAM by read group
for p in pools:
cmds.append(
f"samtools view -b -r {p} {args.sample}.trimmed.rg.sorted.bam -o {args.sample}.{p}.trimmed.rg.sorted.bam"
)
cmds.append(
f"samtools view -b -r {p} {args.sample}.trimmed.rg.sorted.bam -o {args.sample}.{p}.trimmed.rg.sorted.bam"
)

cmds.append(f"samtools index {args.sample}.{p}.trimmed.rg.sorted.bam")
cmds.append(f"samtools index {args.sample}.{p}.trimmed.rg.sorted.bam")

cmds.append(
f"run_clair3.sh --enable_long_indel --chunk_size=10000 --haploid_precise --no_phasing_for_fa --bam_fn='{args.sample}.{p}.trimmed.rg.sorted.bam' --ref_fn='{ref}' --output='{args.sample}_rg_{p}' --threads='{args.threads}' --platform='ont' --model_path='{full_model_path}' --include_all_ctgs"
)
cmds.append(
f"run_clair3.sh --enable_long_indel --chunk_size=10000 --haploid_precise --no_phasing_for_fa --bam_fn='{args.sample}.{p}.trimmed.rg.sorted.bam' --ref_fn='{ref}' --output='{args.sample}_rg_{p}' --threads='{args.threads}' --platform='ont' --model_path='{full_model_path}' --include_all_ctgs"
)

cmds.append(
f"bgzip -dc {args.sample}_rg_{p}/merge_output.vcf.gz > {args.sample}.{p}.vcf"
)
cmds.append(
f"bgzip -dc {args.sample}_rg_{p}/merge_output.vcf.gz > {args.sample}.{p}.vcf"
)

# 7) merge the called variants for each read group
merge_vcf_cmd = "artic_vcf_merge %s %s 2> %s.primersitereport.txt" % (
Expand Down Expand Up @@ -237,7 +236,7 @@ def run(parser, args):
caller = "clair3"
linearise_fasta = "--linearise-fasta" if args.linearise_fasta else ""
cmds.append(
f"artic_fasta_header {linearise_fasta} {args.sample}.consensus.fasta {args.sample} {caller}"
f"artic_fasta_header {linearise_fasta} {args.sample}.consensus.fasta {args.sample}"
)

if args.align_consensus:
Expand Down
11 changes: 7 additions & 4 deletions tests/minion_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,11 @@

# extraFlags is a way to add extra sample-specific commands to the validation test cmd
extraFlags = {
"medaka": {
"SP1": ["--no-frameshifts"],
},
"clair3": {
"SP1": ["--no-frameshifts"],
"CVR1": ["--no-frameshifts"],
},
"clair3_allow_mismatches": {"CVR1": ["--allow-mismatched-primers"]},
}


Expand Down Expand Up @@ -186,7 +184,7 @@ def genCommand(sampleID, workflow):
dataDir + "primer-schemes",
]

if workflow == "clair3":
if workflow == "clair3" or workflow == "clair3_allow_mismatches":
cmd.append("--model")
cmd.append("r941_prom_hac_g360+g422")

Expand Down Expand Up @@ -225,6 +223,8 @@ def runner(workflow, sampleID):

if workflow == "clair3":
data = clair3TestVariants
elif workflow == "clair3_allow_mismatches":
data = clair3TestVariants
elif workflow == "medaka":
data = medakaTestVariants
else:
Expand Down Expand Up @@ -355,6 +355,9 @@ class TestMinion(unittest.TestCase):
def setUp(self):
dataChecker()

def test_Clair3_CVR1_allow_primer_mismatches(self):
runner("clair3_allow_mismatches", "CVR1")

def test_Clair3_CVR1(self):
runner("clair3", "CVR1")

Expand Down
Loading