当前位置: 首页>>代码示例>>Python>>正文


Python Seq.reverse_complement方法代码示例

本文整理汇总了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()
开发者ID:BrianLinSu,项目名称:rop,代码行数:10,代码来源:test_seq.py

示例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
开发者ID:michalwlasnowolski,项目名称:enpredict,代码行数:12,代码来源:kmers.py

示例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)))
开发者ID:BrianLinSu,项目名称:rop,代码行数:16,代码来源:test_seq.py

示例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)))
开发者ID:chenyu600,项目名称:mutalyzer,代码行数:11,代码来源:util.py

示例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
开发者ID:mauriceling,项目名称:cynote,代码行数:12,代码来源:sequence.py

示例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()
开发者ID:bh0085,项目名称:zhang,代码行数:12,代码来源:lox.py

示例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
开发者ID:riforin,项目名称:CRISPRv2,代码行数:57,代码来源:yCRISPRv4.1.py

示例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
开发者ID:wolfsonliu,项目名称:biotools,代码行数:44,代码来源:genomeinfo.py

示例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
开发者ID:gedankenstuecke,项目名称:bioinf-junk,代码行数:14,代码来源:snp_utr_filter.py

示例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
开发者ID:aminmg,项目名称:bcbb,代码行数:22,代码来源:analyze_quality_recal.py

示例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)
开发者ID:mauriceling,项目名称:cynote,代码行数:39,代码来源:sequence.py

示例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]
开发者ID:frankkl,项目名称:biopython,代码行数:6,代码来源:test_seq.py

示例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)
开发者ID:Nazkter,项目名称:deBruijn,代码行数:5,代码来源:dbg.py

示例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)),
开发者ID:kevinwuhoo,项目名称:biopython,代码行数:33,代码来源:test_seq.py

示例15: twin

# 需要导入模块: from Bio import Seq [as 别名]
# 或者: from Bio.Seq import reverse_complement [as 别名]
def twin(km):
    return Seq.reverse_complement(km)
开发者ID:zenlc2000,项目名称:pycuda-euler,代码行数:4,代码来源:referenceAssembler.py


注:本文中的Bio.Seq.reverse_complement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。