Skip to content

Commit a8a96ec

Browse files
committed
Handling nulls in descriptions
1 parent 3543eb9 commit a8a96ec

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

biojava-structure/src/main/java/org/biojava/nbio/structure/io/cif/AbstractCifFileSupplier.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ protected CifFile getInternal(Structure structure, List<WrappedAtom> wrappedAtom
100100
EntityInfo e = entityInfos.get(i);
101101
entityIds[i] = Integer.toString(e.getMolId());
102102
entityTypes[i] = e.getType().getEntityType();
103-
entityDescriptions[i] = e.getDescription();
103+
entityDescriptions[i] = e.getDescription() == null? "?" : e.getDescription();
104104
}
105105

106106
String[] polyEntityIds = entityInfos.stream().filter(e -> e.getType() == EntityType.POLYMER).map(e -> Integer.toString(e.getMolId())).collect(Collectors.toList()).toArray(new String[]{});
107-
String[] entitySeqs = entityInfos.stream().filter(e -> e.getType() == EntityType.POLYMER).map(e -> e.getChains().get(0).getSeqResSequence()).collect(Collectors.toList()).toArray(new String[]{});
107+
String[] polyEntitySeqs = entityInfos.stream().filter(e -> e.getType() == EntityType.POLYMER).map(e -> e.getChains().get(0).getSeqResSequence()).collect(Collectors.toList()).toArray(new String[]{});
108108

109109
blockBuilder.enterEntity()
110110
.enterId()
@@ -127,7 +127,7 @@ protected CifFile getInternal(Structure structure, List<WrappedAtom> wrappedAtom
127127
.leaveColumn()
128128

129129
.enterPdbxSeqOneLetterCodeCan()
130-
.add(entitySeqs)
130+
.add(polyEntitySeqs)
131131
.leaveColumn()
132132

133133
.leaveCategory();

biojava-structure/src/test/java/org/biojava/nbio/structure/io/cif/CifFileSupplierImplTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
import java.io.InputStream;
1111
import java.util.zip.GZIPInputStream;
1212

13-
import static org.junit.Assert.assertEquals;
14-
import static org.junit.Assert.assertTrue;
13+
import static org.junit.Assert.*;
1514

1615
public class CifFileSupplierImplTest {
1716

@@ -29,6 +28,7 @@ public void shouldReadRawPdbOutputtingCifWithEntity() throws IOException {
2928
String cifText = CifStructureConverter.toText(s);
3029
assertTrue(cifText.contains("_entity.type"));
3130
assertTrue(cifText.contains("_entity_poly.pdbx_seq_one_letter_code_can"));
31+
assertFalse(cifText.contains("null"));
3232

3333
InputStream inputStream = new ByteArrayInputStream(cifText.getBytes());
3434
Structure readStruct = CifStructureConverter.fromInputStream(inputStream);

0 commit comments

Comments
 (0)