Skip to content

Commit

Permalink
Adding missing copyright header (based on CVS log this was Andrew's w…
Browse files Browse the repository at this point in the history
…ork). Deprecating the translation and transcription functions (use Bio.Seq instead)
  • Loading branch information
peterc committed Oct 28, 2008
1 parent 41a4497 commit b906372
Showing 1 changed file with 50 additions and 6 deletions.
56 changes: 50 additions & 6 deletions Bio/utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
# Copyright 2000 by Andrew Dalke.
# All rights reserved.
# This code is part of the Biopython distribution and governed by its
# license. Please see the LICENSE file that should have been included
# as part of this package.

"""Miscellaneous functions for dealing with sequences (obsolete?)."""

import string
import Seq
import Alphabet

from PropertyManager import default_manager

def translate(seq, id = None):
"""Translate a sequence (DEPRECATED)."""
import warnings
warnings.warn("Bio.utils.translate() has been deprecated, and we" \
+" intend to remove it in a future release of Biopython."\
+" Please use the translate method or function in Bio.Seq"\
+" instead, as described in the Tutorial.",
DeprecationWarning)
if id is None:
s = "translator"
else:
Expand All @@ -13,6 +28,13 @@ def translate(seq, id = None):
return translator.translate(seq)

def translate_to_stop(seq, id = None):
"""Translate a sequence up to the first in frame stop codon (DEPRECATED)."""
import warnings
warnings.warn("Bio.utils.translate_to_stop() has been deprecated, and we" \
+" intend to remove it in a future release of Biopython."\
+" Please use the translate method or function in Bio.Seq"\
+" instead, as described in the Tutorial.",
DeprecationWarning)
if id is None:
s = "translator"
else:
Expand All @@ -21,6 +43,12 @@ def translate_to_stop(seq, id = None):
return translator.translate_to_stop(seq)

def back_translate(seq, id = None):
"""Back-translate a sequence (DEPRECATED)."""
import warnings
warnings.warn("Bio.utils.back_translate() has been deprecated, and we" \
+" intend to remove it in a future release of Biopython."\
+" If you use it, please tell us on the mailing list.",
DeprecationWarning)
if id is None:
s = "translator"
else:
Expand All @@ -30,15 +58,31 @@ def back_translate(seq, id = None):


def transcribe(seq):
"""Transcribe a sequence (DEPRECATED)."""
import warnings
warnings.warn("Bio.utils.transcribe() has been deprecated, and we" \
+" intend to remove it in a future release of Biopython."\
+" Please use the transcribe method or function in"\
+" Bio.Seq instead, as described in the Tutorial.",
DeprecationWarning)
transcriber = default_manager.resolve(seq.alphabet, "transcriber")
return transcriber.transcribe(seq)

def back_transcribe(seq):
"""Back-transcribe a sequence (DEPRECATED)."""
import warnings
warnings.warn("Bio.utils.back_transcribe() has been deprecated, and we" \
+" intend to remove it in a future release of Biopython."\
+" Please use the back_transcribe method or function in"\
+" Bio.Seq instead, as described in the Tutorial.",
DeprecationWarning)
transcriber = default_manager.resolve(seq.alphabet, "transcriber")
return transcriber.back_transcribe(seq)

def ungap(seq):
"""given a sequence with gap encoding, return the ungapped sequence"""
#TODO - Fix this? It currently assumes the outmost AlphabetEncoder
#is for the gap. Consider HasStopCodon(Gapped(Protein())) as a test case.
gap = seq.gap_char
letters = []
for c in seq.data:
Expand Down Expand Up @@ -66,12 +110,12 @@ def count_monomers(seq):
return dict

def percent_monomers(seq):
dict2 = {}
seq_len = len(seq)
dict = count_monomers(seq)
for m in dict:
dict2[m] = dict[m] * 100. / seq_len
return dict2
dict2 = {}
seq_len = len(seq)
dict = count_monomers(seq)
for m in dict:
dict2[m] = dict[m] * 100. / seq_len
return dict2

def sum(seq, table, zero = 0.0):
total = zero
Expand Down

0 comments on commit b906372

Please sign in to comment.