/** * {@inheritDoc} */ @Override public String getChainId() { if (parent == null) { return ""; } return parent.getId(); }
private List<Chain> getFirstModelChains() { Map<String, Chain> firstModelChains = new LinkedHashMap<>(); Set<String> lookupChainIds = new HashSet<>(getChainIds()); for (Chain chain : chains) { if (lookupChainIds.contains(chain.getId())) { if (!firstModelChains.containsKey(chain.getId())) { firstModelChains.put(chain.getId(), chain); } } } return new ArrayList<>(firstModelChains.values()); }
/** * Test if the given asymId is already present in the list of chains given. If yes, returns the chain * otherwise returns null. */ private static Chain isKnownChain(String asymId, List<Chain> chains){ for (int i = 0; i< chains.size();i++){ Chain testchain = chains.get(i); //System.out.println("comparing chainID >"+chainID+"< against testchain " + i+" >" +testchain.getName()+"<"); if (asymId.equals(testchain.getId())) { //System.out.println("chain "+ chainID+" already known ..."); return testchain; } } return null; }
/** {@inheritDoc} */ @Override public Chain getChain(String asymId, int modelnr) { List<Chain> chains = getChains(modelnr); for (Chain c : chains) { if (c.getId().equals(asymId)) { return c; } } return null; }
@Override public Chain getWaterChain(String asymId, int modelIdx) { Model model = models.get(modelIdx); if (model==null) { return null; } List<Chain> waterChains = model.getWaterChains(); for (Chain c : waterChains){ if (c.getId().equals(asymId)) return c; } return null; }
/** {@inheritDoc} */ @Override public boolean hasChain(String authId) { int modelnr = 0; List<Chain> chains = getChains(modelnr); for (Chain c : chains) { // we check here with equals because we might want to distinguish between upper and lower case chains! if (c.getId().equals(authId)) { return true; } } return false; }
@Override public Chain getNonPolyChain(String asymId, int modelIdx) { Model model = models.get(modelIdx); if (model==null) { return null; } List<Chain> nonpolyChains = model.getNonPolyChains(); for (Chain c : nonpolyChains){ if (c.getId().equals(asymId)) return c; } return null; }
/** * Returns a list of chain ids in the order they are specified in the ATOM * records in the asymmetric unit * @param asymUnit * @return */ private List<String> getChainIds(Structure asymUnit) { List<String> chainIds = new ArrayList<String>(); for ( Chain c : asymUnit.getChains()){ String intChainID = c.getId(); chainIds.add(intChainID); } return chainIds; }
/** {@inheritDoc} */ @Override public boolean hasNonPolyChain(String asymId){ int modelnr = 0; List<Chain> chains = models.get(modelnr).getNonPolyChains(); for (Chain c : chains) { // we check here with equals because we might want to distinguish between upper and lower case chains! if (c.getId().equals(asymId)) { return true; } } return false; }
@Override public Chain getPolyChain(String asymId, int modelIdx) { Model model = models.get(modelIdx); if (model==null) { return null; } List<Chain> polyChains = model.getPolyChains(); for (Chain c : polyChains){ if (c.getId().equals(asymId)) return c; } return null; }
/** * Filter IdMaps for a specific chain */ List<IdMapperEntry> idMapChain(Structure pdbStruct, Chain chain, List<IdMapperEntry> idMaps) { List<IdMapperEntry> idMapChain = new ArrayList<>(); for (IdMapperEntry idmap : idMaps) { if (idmap.pdbId.equals(pdbStruct.getPDBCode()) // && idmap.pdbChainId.equals(chain.getId()) // ) { idMapChain.add(idmap); } } return idMapChain; }
@Override public String toString(){ StringBuilder buf = new StringBuilder(); buf.append("EntityInfo: ").append(molId).append(" "); buf.append(description==null?"(no name)":"("+description+")"); buf.append(" asymIds: "); if (chains!=null) { for (int i=0;i<chains.size();i++) { buf.append(chains.get(i).getId()); if (i!=chains.size()-1) buf.append(","); } } else { buf.append("no chains"); } return buf.toString(); }
public static String toMMCIF(Chain chain, boolean writeHeader) { StringBuilder sb = new StringBuilder(); sb.append(SimpleMMcifParser.MMCIF_TOP_HEADER+"BioJava_mmCIF_file"+newline); sb.append(toMMCIF(chain, chain.getName(), chain.getId(),writeHeader)); return sb.toString(); }
private Chain getEntityChain(String entity_id){ for (Chain chain : entityChains) { if ( chain.getId().equals(entity_id)){ return chain; } } // does not exist yet, so create... Chain chain = new ChainImpl(); chain.setId(entity_id); entityChains.add(chain); return chain; }
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); } }
private ResidueNumber findResNumInOtherChains(int i, Chain chain) { // note that getChains contains all chains from all models, we'll just use first model found and skip the others for (Chain c: getFirstModelChains()) { if (c == chain) continue; Group seqResGroup = c.getSeqResGroup(i); if (seqResGroup==null) { logger.warn("The SEQRES group is null for index {} in chain with asym_id {}, whilst it wasn't null in chain with asym_id {}", i, c.getId(), chain.getId()); continue; } if (seqResGroup.getResidueNumber()!=null) return seqResGroup.getResidueNumber(); } return null; }
/** * Converts a Structure into a List of {@link AtomSite} objects * @param s * @return */ public static List<AtomSite> convertStructureToAtomSites(Structure s) { List<AtomSite> list = new ArrayList<AtomSite>(); for (int m=0;m<s.nrModels();m++) { for (Chain c:s.getChains(m)) { list.addAll(convertChainToAtomSites(c, m+1, c.getName(), c.getId())); } } return list; }
/** * Returns true if the 2 molecules of this interface are the same entity (i.e. homomeric interface), false * otherwise (i.e. heteromeric interface) * @return true if homomeric or if either of the entities is unknonw (null Compounds), false otherwise */ public boolean isHomomeric() { EntityInfo first = getParentChains().getFirst().getEntityInfo(); EntityInfo second = getParentChains().getSecond().getEntityInfo(); if (first==null || second==null) { logger.warn("Some compound of interface {} is null, can't determine whether it is homo/heteromeric. Consider it homomeric", getId()); return true; } return first.getRepresentative().getId().equals(second.getRepresentative().getId()); }
/** * 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 Group getGroup(StructureGroup num, List<Chain> chains) throws StructureException { for (Chain c : chains){ if ( c.getId().equals(num.getChainId())){ ResidueNumber resNum = new ResidueNumber(); resNum.setSeqNum(num.getResidueNumber()); resNum.setInsCode(num.getInsCode()); return c.getGroupByPDB(resNum); } } throw new StructureException("Could not find residue " + num); }