Skip to content

Commit

Permalink
dont use working_dir for temporary files at all
Browse files Browse the repository at this point in the history
  • Loading branch information
Donaim committed Jun 5, 2023
1 parent 9c4f2be commit be84524
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
24 changes: 12 additions & 12 deletions intact/intact.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def __init__(self, name, start, end, deletion_tolerence):
self.end = end
self.deletion_tolerence = deletion_tolerence

def subtyped(working_dir, subtype, name, start, end, deletion_tolerence):
start_s = st.convert_from_hxb2_to_subtype(working_dir, start, subtype)
end_s = st.convert_from_hxb2_to_subtype(working_dir, end, subtype)
def subtyped(subtype, name, start, end, deletion_tolerence):
start_s = st.convert_from_hxb2_to_subtype(start, subtype)
end_s = st.convert_from_hxb2_to_subtype(end, subtype)
return ExpectedORF(name, start_s, end_s, deletion_tolerence)

class ReceivedORF:
Expand Down Expand Up @@ -618,15 +618,15 @@ def intact( working_dir,
# convert ORF positions to appropriate subtype
forward_orfs, reverse_orfs, small_orfs = [
[
ExpectedORF.subtyped(working_dir, subtype, n, s, e, delta) \
ExpectedORF.subtyped(subtype, n, s, e, delta) \
for (n, s, e, delta) in orfs
] \
for orfs in [hxb2_forward_orfs, hxb2_reverse_orfs, hxb2_small_orfs]
]

# convert PSI locus and RRE locus to appropriate subtype
psi_locus = [st.convert_from_hxb2_to_subtype(working_dir, x, subtype) for x in hxb2_psi_locus]
rre_locus = [st.convert_from_hxb2_to_subtype(working_dir, x, subtype) for x in hxb2_rre_locus]
psi_locus = [st.convert_from_hxb2_to_subtype(x, subtype) for x in hxb2_psi_locus]
rre_locus = [st.convert_from_hxb2_to_subtype(x, subtype) for x in hxb2_rre_locus]

reference = st.subtype_sequence(subtype)

Expand All @@ -641,8 +641,8 @@ def intact( working_dir,
)


alignment = wrappers.mafft(working_dir, [reference, sequence])
reverse_alignment = wrappers.mafft(working_dir, [reference, reverse_sequence])
alignment = wrappers.mafft([reference, sequence])
reverse_alignment = wrappers.mafft([reference, reverse_sequence])

forward_score = alignment_score(alignment)
reverse_score = alignment_score(reverse_alignment)
Expand All @@ -666,8 +666,8 @@ def intact( working_dir,

hxb2_found_orfs = [ORF(
o.orientation,
st.convert_from_subtype_to_hxb2(working_dir, o.start, o.orientation, subtype),
st.convert_from_subtype_to_hxb2(working_dir, o.end, o.orientation, subtype)
st.convert_from_subtype_to_hxb2(o.start, o.orientation, subtype),
st.convert_from_subtype_to_hxb2(o.end, o.orientation, subtype)
) for o in sequence_orfs]

if include_packaging_signal:
Expand All @@ -687,8 +687,8 @@ def intact( working_dir,

if check_major_splice_donor_site:
mutated_splice_donor_site = has_mutated_major_splice_donor_site(alignment,
st.convert_from_hxb2_to_subtype(working_dir, hxb2_msd_site_locus, subtype),
st.convert_from_hxb2_to_subtype(working_dir, hxb2_msd_site_locus + 1, subtype),
st.convert_from_hxb2_to_subtype(hxb2_msd_site_locus, subtype),
st.convert_from_hxb2_to_subtype(hxb2_msd_site_locus + 1, subtype),
const.DEFAULT_MSD_SEQUENCE)
if mutated_splice_donor_site is not None:
sequence_errors.append(mutated_splice_donor_site)
Expand Down
10 changes: 4 additions & 6 deletions util/subtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,18 @@ def subtype_sequence(subtype):
name = alignment[0].name
)

def convert_from_hxb2_to_subtype(working_dir, position, subtype):
def convert_from_hxb2_to_subtype(position, subtype):
"""
Convert a position number in HXB2 to the equivalent in another subtype.
Args:
working_dir: working folder in which to place temporary files
position: hxb2 coordinate position to convert
subtype: subtype position to convert to
"""

sequences = [HXB2(), subtype_sequence(subtype)]

alignment = wrappers.mafft(working_dir, sequences)
alignment = wrappers.mafft(sequences)

hxb2_pos = 0
subtype_pos = 0
Expand All @@ -66,12 +65,11 @@ def convert_from_hxb2_to_subtype(working_dir, position, subtype):
if alignment[1][i] != "-":
subtype_pos += 1

def convert_from_subtype_to_hxb2(working_dir, position, orientation, subtype):
def convert_from_subtype_to_hxb2(position, orientation, subtype):
"""
Convert a position number in HXB2 to the equivalent in another subtype.
Args:
working_dir: working folder in which to place temporary files
position: hxb2 coordinate position to convert
subtype: subtype position to convert to
"""
Expand All @@ -81,7 +79,7 @@ def convert_from_subtype_to_hxb2(working_dir, position, orientation, subtype):
sequences = [SeqRecord.SeqRecord(Seq.reverse_complement(s.seq),
id = s.id, name = s.name) for s in sequences]

alignment = wrappers.mafft(working_dir, sequences)
alignment = wrappers.mafft(sequences)

hxb2_pos = 0
subtype_pos = 0
Expand Down
2 changes: 1 addition & 1 deletion util/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from Bio import SeqIO, AlignIO

def mafft(working_dir, sequences):
def mafft(sequences):
'''
Call mafft on a set of sequences and return the resulting alignment.
Expand Down

0 comments on commit be84524

Please sign in to comment.