Skip to content

Commit 4a41270

Browse files
committed
Refactoring of Compound to EntityInfo
1 parent 0a31add commit 4a41270

6 files changed

Lines changed: 35 additions & 35 deletions

File tree

biojava-structure/src/main/java/demo/DemoMMCIFReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public void loadFromDirectAccess(){
102102
System.out.println(h.getAtomSequence());
103103
System.out.println(h.getAtomGroups(GroupType.HETATM));
104104

105-
System.out.println("Compounds: " + s.getEntityInfos());
105+
System.out.println("Entities: " + s.getEntityInfos());
106106

107107
} catch (Exception e) {
108108
e.printStackTrace();

biojava-structure/src/main/java/org/biojava/nbio/structure/Chain.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,16 +191,16 @@ public interface Chain {
191191
public int getSeqResLength();
192192

193193
/**
194-
* Sets the Compound
195-
* @param compound the Compound
194+
* Sets the Entity information
195+
* @param entityInfo the EntityInfo
196196
* @see #getEntityInfo()
197197
*/
198-
public void setEntityInfo(EntityInfo compound);
198+
public void setEntityInfo(EntityInfo entityInfo);
199199

200200
/**
201-
* Returns the Compound for this chain.
201+
* Returns the EntityInfo for this chain.
202202
*
203-
* @return the Compound object
203+
* @return the EntityInfo object
204204
* @see #setEntityInfo(EntityInfo)
205205
*/
206206
public EntityInfo getEntityInfo();

biojava-structure/src/main/java/org/biojava/nbio/structure/ChainImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public Object clone() {
157157
n.setChainID( getChainID());
158158
n.setSwissprotId ( getSwissprotId());
159159

160-
// NOTE the Compound will be reset at the parent level (Structure) if cloning is happening from parent level
160+
// NOTE the EntityInfo will be reset at the parent level (Structure) if cloning is happening from parent level
161161
// here we don't deep-copy it and just keep the same reference, in case the cloning is happening at the Chain level only
162162
n.setEntityInfo(this.mol);
163163

biojava-structure/src/main/java/org/biojava/nbio/structure/Structure.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,14 +523,14 @@ public Chain getChainByPDB(String chainId, int modelnr)
523523
/**
524524
* Get all the EntityInfo for this Structure.
525525
*
526-
* @return a list of Compounds
526+
* @return a list of EntityInfos
527527
*/
528528
public List<EntityInfo> getEntityInfos();
529529

530530
/**
531531
* Add an EntityInfo to this Structure
532532
*/
533-
public void addEntityInfo(EntityInfo compound);
533+
public void addEntityInfo(EntityInfo entityInfo);
534534

535535
/**
536536
* Set the list of database references for this structure
@@ -550,7 +550,7 @@ public Chain getChainByPDB(String chainId, int modelnr)
550550
* Request a particular entity by its entity id (mol id in legacy PDB format)
551551
*
552552
* @param entityId
553-
* @return a compound
553+
* @return a entityInfo
554554
* @deprecated use {@link #getEntityById(int)} instead
555555
*/
556556
public EntityInfo getCompoundById(int entityId);

biojava-structure/src/main/java/org/biojava/nbio/structure/StructureImpl.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public class StructureImpl implements Structure, Serializable {
5757
private List<List<Chain>> models;
5858

5959
private List<Map <String,Integer>> connections ;
60-
private List<EntityInfo> compounds;
60+
private List<EntityInfo> entityInfos;
6161
private List<DBRef> dbrefs;
6262
private List<Bond> ssbonds;
6363
private List<Site> sites;
@@ -79,7 +79,7 @@ public StructureImpl() {
7979
models = new ArrayList<List<Chain>>();
8080
name = "";
8181
connections = new ArrayList<Map<String,Integer>>();
82-
compounds = new ArrayList<EntityInfo>();
82+
entityInfos = new ArrayList<EntityInfo>();
8383
dbrefs = new ArrayList<DBRef>();
8484
pdbHeader = new PDBHeader();
8585
ssbonds = new ArrayList<Bond>();
@@ -167,27 +167,27 @@ public Structure clone() {
167167

168168
}
169169

170-
// deep-copying of Compounds is tricky: there's cross references also in the Chains
171-
// beware: if we copy the compounds we would also need to reset the references to compounds in the individual chains
172-
List<EntityInfo> newCompoundList = new ArrayList<EntityInfo>();
173-
for (EntityInfo compound:this.compounds) {
174-
EntityInfo newCompound = new EntityInfo(compound); // this sets everything but the chains
175-
for (String chainId:compound.getChainIds()) {
170+
// deep-copying of entityInfofos is tricky: there's cross references also in the Chains
171+
// beware: if we copy the entityInfos we would also need to reset the references to entityInfos in the individual chains
172+
List<EntityInfo> newEntityInfoList = new ArrayList<EntityInfo>();
173+
for (EntityInfo entityInfo : this.entityInfos) {
174+
EntityInfo newEntityInfo = new EntityInfo(entityInfo); // this sets everything but the chains
175+
for (String chainId:entityInfo.getChainIds()) {
176176

177177
for (int modelNr=0;modelNr<n.nrModels();modelNr++) {
178178
try {
179179
Chain newChain = n.getChainByPDB(chainId,modelNr);
180-
newChain.setEntityInfo(newCompound);
181-
newCompound.addChain(newChain);
180+
newChain.setEntityInfo(newEntityInfo);
181+
newEntityInfo.addChain(newChain);
182182
} catch (StructureException e) {
183183
// this actually happens for structure 1msh, which has no chain B for model 29 (clearly a deposition error)
184-
logger.warn("Could not find chain id "+chainId+" of model "+modelNr+" while cloning compound "+compound.getMolId()+". Something is wrong!");
184+
logger.warn("Could not find chain id "+chainId+" of model "+modelNr+" while cloning entityInfo "+entityInfo.getMolId()+". Something is wrong!");
185185
}
186186
}
187187
}
188-
newCompoundList.add(newCompound);
188+
newEntityInfoList.add(newEntityInfo);
189189
}
190-
n.setEntityInfos(newCompoundList);
190+
n.setEntityInfos(newEntityInfoList);
191191
// TODO ssbonds are complicated to clone: there are deep references inside Atom objects, how would we do it? - JD 2016-03-03
192192

193193
return n ;
@@ -464,7 +464,7 @@ public String toString(){
464464
str.append(dbref.toPDB()).append(newline);
465465
}
466466
str.append("Molecules: ").append(newline);
467-
for (EntityInfo mol : compounds) {
467+
for (EntityInfo mol : entityInfos) {
468468
str.append(mol).append(newline);
469469
}
470470

@@ -665,33 +665,33 @@ public boolean hasChain(String chainId) {
665665
/** {@inheritDoc} */
666666
@Override
667667
public void setEntityInfos(List<EntityInfo> molList){
668-
this.compounds = molList;
668+
this.entityInfos = molList;
669669
}
670670

671671
/** {@inheritDoc} */
672672
@Override
673-
public void addEntityInfo(EntityInfo compound) {
674-
this.compounds.add(compound);
673+
public void addEntityInfo(EntityInfo entityInfo) {
674+
this.entityInfos.add(entityInfo);
675675
}
676676

677677
/** {@inheritDoc} */
678678
@Override
679679
public List<EntityInfo> getEntityInfos() {
680-
// compounds are parsed from the PDB/mmCIF file normally
681-
// but if the file is incomplete, it won't have the Compounds information and we try
680+
// entity information is parsed from the PDB/mmCIF file normally
681+
// but if the file is incomplete, it won't have the entityInfo information and we try
682682
// to guess it from the existing seqres/atom sequences
683-
if (compounds==null || compounds.isEmpty()) {
683+
if (entityInfos==null || entityInfos.isEmpty()) {
684684
EntityFinder cf = new EntityFinder(this);
685-
this.compounds = cf.findEntities();
685+
this.entityInfos = cf.findEntities();
686686

687687
// now we need to set references in chains:
688-
for (EntityInfo compound:compounds) {
688+
for (EntityInfo compound:entityInfos) {
689689
for (Chain c:compound.getChains()) {
690690
c.setEntityInfo(compound);
691691
}
692692
}
693693
}
694-
return compounds;
694+
return entityInfos;
695695
}
696696

697697
/** {@inheritDoc} */
@@ -703,7 +703,7 @@ public EntityInfo getCompoundById(int molId) {
703703
/** {@inheritDoc} */
704704
@Override
705705
public EntityInfo getEntityById(int entityId) {
706-
for (EntityInfo mol : this.compounds){
706+
for (EntityInfo mol : this.entityInfos){
707707
if (mol.getMolId()==entityId){
708708
return mol;
709709
}

biojava-structure/src/main/java/org/biojava/nbio/structure/StructureTools.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,7 @@ public static final Structure getReducedStructure(Structure s,
10781078
for (EntityInfo comp : s.getEntityInfos()) {
10791079
if (comp.getChainIds() != null
10801080
&& comp.getChainIds().contains(c.getChainID())) {
1081-
// found matching compound. set description...
1081+
// found matching entity info. set description...
10821082
newS.getPDBHeader().setDescription(
10831083
"Chain " + c.getChainID() + " of " + s.getPDBCode()
10841084
+ " " + comp.getDescription());

0 commit comments

Comments
 (0)