diff --git a/util/get_query_aminoacids_table.py b/util/get_query_aminoacids_table.py index 941340e..02014b2 100644 --- a/util/get_query_aminoacids_table.py +++ b/util/get_query_aminoacids_table.py @@ -3,9 +3,6 @@ def get_query_aminoacids_table(sequence): if not hasattr(sequence.seq, "query_aminoacids_table"): - try: - sequence.seq.query_aminoacids_table = [translate_to_aminoacids(sequence.seq, i) for i in range(3)] - except Bio.Data.CodonTable.TranslationError as e: - sequence.seq.query_aminoacids_table = e + sequence.seq.query_aminoacids_table = [translate_to_aminoacids(sequence.seq, i) for i in range(3)] return sequence.seq.query_aminoacids_table diff --git a/util/log.py b/util/log.py index eadc0a1..6d2ee23 100644 --- a/util/log.py +++ b/util/log.py @@ -1,8 +1,4 @@ -import inspect import logging -import os -import select -import subprocess FORMAT = '%(asctime)s - %(name)s - %(levelname)s - %(message)s' @@ -12,46 +8,5 @@ def error(error): logger.error(error) -def warning(warning): - logger.warning(warning) - def info(info): logger.info(info) - -def debug(debug): - logger.debug(debug) - -def logging_call(popenargs, output_stream, error_function): - - """ - Call a subprocess and log the output to stderr to a logfile. - - Args: - popenargs: The arguments to run in the subprocess - output_stream: The stream to pipe stdout to - - Returns: - A path to the SAM output file created. - """ - process = subprocess.Popen(" ".join(popenargs), - stdout=output_stream, - stderr=subprocess.PIPE, - shell=True, - env=os.environ) - - # Get the caller of this function, - # so we can report where we're logging from. - current_frame = inspect.currentframe() - calling_frame = inspect.getouterframes(current_frame, 2) - - def check_io(): - while True: - err = process.stderr.readline().decode() - if err: - error_function("From " + calling_frame[1][3] + " - " + err.rstrip()) - else: - break - - # keep checking stdout/stderr until the child exits - while process.poll() is None: - check_io() \ No newline at end of file diff --git a/util/subtypes.py b/util/subtypes.py index 9853f75..8327850 100644 --- a/util/subtypes.py +++ b/util/subtypes.py @@ -61,31 +61,3 @@ def convert_from_aligned_to_reference(position, alignment): subtype_pos += 1 if alignment[1][i] != "-": hxb2_pos += 1 - -def map_hxb2_positions_to_subtype(subtype): - """ - Convert position numbers in HXB2 to the equivalent in another subtype. - - Args: - subtype: subtype position to convert to - """ - - sequences = [HXB2(), subtype_sequence(subtype)] - alignment = wrappers.mafft(sequences) - return coords.map_positions(alignment[0], alignment[1]) - -def map_subtype_positions_to_hxb2(orientation, subtype): - """ - Convert position numbers in HXB2 to the equivalent in another subtype. - - Args: - subtype: subtype position to convert to - """ - - sequences = [subtype_sequence(subtype), HXB2()] - if orientation == "reverse": - sequences = [SeqRecord.SeqRecord(Seq.reverse_complement(s.seq), - id = s.id, name = s.name) for s in sequences] - - alignment = wrappers.mafft(sequences) - return coords.map_positions(alignment[0], alignment[1])