public String getChainId() { return resNum.getChainName(); }
/** * @param chainId * @return The first {@link ResidueNumber} of the specified chain (the one highest down in the PDB file) */ public ResidueNumber getFirst(String chainId) { Map.Entry<ResidueNumber,Integer> entry = treeMap.firstEntry(); while (true) { if (entry.getKey().getChainName().equals(chainId)) return entry.getKey(); entry = treeMap.higherEntry(entry.getKey()); if (entry == null) return null; } }
/** * @param chainId * @return The last {@link ResidueNumber} of the specified chain (the one farthest down in the PDB file) */ public ResidueNumber getLast(String chainId) { Map.Entry<ResidueNumber,Integer> entry = treeMap.lastEntry(); while (true) { if (entry.getKey().getChainName().equals(chainId)) return entry.getKey(); entry = treeMap.lowerEntry(entry.getKey()); if (entry == null) return null; } }
/** * Calculates the number of residues of the specified chain in a given range, inclusive. * @param positionA index of the first atom to count * @param positionB index of the last atom to count * @param startingChain Case-sensitive chain * @return The number of atoms between A and B inclusive belonging to the given chain */ public int getLength(int positionA, int positionB, String startingChain) { int positionStart, positionEnd; if (positionA <= positionB) { positionStart = positionA; positionEnd = positionB; } else { positionStart = positionB; positionEnd = positionA; } int count = 0; // Inefficient search for (Map.Entry<ResidueNumber, Integer> entry : treeMap.entrySet()) { if (entry.getKey().getChainName().equals(startingChain) && positionStart <= entry.getValue() && entry.getValue() <= positionEnd) { count++; } } return count; }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(pdbName); sb.append('\t'); sb.append(resNum.getChainName()); sb.append('\t'); sb.append(resNum.getSeqNum()); if (resNum.getInsCode() != null) sb.append(resNum.getInsCode()); sb.append('\t'); return sb.toString(); }
/** * Calculates the number of atoms between two ResidueNumbers, inclusive. Both residues * must belong to the same chain. * @param start First residue * @param end Last residue * @return The number of atoms from A to B inclusive * @throws IllegalArgumentException if start and end are on different chains, * or if either of the residues doesn't exist */ public int getLength(ResidueNumber start, ResidueNumber end) { if( ! start.getChainName().equals(end.getChainName())) { throw new IllegalArgumentException(String.format( "Chains differ between %s and %s. Unable to calculate length.", start,end)); } Integer startPos = getPosition(start); Integer endPos = getPosition(end); if(startPos == null) { throw new IllegalArgumentException("Residue "+start+" was not found."); } if(endPos == null) { throw new IllegalArgumentException("Residue "+start+" was not found."); } return getLength(startPos, endPos, start.getChainName()); }
/** * Calculates the number of atoms between two ResidueNumbers, inclusive. Both residues * must belong to the same chain. * Will return a negative value if the start is past the end. * @param start First residue * @param end Last residue * @return The number of atoms from A to B inclusive * @throws IllegalArgumentException if start and end are on different chains, * or if either of the residues doesn't exist */ public int getLengthDirectional(ResidueNumber start, ResidueNumber end) { if( ! start.getChainName().equals(end.getChainName())) { throw new IllegalArgumentException(String.format( "Chains differ between %s and %s. Unable to calculate length.", start,end)); } Integer startPos = getPosition(start); Integer endPos = getPosition(end); if(startPos == null) { throw new IllegalArgumentException("Residue "+start+" was not found."); } if(endPos == null) { throw new IllegalArgumentException("Residue "+start+" was not found."); } return getLengthDirectional(startPos, endPos, start.getChainName()); }
/** * Get a group represented by a ResidueNumber. * * @param struc * a {@link Structure} * @param pdbResNum * a {@link ResidueNumber} * @return a group in the structure that is represented by the pdbResNum. * @throws StructureException * if the group cannot be found. */ public static final Group getGroupByPDBResidueNumber(Structure struc, ResidueNumber pdbResNum) throws StructureException { if (struc == null || pdbResNum == null) { throw new IllegalArgumentException("Null argument(s)."); } Chain chain = struc.getPolyChainByPDB(pdbResNum.getChainName()); return chain.getGroupByPDB(pdbResNum); }
/** * Returns a list of {@link ResidueRange ResidueRanges} corresponding to this entire AtomPositionMap. */ public List<ResidueRangeAndLength> getRanges() { String currentChain = ""; ResidueNumber first = null; ResidueNumber prev = null; List<ResidueRangeAndLength> ranges = new ArrayList<ResidueRangeAndLength>(); for (ResidueNumber rn : treeMap.keySet()) { if (!rn.getChainName().equals(currentChain)) { if (first != null) { ResidueRangeAndLength newRange = new ResidueRangeAndLength(currentChain, first, prev, this.getLength(first, prev)); ranges.add(newRange); } first = rn; } prev = rn; currentChain = rn.getChainName(); } ResidueRangeAndLength newRange = new ResidueRangeAndLength(currentChain, first, prev, this.getLength(first, prev)); ranges.add(newRange); return ranges; }
String chain = residueNumber.getChainName();
/** * Return the symmetric repeats as structure identifiers, if the result is * symmetric and it was refined, return null otherwise. * * @return List of StructureIdentifiers or null if not defined * @throws StructureException */ public List<StructureIdentifier> getRepeatsID() throws StructureException { if (!isRefined()) return null; List<StructureIdentifier> repeats = new ArrayList<StructureIdentifier>( numRepeats); String pdbId = structureId.toCanonical().getPdbId(); Block align = multipleAlignment.getBlocks().get(0); for (int su = 0; su < numRepeats; su++) { // Get the start and end residues of the repeat ResidueNumber res1 = atoms[align.getStartResidue(su)].getGroup() .getResidueNumber(); ResidueNumber res2 = atoms[align.getFinalResidue(su)].getGroup() .getResidueNumber(); ResidueRange range = new ResidueRange(res1.getChainName(), res1, res2); StructureIdentifier id = new SubstructureIdentifier(pdbId, Arrays.asList(range)); repeats.add(id); } return repeats; }
ResidueNumber rn2 = ca2[res2].getGroup().getResidueNumber(); String node1 = name1+rn1.getChainName()+rn1.toString(); String node2 = name2+rn2.getChainName()+rn2.toString(); String last = name1+rn.getChainName()+rn.toString(); for(int i=1;i<ca1.length;i++) { rn = ca1[i].getGroup().getResidueNumber(); String curr = name1+rn.getChainName()+rn.toString(); out.write(String.format("%s\t%s\t%s\n",last, backboneInteraction, curr)); last = curr; !ca1[0].getGroup().getResidueNumber().equals(ca2[0].getGroup().getResidueNumber()) ) ) { rn = ca2[0].getGroup().getResidueNumber(); last = name2+rn.getChainName()+rn.toString(); for(int i=1;i<ca2.length;i++) { rn = ca2[i].getGroup().getResidueNumber(); String curr = name2+rn.getChainName()+rn.toString(); out.write(String.format("%s\t%s\t%s\n",last, backboneInteraction, curr)); last = curr;
String chain = rr.getChainName(); if(start.getChainName() == null) { start = new ResidueNumber(chain,start.getSeqNum(),start.getInsCode()); if(end.getChainName() == null) { end = new ResidueNumber(chain,end.getSeqNum(),end.getInsCode()); if( !key.getChainName().equals(chain) ) continue; if( start.getSeqNum() <= key.getSeqNum() ) { if( !key.getChainName().equals(chain) ) continue; Integer value = getPosition(key);
chain = first.getChainName(); if( ! map.getNavMap().lastKey().getChainName().equals(chain) ) { logger.warn("Multiple possible chains match '_'. Using chain {}",chain);
/** * The method will return a new reference to a Chain with any consecutive groups * having same residue numbers removed. * This is necessary to solve the microheterogeneity issue in entries like 3u7t (see github issue #160) * @param c * @return */ private static Chain removeSeqResHeterogeneity(Chain c) { Chain trimmedChain = new ChainImpl(); ResidueNumber lastResNum = null; for (Group g:c.getAtomGroups()) { // note we have to deep copy this, otherwise they stay linked and would get altered in addGroup(g) ResidueNumber currentResNum = new ResidueNumber( g.getResidueNumber().getChainName(), g.getResidueNumber().getSeqNum(), g.getResidueNumber().getInsCode()); if (lastResNum == null || !lastResNum.equals(currentResNum) ) { trimmedChain.addGroup(g); } else { logger.debug("Removing seqres group because it seems to be repeated in entity_poly_seq, most likely has hetero='y': "+g); } lastResNum = currentResNum; } return trimmedChain; }
pdbAln[0][0][i] = aligned1[i].getChainName()+":"+aligned1[i]; pdbAln[0][1][i] = aligned2[i].getChainName()+":"+aligned2[i];