Пример #1
0
    def test_alifold(self):
        print "testing alifold()"
        align = ["GCCAUCCGAGGGAAAGGUU", "GAUCGACAGCGUCU-AUCG", "CCGUCUUUAUGAGUCCGGC"]

        (css, cen) = RNA.alifold(align)
        self.assertEqual(css,"(((.(((...)))..))).")
        self.assertEqual(RNA.consens_mis(align), "SMBHBHYDRBGDVWmVKBB")
        RNA.free_alifold_arrays()
Пример #2
0
def Consensus(aln, ribosum):
    '''Calculate the consensus MFE from an Biopython Alignment object'''
    if ribosum == True:
        RNA.cvar.ribo = 1
    else:
        RNA.cvar.ribo = 0

    aln_seqs = []
    for rec in aln:
        aln_seqs.append(str(rec.seq))

    cons_str, cons_en = RNA.alifold(aln_seqs)
    return (cons_str, cons_en)
Пример #3
0
def SCI(aln, ribosum):
    '''Calculate the Structure Conservation Index as done in RNAz
    Args:
        aln - AlignIO alignment object
    Returns:
        sci - structure conservation index
    '''
    aln_seqs = []
    for rec in aln:
        aln_seqs.append(str(rec.seq))
        #if ARGS.v >= 1: print rec.seq

    if ribosum == True:
        RNA.cvar.ribo = 1
    else:
        RNA.cvar.ribo = 0

    #Call AliFold
    cons_str, cons_en = RNA.alifold(aln_seqs)
    #if ARGS.v >= 1: print(cons_str, cons_en)

    aln_e = 0
    #Call RNAfold for single Sequences
    for s in aln_seqs:
        s = s.replace(
            '-', '')  #might be a problem for other gap chars, use regex :(
        if s == '': continue  #Exclude pure gaps
        stru, en = RNA.fold(s)
        aln_e += en

    #sci = E_consensus / (1/N) * Sum(E_single seq)
    try:
        sci = float(cons_en) / (float(aln_e) / len(aln_seqs))
        #if ARGS.v >= 1:
        #    print 'Mean E: ',( float(aln_e) / len(aln_seqs) ), 'Consensus E: ', cons_en #For Debug
    except ZeroDivisionError:
        sci = 0
        #if ARGS.v >= 2: print 'Sum of all free energies = 0 (Caught ZeroDivisionError)'
    return sci
import RNA

# The RNA sequence alignment
sequences = [
    "CUGCCUCACAACGUUUGUGCCUCAGUUACCCGUAGAUGUAGUGAGGGU",
    "CUGCCUCACAACAUUUGUGCCUCAGUUACUCAUAGAUGUAGUGAGGGU",
    "---CUCGACACCACU---GCCUCGGUUACCCAUCGGUGCAGUGCGGGU"
]

# compute the consensus sequence
cons = RNA.consensus(sequences)

# predict Minmum Free Energy and corresponding secondary structure
(ss, mfe) = RNA.alifold(sequences)

# print output
print "%s\n%s [ %6.2f ]" % (cons, ss, mfe)