Skip to content

Commit 19931b5

Browse files
sblivenjosemduarte
authored andcommitted
Fix #480. Correct spelling of _symmetry.space_group_name_H-M in CIF output
CIF categories are represented as a simple bean, typically extending AbstractBean. By default, all fields from the bean are taken as the CIF labels. Fields may be omitted by annotating them as @IgnoreField. The CIF label for a field may be changed by defining a function, `static Map<String,String> getCIFLabelMap();`, mapping from the field's name to the correct label. This commit also changes the MMCIFFileTools.toMMCIF method to be generic, so that we enforce at compile time that all loop rows must be of the same type.
1 parent 62926e6 commit 19931b5

File tree

6 files changed

+211
-61
lines changed

6 files changed

+211
-61
lines changed

biojava-structure/src/main/java/org/biojava/nbio/structure/contact/StructureInterface.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,33 @@
2020
*/
2121
package org.biojava.nbio.structure.contact;
2222

23-
import org.biojava.nbio.structure.*;
23+
import java.io.Serializable;
24+
import java.util.ArrayList;
25+
import java.util.List;
26+
import java.util.Map;
27+
import java.util.TreeMap;
28+
29+
import org.biojava.nbio.structure.Atom;
30+
import org.biojava.nbio.structure.Chain;
31+
import org.biojava.nbio.structure.Element;
32+
import org.biojava.nbio.structure.Compound;
33+
import org.biojava.nbio.structure.Group;
34+
import org.biojava.nbio.structure.GroupType;
35+
import org.biojava.nbio.structure.ResidueNumber;
36+
import org.biojava.nbio.structure.Structure;
2437
import org.biojava.nbio.structure.asa.AsaCalculator;
2538
import org.biojava.nbio.structure.asa.GroupAsa;
2639
import org.biojava.nbio.structure.io.FileConvert;
2740
import org.biojava.nbio.structure.io.FileParsingParameters;
2841
import org.biojava.nbio.structure.io.mmcif.MMCIFFileTools;
2942
import org.biojava.nbio.structure.io.mmcif.SimpleMMcifParser;
3043
import org.biojava.nbio.structure.io.mmcif.chem.PolymerType;
44+
import org.biojava.nbio.structure.io.mmcif.model.AtomSite;
3145
import org.biojava.nbio.structure.io.mmcif.model.ChemComp;
3246
import org.biojava.nbio.structure.xtal.CrystalTransform;
3347
import org.slf4j.Logger;
3448
import org.slf4j.LoggerFactory;
3549

36-
import java.io.Serializable;
37-
import java.util.ArrayList;
38-
import java.util.List;
39-
import java.util.Map;
40-
import java.util.TreeMap;
41-
4250

4351
/**
4452
* An interface between 2 molecules (2 sets of atoms).
@@ -753,7 +761,7 @@ public String toMMCIF() {
753761

754762
// we reassign atom ids if sym related (otherwise atom ids would be duplicated and some molecular viewers can't cope with that)
755763
int atomId = 1;
756-
List<Object> atomSites = new ArrayList<Object>();
764+
List<AtomSite> atomSites = new ArrayList<>();
757765
for (Atom atom:this.molecules.getFirst()) {
758766
if (isSymRelated()) {
759767
atomSites.add(MMCIFFileTools.convertAtomToAtomSite(atom, 1, molecId1, molecId1, atomId));
@@ -771,7 +779,7 @@ public String toMMCIF() {
771779
atomId++;
772780
}
773781

774-
sb.append(MMCIFFileTools.toMMCIF(atomSites));
782+
sb.append(MMCIFFileTools.toMMCIF(atomSites,AtomSite.class));
775783

776784
return sb.toString();
777785
}

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -680,12 +680,10 @@ public String toMMCIF() {
680680

681681
str.append(getAtomSiteHeader());
682682

683-
@SuppressWarnings("unchecked")
684-
List<Object> list =
685-
(List<Object>) (List<?>) MMCIFFileTools.convertStructureToAtomSites(structure);
683+
List<AtomSite> list = MMCIFFileTools.convertStructureToAtomSites(structure);
686684

687685

688-
str.append(MMCIFFileTools.toMMCIF(list));
686+
str.append(MMCIFFileTools.toMMCIF(list,AtomSite.class));
689687

690688
return str.toString();
691689
}
@@ -697,11 +695,9 @@ public static String toMMCIF(Chain chain, String chainId, String internalChainId
697695
str.append(getAtomSiteHeader());
698696

699697

700-
@SuppressWarnings("unchecked")
701-
List<Object> list =
702-
(List<Object>) (List<?>) MMCIFFileTools.convertChainToAtomSites(chain, 1, chainId, internalChainId);
698+
List<AtomSite> list = MMCIFFileTools.convertChainToAtomSites(chain, 1, chainId, internalChainId);
703699

704-
str.append(MMCIFFileTools.toMMCIF(list));
700+
str.append(MMCIFFileTools.toMMCIF(list,AtomSite.class));
705701
return str.toString();
706702
}
707703

0 commit comments

Comments
 (0)