diff options
author | AndreaGuarracino | 2020-08-28 10:47:48 +0200 |
---|---|---|
committer | AndreaGuarracino | 2020-08-28 10:47:48 +0200 |
commit | cc8f99d50236b7d0c365990398785ecc319323ea (patch) | |
tree | 6c4c5c98f3ff97038382dc77879737d64fc63495 /bh20sequploader | |
parent | 22f997f59da74c842b6be2a8f4f53e5aa116472e (diff) | |
download | bh20-seq-resource-cc8f99d50236b7d0c365990398785ecc319323ea.tar.gz bh20-seq-resource-cc8f99d50236b7d0c365990398785ecc319323ea.tar.lz bh20-seq-resource-cc8f99d50236b7d0c365990398785ecc319323ea.zip |
qc_fasta returns also the seq_type; verified that only one FASTA is sent at a time; code cleaning
Diffstat (limited to 'bh20sequploader')
-rw-r--r-- | bh20sequploader/main.py | 3 | ||||
-rw-r--r-- | bh20sequploader/qc_fasta.py | 7 |
2 files changed, 6 insertions, 4 deletions
diff --git a/bh20sequploader/main.py b/bh20sequploader/main.py index d5de63e..80c33c8 100644 --- a/bh20sequploader/main.py +++ b/bh20sequploader/main.py @@ -40,7 +40,10 @@ def qc_stuff(metadata, sequence_p1, sequence_p2, do_qc=True): log.debug("FASTA/FASTQ QC" if do_qc else "Limited FASTA/FASTQ QC") target.append(qc_fasta(sequence_p1, check_with_mimimap2=do_qc)) if sequence_p2: + if target[0][2] == 'text/fasta': + raise ValueError("It is possible to upload just one FASTA file at a time") target.append(qc_fasta(sequence_p2)) + target[0] = ("reads_1."+target[0][0][6:], target[0][1]) target[1] = ("reads_2."+target[1][0][6:], target[0][1]) except Exception as e: diff --git a/bh20sequploader/qc_fasta.py b/bh20sequploader/qc_fasta.py index e5c039e..215d6fd 100644 --- a/bh20sequploader/qc_fasta.py +++ b/bh20sequploader/qc_fasta.py @@ -63,8 +63,7 @@ def qc_fasta(arg_sequence, check_with_mimimap2=True): tmp2.write(submitlabel.encode("utf8")) tmp2.write(("".join(submitseq)).encode("utf8")) tmp2.flush() - subbp = 0 - refbp = 0 + similarity = 0 try: cmd = ["minimap2", "-c", tmp1.name, tmp2.name] @@ -85,10 +84,10 @@ def qc_fasta(arg_sequence, check_with_mimimap2=True): if similarity < 70.0: raise ValueError("QC fail: alignment to reference was less than 70%% (was %2.2f%%)" % (similarity)) - return ("sequence.fasta"+gz, seqlabel) + return ("sequence.fasta"+gz, seqlabel, seq_type) elif seq_type == "text/fastq": sequence.seek(0) sequence.detach() - return ("reads.fastq"+gz, seqlabel) + return ("reads.fastq"+gz, seqlabel, seq_type) else: raise ValueError("Sequence file does not look like a DNA FASTA or FASTQ") |