Skip to content

Commit d568743

Browse files
committed
Resolving a warning that should not appear
1 parent 2caac65 commit d568743

3 files changed

Lines changed: 19 additions & 6 deletions

File tree

biojava-integrationtest/src/test/java/org/biojava/nbio/structure/test/io/TestMMCIFWriting.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,11 @@ public void testBiounitWriting1STP() throws IOException, StructureException {
2626
assertTrue(mmcif.contains("A_2"));
2727
}
2828

29+
@Test
30+
public void testStructWriting1STP() throws IOException, StructureException {
31+
Structure s = StructureIO.getStructure("1STP");
32+
String mmcif = s.toMMCIF();
33+
assertNotNull(mmcif);
34+
assertTrue(mmcif.contains("A"));
35+
}
2936
}

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,11 @@ public List<String> getChainIds() {
294294
}
295295

296296
/**
297-
* Given a Group g of Chain c (member of this EnityInfo) return the corresponding position in the
297+
* Given a Group g of Chain c (member of this EntityInfo) return the corresponding position in the
298298
* alignment of all member sequences (1-based numbering), i.e. the index (1-based) in the SEQRES sequence.
299-
* This allows for comparisons of residues belonging to different chains of the same EnityInfo (entity).
299+
* This allows for comparisons of residues belonging to different chains of the same EntityInfo (entity).
300+
* <p>
301+
* Note this method should only be used for entities of type {@link EntityType#POLYMER}
300302
* <p>
301303
* If {@link FileParsingParameters#setAlignSeqRes(boolean)} is not used or SEQRES not present, a mapping
302304
* will not be available and this method will return {@link ResidueNumber#getSeqNum()} for all residues, which
@@ -310,7 +312,7 @@ public List<String> getChainIds() {
310312
* is returned as a fall-back, if the group is not found in the SEQRES groups then -1 is returned
311313
* for the given group and chain
312314
* @throws IllegalArgumentException if the given Chain is not a member of this EnityInfo
313-
* @see {@link Chain#getSeqResGroup(int)}
315+
* @see Chain#getSeqResGroup(int)
314316
*/
315317
public int getAlignedResIndex(Group g, Chain c) {
316318

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.biojava.nbio.structure.Atom;
2828
import org.biojava.nbio.structure.Chain;
2929
import org.biojava.nbio.structure.Element;
30+
import org.biojava.nbio.structure.EntityType;
3031
import org.biojava.nbio.structure.Group;
3132
import org.biojava.nbio.structure.GroupType;
3233
import org.biojava.nbio.structure.Structure;
@@ -375,10 +376,13 @@ record = "ATOM";
375376
String labelSeqId = Integer.toString(g.getResidueNumber().getSeqNum());
376377
if (g.getChain()!=null && g.getChain().getEntityInfo()!=null) {
377378
entityId = Integer.toString(g.getChain().getEntityInfo().getMolId());
378-
labelSeqId = Integer.toString(g.getChain().getEntityInfo().getAlignedResIndex(g, g.getChain()));
379+
if (g.getChain().getEntityInfo().getType() == EntityType.POLYMER) {
380+
// this only makes sense for polymeric chains, non-polymer chains will never have seqres groups and there's no point in calling getAlignedResIndex
381+
labelSeqId = Integer.toString(g.getChain().getEntityInfo().getAlignedResIndex(g, g.getChain()));
382+
}
379383
}
380384

381-
Character altLoc = a.getAltLoc() ;
385+
Character altLoc = a.getAltLoc();
382386
String altLocStr;
383387
if (altLoc==null || altLoc == ' ') {
384388
altLocStr = MMCIF_DEFAULT_VALUE;
@@ -473,7 +477,7 @@ public static List<AtomSite> convertChainToAtomSites(Chain c, int model, String
473477
List<AtomSite> list = new ArrayList<>();
474478

475479
if (c.getEntityInfo()==null) {
476-
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());
480+
logger.warn("No entity found for chain {}: entity_id will be set to 0, label_seq_id will be the same as auth_seq_id", c.getName());
477481
}
478482

479483
for ( int h=0; h<c.getAtomLength();h++){

0 commit comments

Comments
 (0)