dna reverse

来源:互联网 发布:java long 类型长度 编辑:程序博客网 时间:2024/06/06 12:34
Deoxyribonucleic acid (DNA) is a chemical found in the nucleus of cells and carries the "instructions" for the development and functioning of living organisms.If you want to know more http://en.wikipedia.org/wiki/DNAIn DNA strings, symbols "A" and "T" are complements of each other, as "C" and "G". You have function with one side of the DNA (string, except for Haskell); you need to get the other complementary side. DNA strand is never empty or there is no DNA at all (again, except for Haskell).DNAStrand ("ATTGC") # return "TAACG"DNAStrand ("GTAT") # return "CATA"

代码

function DNAStrand(dna){    function switch(x){        switch (x){            case "A":                return "T";break;            case "T":                return "A";break;            case "G":                return "C";break;            case "C":                return "G";break;        }    }    for(var i= 0,r='',l=dna.length;i<l;i++){        r+=switch(dna[i])    }    return r}
原创粉丝点击