newChain.setId(chain.getId()); newChain.setName(chain.getName()); newChain.setEntityInfo(chain.getEntityInfo()); newChain.setSwissprotId(chain.getSwissprotId()); List<Group> groups = chain.getAtomGroups(); n.setResidueNumber(g.getResidueNumber()); n.addAtom(a); newChain.addGroup(n); continue grouploop;
/** * Generate a FASTA sequence with the SS annotation letters in the * aminoacid sequence order. * @return String in FASTA sequence format */ public String printFASTA() { StringBuffer buf = new StringBuffer(); String nl = System.getProperty("line.separator"); buf.append(">"+groups[0].getChain().getStructure().getIdentifier()+nl); for (int g = 0; g < groups.length; g++){ buf.append(getSecStrucState(g).getType()); } return buf.toString(); }
/** * Converts a Chain into a List of {@link AtomSite} objects * @param c the chain * @param model the model number for the output AtomSites * @param chainName the chain identifier (author id) for the output AtomSites * @param chainId the internal chain identifier (asym id) for the output AtomSites * @return */ public static List<AtomSite> convertChainToAtomSites(Chain c, int model, String chainName, String chainId) { List<AtomSite> list = new ArrayList<>(); if (c.getEntityInfo()==null) { logger.warn("No Compound (entity) found for chain {}: entity_id will be set to 0, label_seq_id will be the same as auth_seq_id", c.getName()); } for ( int h=0; h<c.getAtomLength();h++){ Group g= c.getAtomGroup(h); list.addAll(convertGroupToAtomSites(g, model, chainName, chainId)); } return list; }
/** * Adds a chain to the given structure to form a biological assembly, * adding the symmetry-expanded chains as new chains with renamed * chain ids and names (in the form originalAsymId_transformId and originalAuthId_transformId). * @param s * @param newChain * @param transformId */ private void addChainFlattened(Structure s, Chain newChain, String transformId) { newChain.setId(newChain.getId()+"_"+transformId); newChain.setName(newChain.getName()+"_"+transformId); s.addChain(newChain); }
private void alignNucleotideChains(Chain seqRes, Chain atomRes) { if ( atomRes.getAtomGroups(GroupType.NUCLEOTIDE).size() < 1) { logger.debug("ATOM chain {} does not contain nucleotides, ignoring...", atomRes.getId()); return; } logger.debug("Alignment for chain {}", atomRes.getId() ); List<Group> seqResGroups = seqRes.getAtomGroups(); boolean noMatchFound = alignNucleotideGroups(seqResGroups,atomRes.getAtomGroups()); if ( ! noMatchFound){ atomRes.setSeqResGroups(seqResGroups); } }
assert !chainId.isEmpty(); Chain chain; if(chainGuess != null && chainGuess.getId() == chainId) { chain.setId(chainId); chain.setName(oldChain.getName()); EntityInfo oldEntityInfo = oldChain.getEntityInfo(); chain.setEntityInfo(newEntityInfo); chain.setSeqResGroups(oldChain.getSeqResGroups()); chain.setSeqMisMatches(oldChain.getSeqMisMatches()); g = (Group)g.clone(); chain.addGroup(g);
/** * Get all AAs in a chain */ List<AminoAcid> aminoAcids(Chain chain) { ArrayList<AminoAcid> aas = new ArrayList<AminoAcid>(); for (Group group : chain.getAtomGroups()) if (group instanceof AminoAcid) aas.add((AminoAcid) group); return aas; }
List<Group> agr = cha.getAtomGroups(GroupType.AMINOACID); List<Group> hgr = cha.getAtomGroups(GroupType.HETATM); List<Group> ngr = cha.getAtomGroups(GroupType.NUCLEOTIDE); .append(cha.getId()) .append(" authId:") .append(cha.getName()).append(" "); if ( cha.getEntityInfo() != null){ EntityInfo comp = cha.getEntityInfo(); String molName = comp.getDescription(); if ( molName != null){ str.append(" length SEQRES: ").append(cha.getSeqResLength()); str.append(" length ATOM: ").append(cha.getAtomLength()); str.append(" aminos: ").append(agr.size()); str.append(" hetatms: ").append(hgr.size());
private static boolean areResNumbersAligned(Chain c1, Chain c2) { boolean isC1prot = c1.isProtein(); boolean isC2prot = c2.isProtein(); c1AtomGroups = c1.getAtomGroups(GroupType.AMINOACID); c1AtomGroups = c1.getAtomGroups(GroupType.NUCLEOTIDE); Group g2 = c2.getGroupByPDB(g1.getResidueNumber()); if (!g2.getPDBName().equals(g1.getPDBName())) { logger.debug("Mismatch of residues between chains {},{} for residue number {}: {} {}", c1.getId(),c2.getId(),g1.getResidueNumber(), g1.getPDBName(), g2.getPDBName()); return false; RATIO_GAPS_FOR_MISMATCH, countNonExisting, c1AtomGroups.size(), c2.getId(), c1.getId()); return false;
Chain c = g.getChain(); if (c != null) { s = c.getStructure(); for(Chain c : allChains) { if(types == null) { full.addAll(c.getAtomGroups()); } else { full.addAll(c.getAtomGroups(types));
currentChain.addGroup(currentGroup); if (isKnownChain(currentChain.getId(),currentModel) == null) { currentModel.add(currentChain); Chain seqres = (Chain)s.clone(); seqres.setId(asym.getId()); if (asymId2authorId.get(asym.getId()) !=null ){ seqres.setName(asymId2authorId.get(asym.getId())); } else { seqres.setName(asym.getId()); continue; if (c.getEntityType() == EntityType.POLYMER && !c.getEntityInfo().getDescription().contains("SUGAR") ) { chain.setSeqMisMatches(misMatchMap.get(chainId));
/** * {@inheritDoc} */ @Override public String getChainId() { if (parent == null) { return ""; } return parent.getId(); }
for(int chainInModelIndex=0; chainInModelIndex<modelChains.size(); chainInModelIndex++) { 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++){ Group group = groups.get(groupInChainIndex);
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()); } } }
public synchronized void setChain(Chain c){ List<Group> a = c.getAtomGroups(GroupType.AMINOACID); seqArr = new Character[a.size()]; chain = new ChainImpl(); Iterator<Group> iter = a.iterator(); int i = 0; while (iter.hasNext()){ AminoAcid aa = (AminoAcid) iter.next(); // preserver original hierarchy ... for highlighting in Jmol Chain old = aa.getChain(); chain.addGroup(aa); aa.setChain(old); seqArr[i] = aa.getAminoType(); i++; } chainLength = i; coordManager.setLength(chainLength); setPrefSize(); this.repaint(); }
String cOrigId = c.getId(); String cOrigName = c.getName(); Chain clonedChain = (Chain)c.clone(); String newChainId = cOrigId+(iOperator+1)+NCS_CHAINID_SUFFIX_CHAR; String newChainName = cOrigName+(iOperator+1)+NCS_CHAINID_SUFFIX_CHAR; clonedChain.setId(newChainId); clonedChain.setName(newChainName); c.getEntityInfo().addChain(clonedChain);
/** get an artificial List of chains containing the Atoms and groups. * Does NOT rotate anything. * @param ca * @return a list of Chains that is built up from the Atoms in the ca array * @throws StructureException */ public static final List<Chain> getAlignedModel(Atom[] ca){ List<Chain> model = new ArrayList<Chain>(); for ( Atom a: ca){ Group g = a.getGroup(); Chain parentC = g.getChain(); Chain newChain = null; for ( Chain c : model) { if ( c.getId().equals(parentC.getId())){ newChain = c; break; } } if ( newChain == null){ newChain = new ChainImpl(); newChain.setId(parentC.getId()); model.add(newChain); } newChain.addGroup(g); } return model; }
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); } }