/** * Insert the group in the given position in the sequence. * @param chain the chain to add the seq res group to * @param group the group to add * @param sequenceIndexId the index to add it in */ public static void insertSeqResGroup(Chain chain, Group group, int sequenceIndexId) { List<Group> seqResGroups = chain.getSeqResGroups(); addGroupAtId(seqResGroups, group, sequenceIndexId); }
import org.biojava.nbio.structure.Chain; import org.biojava.nbio.structure.Group; import org.biojava.nbio.structure.Structure; import org.biojava.nbio.structure.StructureIO; public class StackOverflowIssue { public static void main(String[] args) throws Exception { Structure s = StructureIO.getStructure("2a65"); Chain c = s.getChainByPDB("A"); for (Group gr : c.getSeqResGroups()) { System.out.println(gr.getResidueNumber()+" "+gr.getPDBName()); } for (Group gr : c.getAtomGroups()) { if (!gr.isWater()) System.out.println(gr.getResidueNumber()+" "+gr.getPDBName()); } } }
private void initResSerialsMap(Chain c) { if (c.getSeqResGroups()==null || c.getSeqResGroups().isEmpty()) { logger.warn("No SEQRES groups found in chain with asym_id {}, will use residue numbers as given (no insertion codes, not necessarily aligned). " + "Make sure your structure has SEQRES records and that you use FileParsingParameters.setAlignSeqRes(true)", c.getId()); // we add a explicit null to the map so that we flag it as unavailable for this chain chains2pdbResNums2ResSerials.put(c.getId(), null); return; } Map<ResidueNumber,Integer> resNums2ResSerials = new HashMap<ResidueNumber, Integer>(); chains2pdbResNums2ResSerials.put(c.getId(), resNums2ResSerials); for (int i=0;i<c.getSeqResGroups().size();i++) { // The seqres group will have a null residue number whenever its corresponding atom group doesn't exist // because it is missing in the electron density. // However, it can be observed in the density in other chains of the same entity, // to be complete we go and look for the residue number in other chains, so that we have a // seqres to atom mapping as complete as possible (with all known atom groups of any chain of this entity) ResidueNumber resNum = c.getSeqResGroup(i).getResidueNumber(); if (resNum==null) { resNum = findResNumInOtherChains(i,c); } // NOTE that resNum will still be null here for cases where the residue // is missing in atom groups (not observed in density) in all chains // Thus the mapping will not be possible for residues that are only in SEQRES groups resNums2ResSerials.put(resNum, i+1); } }
/** * Add the missing groups to the SeqResGroups. * @param modelChain the chain to add the information for * @param sequence the sequence of the construct */ public static void addSeqRes(Chain modelChain, String sequence) { List<Group> seqResGroups = modelChain.getSeqResGroups(); GroupType chainType = getChainType(modelChain.getAtomGroups()); for(int i=0; i<sequence.length(); i++){ char singleLetterCode = sequence.charAt(i); Group group = null; if(seqResGroups.size()<=i){ } else{ group=seqResGroups.get(i); } if(group!=null){ continue; } group = getSeqResGroup(modelChain, singleLetterCode, chainType); addGroupAtId(seqResGroups, group, i); seqResGroups.set(i, group); } }
private void formNucleotideBonds() { for (int modelInd=0; modelInd<structure.nrModels(); modelInd++){ for (Chain chain : structure.getChains(modelInd)) { List<Group> groups = chain.getSeqResGroups(); for (int i = 0; i < groups.size() - 1; i++) { if (!(groups.get(i) instanceof NucleotideImpl) || !(groups.get(i + 1) instanceof NucleotideImpl)) continue; NucleotideImpl tail = (NucleotideImpl) groups.get(i); NucleotideImpl head = (NucleotideImpl) groups.get(i + 1); // atoms with no residue number don't have atom information if (tail.getResidueNumber() == null || head.getResidueNumber() == null) { continue; } Atom phosphorous = head.getP(); Atom oThreePrime = tail.getO3Prime(); if (phosphorous == null || oThreePrime == null) { continue; } if (Calc.getDistance(phosphorous, oThreePrime) < MAX_NUCLEOTIDE_BOND_LENGTH) { new BondImpl(phosphorous, oThreePrime, 1); } } } } }
private void formPeptideBonds() { for (int modelInd=0; modelInd<structure.nrModels(); modelInd++){ for (Chain chain : structure.getChains(modelInd)) { List<Group> groups = chain.getSeqResGroups();
if (resNum==null && c.getSeqResGroups()!=null && !c.getSeqResGroups().isEmpty()) { int index = c.getSeqResGroups().indexOf(g);
/** * Auxiliary method to reset chain ids of residue numbers in a chain. * Used when cloning chains and resetting their ids: one needs to take care of * resetting the ids within residue numbers too. * @param c * @param newChainName */ private static void setChainIdsInResidueNumbers(Chain c, String newChainName) { for (Group g:c.getAtomGroups()) { g.setResidueNumber(newChainName, g.getResidueNumber().getSeqNum(), g.getResidueNumber().getInsCode()); } for (Group g:c.getSeqResGroups()) { if (g.getResidueNumber()==null) continue; g.setResidueNumber(newChainName, g.getResidueNumber().getSeqNum(), g.getResidueNumber().getInsCode()); } }
Chain chain = modelChains.get(chainInModelIndex); List<Group> groups = chain.getAtomGroups(); List<Group> sequenceGroups = chain.getSeqResGroups(); mmtfDecoderInterface.setChainInfo(chain.getId(), chain.getName(), groups.size()); for(int groupInChainIndex=0; groupInChainIndex<groups.size(); groupInChainIndex++){
chain.setSeqResGroups(oldChain.getSeqResGroups()); chain.setSeqMisMatches(oldChain.getSeqMisMatches());