Skip to content

Commit b9d78c6

Browse files
committed
Refactored Compound to EntityInfo
Updated the mmtf parser to use Set and not Get entityInfo
1 parent c269b5e commit b9d78c6

7 files changed

Lines changed: 23 additions & 27 deletions

File tree

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -514,24 +514,23 @@ public Chain getChainByPDB(String chainId, int modelnr)
514514
public String toMMCIF();
515515

516516
/**
517-
* Set the Compounds
517+
* Set the EntityInfo
518518
*
519519
* @param molList
520520
*/
521-
public void setCompounds(List<EntityInfo> molList);
521+
public void setEntityInfo(List<EntityInfo> molList);
522522

523523
/**
524-
* Get all the Compounds for this Structure.
525-
* Compounds are called Entities in mmCIF dictionary.
524+
* Get all the EntityInfo for this Structure.
526525
*
527526
* @return a list of Compounds
528527
*/
529528
public List<EntityInfo> getEntityInformation();
530529

531530
/**
532-
* Add a Compound to this Structure
531+
* Add an EntityInfo to this Structure
533532
*/
534-
public void addCompound(EntityInfo compound);
533+
public void addEntityInfo(EntityInfo compound);
535534

536535
/**
537536
* Set the list of database references for this structure

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public Structure clone() {
187187
}
188188
newCompoundList.add(newCompound);
189189
}
190-
n.setCompounds(newCompoundList);
190+
n.setEntityInfo(newCompoundList);
191191

192192
// TODO ssbonds are complicated to clone: there are deep references inside Atom objects, how would we do it? - JD 2016-03-03
193193

@@ -665,13 +665,13 @@ public boolean hasChain(String chainId) {
665665

666666
/** {@inheritDoc} */
667667
@Override
668-
public void setCompounds(List<EntityInfo> molList){
668+
public void setEntityInfo(List<EntityInfo> molList){
669669
this.compounds = molList;
670670
}
671671

672672
/** {@inheritDoc} */
673673
@Override
674-
public void addCompound(EntityInfo compound) {
674+
public void addEntityInfo(EntityInfo compound) {
675675
this.compounds.add(compound);
676676
}
677677

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ public static final Structure getReducedStructure(Structure s,
10461046
newS.setDBRefs(s.getDBRefs());
10471047
newS.setSites(s.getSites());
10481048
newS.setBiologicalAssembly(s.isBiologicalAssembly());
1049-
newS.setCompounds(s.getEntityInformation());
1049+
newS.setEntityInfo(s.getEntityInformation());
10501050
newS.setConnections(s.getConnections());
10511051
newS.setSSBonds(s.getSSBonds());
10521052
newS.setSites(s.getSites());
@@ -1116,7 +1116,7 @@ public static final Structure getReducedStructure(Structure s, int chainNr)
11161116
newS.setDBRefs(s.getDBRefs());
11171117
newS.setSites(s.getSites());
11181118
newS.setBiologicalAssembly(s.isBiologicalAssembly());
1119-
newS.setCompounds(s.getEntityInformation());
1119+
newS.setEntityInfo(s.getEntityInformation());
11201120
newS.setConnections(s.getConnections());
11211121
newS.setSSBonds(s.getSSBonds());
11221122
newS.setSites(s.getSites());

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public Structure reduce(Structure s) throws StructureException {
182182
"sub-range " + ranges + " of " + newS.getPDBCode() + " "
183183
+ s.getPDBHeader().getDescription());
184184
// TODO The following should be only copied for atoms which are present in the range.
185-
newS.setCompounds(s.getEntityInformation());
185+
newS.setEntityInfo(s.getEntityInformation());
186186

187187
newS.setSSBonds(s.getSSBonds());
188188
newS.setSites(s.getSites());
@@ -198,7 +198,7 @@ public Structure reduce(Structure s) throws StructureException {
198198

199199
if(getResidueRanges().isEmpty()) {
200200
// Include all residues
201-
newS.setCompounds(s.getEntityInformation());
201+
newS.setEntityInfo(s.getEntityInformation());
202202
newS.setSSBonds(s.getSSBonds());
203203
newS.setSites(s.getSites());
204204

biojava-structure/src/main/java/org/biojava/nbio/structure/io/PDBFileParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2909,7 +2909,7 @@ private void triggerEndFileChecks(){
29092909

29102910

29112911
linkChains2Compound(structure);
2912-
structure.setCompounds(compounds);
2912+
structure.setEntityInfo(compounds);
29132913

29142914
//associate the temporary Groups in the siteMap to the ones
29152915

biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/SimpleMMcifConsumer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ private void linkCompounds() {
994994
compound.setMolId(eId);
995995
compound.addChain(chain);
996996
chain.setCompound(compound);
997-
structure.addCompound(compound);
997+
structure.addEntityInfo(compound);
998998
} else {
999999
logger.debug("Adding chain with chain id {} (asym id {}) to compound with entity_id {}",
10001000
chain.getChainID(), chain.getInternalChainID(), eId);
@@ -1158,7 +1158,7 @@ private void addCompounds(StructAsym asym) {
11581158
c.setDescription(e.getPdbx_description());
11591159
c.setType(e.getType());
11601160
addAnicilliaryEntityData(asym, eId, e, c);
1161-
structure.addCompound(c);
1161+
structure.addEntityInfo(c);
11621162
logger.debug("Adding Compound with entity id {} from _entity, with name: {}",eId, c.getDescription());
11631163
}
11641164
}

biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmtf/BioJavaStructureDecoder.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ public class BioJavaStructureDecoder implements StructureDecoderInterface, Seria
6767

6868
/** All the atoms. */
6969
private List<Atom> allAtoms;
70+
71+
/** The list of EntityInformation */
72+
private List<EntityInfo> entityInfoList;
7073

7174
/**
7275
* Instantiates a new bio java structure decoder.
@@ -75,7 +78,8 @@ public BioJavaStructureDecoder() {
7578
structure = new StructureImpl();
7679
modelNumber = 0;
7780
chemicalComponentGroup = new ChemComp();
78-
allAtoms = new ArrayList<Atom>();
81+
allAtoms = new ArrayList<>();
82+
entityInfoList = new ArrayList<>();
7983
}
8084

8185
/**
@@ -420,20 +424,13 @@ public void cleanUpStructure() {
420424
}
421425
}
422426
}
423-
// Remove null or empty entity information
424-
List<EntityInfo> entityInfosToRemove = new ArrayList<>();
425-
for (EntityInfo entityInfo : structure.getEntityInformation()) {
426-
if (entityInfo.getDescription()==null) {
427-
entityInfosToRemove.add(entityInfo);
428-
}
429-
}
430-
structure.getEntityInformation().removeAll(entityInfosToRemove);
431427
// Number the remaining ones
432428
int counter =0;
433-
for (EntityInfo entityInfo : structure.getEntityInformation()) {
429+
for (EntityInfo entityInfo : entityInfoList) {
434430
counter++;
435431
entityInfo.setMolId(counter);
436432
}
433+
structure.setEntityInfo(entityInfoList);
437434
}
438435

439436
@Override
@@ -459,7 +456,7 @@ public void setEntityInfo(String[] chainIds, String sequence, String description
459456
}
460457
}
461458
entityInfo.setChains(chains);
462-
structure.getEntityInformation().add(entityInfo);
459+
entityInfoList.add(entityInfo);
463460
}
464461

465462
@Override

0 commit comments

Comments
 (0)