本文整理汇总了Python中Bio.Seq.reverse_complement方法的典型用法代码示例。如果您正苦于以下问题:Python Seq.reverse_complement方法的具体用法?Python Seq.reverse_complement怎么用?Python Seq.reverse_complement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bio.Seq
的用法示例。
在下文中一共展示了Seq.reverse_complement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_reverse_complement_on_proteins
# 需要导入模块: from Bio import Seq [as 别名]
# 或者: from Bio.Seq import reverse_complement [as 别名]
def test_reverse_complement_on_proteins(self):
"""Test reverse complement shouldn't work on a protein!"""
for s in protein_seqs:
with self.assertRaises(ValueError):
Seq.reverse_complement(s)
with self.assertRaises(ValueError):
s.reverse_complement()
示例2: rc_kmers
# 需要导入模块: from Bio import Seq [as 别名]
# 或者: from Bio.Seq import reverse_complement [as 别名]
def rc_kmers(self, kmers):
res={}
keys=[]
for s in kmers:
if Seq.reverse_complement(s) in keys:
res[s]=Seq.reverse_complement(s)
else:
keys.append(s)
res[s]=s
return keys,res
示例3: test_reverse_complement
# 需要导入模块: from Bio import Seq [as 别名]
# 或者: from Bio.Seq import reverse_complement [as 别名]
def test_reverse_complement(self):
test_seqs_copy = copy.copy(test_seqs)
test_seqs_copy.pop(21)
for nucleotide_seq in test_seqs_copy:
if not isinstance(nucleotide_seq.alphabet, Alphabet.ProteinAlphabet) and \
isinstance(nucleotide_seq, Seq.Seq):
expected = Seq.reverse_complement(nucleotide_seq)
self.assertEqual(repr(expected), repr(nucleotide_seq.reverse_complement()))
self.assertEqual(repr(expected[::-1]), repr(nucleotide_seq.complement()))
self.assertEqual(str(nucleotide_seq.complement()),
str(Seq.reverse_complement(nucleotide_seq))[::-1])
self.assertEqual(str(nucleotide_seq.reverse_complement()),
str(Seq.reverse_complement(nucleotide_seq)))
示例4: reverse_complement
# 需要导入模块: from Bio import Seq [as 别名]
# 或者: from Bio.Seq import reverse_complement [as 别名]
def reverse_complement(sequence):
"""
Reverse complement of a sequence represented as unicode string.
Unfortunately, BioPython's reverse_complement doesn't work on unicode
strings. We work almost exclusively with unicode strings, so this is a
convenience wrapper.
"""
return unicode(Seq.reverse_complement(str(sequence)))
示例5: translate
# 需要导入模块: from Bio import Seq [as 别名]
# 或者: from Bio.Seq import reverse_complement [as 别名]
def translate(seq):
r = {}
r['First Frame'] = Seq.translate(seq)
r['Second Frame'] = Seq.translate(seq[1:])
r['Third Frame'] = Seq.translate(seq[2:])
seq = Seq.reverse_complement(seq)
r['Complement First Frame'] = Seq.translate(seq)
r['Complement Second Frame'] = Seq.translate(seq[1:])
r['Complement Third Frame'] = Seq.translate(seq[2:])
return r
示例6: oligos_1
# 需要导入模块: from Bio import Seq [as 别名]
# 或者: from Bio.Seq import reverse_complement [as 别名]
def oligos_1():
overhangs = ['CATG', 'ACAA']
bc = 'GATGATTGA'
kozak = 'gccacc'
start = 'atg'
fwd =overhangs[0] + loxp + bc + kozak + start + lox71
rev = seq.reverse_complement(loxp+bc+kozak+start+lox71+overhangs[1])
print fwd.upper()
print rev.upper()
示例7: delGene
# 需要导入模块: from Bio import Seq [as 别名]
# 或者: from Bio.Seq import reverse_complement [as 别名]
def delGene(geneName, cutsite):
# This function asks user for a chromosomal locus, a region to be deleted, a suitable CRIPSR cutsite
# and outputs oligos for cloning of a pL308 Cas9-gRNA vector, and ones for generating a donor DNA
# to delete the unwanted chromosomal region. Primers Lup+Rdown produce a 1kb band if deletion was
# successful.
# part of yCRISPRv3 by [email protected]
#GeneName=input("Name, using quotes: ")
#cutsite=input("20-mer cut sequence, using quotes: ").upper()
locus = genomicData[geneName][0]
deletion = genomicData[geneName][1]
deletion = Seq(deletion)
if deletion.find(cutsite)==-1:
if deletion.reverse_complement().find(cutsite)==-1:
print ("WARNING: Guide 20-mer sequence not found in deletion region.")
locus=Seq(locus)
index=locus.find(deletion)
# index gives the start position within locus of the string deletion.
# now we delete the deletion region to redefine a newlocus:
newlocus=locus[0:index]+locus[index+len(deletion):]
# note that since index starts at 0, a value of n points to, in the newlocus,
# the first nt after the deletion. So we define the newlocus as above. Note too
# that a string of len=40 ends at an index of 39--so we pick up at index+len-1.
Lup=newlocus[index-500:index-470]
Rdown=newlocus[index+469:index+499].reverse_complement()
Rtemp1 = newlocus[:index].reverse_complement()
Rtemp2 = newlocus[index:].reverse_complement()
rPrimer, rLength = getPrimer(Rtemp1)
lPrimer, lLength = getPrimer(newlocus[index:])
Rup = getOverhang(Rtemp2, rLength) + rPrimer
Ldown = getOverhang(newlocus[:index], lLength) + lPrimer
cutSequence=Seq("cgggtggcgaatgggacttt")+cutsite+Seq("gttttagagctagaaatagc")
seqprimer=Seq("gacttt")+cutsite
print("cut" + GeneName + " " + cutSequence)
print("seq" + GeneName + " " + seqprimer)
print("Lup" + GeneName + "del" + " " + Lup)
print("Rup" + GeneName + "del" + " " + Rup)
print("Ldown" + GeneName + "del" + " " + Ldown)
print("Rdown" + GeneName + "del" + " " + Rdown)
return Ldown, Rup
示例8: get_sgrna
# 需要导入模块: from Bio import Seq [as 别名]
# 或者: from Bio.Seq import reverse_complement [as 别名]
def get_sgrna(self):
# return DataFrame contains possible sgRNAs.
if not hasattr(self, 'sgrna'):
ngg = re.compile(
'([atgcATGC]{20})([atgcATGC](GG|gg|Gg|gG))'
)
ccn = re.compile(
'((CC|cc|Cc|cC)[atgcATGC])([atgcATGC]{20})'
)
columns = ['seqname', 'start', 'cut', 'end', 'sgrna', 'pam']
sgrna = list()
for chromosome in self.genome:
sglist = [
{
'seqname': chromosome.id,
'start': x.start(),
'cut': x.end() - 6,
'end': x.end() - 3,
'sgrna': x.group(1),
'pam': x.group(2)
}
for x in ngg.finditer(str(chromosome.seq))
]
sglist.extend(
{
'seqname': chromosome.id,
'start': x.start() + 3,
'cut': x.start() + 6,
'end': x.end(),
'sgrna': Seq.reverse_complement(x.group(3)),
'pam': Seq.reverse_complement(x.group(1))
}
for x in ccn.finditer(str(chromosome.seq))
)
sgrna.append(
pd.DataFrame(
sglist,
columns = columns
)
)
self.sgrna = pd.concat(sgrna, axis = 0, ignore_index = True)
return self.sgrna
示例9: orf_reader
# 需要导入模块: from Bio import Seq [as 别名]
# 或者: from Bio.Seq import reverse_complement [as 别名]
def orf_reader(infile):
orfs = {}
handle = open(infile,"r")
lines = handle.readlines()
for line in lines:
if line[0] != "#":
line_array = line.split("\t")
if int(line_array[1]) < 0:
orfs[line_array[0]] = [Seq.reverse_complement(line_array[4]),line_array[4]]
else:
orfs[line_array[0]] = [line_array[4],line_array[4]]
return orfs
示例10: bam_to_fastq
# 需要导入模块: from Bio import Seq [as 别名]
# 或者: from Bio.Seq import reverse_complement [as 别名]
def bam_to_fastq(bam_file, is_paired):
"""Convert a BAM file to fastq files.
"""
out_files, out_handles = _get_fastq_handles(bam_file,
is_paired)
if len(out_handles) > 0:
in_bam = pysam.Samfile(bam_file, mode='rb')
for read in in_bam:
num = 1 if (not read.is_paired or read.is_read1) else 2
# reverse the sequence and quality if mapped to opposite strand
if read.is_reverse:
seq = str(Seq.reverse_complement(Seq.Seq(read.seq)))
qual = "".join(reversed(read.qual))
else:
seq = read.seq
qual = read.qual
out_handles[num].write("@%s\n%s\n+\n%s\n" % (read.qname,
seq, qual))
[h.close() for h in out_handles.values()]
return out_files
示例11: dna_aa
# 需要导入模块: from Bio import Seq [as 别名]
# 或者: from Bio.Seq import reverse_complement [as 别名]
def dna_aa():
if session.username == None:
redirect(URL(r=request, c='account', f='log_in'))
form = FORM(TABLE(TR('Sequence (raw format): ',
TEXTAREA(_type='text', _name='sequence',
requires=IS_NOT_EMPTY())),
#TR("Sequence Type: ",
# SELECT("Raw Format", "FASTA",
# _name="seq_type")),
TR('Action: ',
SELECT('Complementation', 'Transcribe', 'Translate',
'Back Transcribe', 'Back Translate',
_name='action'),
INPUT(_type='submit', _value='SUBMIT'))))
if form.accepts(request.vars,session):
#if form.vars.seq_type == "FASTA":
# session['sequence'] = \
# seqClean(fasta_to_raw(form.vars.sequence.upper()))
#else:
session['sequence'] = seqClean(form.vars.sequence.upper())
if form.vars.action == "Complementation":
session['action'] = "Complementation"
session['Complement'] = Seq.reverse_complement(session['sequence'])
if form.vars.action == "Transcribe":
session['action'] = 'Transcribe'
session['Transcribed RNA'] = Seq.transcribe(session['sequence'])
if form.vars.action == "Back Transcribe":
session['action'] = 'Back Transcribe'
session['DNA'] = Seq.back_transcribe(session['sequence'])
if form.vars.action == "Translate":
session['action'] = 'Translate'
session.update(translate(session['sequence']))
if form.vars.action == "Back Translate":
session['action'] = 'Back Translate'
session.update(back_translate(session['sequence']))
redirect(URL(r=request, f='dna_aa_output'))
return dict(form=form)
示例12: complement
# 需要导入模块: from Bio import Seq [as 别名]
# 或者: from Bio.Seq import reverse_complement [as 别名]
def complement(sequence) :
#TODO - Add a complement function to Bio/Seq.py?
#There is already a complement method on the Seq and MutableSeq objects.
return Seq.reverse_complement(sequence)[::-1]
示例13: twin
# 需要导入模块: from Bio import Seq [as 别名]
# 或者: from Bio.Seq import reverse_complement [as 别名]
def twin(km):
''' Retorna la secuencia invertida '''
return Seq.reverse_complement(km)
示例14: complement
# 需要导入模块: from Bio import Seq [as 别名]
# 或者: from Bio.Seq import reverse_complement [as 别名]
compl_values = complement(values).replace("T", "U") # need to help as no alphabet
print("%s={%s} --> {%s}=%s" %
(ambig_char, values, compl_values, ambiguous_rna_complement[ambig_char]))
assert set(compl_values) == set(ambiguous_rna_values[ambiguous_rna_complement[ambig_char]])
print("")
print("Reverse complements:")
for sequence in [Seq.Seq("".join(sorted(ambiguous_rna_values))),
Seq.Seq("".join(sorted(ambiguous_dna_values))),
Seq.Seq("".join(sorted(ambiguous_rna_values)), Alphabet.generic_rna),
Seq.Seq("".join(sorted(ambiguous_dna_values)), Alphabet.generic_dna),
Seq.Seq("".join(sorted(ambiguous_rna_values)).replace("X", ""), IUPAC.IUPACAmbiguousRNA()),
Seq.Seq("".join(sorted(ambiguous_dna_values)).replace("X", ""), IUPAC.IUPACAmbiguousDNA()),
Seq.Seq("AWGAARCKG")]: # Note no U or T
print("%s -> %s"
% (repr(sequence), repr(Seq.reverse_complement(sequence))))
assert str(sequence) \
== str(Seq.reverse_complement(Seq.reverse_complement(sequence))), \
"Dobule reverse complement didn't preserve the sequence!"
print("")
###########################################################################
test_seqs = [s, t, u,
Seq.Seq("ATGAAACTG"),
"ATGAAACtg",
# TODO - Fix ambiguous translation
# Seq.Seq("ATGAARCTG"),
# Seq.Seq("AWGAARCKG"), # Note no U or T
# Seq.Seq("".join(ambiguous_rna_values)),
# Seq.Seq("".join(ambiguous_dna_values)),
示例15: twin
# 需要导入模块: from Bio import Seq [as 别名]
# 或者: from Bio.Seq import reverse_complement [as 别名]
def twin(km):
return Seq.reverse_complement(km)