diff --git a/biojava-aa-prop/pom.xml b/biojava-aa-prop/pom.xml index fa35407577..04d380787b 100644 --- a/biojava-aa-prop/pom.xml +++ b/biojava-aa-prop/pom.xml @@ -2,7 +2,7 @@ biojava org.biojava - 5.0.1 + 5.0.2 4.0.0 biojava-aa-prop @@ -70,12 +70,12 @@ org.biojava biojava-core - 5.0.1 + 5.0.2 org.biojava biojava-structure - 5.0.1 + 5.0.2 diff --git a/biojava-alignment/pom.xml b/biojava-alignment/pom.xml index cbf5ae5a47..6e08f82d0e 100644 --- a/biojava-alignment/pom.xml +++ b/biojava-alignment/pom.xml @@ -4,7 +4,7 @@ biojava org.biojava - 5.0.1 + 5.0.2 biojava-alignment biojava-alignment @@ -47,7 +47,7 @@ org.biojava biojava-core - 5.0.1 + 5.0.2 compile diff --git a/biojava-core/pom.xml b/biojava-core/pom.xml index 00fe539ebe..ff8351f898 100644 --- a/biojava-core/pom.xml +++ b/biojava-core/pom.xml @@ -3,7 +3,7 @@ biojava org.biojava - 5.0.1 + 5.0.2 4.0.0 biojava-core diff --git a/biojava-genome/pom.xml b/biojava-genome/pom.xml index 072ce66d85..c9c51a1fd6 100644 --- a/biojava-genome/pom.xml +++ b/biojava-genome/pom.xml @@ -3,7 +3,7 @@ biojava org.biojava - 5.0.1 + 5.0.2 4.0.0 biojava-genome @@ -85,13 +85,13 @@ org.biojava biojava-core - 5.0.1 + 5.0.2 compile org.biojava biojava-alignment - 5.0.1 + 5.0.2 compile diff --git a/biojava-integrationtest/pom.xml b/biojava-integrationtest/pom.xml index b8e58dbd62..b21091a38e 100644 --- a/biojava-integrationtest/pom.xml +++ b/biojava-integrationtest/pom.xml @@ -4,7 +4,7 @@ biojava org.biojava - 5.0.1 + 5.0.2 biojava-integrationtest jar @@ -28,7 +28,7 @@ org.biojava biojava-structure - 5.0.1 + 5.0.2 diff --git a/biojava-modfinder/pom.xml b/biojava-modfinder/pom.xml index 404ffdd16d..08032a6f6e 100644 --- a/biojava-modfinder/pom.xml +++ b/biojava-modfinder/pom.xml @@ -4,7 +4,7 @@ biojava org.biojava - 5.0.1 + 5.0.2 biojava-modfinder biojava-modfinder @@ -31,7 +31,7 @@ org.biojava biojava-structure - 5.0.1 + 5.0.2 jar compile diff --git a/biojava-ontology/pom.xml b/biojava-ontology/pom.xml index c95707f5db..c5526617b0 100644 --- a/biojava-ontology/pom.xml +++ b/biojava-ontology/pom.xml @@ -4,7 +4,7 @@ org.biojava biojava - 5.0.1 + 5.0.2 biojava-ontology diff --git a/biojava-protein-disorder/pom.xml b/biojava-protein-disorder/pom.xml index 8a0aaf6af5..c28cd35255 100644 --- a/biojava-protein-disorder/pom.xml +++ b/biojava-protein-disorder/pom.xml @@ -3,7 +3,7 @@ biojava org.biojava - 5.0.1 + 5.0.2 biojava-protein-disorder jar @@ -63,7 +63,7 @@ org.biojava biojava-core - 5.0.1 + 5.0.2 diff --git a/biojava-structure-gui/pom.xml b/biojava-structure-gui/pom.xml index 997c104af6..d5b399e224 100644 --- a/biojava-structure-gui/pom.xml +++ b/biojava-structure-gui/pom.xml @@ -3,7 +3,7 @@ biojava org.biojava - 5.0.1 + 5.0.2 4.0.0 biojava-structure-gui @@ -27,13 +27,13 @@ org.biojava biojava-structure - 5.0.1 + 5.0.2 compile org.biojava biojava-core - 5.0.1 + 5.0.2 compile diff --git a/biojava-structure/pom.xml b/biojava-structure/pom.xml index 82c8eabb01..ded3b4aa66 100644 --- a/biojava-structure/pom.xml +++ b/biojava-structure/pom.xml @@ -4,7 +4,7 @@ biojava org.biojava - 5.0.1 + 5.0.2 biojava-structure biojava-structure @@ -40,13 +40,13 @@ org.biojava biojava-alignment - 5.0.1 + 5.0.2 compile org.biojava biojava-core - 5.0.1 + 5.0.2 compile diff --git a/biojava-structure/src/main/java/org/biojava/nbio/structure/PDBHeader.java b/biojava-structure/src/main/java/org/biojava/nbio/structure/PDBHeader.java index 9a96e03a20..29b4142f9d 100644 --- a/biojava-structure/src/main/java/org/biojava/nbio/structure/PDBHeader.java +++ b/biojava-structure/src/main/java/org/biojava/nbio/structure/PDBHeader.java @@ -90,7 +90,7 @@ public PDBHeader(){ rFree = DEFAULT_RFREE; rWork = DEFAULT_RFREE; - bioAssemblies = new HashMap(); + bioAssemblies = new LinkedHashMap(); crystallographicInfo = new PDBCrystallographicInfo(); } diff --git a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/SimpleMMcifConsumer.java b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/SimpleMMcifConsumer.java index e3d431fd3e..70cca55f83 100644 --- a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/SimpleMMcifConsumer.java +++ b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/SimpleMMcifConsumer.java @@ -26,6 +26,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.Map; @@ -791,7 +792,7 @@ public void documentEnd() { // the more detailed mapping of chains to rotation operations happens in StructureIO... - Map bioAssemblies = new HashMap(); + Map bioAssemblies = new LinkedHashMap(); for ( PdbxStructAssembly psa : strucAssemblies){ diff --git a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmtf/MmtfStructureReader.java b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmtf/MmtfStructureReader.java index 224fa6ce03..bf3b28d0f0 100644 --- a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmtf/MmtfStructureReader.java +++ b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmtf/MmtfStructureReader.java @@ -24,6 +24,7 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -479,6 +480,8 @@ public void setBioAssemblyTrans(int bioAssemblyId, int[] inputChainIndices, doub bioAssTrans.setTransformationMatrix(mat4d); // Now add this bioAssInfo.getTransforms().add(bioAssTrans); + // sort transformations into a unique order + Collections.sort(bioAssInfo.getTransforms()); } } diff --git a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmtf/MmtfUtils.java b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmtf/MmtfUtils.java index f602fa81fd..7ee5a8f81a 100644 --- a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmtf/MmtfUtils.java +++ b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmtf/MmtfUtils.java @@ -24,8 +24,8 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; -import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -243,7 +243,7 @@ public static String dateToIsoString(Date inputDate) { * @return the bioassembly information (as primitive types). */ public static Map getTransformMap(BioAssemblyInfo bioassemblyInfo, Map chainIdToIndexMap) { - Map> matMap = new HashMap<>(); + Map> matMap = new LinkedHashMap<>(); List transforms = bioassemblyInfo.getTransforms(); for (BiologicalAssemblyTransformation transformation : transforms) { Matrix4d transMatrix = transformation.getTransformationMatrix(); @@ -261,7 +261,8 @@ public static Map getTransformMap(BioAssemblyInfo bioassemblyIn matMap.put(transMatrix, chainIdList); } } - Map outMap = new HashMap<>(); + + Map outMap = new LinkedHashMap<>(); for (Entry> entry : matMap.entrySet()) { outMap.put(convertToDoubleArray(entry.getKey()), CodecUtils.convertToIntArray(entry.getValue())); } @@ -411,7 +412,7 @@ public static MmtfSummaryDataBean getStructureInfo(Structure structure) { // Get all the atoms List theseAtoms = new ArrayList<>(); List allChains = new ArrayList<>(); - Map chainIdToIndexMap = new HashMap<>(); + Map chainIdToIndexMap = new LinkedHashMap<>(); int chainCounter = 0; int bondCount = 0; mmtfSummaryDataBean.setAllAtoms(theseAtoms); diff --git a/biojava-structure/src/main/java/org/biojava/nbio/structure/quaternary/BiologicalAssemblyTransformation.java b/biojava-structure/src/main/java/org/biojava/nbio/structure/quaternary/BiologicalAssemblyTransformation.java index 82f0b61be3..581a4ee155 100644 --- a/biojava-structure/src/main/java/org/biojava/nbio/structure/quaternary/BiologicalAssemblyTransformation.java +++ b/biojava-structure/src/main/java/org/biojava/nbio/structure/quaternary/BiologicalAssemblyTransformation.java @@ -51,7 +51,7 @@ * @author Jose Duarte * @see CrystalTransform */ -public class BiologicalAssemblyTransformation implements Cloneable, Serializable { +public class BiologicalAssemblyTransformation implements Cloneable, Comparable, Serializable { private static final long serialVersionUID = -6388503076022480391L; @@ -339,4 +339,9 @@ public static String translVecToString(Matrix4d m) { return String.format("(%5.2f %5.2f %5.2f)", m.m03, m.m13, m.m23); } + @Override + public int compareTo(BiologicalAssemblyTransformation other) { + int comp = this.chainId.compareTo(other.chainId); + return comp == 0 ? this.id.compareTo(other.id) : comp; + } } diff --git a/biojava-structure/src/test/java/org/biojava/nbio/structure/io/mmtf/TestMmtfRoundTrip.java b/biojava-structure/src/test/java/org/biojava/nbio/structure/io/mmtf/TestMmtfRoundTrip.java index 70b78a8f1e..1fa32c5cc0 100644 --- a/biojava-structure/src/test/java/org/biojava/nbio/structure/io/mmtf/TestMmtfRoundTrip.java +++ b/biojava-structure/src/test/java/org/biojava/nbio/structure/io/mmtf/TestMmtfRoundTrip.java @@ -20,13 +20,17 @@ */ package org.biojava.nbio.structure.io.mmtf; -import static org.junit.Assert.*; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; +import java.util.Map; import org.biojava.nbio.structure.Atom; import org.biojava.nbio.structure.Bond; @@ -36,8 +40,11 @@ import org.biojava.nbio.structure.StructureException; import org.biojava.nbio.structure.StructureIO; import org.biojava.nbio.structure.align.util.AtomCache; +import org.biojava.nbio.structure.io.FileParsingParameters; import org.biojava.nbio.structure.io.mmcif.ChemCompGroupFactory; import org.biojava.nbio.structure.io.mmcif.DownloadChemCompProvider; +import org.biojava.nbio.structure.quaternary.BioAssemblyInfo; +import org.biojava.nbio.structure.quaternary.BiologicalAssemblyTransformation; import org.junit.Test; import org.rcsb.mmtf.decoder.StructureDataToAdapter; import org.rcsb.mmtf.encoder.AdapterToStructureData; @@ -57,17 +64,25 @@ public class TestMmtfRoundTrip { @Test public void testRoundTrip() throws IOException, StructureException { AtomCache cache = new AtomCache(); + FileParsingParameters params = new FileParsingParameters(); + params.setParseBioAssembly(true); + cache.setFileParsingParams(params); cache.setUseMmCif(true); - ChemCompGroupFactory.setChemCompProvider(new DownloadChemCompProvider()); + StructureIO.setAtomCache(cache); + ChemCompGroupFactory.setChemCompProvider(new DownloadChemCompProvider()); - StructureIO.setAtomCache(cache); - Structure structure = StructureIO.getStructure("4CUP"); + // test case for biojava issue #770, order of subunits + Structure structure1 = StructureIO.getStructure("3BW1"); AdapterToStructureData writerToEncoder = new AdapterToStructureData(); - new MmtfStructureWriter(structure, writerToEncoder); + new MmtfStructureWriter(structure1, writerToEncoder); MmtfStructureReader mmtfStructureReader = new MmtfStructureReader(); new StructureDataToAdapter(writerToEncoder, mmtfStructureReader); - assertTrue(checkIfAtomsSame(structure,mmtfStructureReader.getStructure())); + Structure structure2 = mmtfStructureReader.getStructure(); + + assertTrue(checkIfAtomsSame(structure1, structure2)); + + checkBioAssemblies1(structure1, structure2); } /** @@ -290,4 +305,36 @@ private void checkSeqresGroups(Chain chainOne, Chain chainTwo) { } } + + /** + * Checks consistency of bioassemblies + * @param structOne the first input structure + * @param structTwo the second input structure + */ + private void checkBioAssemblies1(Structure structOne, Structure structTwo) throws IOException { + + Map expecteds = structOne.getPDBHeader().getBioAssemblies(); + Map actuals = structTwo.getPDBHeader().getBioAssemblies(); + assertEquals(expecteds.size(), actuals.size()); + + assertEquals(new ArrayList<>(expecteds.keySet()), new ArrayList<>(actuals.keySet())); + + List assemblies1 = new ArrayList<>(expecteds.values()); + List assemblies2 = new ArrayList<>(actuals.values()); + + for (int i = 0; i < assemblies1.size(); i++) { + BioAssemblyInfo info1 = assemblies1.get(i); + BioAssemblyInfo info2 = assemblies2.get(i); + assertEquals(info1.getId(), info2.getId()); + assertEquals(info1.getTransforms().size(), info2.getTransforms().size()); + + for (int j = 0; j < info1.getTransforms().size(); j++) { + BiologicalAssemblyTransformation trans1 = info1.getTransforms().get(j); + BiologicalAssemblyTransformation trans2 = info2.getTransforms().get(j); + + assertEquals(trans1.getChainId(), trans2.getChainId()); + assertTrue(trans1.getTransformationMatrix().epsilonEquals(trans2.getTransformationMatrix(), 0.000001)); + } + } + } } diff --git a/biojava-survival/pom.xml b/biojava-survival/pom.xml index aa1bd5c801..cfcf245996 100644 --- a/biojava-survival/pom.xml +++ b/biojava-survival/pom.xml @@ -4,7 +4,7 @@ org.biojava biojava - 5.0.1 + 5.0.2 biojava-survival diff --git a/biojava-ws/pom.xml b/biojava-ws/pom.xml index e4d66dda78..7f3a71b21a 100644 --- a/biojava-ws/pom.xml +++ b/biojava-ws/pom.xml @@ -3,7 +3,7 @@ biojava org.biojava - 5.0.1 + 5.0.2 biojava-ws biojava-ws @@ -19,7 +19,7 @@ org.biojava biojava-core - 5.0.1 + 5.0.2 compile diff --git a/pom.xml b/pom.xml index dd1a210b4e..7b87480976 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ org.biojava biojava pom - 5.0.1 + 5.0.2 biojava BioJava is an open-source project dedicated to providing a Java framework for processing biological data. It provides analytical and statistical routines, parsers for common file formats and allows the @@ -39,7 +39,7 @@ UTF-8 512M - 1.0.7 + 1.0.8 1.7.25 2.6.2 @@ -48,7 +48,7 @@ scm:git:git@github.com:biojava/biojava.git https://github.com/biojava/biojava - biojava-5.0.1 + biojava-5.0.2