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


Python RNA.fold方法代码示例

本文整理汇总了Python中RNA.fold方法的典型用法代码示例。如果您正苦于以下问题:Python RNA.fold方法的具体用法?Python RNA.fold怎么用?Python RNA.fold使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RNA的用法示例。


在下文中一共展示了RNA.fold方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: prep_sec2

# 需要导入模块: import RNA [as 别名]
# 或者: from RNA import fold [as 别名]
def prep_sec2(seq_five, seq_three, seq_apta, shift, rand):
    (take, dump) = RNA.fold(seq_five + "N" + "G" * 100 + "N" * 4 + "C" * 100 + "N" + seq_three)
    (take1, dump) = RNA.fold(seq_apta)
    seq = (
        len(take.split("." + "(" * 100 + "." * 4 + ")" * 100 + ".", 1)[0]) * "."
        + "(" * rand
        + take1
        + ")" * (rand)
        + "." * shift
        + len(take.split("." + "(" * 100 + "." * 4 + ")" * 100 + ".", 1)[1]) * "."
    )
    return seq
开发者ID:kentgorday,项目名称:Heidelberg_15,代码行数:14,代码来源:JAWS.py

示例2: Rewards

# 需要导入模块: import RNA [as 别名]
# 或者: from RNA import fold [as 别名]
    def Rewards(self,k):
        #copy_unpairedposition=list(unpairedposition)
        #copy_bppused=list(bppused)
        if k > len(str_uindex)-1:
            posbasep=self.position[len(str_uindex):self.n]
            posbase=self.position[0:len(str_uindex)]
            e=list(itertools.chain(*posbasep))
            for i in range(len(a)):
                posbase.insert(b[i],e[c[i]])
            mutated_s= ''.join(map(str, posbase))
            mutated_str1=RNA.fold(mutated_s)
            mutated_str=mutated_str1[0]

            d=0.0
            g=0.0
            n=len(s)
            for i in range(len(s)):
                if mutated_str[i]!=s[i]:
                    d=d+1
            g=(n-d)/n
            if g==1.0:
                solution.append(mutated_s)
                return g
            else:
                return g




        if k <= len(str_uindex)-1:
            posbasep=self.position[len(str_uindex):self.n]
            posbase=self.position[0:len(str_uindex)]
            e=list(itertools.chain(*posbasep))
            for i in range(len(a)):
                posbase.insert(b[i],e[c[i]])
            mutated_s= ''.join(map(str, posbase))
            mutated_str1=RNA.fold(mutated_s)
            mutated_str=mutated_str1[0]
            d=0.0
            g=0.0
            n=len(s)
            for i in range(len(s)):
                if mutated_str[i]!=s[i]:
                    d=d+1
            g=(n-d)/n
            if g==1.0:
                solution.append(mutated_s)
                return g
            else:
                return g
开发者ID:tsudalab,项目名称:MCTS-RNA,代码行数:52,代码来源:MCTS-RNA.py

示例3: mfe_bp_distance

# 需要导入模块: import RNA [as 别名]
# 或者: from RNA import fold [as 别名]
def mfe_bp_distance(S, G, masked=None):
    """This function takes an RNA sequence S, a secondary structure G,
    and returns de base pairs distance between the mfe structure (a mask
    for the folding can be provided as an optional argument) of S
    and G
    """
    Sec_struct = RNA.fold(S)[0]
    return RNA.bp_distance(Sec_struct, G)
开发者ID:dcbecerrar,项目名称:comp-761,代码行数:10,代码来源:ViennaRNA.py

示例4: prep_sec2_comp

# 需要导入模块: import RNA [as 别名]
# 或者: from RNA import fold [as 别名]
def prep_sec2_comp(seq_five, seq_three, seq_apta, comp, rand):
    (take, dump) = RNA.fold(seq_five + "N" + "G" * 100 + "N" * 4 + "C" * 100 + "N" + seq_three)
    seq = (
        (len(seq_five) - comp) * "."
        + "(" * (rand + comp)
        + "." * (len(seq_apta) - comp)
        + ")" * (rand + comp)
        + len(seq_three) * "."
    )
    return seq
开发者ID:kentgorday,项目名称:Heidelberg_15,代码行数:12,代码来源:JAWS.py

