public NucleotideCouple buildHalfCoupleChainFromOneSingle(Nucleotide chain) { if (chain.isPaired) { return(null); } chain = getHeadOfSingleChain(chain); Nucleotide nhead = chain; NucleotideCouple n = (Instantiate(couplePrefab) as GameObject).GetComponent <NucleotideCouple>(); NucleotideCouple head = n; n.setLeftColor(chain.getColor()); n.setType(chain.type, Nucleotide.Type.Empty); n.needHelix = false; while (chain.next) { chain = chain.next; n.next = (Instantiate(couplePrefab) as GameObject).GetComponent <NucleotideCouple>(); n.next.setLeftColor(chain.getColor()); n.next.setType(chain.type, Nucleotide.Type.Empty); n.next.prev = n; n.next.needHelix = false; n.next.transform.rotation = nhead.transform.rotation; n = n.next; } head.transform.rotation = nhead.transform.rotation; head.transform.position = nhead.transform.position; head.broadcastUpdateTransform(); destroySingleChain(chain); return(head); }
public NucleotideCouple buildCoupleChainFromTwoSingles(Nucleotide c1, Nucleotide c2, Vector3 position = default(Vector3)) { if (c1.isPaired || c2.isPaired) { return(null); } if (getLengthOfSingleChain(c1) != getLengthOfSingleChain(c2)) { return(null); } c1 = getHeadOfSingleChain(c1); if (c1 == getHeadOfSingleChain(c2)) { return(null); } c2 = getTailOfSingleChain(c2); NucleotideCouple n = (Instantiate(couplePrefab) as GameObject).GetComponent <NucleotideCouple>(); NucleotideCouple head = n; n.setLeftColor(c1.getColor()); n.setRightColor(c2.getColor()); n.setType(c1.type, c2.type); while (c1.next) { c1 = c1.next; c2 = c2.prev; n.next = (Instantiate(couplePrefab) as GameObject).GetComponent <NucleotideCouple>(); n.next.setLeftColor(c1.getColor()); n.next.setRightColor(c2.getColor()); n.next.setType(c1.type, c2.type); n.next.prev = n; n = n.next; } head.transform.position = position; head.broadcastUpdateTransform(); destroySingleChain(c1); destroySingleChain(c2); return(n); }
//核苷酸之间氢键角度不知道怎么归位,deHelix先注释掉了 //public void deHelix(NucleotideCouple n) //{ // if(n.needHelix == true) // { // n.needHelix = false; // } //} public NucleotideCouple buildCoupleChainFromOneSingle(Nucleotide n, bool reverse = false) { if (n.isPaired) { return(null); } Nucleotide head = getHeadOfSingleChain(n); Nucleotide next = head.next; if (next == null) { return(buildCoupleFromOneSingle(head)); } else { NucleotideCouple coupleHead = buildCoupleFromOneSingle(head); NucleotideCouple couple = coupleHead; while (next.next) { next = next.next; couple.next = buildCoupleFromOneSingle(next.prev, reverse); couple.next.prev = couple; couple = couple.next; } couple.next = buildCoupleFromOneSingle(next); couple.next.prev = couple; if (!reverse) { coupleHead.broadcastUpdateTransform(); } else { couple.next.broadcastUpdateTransform(); } return(coupleHead); } }
public NucleotideCouple String2CoupleChain(string s, Vector3 position = default(Vector3)) { if (s[0] != '2') { return(null); } NucleotideCouple n = (Instantiate(couplePrefab) as GameObject).GetComponent <NucleotideCouple>(); NucleotideCouple head = n; n.setType(Char2Type(s[1]), Char2Type(s[2])); for (int i = 3; i < s.Length; i += 2) { n.next = (Instantiate(couplePrefab) as GameObject).GetComponent <NucleotideCouple>(); n.next.setType(Char2Type(s[i]), Char2Type(s[i + 1])); n.next.prev = n; n = n.next; } head.transform.position = position; head.broadcastUpdateTransform(); return(n); }