/usr/lib/python3/dist-packages/screed/dna.py is in python3-screed 1.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | # Copyright (c) 2016, The Regents of the University of California.
import array
import string
legal_dna = "ACGTN"
def is_DNA(seq):
"""
Returns 1 if it contains only legal values for a DNA sequence.
c.f. http://www.ncbi.nlm.nih.gov/BLAST/fasta.html
"""
for ch in seq:
if ch not in legal_dna:
return 0
return 1
def reverse_complement(s):
"""
Build reverse complement of 's'.
"""
s = s.upper()
assert is_DNA(s), "Your sequence must be DNA!"
r = reverse(s)
rc = complement(r)
return rc
rc = reverse_complement # alias 'rc' to 'reverse_complement'
__complementTranslation = {"A": "T", "C": "G", "G": "C", "T": "A", "N": "N"}
def complement(s):
"""
Return complement of 's'.
"""
c = "".join(__complementTranslation[n] for n in s)
return c
def reverse(s):
"""
Return reverse of 's'.
"""
r = "".join(reversed(s))
return r
|