/** * This method reports all the nucleic acid chains and has an option to remove duplicates if you * are considering an analysis of only unique DNA or RNA helices in the Structure. * @param removeDups If true, it will ignore duplicate chains * @return A list of all the nucleic acid chains in order of the Structure */ public List<Chain> getNucleicChains(boolean removeDups) { if (structure == null) return new ArrayList<>(); List<Chain> chains = structure.getChains(); List<Chain> result = new ArrayList<>(); for (Chain c: chains) { if (c.isNucleicAcid()) { result.add(c); } } if (removeDups) for (int i = 0; i < result.size(); i++) { for (int j = i+2; j < result.size(); j++) { // remove duplicate sequences (structures with two or more identical units) if (result.get(i).getAtomSequence().equals(result.get(j).getAtomSequence())) { result.remove(j); } } } return result; }
for (int i = 0; i < chains.size(); i++) { Chain c = chains.get(i); String sequence = c.getAtomSequence(); for (int m = 0; m < sequence.length(); m++) { boolean foundPair = false; for (int j = i + 1; j < chains.size() && !foundPair; j++) { Chain c2 = chains.get(j); if (j > i+1 && c.getAtomSequence().equals(c2.getAtomSequence()) && nonredundant) continue; String sequence2 = c2.getAtomSequence(); for (int k = c2.getAtomSequence().length() - 1; k >= 0 && !foundPair; k--) { if (canonical && !BasePairParameters.match(sequence.charAt(m), sequence2.charAt(k), useRNA)) continue; Group g1 = c.getAtomGroup(m); pairSequence += ' '; if (foundPair) pairSequence += (c.getAtomSequence().charAt(i)); lastFoundPair = foundPair;
Chain c = chains.get(i); for (int j = i+1; j < chains.size(); j++) { String complement = complement(chains.get(j).getAtomSequence(), useRNA); String match = longestCommonSubstring(c.getAtomSequence(), complement); if (log.isDebugEnabled()) { log.debug(c.getAtomSequence() + " " + chains.get(j).getAtomSequence() + " " + match); int index1 = c.getAtomSequence().indexOf(match); int index2 = complement.length() - complement.indexOf(match) - 1; for (int k = 0; k < match.length(); k++) { result.add(new Pair<Group>(g1, g2)); pairingNames.add((useRNA ? BASE_LIST_RNA[type1]+ BASE_LIST_RNA[type2] : BASE_LIST_DNA[type1]+ BASE_LIST_DNA[type2])); pairSequence += c.getAtomSequence().charAt(index1 + k); } else if (pairSequence.length() != 0 && pairSequence.charAt(pairSequence.length()-1) != ' ') pairSequence += ' '; } else if (pairSequence.length() != 0 && pairSequence.charAt(pairSequence.length()-1) != ' ') pairSequence += ' ';
for (int i = 0; i < chains.size(); i++) { Chain c = chains.get(i); String sequence = c.getAtomSequence(); Integer type1, type2; for (int j = 0; j < sequence.length(); j++) { pairSequence += ' '; if (foundPair) pairSequence += (c.getAtomSequence().charAt(j)); lastFoundPair = foundPair;