示例5: prep_sec1

# 需要导入模块: import RNA [as 别名]
# 或者: from RNA import fold [as 别名]
def prep_sec1(seq_five, seq_three, seq_apta, shift):
    (take, dump) = RNA.fold(seq_five + "N" + "G" * 100 + "N" * 4 + "C" * 100 + "N" + seq_three)
    seq = (
        len(take.split("." + "(" * 100 + "." * 4 + ")" * 100 + ".", 1)[0]) * "."
        + "(" * shift
        + "." * (len(seq_apta))
        + ")" * shift
        + len(take.split("." + "(" * 100 + "." * 4 + ")" * 100 + ".", 1)[1]) * "."
    )
    return seq
开发者ID:kentgorday,项目名称:Heidelberg_15,代码行数:12,代码来源:JAWS.py

示例6: rnafold

# 需要导入模块: import RNA [as 别名]
# 或者: from RNA import fold [as 别名]
def rnafold(seq, name=None):
    """Run RNAfold for precursor"""

    import RNA
    try:
        x = RNA.fold(seq)
    except Exception as e:
        print (e)
        return
    return x
开发者ID:dmnfarrell,项目名称:mirnaseq,代码行数:12,代码来源:utils.py

示例7: rnaplot

# 需要导入模块: import RNA [as 别名]
# 或者: from RNA import fold [as 别名]
def rnaplot(seq, struct=None, path='rnaplots', name='temp'):

    import RNA
    if struct==None:
        struct = RNA.fold(seq)[0]
    filename = os.path.join(path,name+'.ps')
    #RNA.svg_rna_plot(seq,struct,filename)
    colors = [" 1. 0. .2", " 0. .9 .5"]
    macro = format_cmark_values(range(0,10), rgb=colors[0])
    RNA.PS_rna_plot_a(seq, struct, filename, '', macro)
    return filename
开发者ID:dmnfarrell,项目名称:mirnaseq,代码行数:13,代码来源:utils.py

示例8: prep_sec2_left

# 需要导入模块: import RNA [as 别名]
# 或者: from RNA import fold [as 别名]
def prep_sec2_left(seq_five, seq_three, seq_apta, shift, rand):
    (take, dump) = RNA.fold(seq_five + "N" + "C" * 100 + "N" * 4 + "G" * 100 + "N" + seq_three)
    seq = (
        (len(seq_five) - shift) * "."
        + "(" * (rand + shift)
        + "." * (len(seq_apta) - shift)
        + ")" * (rand)
        + ")" * shift
        + len(seq_three) * "."
    )
    return seq
开发者ID:kentgorday,项目名称:Heidelberg_15,代码行数:13,代码来源:JAWS.py

示例9: tenfold

# 需要导入模块: import RNA [as 别名]
# 或者: from RNA import fold [as 别名]
def tenfold(fasta):
    """Fold tabbed FASTA input (gene;chr:start-stop \t sequence) and
    convert to binary output representing highest likelihood secondary  
    structure
    1 = double-stranded
    0 = single-standed
    """
    for line in open(fasta):
        label, sequence = line.strip().split("\t")
        dotplot, fe = RNA.fold(sequence)
        re1 = re.sub(r'\(|\)',r'1',dotplot)
        re10 = re.sub(r'\.',r'0',re1)
        print label + "\t" + re10
开发者ID:hesselberthlab,项目名称:5OH,代码行数:15,代码来源:tenfold.py

示例10: full_hairpin

# 需要导入模块: import RNA [as 别名]
# 或者: from RNA import fold [as 别名]
def full_hairpin(seq_five, seq_three, aptamer, shift):
    RNAbet = ["a", "c", "g", "u"]
    DNAbet = ["a", "c", "g", "t"]
    take, free_E = RNA.fold(aptamer)
    final_seq = seq_five
    for k in range(0, shift):
        final_seq += random.choice(DNAbet)
    final_seq += aptamer
    for k in range(0, shift):
        final_seq += random.choice(DNAbet)
    final_seq += seq_three
    active_seq = final_seq.split(aptamer)[0] + take.replace(".", "N") + final_seq.split(aptamer)[1]
    return final_seq, active_seq
