本文介绍了找出哪个子串先出现,哪个第二,哪个第三的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

String s="CCATGTTGGCCTAGGTGACAC";

我试图从上面的 DNA 序列中找到一个开放阅读框.首先,我必须找到是否存在作为子字符串的ATG".如果存在,那么我必须找出这些子字符串中的任何一个是否存在TAA"、TAG"、TGA".在这三个子字符串中,以先到者为准,然后我会将字符串从ATG"打印到TAA"或TAG"或TGA",以先到者为准.从上面的字符串输出应该是ATG TTGGCC TAG".

I am trying to find an Open reading frame from above DNA sequence. First I have to find whether there is "ATG" present as a sub string. If it is there then I have to find out whether any one of these sub strings is present "TAA", "TAG", "TGA". Among these three sub strings whichever comes first is to be taken into considerartion and then I would print the string from "ATG" to "TAA" or "TAG" or "TGA" whichever comes first.From above string output should be "ATG TTGGCC TAG".

推荐答案

    String testString = "ddddeeaxgghnnnbykkkkkklllllczfr";


    String[] frags = testString.split("(ax|by|cz)");
    if(frags.length >= 1) {
        System.out.println("first=" + frags[0]);
        if(frags.length >= 2) {
            System.out.println("second=" + frags[1]);
            if(frags.length >= 3) {
                System.out.println("third=" + frags[2]);
            }
        }
    } else {
        System.out.println("nothing found");
    }

它打印:

第一个=ddddee
第二=gghnnn
第三=kkkkkkllll

这篇关于找出哪个子串先出现,哪个第二,哪个第三的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 01:03