1616import org .biojava .nbio .structure .quaternary .BioAssemblyInfo ;
1717import org .rcsb .mmtf .api .MmtfDecoderInterface ;
1818import org .rcsb .mmtf .api .MmtfWriter ;
19+ import org .rcsb .mmtf .dataholders .MmtfBean ;
1920
2021/**
2122 * Class to take Biojava structure data and covert to the DataApi for encoding.
@@ -49,8 +50,9 @@ public void write(MmtfDecoderInterface decoder) {
4950 Map <String , Integer > chainIdToIndexMap = MmtfUtils .getChainIdToIndexMap (structure );
5051 List <Chain > allChains = MmtfUtils .getAllChains (structure );
5152 List <Atom > allAtoms = MmtfUtils .getAllAtoms (structure );
53+ int numBonds = MmtfUtils .getNumBonds (allAtoms );
5254
53- mmtfDecoderInterface .initStructure (allAtoms .size (), MmtfUtils .getNumGroups (structure ), allChains .size (), structure .nrModels (), structure .getPDBCode ());
55+ mmtfDecoderInterface .initStructure (numBonds , allAtoms .size (), MmtfUtils .getNumGroups (structure ), allChains .size (), structure .nrModels (), structure .getPDBCode ());
5456 // Get the header and the xtal info.
5557 PDBHeader pdbHeader = structure .getPDBHeader ();
5658 PDBCrystallographicInfo xtalInfo = pdbHeader .getCrystallographicInfo ();
@@ -77,8 +79,12 @@ public void write(MmtfDecoderInterface decoder) {
7779 List <Atom > atomsInGroup = MmtfUtils .getAtomsForGroup (group );
7880 // Get the group type
7981 ChemComp chemComp = group .getChemComp ();
80- mmtfDecoderInterface .setGroupInfo (group .getPDBName (), group .getResidueNumber ().getSeqNum (), group .getResidueNumber ().getInsCode ().charValue (),
81- chemComp .getPdbx_type (), atomsInGroup .size (), chemComp .getOne_letter_code ().charAt (0 ), sequenceGroups .indexOf (group ));
82+ Character insCode = group .getResidueNumber ().getInsCode ();
83+ if (insCode ==null ){
84+ insCode =MmtfBean .UNAVAILABLE_CHAR_VALUE ;
85+ }
86+ mmtfDecoderInterface .setGroupInfo (group .getPDBName (), group .getResidueNumber ().getSeqNum (), insCode .charValue (),
87+ chemComp .getPdbx_type (), atomsInGroup .size (), chemComp .getBonds ().size (), chemComp .getOne_letter_code ().charAt (0 ), sequenceGroups .indexOf (group ));
8288 for (Atom atom : atomsInGroup ){
8389 mmtfDecoderInterface .setAtomInfo (atom .getName (), atom .getPDBserial (), atom .getAltLoc ().charValue (), (float ) atom .getX (),
8490 (float ) atom .getY (), (float ) atom .getZ (), atom .getOccupancy (),
@@ -99,6 +105,9 @@ public void write(MmtfDecoderInterface decoder) {
99105 * @param allAtoms the list of atoms in the whole structure
100106 */
101107 private void addBonds (Atom atom , List <Atom > atomsInGroup , List <Atom > allAtoms ) {
108+ if (atom .getBonds ()==null ){
109+ return ;
110+ }
102111 for (Bond bond : atom .getBonds ()) {
103112 // Now set the bonding information.
104113 Atom other = bond .getOther (atom );
@@ -119,7 +128,7 @@ private void addBonds(Atom atom, List<Atom> atomsInGroup, List<Atom> allAtoms) {
119128 // Don't add the same bond twice
120129 if (firstBondIndex <secondBondIndex ){
121130 int bondOrder = bond .getBondOrder ();
122- mmtfDecoderInterface .setGroupBond (firstBondIndex , secondBondIndex , bondOrder );
131+ mmtfDecoderInterface .setInterGroupBond (firstBondIndex , secondBondIndex , bondOrder );
123132 }
124133 }
125134 }
0 commit comments