开发者ID:kentgorday,项目名称:Heidelberg_15,代码行数:15,代码来源:JAWS.py

示例11: full_hairpin_comp

# 需要导入模块: import RNA [as 别名]
# 或者: from RNA import fold [as 别名]
def full_hairpin_comp(seq_five, seq_three, aptamer, comp, rand):
    RNAbet = ["a", "c", "g", "u"]
    DNAbet = ["a", "c", "g", "t"]
    take, free_E = RNA.fold(aptamer)
    final_seq = seq_five
    for k in range(0, rand):
        final_seq += random.choice(RNAbet)
    final_seq += aptamer
    for k in range(0, rand - comp):
        final_seq += random.choice(RNAbet)
    final_seq += pseudo_revcomp(seq_five[-comp:])
    final_seq += seq_three
    active_seq = final_seq.split(aptamer)[0] + take.replace(".", "N") + final_seq.split(aptamer)[1]
    return final_seq, active_seq
开发者ID:kentgorday,项目名称:Heidelberg_15,代码行数:16,代码来源:JAWS.py

示例12: mfe_struct

# 需要导入模块: import RNA [as 别名]
# 或者: from RNA import fold [as 别名]
    def mfe_struct():
        app.logger.info(request.json);
        if not request.json:
            abort(400, "Request has no json.")
            
        if 'seq' not in request.json:
            abort(400, "Request has no sequence in the json.")

        if re.match("^[ACGTUWSMKRYBDHVN]+$", request.json['seq']) is None:
            abort(400, "Invalid sequence: {}".format(request.json['seq']))

        try:
            result = RNA.fold(str(request.json['seq']))[0]
        except Exception as ex:
            app.logger.exception(ex)
            abort(400, "Server exception: {}".format(ex))
        
        return json.dumps(result), 201
开发者ID:mnori,项目名称:forna,代码行数:20,代码来源:forna_server.py

示例13: obtain_initial_sequence

# 需要导入模块: import RNA [as 别名]
# 或者: from RNA import fold [as 别名]
def obtain_initial_sequence(input_structure_s):##obtain some good initial sequence over 0.8
    ini_seq_pool=[]
    ini_str_pool=[]

    some_str_index,some_str_uindex=calculate_sequence_position(input_structure_s)
    some_midea=getbasepairs(some_str_index)#### this is global varable
    some_copy_str_uindex=getunbases(some_str_uindex)# unpaired bases ## this is global varable
    some_a=calculate_a(some_str_index)
    some_b=calculate_b(some_a)
    some_c=calculate_c(some_a)
    some_d=calculate_d(some_midea)
    some_ini_seq,some_ini_str_seq=getwholesequence(some_b,some_c ,some_d , some_copy_str_uindex)
    some_str_mfe,some_str_value=calculate_mfe_and_str(some_ini_seq)
    some_str_distance=calculate_structure_distance(input_structure_s,len(input_structure_s),some_str_value)
    ini_seq_pool.append(some_ini_seq)
    ini_str_pool.append(some_str_distance)
    print some_str_value



    for i in range(10):


        paired_pos,dif_ini=dif_str(some_str_value)
        mutated_seq=check_seq_base(paired_pos,some_ini_str_seq)
        mutated_seq1=check_GC_base(dif_ini,mutated_seq)
        mutated_seq2=''.join(map(str, mutated_seq1))

        kkk=RNA.fold(mutated_seq2)[0]
        some_str_value=kkk
        some_ini_seq=mutated_seq2
        new_str_distance=calculate_structure_distance(s,len(s),kkk)
        ini_seq_pool.append(mutated_seq2)
        ini_str_pool.append(new_str_distance)


    max_idx = np.argmax(ini_str_pool)
    max_val = ini_str_pool[max_idx]


    seq=ini_seq_pool[max_idx]


    return seq,max_val,mutated_seq1
开发者ID:tsudalab,项目名称:MCTS-RNA,代码行数:46,代码来源:MCTS-RNA.py

示例14: prep_sec1_left

