diff --git a/gene_splicer/landscapes.py b/gene_splicer/landscapes.py index 60fe908..9da65e7 100644 --- a/gene_splicer/landscapes.py +++ b/gene_splicer/landscapes.py @@ -56,14 +56,15 @@ def generate_proviral_landscape_csv_1_cont(blastn_reader: csv.DictReader, ref_end = new_end is_inverted = 'yes' - verdict = verdicts.get(qseqid) + verdict = verdicts[qseqid] + is_defective = verdict != 'Intact' landscape_entry = {'ref_start': ref_start, 'ref_end': ref_end, 'samp_name': sample_name, 'run_name': run_name, 'is_inverted': is_inverted, - 'is_defective': verdict is not None, - 'defect': verdict or 'Intact', + 'is_defective': is_defective, + 'defect': verdict, } landscape_writer.writerow(landscape_entry) diff --git a/gene_splicer/utils.py b/gene_splicer/utils.py index 957c5c7..4669b90 100644 --- a/gene_splicer/utils.py +++ b/gene_splicer/utils.py @@ -428,8 +428,12 @@ def iterate_hivintact_verdicts_1(directory: Path, intact: Set[str] = set()) -> I intact = set() def get_verdict(SEQID: str, all_errors) -> Tuple[str, str]: - ordered = sorted(all_errors, key=HIVINTACT_ERRORS_TABLE.index) - verdict = ordered[0] + if all_errors: + ordered = sorted(all_errors, key=HIVINTACT_ERRORS_TABLE.index) + verdict = ordered[0] + else: + verdict = "Intact" + return (SEQID, verdict) with open(os.path.join(directory, 'holistic.csv'), 'r') as f: @@ -437,6 +441,8 @@ def get_verdict(SEQID: str, all_errors) -> Tuple[str, str]: for row in reader: if row["intact"] == "True": intact.add(row["qseqid"]) + SEQID = row["qseqid"] + yield get_verdict(SEQID, all_errors=[]) with open(os.path.join(directory, 'defects.csv'), 'r') as f: reader = csv.DictReader(f)