From 04df498f5cd85015afce79e1e87a3979e596dcc6 Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Fri, 3 Jul 2020 17:08:25 -0400 Subject: Adding --skip-qc Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- bh20sequploader/main.py | 9 +++++---- bh20sequploader/qc_fasta.py | 7 +++++-- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'bh20sequploader') diff --git a/bh20sequploader/main.py b/bh20sequploader/main.py index 89c30e8..dc63bfc 100644 --- a/bh20sequploader/main.py +++ b/bh20sequploader/main.py @@ -22,10 +22,10 @@ ARVADOS_API_HOST='lugli.arvadosapi.com' ARVADOS_API_TOKEN='2fbebpmbo3rw3x05ueu2i6nx70zhrsb1p22ycu3ry34m4x4462' UPLOAD_PROJECT='lugli-j7d0g-n5clictpuvwk8aa' -def qa_stuff(metadata, sequence_p1, sequence_p2): +def qc_stuff(metadata, sequence_p1, sequence_p2, do_qc=True): try: log.debug("Checking metadata") - if not qc_metadata(metadata.name): + if do_qc and not qc_metadata(metadata.name): log.warning("Failed metadata qc") exit(1) except ValueError as e: @@ -37,7 +37,7 @@ def qa_stuff(metadata, sequence_p1, sequence_p2): target = [] try: log.debug("Checking FASTA/FASTQ QC") - target.append(qc_fasta(sequence_p1)) + target.append(qc_fasta(sequence_p1, check_with_clustalw=do_qc)) if sequence_p2: target.append(qc_fasta(sequence_p2)) target[0] = ("reads_1."+target[0][0][6:], target[0][1]) @@ -64,11 +64,12 @@ def main(): parser.add_argument('sequence_p1', type=argparse.FileType('rb'), help='sequence FASTA/FASTQ') parser.add_argument('sequence_p2', type=argparse.FileType('rb'), default=None, nargs='?', help='sequence FASTQ pair') parser.add_argument("--validate", action="store_true", help="Dry run, validate only") + parser.add_argument("--skip-qc", action="store_true", help="Skip local qc check") args = parser.parse_args() api = arvados.api(host=ARVADOS_API_HOST, token=ARVADOS_API_TOKEN, insecure=True) - target = qa_stuff(args.metadata, args.sequence_p1, args.sequence_p2) + target = qc_stuff(args.metadata, args.sequence_p1, args.sequence_p2, not args.skip_qc) seqlabel = target[0][1] if args.validate: diff --git a/bh20sequploader/qc_fasta.py b/bh20sequploader/qc_fasta.py index 1587def..944b52c 100644 --- a/bh20sequploader/qc_fasta.py +++ b/bh20sequploader/qc_fasta.py @@ -25,7 +25,7 @@ def read_fasta(sequence): raise ValueError("FASTA file contains multiple entries") return label, bases -def qc_fasta(arg_sequence): +def qc_fasta(arg_sequence, check_with_clustalw=True): log.debug("Starting qc_fasta") schema_resource = pkg_resources.resource_stream(__name__, "validation/formats") with tempfile.NamedTemporaryFile() as tmp: @@ -64,6 +64,9 @@ def qc_fasta(arg_sequence): refbp = 0 similarity = 0 try: + if not check_with_clustalw: + raise Exception("skipping QC") + cmd = ["clustalw", "-infile="+tmp1.name, "-quicktree", "-iteration=none", "-type=DNA"] print("QC checking similarity to reference") @@ -81,7 +84,7 @@ def qc_fasta(arg_sequence): print(g2.group(0)) print(g3.group(0)) except Exception as e: - logging.warn("Error trying to QC against reference sequence using 'clustalw': %s", e) + logging.warn("QC against reference sequence using 'clustalw': %s", e) if refbp and (subbp/refbp) < .7: raise ValueError("QC fail: submit sequence length is shorter than 70% reference") -- cgit v1.2.3