# 需要导入模块: import RNA [as 别名]
# 或者: from RNA import fold [as 别名]
def prep_sec1_left(seq_five, seq_three, seq_apta, shift):
    (take, dump) = RNA.fold(seq_five + "N" + "C" * 100 + "N" * 4 + "G" * 100 + "N" + seq_three)
    seq = len(seq_five) * "." + "(" * shift + "." * (len(seq_apta)) + ")" * shift + len(seq_three) * "."
    return seq
开发者ID:kentgorday,项目名称:Heidelberg_15,代码行数:6,代码来源:JAWS.py

示例15: MCTS

# 需要导入模块: import RNA [as 别名]
# 或者: from RNA import fold [as 别名]

#.........这里部分代码省略.........

                state.simulationGC(cpa)
                count_number=count_number+1
                pa.remove(cpa)
            else:
                state.simulationAU(cpa)
                pa.remove(cpa)
        while upa!=[]:
            ucpa=random.choice(upa)

            if count_number<=need_GC:
                new_count=need_GC-count_number
                if count_number1<=new_count*2:
                    state.simulationunpairedGC(ucpa)
                    upa.remove(ucpa)
                    count_number1=count_number1+1
                else:
                    state.simulationunpairedAU(ucpa)
                    upa.remove(ucpa)
            else:
                state.simulationunpairedAU(ucpa)
                upa.remove(ucpa)


        posbasep=state.position[len(str_uindex):state.n]
        posbase=state.position[0:len(str_uindex)]
        e=list(itertools.chain(*posbasep))
        for i in range(len(a)):
            posbase.insert(b[i],e[c[i]])
        mutated_s= ''.join(map(str, posbase))
        ini_seq_pool=[]
        ini_str_pool=[]
        GC_pool=[]
        index_seq=0
        if defined_pseudo==1:
            some_str_mfe,some_str_value=calculate__pseudo_mfe_and_str_pkiss(mutated_s)
            some_str_distance=calculate_structure_distance_pKiss(str_index,len(str_index),some_str_value)


        else:
            some_str_mfe,some_str_value=calculate_mfe_and_str(mutated_s)#this is the nest structures
            some_str_distance=calculate_structure_distance(s,len(s),some_str_value)

        ini_seq_pool.append(mutated_s)
        ini_str_pool.append(some_str_distance)
        GCnum=measureGC(mutated_s)

        GC_pool.append(GCnum)
        for i in range(50):
            paired_pos,dif_ini=dif_str(some_str_value)
            mutated_seq=GCcontent(defined_GC,GCnum,paired_pos,posbase,posl)
            mutated_seq1=check_GC_base3(dif_ini,mutated_seq,posl,defined_GC)
            mutated_seq2=''.join(map(str, mutated_seq1))
            GCnum=measureGC(mutated_seq2)
            GC_pool.append(GCnum)
            if defined_pseudo==1:
                mfe,kkk=pseudoknot_pkiss(mutated_seq2)
                new_str_distance=calculate_structure_distance_pKiss(str_index+str_uindex,len(str_index+str_uindex),kkk)
            else:
                kkk=RNA.fold(mutated_seq2)[0]
                new_str_distance=calculate_structure_distance(s,len(s),kkk)
            some_str_value=kkk
            some_ini_seq=mutated_seq2
            ini_seq_pool.append(mutated_seq2)
            ini_str_pool.append(new_str_distance)
            index_seq=index_seq+1
            ggg=abs(defined_GC-GCnum)

            if ini_str_pool[index_seq]==1.0:
                break
        max_idx = np.argmax(ini_str_pool)
        GCnew=GC_pool[max_idx]


        max_val = ini_str_pool[max_idx]
        seq=ini_seq_pool[index_seq]
        ggg=abs(defined_GC-GCnum)
        gggg=abs(defined_GC-GCnew)
        if ini_str_pool[index_seq]==1.0 and ggg<=defined_gd:
            break

        if ini_str_pool[index_seq]==1.0:
            if ggg<=0.01:
                re=1.0+1.0

            else:
                re=1.0+0.0

        if max_val<1.0:
            if gggg<=0.01:
                re=1.0+max_val
            else:
                re=0.0+max_val


        while node != None:
            node.Update(re)
            node = node.parentNode

    return seq, max_val, GCnum
开发者ID:tsudalab,项目名称:MCTS-RNA,代码行数:104,代码来源:MCTS-RNA.py


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