Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
remove handling of alignment failures
Browse files Browse the repository at this point in the history
  • Loading branch information
Donaim committed Sep 27, 2023
1 parent c7b622b commit 1fe61c6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
11 changes: 1 addition & 10 deletions intact/intact.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
SCRAMBLE_ERROR = "Scramble"
NONHIV_ERROR = "NonHIV"
INTERNALINVERSION_ERROR = "InternalInversion"
ALIGNMENT_FAILED = "AlignmentFailed" # Happens when mafft process fails
UNKNOWN_NUCLEOTIDE = "UnknownNucleotide" # Happens when there is an invalid codon anywhere in a sequence

FRAMESHIFTINORF_ERROR = "FrameshiftInOrf"
Expand Down Expand Up @@ -879,15 +878,7 @@ def analyse_single_sequence(holistic, sequence, blast_rows):
blast_it = blast_iterate_inf(subtype, input_file, working_dir) if check_internal_inversion or check_nonhiv or check_scramble or 1 < len(subtype_choices) else iterate_empty_lists()
for (sequence, blast_rows) in with_blast_rows(blast_it, iterate_sequences(input_file)):
holistic = HolisticInfo()

try:
is_intact, hxb2_found_orfs, sequence_errors = analyse_single_sequence(holistic, sequence, blast_rows)
except wrappers.AlignmentFailure:
err = IntactnessError(sequence.id, ALIGNMENT_FAILED, "Alignment failed for this sequence. It probably contains invalid symbols.")
is_intact = False
hxb2_found_orfs = []
sequence_errors = [err]

is_intact, hxb2_found_orfs, sequence_errors = analyse_single_sequence(holistic, sequence, blast_rows)
orfs = [x.__dict__ for x in hxb2_found_orfs]
errors = [x.__dict__ for x in sequence_errors]
holistic = holistic.__dict__
Expand Down
10 changes: 1 addition & 9 deletions util/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@

from util.blastrow import BlastRow

class AlignmentFailure(Exception):
pass

def mafft(sequences):
'''
Call mafft on a set of sequences and return the resulting alignment.
Expand All @@ -22,12 +19,7 @@ def mafft(sequences):

with tempfile.NamedTemporaryFile() as alignment_input, tempfile.NamedTemporaryFile() as alignment_output:
SeqIO.write(sequences, alignment_input.name, "fasta")

try:
subprocess.run(["mafft", "--quiet", alignment_input.name], shell=False, stdout=alignment_output, check=True)
except subprocess.CalledProcessError:
raise AlignmentFailure()

subprocess.run(["mafft", "--quiet", alignment_input.name], shell=False, stdout=alignment_output, check=True)
alignment = AlignIO.read(alignment_output.name, "fasta")
return alignment

Expand Down

0 comments on commit 1fe61c6

Please sign in to comment.