diff --git a/biojava-aa-prop/pom.xml b/biojava-aa-prop/pom.xml index d20dfbb6ce..5c35a618b8 100644 --- a/biojava-aa-prop/pom.xml +++ b/biojava-aa-prop/pom.xml @@ -2,7 +2,7 @@ biojava org.biojava - 4.2.4 + 4.2.5 4.0.0 biojava-aa-prop @@ -70,12 +70,12 @@ org.biojava biojava-core - 4.2.4 + 4.2.5 org.biojava biojava-structure - 4.2.4 + 4.2.5 diff --git a/biojava-alignment/pom.xml b/biojava-alignment/pom.xml index f6dae05256..d42f48f857 100644 --- a/biojava-alignment/pom.xml +++ b/biojava-alignment/pom.xml @@ -4,7 +4,7 @@ biojava org.biojava - 4.2.4 + 4.2.5 biojava-alignment biojava-alignment @@ -46,7 +46,7 @@ org.biojava biojava-core - 4.2.4 + 4.2.5 compile @@ -74,7 +74,7 @@ org.biojava biojava-phylo - 4.2.4 + 4.2.5 diff --git a/biojava-core/pom.xml b/biojava-core/pom.xml index 38b1f1ba0c..80cab2a58a 100644 --- a/biojava-core/pom.xml +++ b/biojava-core/pom.xml @@ -3,7 +3,7 @@ biojava org.biojava - 4.2.4 + 4.2.5 4.0.0 biojava-core diff --git a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/AccessionID.java b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/AccessionID.java index a1199e4706..a9fb6a1b47 100644 --- a/biojava-core/src/main/java/org/biojava/nbio/core/sequence/AccessionID.java +++ b/biojava-core/src/main/java/org/biojava/nbio/core/sequence/AccessionID.java @@ -133,6 +133,8 @@ public void setVersion(Integer version) { /** * In case if {@link #getID() } in not unique keeps the alternative id, eg. NCBI GI number. + * + * This may null. * * @return */ diff --git a/biojava-core/src/test/java/org/biojava/nbio/core/sequence/loader/GenbankProxySequenceReaderTest.java b/biojava-core/src/test/java/org/biojava/nbio/core/sequence/loader/GenbankProxySequenceReaderTest.java index a20faf7ce7..78b6c16607 100644 --- a/biojava-core/src/test/java/org/biojava/nbio/core/sequence/loader/GenbankProxySequenceReaderTest.java +++ b/biojava-core/src/test/java/org/biojava/nbio/core/sequence/loader/GenbankProxySequenceReaderTest.java @@ -99,9 +99,10 @@ so it should be done here (manualy). logger.info("accession id: {}", seq.getAccession().getID()); Assert.assertNotNull(seq.getAccession().getID()); // test GID number - Assert.assertEquals(gi, seq.getAccession().getIdentifier()); - logger.info("found identifier '{}'", seq.getAccession().getIdentifier()); - + if( seq.getAccession().getIdentifier() != null) { // GI: in header now optional. See #596 + Assert.assertEquals(gi, seq.getAccession().getIdentifier()); + logger.info("found identifier '{}'", seq.getAccession().getIdentifier()); + } // test taxonomy id logger.info("taxonomy id: {}", seq.getTaxonomy().getID()); Assert.assertNotNull(seq.getTaxonomy().getID()); diff --git a/biojava-genome/pom.xml b/biojava-genome/pom.xml index bb8d08147c..93ca9d0423 100644 --- a/biojava-genome/pom.xml +++ b/biojava-genome/pom.xml @@ -3,7 +3,7 @@ biojava org.biojava - 4.2.4 + 4.2.5 4.0.0 biojava-genome @@ -85,13 +85,13 @@ org.biojava biojava-core - 4.2.4 + 4.2.5 compile org.biojava biojava-alignment - 4.2.4 + 4.2.5 compile diff --git a/biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff/Location.java b/biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff/Location.java index d36389ce89..76e092d0d6 100644 --- a/biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff/Location.java +++ b/biojava-genome/src/main/java/org/biojava/nbio/genome/parsers/gff/Location.java @@ -286,34 +286,41 @@ public Location union( Location other ) } /** - * Return the intersection, or null if no overlap. - * - * @param other The location to intersect. - * @return The maximal location that is contained by both. Returns null if no overlap! - * @throws IllegalArgumentException Locations are on opposite strands. - */ - public Location intersection( Location other ) - { - if( isSameStrand( other ) ) - { - int start= ( mStart > other.mStart)? mStart: other.mStart; //pick larger - int end= ( mEnd < other.mEnd)? mEnd: other.mEnd; //pick smaller - - if( start <= end ) - { - return new Location( start, end ); - } - else - { - return null; - } + * Return the intersection, or null if no overlap. + * + * @param other + * The location to intersect. + * @return The maximal location that is contained by both. Returns null if + * no overlap! + * @throws IllegalArgumentException + * Locations are on opposite strands. + */ + public Location intersection(Location other) { + if (isSameStrand(other)) { + return intersect(mStart, mEnd, other.mStart, other.mEnd); + } else { + throw new IllegalArgumentException("Locations are on opposite strands."); } - else - { - throw new IllegalArgumentException( "Locations are on opposite strands." ); + } + + private Location intersect(int a1, int a2, int b1, int b2) { + if (a1 > b1) { + return intersect(b1, b2, a1, a2); } + // Safe to assume a1 <= b1 + if (b1 >= a2) { + // b starts after a ends + return null; + } else if (b1 < a2 && b2 <= a2) { + // b starts after a starts and ends before or at where a ends + return new Location(b1, b2); + } else if (b1 >= a1 && a2 <= b2) { + // b starts after a but extends after the end of a + return new Location(b1, a2); + } + return null; + } - } /** * Get starting index (origin 0). @@ -906,7 +913,7 @@ static private Location R( int s, int e ) */ @Deprecated @SuppressWarnings("unused") - public static void main( String args[] ) + public static void main(String[] args ) throws Exception { Location p3_7= new Location( 3, 7 ); diff --git a/biojava-genome/src/test/java/org/biojava/nbio/genome/TestIssue355.java b/biojava-genome/src/test/java/org/biojava/nbio/genome/TestIssue355.java new file mode 100644 index 0000000000..ad4639882d --- /dev/null +++ b/biojava-genome/src/test/java/org/biojava/nbio/genome/TestIssue355.java @@ -0,0 +1,29 @@ +package org.biojava.nbio.genome; + +import static org.junit.Assert.*; + +import org.biojava.nbio.genome.parsers.gff.Location; +import org.junit.Test; + +public class TestIssue355 { + + @Test + public void testIssue1() { + Location l1 = Location.fromBio(51227320, 51227381, '+'); + Location l2 = Location.fromBio(51227323, 51227382, '+'); + + Location union = l1.union(l2); + assertEquals(51227320,union.bioStart()); + assertEquals(51227382,union.bioEnd()); + } + + @Test + public void testIssue2() { + Location l1 = Location.fromBio(100, 200, '+'); + Location l2 = Location.fromBio(1, 99, '+'); + Location intersection = l1.intersection(l2); + assertNull(intersection); + } + +} + diff --git a/biojava-genome/src/test/java/org/biojava/nbio/genome/TestLocation.java b/biojava-genome/src/test/java/org/biojava/nbio/genome/TestLocation.java index 14e277b66b..57de38b909 100644 --- a/biojava-genome/src/test/java/org/biojava/nbio/genome/TestLocation.java +++ b/biojava-genome/src/test/java/org/biojava/nbio/genome/TestLocation.java @@ -91,6 +91,29 @@ public void testLocation() { assertEquals(L(12,20), L(2,20).suffix( L(10,12))); } + + @Test + public void testLocationIntersections() { + // One inside another + Location r21_25 = new Location( 21, 25 ); + Location r1_100 = new Location(1, 100 ); + + assertEquals(r21_25, r21_25.intersection( r1_100)); + assertEquals(r21_25, r1_100.intersection( r21_25)); + + // Non overlapping + Location r10_100 = new Location(10, 100 ); + Location r1_9 = new Location( 1, 9 ); + + assertNull(r10_100.intersection( r1_9)); + assertNull(r1_9.intersection( new Location( 9, 10 ))); + + // Partially overlappping + Location r1_25 = new Location( 1, 25 ); + Location r21_100 = new Location(21, 100 ); + assertEquals(r21_25, r1_25.intersection( r21_100)); + assertEquals(r21_25, r21_100.intersection( r1_25)); + } //shorthand for testing private static Location L( int s, int e ) { diff --git a/biojava-integrationtest/pom.xml b/biojava-integrationtest/pom.xml index c10746a76e..82703c0da0 100644 --- a/biojava-integrationtest/pom.xml +++ b/biojava-integrationtest/pom.xml @@ -4,7 +4,7 @@ biojava org.biojava - 4.2.4 + 4.2.5 biojava-integrationtest jar @@ -32,7 +32,7 @@ org.biojava biojava-structure - 4.2.4 + 4.2.5 diff --git a/biojava-integrationtest/src/test/java/org/biojava/nbio/structure/test/io/TestCrystallographicMetadata.java b/biojava-integrationtest/src/test/java/org/biojava/nbio/structure/test/io/TestCrystallographicMetadata.java new file mode 100644 index 0000000000..5e53ddc793 --- /dev/null +++ b/biojava-integrationtest/src/test/java/org/biojava/nbio/structure/test/io/TestCrystallographicMetadata.java @@ -0,0 +1,76 @@ +package org.biojava.nbio.structure.test.io; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.biojava.nbio.structure.Structure; +import org.biojava.nbio.structure.StructureIO; +import org.biojava.nbio.structure.align.util.AtomCache; + +/** + * A test for the parsing of some crystallographic metadata: non standard space group and non standard coordinate frame convention. + * + * + * For more info see https://github.com/eppic-team/owl/issues/4 and https://github.com/eppic-team/eppic/issues/37 + * + * + * + * @author Jose Duarte + * @since 4.2.5 + */ +public class TestCrystallographicMetadata { + + + @Test + public void test4hhb() throws Exception { + + AtomCache cache = new AtomCache(); + // at the moment implemented only in mmcif + cache.setUseMmCif(true); + StructureIO.setAtomCache(cache); + + Structure s = StructureIO.getStructure("4hhb"); + + // 4hhb is one of the few entries that aren't in the standard coordinate frame convention + assertTrue(s.getCrystallographicInfo().isNonStandardCoordFrameConvention()); + + // 4hhn has a standard SG + assertFalse(s.getCrystallographicInfo().isNonStandardSg()); + assertNotNull(s.getCrystallographicInfo().getSpaceGroup()); + } + + @Test + public void test1smt() throws Exception { + + AtomCache cache = new AtomCache(); + // at the moment implemented only in mmcif + cache.setUseMmCif(true); + StructureIO.setAtomCache(cache); + + Structure s = StructureIO.getStructure("1smt"); + + // 1smt is a normal entry, should be standard + assertFalse(s.getCrystallographicInfo().isNonStandardCoordFrameConvention()); + + // 1smt has a standard SG + assertFalse(s.getCrystallographicInfo().isNonStandardSg()); + assertNotNull(s.getCrystallographicInfo().getSpaceGroup()); + + } + + @Test + public void test1zna() throws Exception { + AtomCache cache = new AtomCache(); + // at the moment implemented only in mmcif + cache.setUseMmCif(true); + StructureIO.setAtomCache(cache); + + Structure s = StructureIO.getStructure("1zna"); + + // 1zna is one of the few entries that has a non-standard SG + assertTrue(s.getCrystallographicInfo().isNonStandardSg()); + assertNull(s.getCrystallographicInfo().getSpaceGroup()); + } + + +} diff --git a/biojava-structure/src/test/java/org/biojava/nbio/structure/xtal/TestCrystalBuilder.java b/biojava-integrationtest/src/test/java/org/biojava/nbio/structure/test/xtal/TestCrystalBuilder.java similarity index 79% rename from biojava-structure/src/test/java/org/biojava/nbio/structure/xtal/TestCrystalBuilder.java rename to biojava-integrationtest/src/test/java/org/biojava/nbio/structure/test/xtal/TestCrystalBuilder.java index cb4b536ee0..b275b2d3f2 100644 --- a/biojava-structure/src/test/java/org/biojava/nbio/structure/xtal/TestCrystalBuilder.java +++ b/biojava-integrationtest/src/test/java/org/biojava/nbio/structure/test/xtal/TestCrystalBuilder.java @@ -18,18 +18,19 @@ * http://www.biojava.org/ * */ -package org.biojava.nbio.structure.xtal; +package org.biojava.nbio.structure.test.xtal; import org.biojava.nbio.structure.Structure; 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.contact.StructureInterfaceList; +import org.biojava.nbio.structure.xtal.CrystalBuilder; import org.junit.Test; import java.io.IOException; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class TestCrystalBuilder { @@ -42,7 +43,7 @@ public void test1NMR() throws IOException, StructureException { StructureIO.setAtomCache(cache); - cache.setUseMmCif(false); + cache.setUseMmCif(true); Structure s1 = StructureIO.getStructure("1NMR"); CrystalBuilder cb = new CrystalBuilder(s1); @@ -60,7 +61,7 @@ public void test1B8G() throws IOException, StructureException { StructureIO.setAtomCache(cache); - cache.setUseMmCif(false); + cache.setUseMmCif(true); Structure s1 = StructureIO.getStructure("1B8G"); CrystalBuilder cb = new CrystalBuilder(s1); StructureInterfaceList interfaces = cb.getUniqueInterfaces(5.5); @@ -78,7 +79,7 @@ public void test2MFZ() throws IOException, StructureException { StructureIO.setAtomCache(cache); - cache.setUseMmCif(false); + cache.setUseMmCif(true); Structure s1 = StructureIO.getStructure("2MFZ"); CrystalBuilder cb = new CrystalBuilder(s1); StructureInterfaceList interfaces = cb.getUniqueInterfaces(5.5); @@ -95,7 +96,7 @@ public void test4MF8() throws IOException, StructureException { StructureIO.setAtomCache(cache); - cache.setUseMmCif(false); + cache.setUseMmCif(true); Structure s1 = StructureIO.getStructure("4MF8"); CrystalBuilder cb = new CrystalBuilder(s1); StructureInterfaceList interfaces = cb.getUniqueInterfaces(5.5); @@ -115,11 +116,30 @@ public void test2H2Z() throws IOException, StructureException { StructureIO.setAtomCache(cache); - cache.setUseMmCif(false); + cache.setUseMmCif(true); Structure s1 = StructureIO.getStructure("2H2Z"); CrystalBuilder cb = new CrystalBuilder(s1); StructureInterfaceList interfaces = cb.getUniqueInterfaces(5.5); assertTrue(interfaces.size()>=3); } + + @Test + public void test4HHB() throws IOException, StructureException { + + // 4hhb is a very old entry with a non-standard coordinate frame convention, we should calculate only AU contacts + + AtomCache cache = new AtomCache(); + + StructureIO.setAtomCache(cache); + + cache.setUseMmCif(true); + Structure s1 = StructureIO.getStructure("4HHB"); + CrystalBuilder cb = new CrystalBuilder(s1); + StructureInterfaceList interfaces = cb.getUniqueInterfaces(5.5); + // 5 interfaces in the AU: the 4 of the tetramer + 1 cross-interface + assertEquals(5, interfaces.size()); + + } + } diff --git a/biojava-modfinder/pom.xml b/biojava-modfinder/pom.xml index 4551514d9a..a1f7b57970 100644 --- a/biojava-modfinder/pom.xml +++ b/biojava-modfinder/pom.xml @@ -4,7 +4,7 @@ biojava org.biojava - 4.2.4 + 4.2.5 biojava-modfinder biojava-modfinder @@ -31,7 +31,7 @@ org.biojava biojava-structure - 4.2.4 + 4.2.5 jar compile diff --git a/biojava-modfinder/src/main/java/org/biojava/nbio/phosphosite/Dataset.java b/biojava-modfinder/src/main/java/org/biojava/nbio/phosphosite/Dataset.java index 7fde73973f..ec65c2385a 100644 --- a/biojava-modfinder/src/main/java/org/biojava/nbio/phosphosite/Dataset.java +++ b/biojava-modfinder/src/main/java/org/biojava/nbio/phosphosite/Dataset.java @@ -21,10 +21,14 @@ package org.biojava.nbio.phosphosite; import org.biojava.nbio.structure.align.util.AtomCache; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.*; import java.net.URL; import java.nio.channels.FileChannel; +import java.nio.file.Files; +import java.nio.file.StandardCopyOption; import java.util.ArrayList; import java.util.List; @@ -43,6 +47,7 @@ */ public class Dataset { + private static final Logger logger = LoggerFactory.getLogger(Dataset.class); public static final String ACETYLATION = "http://www.phosphosite.org/downloads/Acetylation_site_dataset.gz"; @@ -110,8 +115,8 @@ public File getLocalDir(){ public void download(){ - System.out.println("Downloading data from www.phosposite.org. Data is under CC-BY-NC-SA license. Please link to site and cite: "); - System.out.println("Hornbeck PV, Kornhauser JM, Tkachev S, Zhang B, Skrzypek E, Murray B, Latham V, Sullivan M (2012) PhosphoSitePlus: a comprehensive resource for investigating the structure and function of experimentally determined post-translational modifications in man and mouse. Nucleic Acids Res. 40(Database issue), D261–70."); + logger.warn("Downloading data from www.phosposite.org. Data is under CC-BY-NC-SA license. Please link to site and cite: "); + logger.warn("Hornbeck PV, Kornhauser JM, Tkachev S, Zhang B, Skrzypek E, Murray B, Latham V, Sullivan M (2012) PhosphoSitePlus: a comprehensive resource for investigating the structure and function of experimentally determined post-translational modifications in man and mouse. Nucleic Acids Res. 40(Database issue), D261–70."); File dir = getLocalDir(); @@ -154,9 +159,9 @@ public void download(){ } - private void downloadFile(URL u, File localFile) throws IOException { + public void downloadFile(URL u, File localFile) throws IOException { - System.out.println("Downloading " + u); + logger.info("Downloading " + u); File tmp = File.createTempFile("tmp","phosphosite"); @@ -185,37 +190,8 @@ private void downloadFile(URL u, File localFile) throws IOException { public static void copyFile(File src, File dst) throws IOException { - // TODO: upgrade to Java 7: + Files.copy(src.toPath(), dst.toPath(), StandardCopyOption.REPLACE_EXISTING); - // Files.copy(src.toPath(), dst.toPath(), StandardCopyOption.REPLACE_EXISTING); - - - - long p = 0, dp, size; - FileChannel in = null, out = null; - - try - { - if (!dst.exists()) dst.createNewFile(); - - in = new FileInputStream(src).getChannel(); - out = new FileOutputStream(dst).getChannel(); - size = in.size(); - - while ((dp = out.transferFrom(in, p, size)) > 0) - { - p += dp; - } - } - finally { - try - { - if (out != null) out.close(); - } - finally { - if (in != null) in.close(); - } - } } @@ -227,16 +203,16 @@ public static void main(String[] args) { try { - for (File f : ds.getLocalFiles()) { - System.out.println(f.getAbsoluteFile()); + logger.info(f.getAbsolutePath()); List sites = Site.parseSites(f); + logger.info("Got " + sites.size() + " sites"); for (Site s : sites) { if (s.getUniprot().equals("P50225") || s.getUniprot().equals("P48025")) { - System.out.println(s); + logger.info(s.toString()); } } diff --git a/biojava-modfinder/src/main/java/org/biojava/nbio/phosphosite/Site.java b/biojava-modfinder/src/main/java/org/biojava/nbio/phosphosite/Site.java index 1585f8a588..ca5e4a5f2f 100644 --- a/biojava-modfinder/src/main/java/org/biojava/nbio/phosphosite/Site.java +++ b/biojava-modfinder/src/main/java/org/biojava/nbio/phosphosite/Site.java @@ -56,25 +56,26 @@ public static List parseSites(File f) throws IOException { int proteinIndex = -1; int uniprotIndex = -1; - int modTypeIndex = -1; int residueIndex = -1; int orgIndex = -1; int groupIndex = -1; + int geneIndex = -1; boolean inHeader = true; while ((line = buf.readLine()) != null){ - if ( line.startsWith("PROTEIN")) { + if ( line.startsWith("GENE") || + line.startsWith("PROTEIN")) { headerFields = parseHeaderFields(line); proteinIndex = headerFields.indexOf("PROTEIN"); uniprotIndex = headerFields.indexOf("ACC_ID"); - modTypeIndex = headerFields.indexOf("MOD_TYPE"); residueIndex = headerFields.indexOf("MOD_RSD"); - orgIndex = headerFields.indexOf("ORG"); + orgIndex = headerFields.indexOf("ORGANISM"); groupIndex = headerFields.indexOf("SITE_GRP_ID"); + geneIndex = headerFields.indexOf("GENE"); inHeader = false; continue; @@ -95,19 +96,25 @@ public static List parseSites(File f) throws IOException { String protein = spl[proteinIndex]; String uniprot = spl[uniprotIndex]; - //String geneSymb = spl[2]; - //String chrLoc = spl[3]; - String modType = spl[modTypeIndex]; + String residue = spl[residueIndex]; + + String[] resSpl = residue.split("-"); + String modType = null; + if ( resSpl.length == 2) { + + modType = resSpl[1]; + } String group = spl[groupIndex]; String organism = spl[orgIndex]; + String geneSymb = spl[geneIndex]; + Site s = new Site(); s.setProtein(protein); s.setUniprot(uniprot); - //s.setGeneSymb(geneSymb); - //s.setChrLoc(chrLoc); + s.setGeneSymb(geneSymb); s.setModType(modType); s.setResidue(residue); s.setGroup(group); diff --git a/biojava-modfinder/src/test/java/org/biojava/nbio/protmod/phosphosite/TestAcetylation.java b/biojava-modfinder/src/test/java/org/biojava/nbio/protmod/phosphosite/TestAcetylation.java new file mode 100644 index 0000000000..fea66a55b3 --- /dev/null +++ b/biojava-modfinder/src/test/java/org/biojava/nbio/protmod/phosphosite/TestAcetylation.java @@ -0,0 +1,86 @@ +package org.biojava.nbio.protmod.phosphosite; + + +import org.biojava.nbio.phosphosite.Dataset; +import org.biojava.nbio.phosphosite.Site; +import org.junit.Before; +import org.junit.Test; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.List; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + + +/** Makes sure there is a local installation of the Acetylation site file from Phosphosite and + * tests if it can get parsed by the parser. + * + * Created by andreas on 11/29/16. + */ +public class TestAcetylation { + + + /** Make sure an Acetylation file is available locally. + * Downloads from Phosphosite if needed. + * + */ + @Before + public void setUp() throws IOException{ + + Dataset ds = new Dataset(); + + String f = Dataset.ACETYLATION; + + File localFile = getLocalFileName(f); + + if (!localFile.exists()) { + ds.downloadFile(new URL(f), localFile); + } + + } + + /** returns the local file name where the Acetylation file will get cached locally. + * + * @param phosphoSiteFileLocation location of file at PhosphoSitePlus. + * @return a File pointing to the location of the locally cached file. + */ + private File getLocalFileName(String phosphoSiteFileLocation){ + + Dataset ds = new Dataset(); + File localDir = ds.getLocalDir(); + if ( ! localDir.exists()) { + boolean success = localDir.mkdir(); + if ( ! success) + fail("Could not create directory " + localDir.getAbsolutePath()); + } + + int slashIndex = phosphoSiteFileLocation.lastIndexOf("/"); + + String fileName = phosphoSiteFileLocation.substring(slashIndex); + + return new File(localDir + "/" + fileName); + } + + /** Tests that the acetylation file can get parsed without problems. + * + */ + @Test + public void testAcetylation() throws IOException { + + File localFile = getLocalFileName(Dataset.ACETYLATION); + + List sites = Site.parseSites(localFile); + + assertTrue(sites.size() > 0); + + for (Site s : sites) { + + assertTrue(s.getResidue() != null); + + } + + } +} diff --git a/biojava-ontology/pom.xml b/biojava-ontology/pom.xml index 8e0ccad72f..441b3bded0 100644 --- a/biojava-ontology/pom.xml +++ b/biojava-ontology/pom.xml @@ -4,7 +4,7 @@ org.biojava biojava - 4.2.4 + 4.2.5 biojava-ontology diff --git a/biojava-phylo/pom.xml b/biojava-phylo/pom.xml index e7758ae1ec..affe865373 100644 --- a/biojava-phylo/pom.xml +++ b/biojava-phylo/pom.xml @@ -3,7 +3,7 @@ biojava org.biojava - 4.2.4 + 4.2.5 4.0.0 biojava-phylo @@ -44,7 +44,7 @@ org.biojava biojava-core - 4.2.4 + 4.2.5 compile diff --git a/biojava-protein-disorder/pom.xml b/biojava-protein-disorder/pom.xml index 535e7095ff..9e12925676 100644 --- a/biojava-protein-disorder/pom.xml +++ b/biojava-protein-disorder/pom.xml @@ -3,7 +3,7 @@ biojava org.biojava - 4.2.4 + 4.2.5 biojava-protein-disorder jar @@ -63,7 +63,7 @@ org.biojava biojava-core - 4.2.4 + 4.2.5 diff --git a/biojava-sequencing/pom.xml b/biojava-sequencing/pom.xml index 461bddf663..eb65c46b23 100644 --- a/biojava-sequencing/pom.xml +++ b/biojava-sequencing/pom.xml @@ -3,7 +3,7 @@ biojava org.biojava - 4.2.4 + 4.2.5 4.0.0 biojava-sequencing @@ -47,7 +47,7 @@ org.biojava biojava-core - 4.2.4 + 4.2.5 compile diff --git a/biojava-structure-gui/pom.xml b/biojava-structure-gui/pom.xml index df3eb75ffe..d5b18c9e14 100644 --- a/biojava-structure-gui/pom.xml +++ b/biojava-structure-gui/pom.xml @@ -3,7 +3,7 @@ biojava org.biojava - 4.2.4 + 4.2.5 4.0.0 biojava-structure-gui @@ -25,13 +25,13 @@ org.biojava biojava-structure - 4.2.4 + 4.2.5 compile org.biojava biojava-core - 4.2.4 + 4.2.5 compile @@ -40,7 +40,7 @@ net.sourceforge.jmol jmol - 13.0.14 + 14.6.2_2016.08.28 diff --git a/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/jmol/AbstractAlignmentJmol.java b/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/jmol/AbstractAlignmentJmol.java index ec2c660deb..2a62b84961 100644 --- a/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/jmol/AbstractAlignmentJmol.java +++ b/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/jmol/AbstractAlignmentJmol.java @@ -41,6 +41,7 @@ import org.biojava.nbio.structure.jama.Matrix; import org.jcolorbrewer.ColorBrewer; import org.jmol.api.JmolViewer; +import org.jmol.viewer.Viewer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -219,7 +220,7 @@ public void mouseMoved(MouseEvent e) { int pos = viewer.findNearestAtomIndex( e.getX(), e.getY() ); if ( pos == -1 ) { return ; } - String atomInfo = viewer.getAtomInfo(pos); + String atomInfo = ((Viewer) viewer).getAtomInfo(pos); text.setText(atomInfo); } @@ -243,7 +244,7 @@ public void mouseReleased(MouseEvent e) { int pos = viewer.findNearestAtomIndex(e.getX(), e.getY()); if (pos == -1) return; - String atomInfo = viewer.getAtomInfo(pos); + String atomInfo = ((Viewer) viewer).getAtomInfo(pos); status.setText("clicked: " + atomInfo); AtomInfo ai = AtomInfoParser.parse(atomInfo); diff --git a/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/jmol/JmolPanel.java b/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/jmol/JmolPanel.java index b578793f01..738888f0c4 100644 --- a/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/jmol/JmolPanel.java +++ b/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/jmol/JmolPanel.java @@ -38,9 +38,12 @@ import org.jmol.api.JmolAdapter; import org.jmol.api.JmolStatusListener; import org.jmol.api.JmolViewer; -import org.jmol.util.Logger; +import org.jmol.util.LoggerInterface; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.swing.*; + import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -52,6 +55,8 @@ public class JmolPanel extends JPrintPanel implements ActionListener { + private static final Logger logger = LoggerFactory.getLogger(JmolPanel.class); + private static final long serialVersionUID = -3661941083797644242L; private JmolViewer viewer; @@ -62,13 +67,13 @@ public class JmolPanel Structure structure; - private boolean verbose = false; - public JmolPanel() { super(); statusListener = new MyJmolStatusListener(); adapter = new SmarterJmolAdapter(); - Logger.setLogLevel( verbose?Logger.LEVEL_INFO:Logger.LEVEL_ERROR); + JmolLoggerAdapter jmolLogger = new JmolLoggerAdapter(LoggerFactory.getLogger(org.jmol.api.JmolViewer.class)); + org.jmol.util.Logger.setLogger(jmolLogger); + org.jmol.util.Logger.setLogLevel( jmolLogger.getLogLevel() ); viewer = JmolViewer.allocateViewer(this, adapter, null,null,null,null, @@ -112,8 +117,8 @@ public void executeCmd(String rasmolScript) { public void setStructure(Structure s) { this.structure = s; - String pdb = s.toPDB(); - viewer.openStringInline(pdb); + String serialized = s.toMMCIF(); + viewer.openStringInline(serialized); evalString("save STATE state_1"); } @@ -173,7 +178,8 @@ public void actionPerformed(ActionEvent event) { return; } - JComboBox source = (JComboBox) event.getSource(); + @SuppressWarnings("unchecked") + JComboBox source = (JComboBox) event.getSource(); String value = source.getSelectedItem().toString(); evalString("save selection; "); @@ -267,7 +273,7 @@ private void colorBySCOP() { Listranges = domain.getRanges(); for (String range : ranges){ - if(verbose) System.out.println(range); + logger.debug(range); String[] spl = range.split(":"); String script = " select "; if ( spl.length > 1 ) @@ -276,7 +282,7 @@ private void colorBySCOP() { script += "*" + spl[0]+"/1;"; script += " color [" + c1.getRed() + ","+c1.getGreen() + "," +c1.getBlue()+"];"; script += " color cartoon [" + c1.getRed() + ","+c1.getGreen() + "," +c1.getBlue()+"] ;"; - if(verbose) System.out.println(script); + logger.debug(script); evalString(script); } @@ -286,7 +292,7 @@ private void colorBySCOP() { } private void colorByPDP() { - if(verbose) System.out.println("colorByPDP"); + logger.debug("colorByPDP"); if ( structure == null) return; @@ -310,13 +316,13 @@ private void colorByPDP() { int end = s.getTo(); Group startG = ca[start].getGroup(); Group endG = ca[end].getGroup(); - if(verbose) System.out.println(" Segment: " +startG.getResidueNumber() +":" + startG.getChainId() + " - " + endG.getResidueNumber()+":"+endG.getChainId() + " " + s); + logger.debug(" Segment: " +startG.getResidueNumber() +":" + startG.getChainId() + " - " + endG.getResidueNumber()+":"+endG.getChainId() + " " + s); String j1 = startG.getResidueNumber()+""; String j2 = endG.getResidueNumber()+":"+endG.getChainId(); String script = " select " +j1 +"-" +j2 +"/1;"; script += " color [" + c1.getRed() + ","+c1.getGreen() + "," +c1.getBlue()+"];"; script += " color cartoon [" + c1.getRed() + ","+c1.getGreen() + "," +c1.getBlue()+"] ;"; - if(verbose) System.out.println(script); + logger.debug(script); evalString(script); } @@ -356,15 +362,55 @@ public void destroy(){ adapter = null; } - public boolean isVerbose() { - return verbose; - } - - public void setVerbose(boolean verbose) { - this.verbose = verbose; - if(statusListener instanceof MyJmolStatusListener) { - ((MyJmolStatusListener)statusListener).setVerbose(verbose); + public static class JmolLoggerAdapter implements LoggerInterface { + private Logger slf; + public JmolLoggerAdapter(Logger slf) { + this.slf=slf; + } + public int getLogLevel() { + if( slf.isTraceEnabled() ) + return org.jmol.util.Logger.LEVEL_MAX; + if( slf.isDebugEnabled() ) + return org.jmol.util.Logger.LEVEL_DEBUG; + if( slf.isInfoEnabled() ) + return org.jmol.util.Logger.LEVEL_INFO; + if( slf.isWarnEnabled() ) + return org.jmol.util.Logger.LEVEL_WARN; + if( slf.isErrorEnabled() ) + return org.jmol.util.Logger.LEVEL_ERROR; + throw new IllegalStateException("Unknown SLF4J error level"); + } + @Override + public void debug(String txt) { + slf.debug(txt); + } + @Override + public void info(String txt) { + slf.info(txt); + } + @Override + public void warn(String txt) { + slf.warn(txt); + } + @Override + public void warnEx(String txt, Throwable e) { + slf.warn(txt,e); + } + @Override + public void error(String txt) { + slf.error(txt); + } + @Override + public void errorEx(String txt, Throwable e) { + slf.error(txt,e); + } + @Override + public void fatal(String txt) { + slf.error(txt); + } + @Override + public void fatalEx(String txt, Throwable e) { + slf.error(txt,e); } } - } diff --git a/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/jmol/MultipleAlignmentJmol.java b/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/jmol/MultipleAlignmentJmol.java index 949f17afb8..10cfe94a9f 100644 --- a/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/jmol/MultipleAlignmentJmol.java +++ b/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/jmol/MultipleAlignmentJmol.java @@ -20,6 +20,7 @@ */ package org.biojava.nbio.structure.align.gui.jmol; +import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import java.awt.Dimension; @@ -40,6 +41,7 @@ import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JMenuBar; +import javax.swing.JPanel; import javax.swing.JTextField; import org.biojava.nbio.structure.Atom; @@ -56,6 +58,7 @@ import org.biojava.nbio.structure.align.multiple.util.MultipleAlignmentTools; import org.biojava.nbio.structure.align.multiple.util.MultipleAlignmentWriter; import org.biojava.nbio.structure.align.webstart.AligUIManager; +import org.biojava.nbio.structure.gui.WrapLayout; import org.biojava.nbio.structure.jama.Matrix; import org.forester.archaeopteryx.Archaeopteryx; import org.forester.phylogeny.Phylogeny; @@ -137,14 +140,13 @@ public void windowClosing(WindowEvent e) { }); Container contentPane = frame.getContentPane(); - Box vBox = Box.createVerticalBox(); jmolPanel.addMouseMotionListener(this); jmolPanel.addMouseListener(this); - jmolPanel - .setPreferredSize(new Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT)); + jmolPanel.setPreferredSize(new Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT)); + contentPane.add(jmolPanel,BorderLayout.CENTER); - vBox.add(jmolPanel); + Box vBox = Box.createVerticalBox(); // / USER SCRIPTING COMMAND JTextField field = new JTextField(); @@ -162,8 +164,10 @@ public void windowClosing(WindowEvent e) { // / STRUCTURE SELECTION if (multAln != null) { - Box hBox00 = Box.createHorizontalBox(); - hBox00.setMaximumSize(new Dimension(Short.MAX_VALUE, 30)); + JPanel modelSelection = new JPanel(); + modelSelection.setLayout(new WrapLayout(WrapLayout.LEFT)); + modelSelection.setSize(new Dimension(DEFAULT_WIDTH,30)); + vBox.add(modelSelection); JButton show = new JButton("Show Only: "); show.addActionListener(new ActionListener() { @@ -184,27 +188,16 @@ public void actionPerformed(ActionEvent e) { jmolPanel.executeCmd(cmd + " restore selection;"); } }); - hBox00.add(show); - hBox00.add(Box.createGlue()); - vBox.add(hBox00); + modelSelection.add(show); - // A line of structures of maximum 5 - for (int line = 0; line < 1 + (multAln.size() / 5); line++) { - Box hBox0 = Box.createHorizontalBox(); - hBox0.setMaximumSize(new Dimension(Short.MAX_VALUE, 30)); - - for (int str = line * 5; str < Math.min((line + 1) * 5, - multAln.size()); str++) { - JCheckBox structureSelection = new JCheckBox(multAln - .getEnsemble().getStructureIdentifiers().get(str) - .getIdentifier()); - hBox0.add(structureSelection); - hBox0.add(Box.createGlue()); - structureSelection.setSelected(true); - selectedStructures.add(structureSelection); - } - - vBox.add(hBox0); + // Check boxes for all models + for(int str = 0; str < multAln.size();str++) { + JCheckBox structureSelection = new JCheckBox(multAln + .getEnsemble().getStructureIdentifiers().get(str) + .getIdentifier()); + modelSelection.add(structureSelection); + structureSelection.setSelected(true); + selectedStructures.add(structureSelection); } } @@ -214,21 +207,20 @@ public void actionPerformed(ActionEvent e) { String[] styles = new String[] { "Cartoon", "Backbone", "CPK", "Ball and Stick", "Ligands", "Ligands and Pocket" }; - JComboBox style = new JComboBox(styles); + JComboBox style = new JComboBox<>(styles); hBox1.setMaximumSize(new Dimension(Short.MAX_VALUE, 30)); hBox1.add(new JLabel("Style")); hBox1.add(style); vBox.add(hBox1); - contentPane.add(vBox); style.addActionListener(jmolPanel); String[] colorModes = new String[] { "Secondary Structure", "By Chain", "Rainbow", "By Element", "By Amino Acid", "Hydrophobicity", "Suggest Domains", "Show SCOP Domains" }; - JComboBox jcolors = new JComboBox(colorModes); + JComboBox jcolors = new JComboBox<>(colorModes); jcolors.addActionListener(jmolPanel); hBox1.add(Box.createGlue()); @@ -236,13 +228,14 @@ public void actionPerformed(ActionEvent e) { hBox1.add(jcolors); String[] cPalette = { "Spectral", "Set1", "Set2", "Pastel" }; - JComboBox palette = new JComboBox(cPalette); + JComboBox palette = new JComboBox<>(cPalette); palette.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - JComboBox source = (JComboBox) e.getSource(); + @SuppressWarnings("unchecked") + JComboBox source = (JComboBox) e.getSource(); String value = source.getSelectedItem().toString(); evalString("save selection; select *; color grey; " + "select ligand; color CPK;"); @@ -268,6 +261,7 @@ public void actionPerformed(ActionEvent e) { // / CHECK BOXES Box hBox2 = Box.createHorizontalBox(); + hBox2.setMaximumSize(new Dimension(Short.MAX_VALUE, 30)); JButton resetDisplay = new JButton("Reset Display"); resetDisplay.addActionListener(new ActionListener() { @@ -337,7 +331,7 @@ public void itemStateChanged(ItemEvent e) { vBox.add(hBox); - contentPane.add(vBox); + contentPane.add(vBox,BorderLayout.SOUTH); MyJmolStatusListener li = (MyJmolStatusListener) jmolPanel .getStatusListener(); diff --git a/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/jmol/MyJmolStatusListener.java b/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/jmol/MyJmolStatusListener.java index ae61cc1a73..f0a5a5864d 100644 --- a/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/jmol/MyJmolStatusListener.java +++ b/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/jmol/MyJmolStatusListener.java @@ -24,17 +24,17 @@ package org.biojava.nbio.structure.align.gui.jmol; -import org.jmol.api.JmolStatusListener; -import org.jmol.constant.EnumCallback; +import java.util.Map; -import javax.swing.*; +import javax.swing.JTextField; -import java.util.Hashtable; -import java.util.Map; +import org.jmol.api.JmolStatusListener; +import org.jmol.c.CBK; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class MyJmolStatusListener implements JmolStatusListener { - - private boolean verbose = false; + private static final Logger logger = LoggerFactory.getLogger(MyJmolStatusListener.class); JTextField status; public MyJmolStatusListener(){ @@ -46,33 +46,30 @@ public void setTextField (JTextField statusField) { @Override public String createImage(String arg0, String arg1, Object arg2, int arg3) { - // TODO Auto-generated method stub - return null; + return null; //Cancelled } @Override public String eval(String arg0) { - if(verbose) System.out.println("eval " + arg0); + logger.debug("eval {}",arg0); return null; } @Override public float[][] functionXY(String arg0, int arg1, int arg2) { - if(verbose) System.out.println("XY " + arg0 + " " + arg1 + " " + arg2); - return null; + logger.debug("XY {} {} {}",arg0,arg1, arg2); + return null; //Ignore isosurface commands } @Override public float[][][] functionXYZ(String arg0, int arg1, int arg2, int arg3) { - // TODO Auto-generated method stub - return null; + logger.debug("XYZ {} {} {} {}",arg0,arg1, arg2, arg3); + return null; //Ignore isosurface commands } - @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public Hashtable getRegistryInfo() { - // TODO Auto-generated method stub - return null; + public Map getRegistryInfo() { + return null; //Ignore } @Override @@ -87,79 +84,48 @@ public void notifyCallback(int arg0, Object[] arg1) { } public boolean notifyEnabled(int arg0) { - // TODO Auto-generated method stub return false; } @Override public void setCallbackFunction(String arg0, String arg1) { - if(verbose) System.out.println("callback:" + arg0 + " " + arg1); + logger.debug("callback: {} {}", arg0, arg1); status.setText(arg0 + " " + arg1); - } public String dialogAsk(String arg0, String arg1) { - // TODO Auto-generated method stub - if(verbose) System.out.println("dialogAsk"); - return null; + logger.debug("dialogAsk {} {}",arg0,arg1); + return null; //Ignore } public void handlePopupMenu(int arg0, int arg1) { - // TODO Auto-generated method stub - if(verbose) System.out.println("handlePopupMenu"); + logger.debug("handlePopupMenu {} {}",arg0,arg1); } public void showConsole(boolean arg0) { - - // TODO Auto-generated method stub - if(verbose) System.out.println("showConsole"); - + logger.debug("showConsole {}",arg0); } - @Override - public void notifyCallback(EnumCallback arg0, Object[] arg1) { - // TODO Auto-generated method stub + @Override + public void notifyCallback(CBK message, Object[] data) { } - @Override - public boolean notifyEnabled(EnumCallback arg0) { - // TODO Auto-generated method stub + public boolean notifyEnabled(CBK type) { return false; } - @Override - public Map getProperty(String arg0) { - // TODO Auto-generated method stub - return null; - } - - - public Map getJSpecViewProperty(String arg0) { - // TODO Auto-generated method stub return null; } @Override - public void resizeInnerPanel(String data) { - // TODO Auto-generated method stub - - } - - public boolean isVerbose() { - return verbose; - } - - public void setVerbose(boolean verbose) { - this.verbose = verbose; + public int[] resizeInnerPanel(String data) { + return null; } - - - } diff --git a/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/gui/WrapLayout.java b/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/gui/WrapLayout.java new file mode 100644 index 0000000000..1516a643ef --- /dev/null +++ b/biojava-structure-gui/src/main/java/org/biojava/nbio/structure/gui/WrapLayout.java @@ -0,0 +1,195 @@ +package org.biojava.nbio.structure.gui; + +import java.awt.*; +import javax.swing.JScrollPane; +import javax.swing.SwingUtilities; + +/** + * FlowLayout subclass that fully supports wrapping of components. + * + * Originally written by Rob Camick + * https://tips4java.wordpress.com/2008/11/06/wrap-layout/ + */ +public class WrapLayout extends FlowLayout +{ + private Dimension preferredLayoutSize; + + /** + * Constructs a new WrapLayout with a left + * alignment and a default 5-unit horizontal and vertical gap. + */ + public WrapLayout() + { + super(); + } + + /** + * Constructs a new FlowLayout with the specified + * alignment and a default 5-unit horizontal and vertical gap. + * The value of the alignment argument must be one of + * WrapLayout, WrapLayout, + * or WrapLayout. + * @param align the alignment value + */ + public WrapLayout(int align) + { + super(align); + } + + /** + * Creates a new flow layout manager with the indicated alignment + * and the indicated horizontal and vertical gaps. + *

+ * The value of the alignment argument must be one of + * WrapLayout, WrapLayout, + * or WrapLayout. + * @param align the alignment value + * @param hgap the horizontal gap between components + * @param vgap the vertical gap between components + */ + public WrapLayout(int align, int hgap, int vgap) + { + super(align, hgap, vgap); + } + + /** + * Returns the preferred dimensions for this layout given the + * visible components in the specified target container. + * @param target the component which needs to be laid out + * @return the preferred dimensions to lay out the + * subcomponents of the specified container + */ + @Override + public Dimension preferredLayoutSize(Container target) + { + return layoutSize(target, true); + } + + /** + * Returns the minimum dimensions needed to layout the visible + * components contained in the specified target container. + * @param target the component which needs to be laid out + * @return the minimum dimensions to lay out the + * subcomponents of the specified container + */ + @Override + public Dimension minimumLayoutSize(Container target) + { + Dimension minimum = layoutSize(target, false); + minimum.width -= (getHgap() + 1); + return minimum; + } + + /** + * Returns the minimum or preferred dimension needed to layout the target + * container. + * + * @param target target to get layout size for + * @param preferred should preferred size be calculated + * @return the dimension to layout the target container + */ + private Dimension layoutSize(Container target, boolean preferred) + { + synchronized (target.getTreeLock()) + { + // Each row must fit with the width allocated to the containter. + // When the container width = 0, the preferred width of the container + // has not yet been calculated so lets ask for the maximum. + + int targetWidth = target.getSize().width; + Container container = target; + + while (container.getSize().width == 0 && container.getParent() != null) + { + container = container.getParent(); + } + + targetWidth = container.getSize().width; + + if (targetWidth == 0) + targetWidth = Integer.MAX_VALUE; + + int hgap = getHgap(); + int vgap = getVgap(); + Insets insets = target.getInsets(); + int horizontalInsetsAndGap = insets.left + insets.right + (hgap * 2); + int maxWidth = targetWidth - horizontalInsetsAndGap; + + // Fit components into the allowed width + + Dimension dim = new Dimension(0, 0); + int rowWidth = 0; + int rowHeight = 0; + + int nmembers = target.getComponentCount(); + + for (int i = 0; i < nmembers; i++) + { + Component m = target.getComponent(i); + + if (m.isVisible()) + { + Dimension d = preferred ? m.getPreferredSize() : m.getMinimumSize(); + + // Can't add the component to current row. Start a new row. + + if (rowWidth + d.width > maxWidth) + { + addRow(dim, rowWidth, rowHeight); + rowWidth = 0; + rowHeight = 0; + } + + // Add a horizontal gap for all components after the first + + if (rowWidth != 0) + { + rowWidth += hgap; + } + + rowWidth += d.width; + rowHeight = Math.max(rowHeight, d.height); + } + } + + addRow(dim, rowWidth, rowHeight); + + dim.width += horizontalInsetsAndGap; + dim.height += insets.top + insets.bottom + vgap * 2; + + // When using a scroll pane or the DecoratedLookAndFeel we need to + // make sure the preferred size is less than the size of the + // target containter so shrinking the container size works + // correctly. Removing the horizontal gap is an easy way to do this. + + Container scrollPane = SwingUtilities.getAncestorOfClass(JScrollPane.class, target); + + if (scrollPane != null && target.isValid()) + { + dim.width -= (hgap + 1); + } + + return dim; + } + } + + /* + * A new row has been completed. Use the dimensions of this row + * to update the preferred size for the container. + * + * @param dim update the width and height when appropriate + * @param rowWidth the width of the row to add + * @param rowHeight the height of the row to add + */ + private void addRow(Dimension dim, int rowWidth, int rowHeight) + { + dim.width = Math.max(dim.width, rowWidth); + + if (dim.height > 0) + { + dim.height += getVgap(); + } + + dim.height += rowHeight; + } +} \ No newline at end of file diff --git a/biojava-structure/pom.xml b/biojava-structure/pom.xml index c59b4e1068..0be0265a08 100644 --- a/biojava-structure/pom.xml +++ b/biojava-structure/pom.xml @@ -4,7 +4,7 @@ biojava org.biojava - 4.2.4 + 4.2.5 biojava-structure biojava-structure @@ -22,13 +22,13 @@ org.biojava biojava-alignment - 4.2.4 + 4.2.5 compile org.biojava biojava-core - 4.2.4 + 4.2.5 compile diff --git a/biojava-structure/src/main/java/org/biojava/nbio/structure/PDBCrystallographicInfo.java b/biojava-structure/src/main/java/org/biojava/nbio/structure/PDBCrystallographicInfo.java index b8d9ef18ee..2e10faef06 100644 --- a/biojava-structure/src/main/java/org/biojava/nbio/structure/PDBCrystallographicInfo.java +++ b/biojava-structure/src/main/java/org/biojava/nbio/structure/PDBCrystallographicInfo.java @@ -48,6 +48,23 @@ public class PDBCrystallographicInfo implements Serializable { * are not stored. */ private Matrix4d[] ncsOperators; + + /** + * Whether this structure has a non-standard space group not supported + * by Biojava. If this is true the sg member will be null. + * @since 4.2.5 + */ + private boolean nonStandardSg; + + /** + * Whether this structure is non-standard coordinate frame convention, for which our scale matrix + * calculation and thus the crystal reconstruction will be incorrect. + * There's ~ 200 old structures in the PDB affected by the non-standard frame problem, hopefully they will + * be remediated in the future. + * For more info see: https://github.com/eppic-team/owl/issues/4 + * @since 4.2.5 + */ + private boolean nonStandardCoordFrameConvention; public PDBCrystallographicInfo() { @@ -179,6 +196,45 @@ public Matrix4d[] getNcsOperators() { public void setNcsOperators(Matrix4d[] ncsOperators) { this.ncsOperators = ncsOperators; } + + /** + * Whether this structure has a non-standard space group not supported + * by Biojava. If this is true {@link #getSpaceGroup()} will be null. + * @since 4.2.5 + */ + public boolean isNonStandardSg() { + return nonStandardSg; + } + + /** + * Set the non-standard space group field + * @param nonStandardSg + * @since 4.2.5 + */ + public void setNonStandardSg(boolean nonStandardSg) { + this.nonStandardSg = nonStandardSg; + } + + /** + * Whether this structure is non-standard coordinate frame convention, for which our scale matrix + * calculation and thus the crystal reconstruction will be incorrect. + * There's ~ 200 old structures in the PDB affected by the non-standard frame problem, hopefully they will + * be remediated in the future. + * For more info see: https://github.com/eppic-team/owl/issues/4 + * @since 4.2.5 + */ + public boolean isNonStandardCoordFrameConvention() { + return nonStandardCoordFrameConvention; + } + + /** + * Set the non-standard coordinate frame convention field + * @param nonStandardCoordFrameConvention + * @since 4.2.5 + */ + public void setNonStandardCoordFrameConvention(boolean nonStandardCoordFrameConvention) { + this.nonStandardCoordFrameConvention = nonStandardCoordFrameConvention; + } @Override diff --git a/biojava-structure/src/main/java/org/biojava/nbio/structure/cath/CathInstallation.java b/biojava-structure/src/main/java/org/biojava/nbio/structure/cath/CathInstallation.java index 41ae6b014f..265248d361 100644 --- a/biojava-structure/src/main/java/org/biojava/nbio/structure/cath/CathInstallation.java +++ b/biojava-structure/src/main/java/org/biojava/nbio/structure/cath/CathInstallation.java @@ -53,8 +53,7 @@ public class CathInstallation implements CathDatabase{ public static final String domallFileName = "cath-domain-boundaries-v%s.txt"; public static final String CATH_DOWNLOAD_URL = "http://download.cathdb.info/cath/releases/"; - public static final String CATH_DOWNLOAD_LATEST_RELEASE_DIR = "latest-release"; - public static final String CATH_DOWNLOAD_PREV_RELEASE_DIR = "previous-releases"; + public static final String CATH_DOWNLOAD_ALL_RELEASES_DIR = "all-releases"; public static final String CATH_DOWNLOAD_CLASSIFICATION_DATA_DIR = "cath-classification-data"; public static final String NEWLINE = System.getProperty("line.separator");; @@ -134,10 +133,7 @@ private String buildFileName(String fileNameTemplate) { private String buildUrl(String remoteFileName) { String remoteFileNameWithVer = buildFileName(remoteFileName); - String releasesDir = CATH_DOWNLOAD_LATEST_RELEASE_DIR; - if (!cathVersion.equals(CathFactory.LATEST_VERSION)) { - releasesDir = CATH_DOWNLOAD_PREV_RELEASE_DIR; - } + String releasesDir = CATH_DOWNLOAD_ALL_RELEASES_DIR; return cathDownloadUrl + releasesDir + "/v" + cathVersion + "/" + CATH_DOWNLOAD_CLASSIFICATION_DATA_DIR + "/" + remoteFileNameWithVer; } diff --git a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/FileConvert.java b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/FileConvert.java index 0d3127b9b4..4103e4ef1f 100644 --- a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/FileConvert.java +++ b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/FileConvert.java @@ -407,9 +407,10 @@ record = "ATOM "; String serial = String.format("%5d",seri); String fullName = formatAtomName(a); - - - Character altLoc = a.getAltLoc() ; + Character altLoc = a.getAltLoc(); + if ( altLoc == null) + altLoc = ' '; + String resseq = "" ; if ( hasInsertionCode(pdbcode) ) resseq = String.format("%5s",pdbcode); diff --git a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/PDBFileParser.java b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/PDBFileParser.java index 10cade8e16..ba52b5794c 100644 --- a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/PDBFileParser.java +++ b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/PDBFileParser.java @@ -1502,8 +1502,13 @@ private void pdb_CRYST1_Handler(String line) { } SpaceGroup sg = SymoplibParser.getSpaceGroup(spaceGroup); - if (sg==null) logger.warn("Space group '"+spaceGroup+"' not recognised as a standard space group"); - crystallographicInfo.setSpaceGroup(sg); + if (sg==null) { + logger.warn("Space group '"+spaceGroup+"' not recognised as a standard space group"); + crystallographicInfo.setNonStandardSg(true); + } else { + crystallographicInfo.setSpaceGroup(sg); + crystallographicInfo.setNonStandardSg(false); + } } /** diff --git a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/ChemCompConsumer.java b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/ChemCompConsumer.java index 00cbd87ec6..c9fbef0b06 100644 --- a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/ChemCompConsumer.java +++ b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/ChemCompConsumer.java @@ -78,19 +78,19 @@ public void documentEnd() { @Override public void newAtomSite(AtomSite atom) { - // TODO Auto-generated method stub + } @Override public void newDatabasePDBremark(DatabasePDBremark remark) { - // TODO Auto-generated method stub + } @Override public void newDatabasePDBrev(DatabasePDBrev dbrev) { - // TODO Auto-generated method stub + } @@ -101,94 +101,99 @@ public void newDatabasePDBrevRecord(DatabasePdbrevRecord dbrev) { @Override public void newEntity(Entity entity) { - // TODO Auto-generated method stub + } @Override public void newEntityPolySeq(EntityPolySeq epolseq) { - // TODO Auto-generated method stub + } @Override public void newExptl(Exptl exptl) { - // TODO Auto-generated method stub + } @Override public void newCell(Cell cell) { - // TODO Auto-generated method stub + } @Override public void newSymmetry(Symmetry symmetry) { - // TODO Auto-generated method stub + } @Override public void newStructNcsOper(StructNcsOper sNcsOper) { - // TODO Auto-generated method stub + + } + + @Override + public void newAtomSites(AtomSites atomSites) { + } @Override public void newPdbxEntityNonPoly(PdbxEntityNonPoly pen) { - // TODO Auto-generated method stub + } @Override public void newPdbxNonPolyScheme(PdbxNonPolyScheme ppss) { - // TODO Auto-generated method stub + } @Override public void newPdbxPolySeqScheme(PdbxPolySeqScheme ppss) { - // TODO Auto-generated method stub + } @Override public void newRefine(Refine r) { - // TODO Auto-generated method stub + } @Override public void newStructAsym(StructAsym sasym) { - // TODO Auto-generated method stub + } @Override public void newStructKeywords(StructKeywords kw) { - // TODO Auto-generated method stub + } @Override public void newStructRef(StructRef sref) { - // TODO Auto-generated method stub + } @Override public void newStructRefSeq(StructRefSeq sref) { - // TODO Auto-generated method stub + } @Override public void newStructRefSeqDif(StructRefSeqDif sref) { - // TODO Auto-generated method stub + } @Override public void setStruct(Struct struct) { - // TODO Auto-generated method stub + } @@ -203,7 +208,7 @@ public void newGenericData(String category, List loopFields, @Override public void newAuditAuthor(AuditAuthor aa) { - // TODO Auto-generated method stub + } @@ -217,7 +222,7 @@ public FileParsingParameters getFileParsingParameters() @Override public void setFileParsingParameters(FileParsingParameters params) { - // TODO Auto-generated method stub + } @@ -230,19 +235,19 @@ public void newChemCompDescriptor(ChemCompDescriptor ccd) { @Override public void newPdbxStructOperList(PdbxStructOperList structOper) { - // TODO Auto-generated method stub + } @Override public void newPdbxStrucAssembly(PdbxStructAssembly strucAssembly) { - // TODO Auto-generated method stub + } @Override public void newPdbxStrucAssemblyGen(PdbxStructAssemblyGen strucAssembly) { - // TODO Auto-generated method stub + } @@ -253,7 +258,7 @@ public void newChemCompAtom(ChemCompAtom atom) { @Override public void newPdbxChemCompIndentifier(PdbxChemCompIdentifier id) { - // TODO Auto-generated method stub + } @@ -264,41 +269,41 @@ public void newChemCompBond(ChemCompBond bond) { @Override public void newPdbxChemCompDescriptor(PdbxChemCompDescriptor desc) { - // TODO Auto-generated method stub + } @Override public void newEntitySrcGen(EntitySrcGen entitySrcGen) { - // TODO Auto-generated method stub + } @Override public void newEntitySrcNat(EntitySrcNat entitySrcNat) { - // TODO Auto-generated method stub + } @Override public void newEntitySrcSyn(EntitySrcSyn entitySrcSyn) { - // TODO Auto-generated method stub + } @Override public void newStructConn(StructConn structConn) { - // TODO Auto-generated method stub + } @Override public void newStructSiteGen(StructSiteGen gen) { - // TODO + } @Override public void newStructSite(StructSite site) { - // TODO + } } diff --git a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/MMcifConsumer.java b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/MMcifConsumer.java index 1204d3cf9b..e86a30826f 100644 --- a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/MMcifConsumer.java +++ b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/MMcifConsumer.java @@ -61,6 +61,7 @@ public interface MMcifConsumer { public void newCell(Cell cell); public void newSymmetry(Symmetry symmetry); public void newStructNcsOper(StructNcsOper sNcsOper); + public void newAtomSites(AtomSites atomSites); public void newStructRef(StructRef sref); public void newStructRefSeq(StructRefSeq sref); public void newStructRefSeqDif(StructRefSeqDif sref); diff --git a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/MetalBondConsumer.java b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/MetalBondConsumer.java index 34f85b6614..a76e55a795 100644 --- a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/MetalBondConsumer.java +++ b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/MetalBondConsumer.java @@ -94,6 +94,11 @@ public void newSymmetry(Symmetry symmetry) { @Override public void newStructNcsOper(StructNcsOper sNcsOper) { + } + + @Override + public void newAtomSites(AtomSites atomSites) { + } @Override 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 5ef567c93c..096bd77797 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 @@ -45,6 +45,7 @@ import org.biojava.nbio.structure.GroupType; import org.biojava.nbio.structure.HetatomImpl; import org.biojava.nbio.structure.NucleotideImpl; +import org.biojava.nbio.structure.PDBCrystallographicInfo; import org.biojava.nbio.structure.PDBHeader; import org.biojava.nbio.structure.ResidueNumber; import org.biojava.nbio.structure.SeqMisMatch; @@ -59,6 +60,7 @@ import org.biojava.nbio.structure.io.FileParsingParameters; import org.biojava.nbio.structure.io.SeqRes2AtomAligner; import org.biojava.nbio.structure.io.mmcif.model.AtomSite; +import org.biojava.nbio.structure.io.mmcif.model.AtomSites; import org.biojava.nbio.structure.io.mmcif.model.AuditAuthor; import org.biojava.nbio.structure.io.mmcif.model.Cell; import org.biojava.nbio.structure.io.mmcif.model.ChemComp; @@ -136,6 +138,8 @@ public class SimpleMMcifConsumer implements MMcifConsumer { private List structNcsOper; private List sequenceDifs; private List structSiteGens; + + private Matrix4d parsedScaleMatrix; /** * A map of asym ids (internal chain ids) to strand ids (author chain ids) @@ -871,6 +875,8 @@ public void documentEnd() { } setStructNcsOps(); + + setCrystallographicInfoMetadata(); Map> misMatchMap = new HashMap>(); @@ -1273,6 +1279,20 @@ private void setStructNcsOps() { ncsOperators.toArray(new Matrix4d[ncsOperators.size()])); } } + + private void setCrystallographicInfoMetadata() { + if (parsedScaleMatrix!=null) { + + PDBCrystallographicInfo crystalInfo = structure.getCrystallographicInfo(); + + boolean nonStd = false; + if (crystalInfo.getCrystalCell()!=null && !crystalInfo.getCrystalCell().checkScaleMatrix(parsedScaleMatrix)) { + nonStd = true; + } + + crystalInfo.setNonStandardCoordFrameConvention(nonStd); + } + } /** This method will return the parsed protein structure, once the parsing has been finished * @@ -1507,15 +1527,38 @@ public void newCell(Cell cell) { public void newSymmetry(Symmetry symmetry) { String spaceGroup = symmetry.getSpace_group_name_H_M(); SpaceGroup sg = SymoplibParser.getSpaceGroup(spaceGroup); - if (sg==null) logger.warn("Space group '"+spaceGroup+"' not recognised as a standard space group"); - - structure.getPDBHeader().getCrystallographicInfo().setSpaceGroup(sg); + if (sg==null) { + logger.warn("Space group '"+spaceGroup+"' not recognised as a standard space group"); + structure.getPDBHeader().getCrystallographicInfo().setNonStandardSg(true); + } else { + structure.getPDBHeader().getCrystallographicInfo().setSpaceGroup(sg); + structure.getPDBHeader().getCrystallographicInfo().setNonStandardSg(false); + } } @Override public void newStructNcsOper(StructNcsOper sNcsOper) { structNcsOper.add(sNcsOper); } + + public void newAtomSites(AtomSites atomSites) { + + try { + Matrix4d m = new Matrix4d( + Double.parseDouble(atomSites.getFract_transf_matrix11()), Double.parseDouble(atomSites.getFract_transf_matrix12()), Double.parseDouble(atomSites.getFract_transf_matrix13()), Double.parseDouble(atomSites.getFract_transf_vector1()), + Double.parseDouble(atomSites.getFract_transf_matrix21()), Double.parseDouble(atomSites.getFract_transf_matrix22()), Double.parseDouble(atomSites.getFract_transf_matrix23()), Double.parseDouble(atomSites.getFract_transf_vector2()), + Double.parseDouble(atomSites.getFract_transf_matrix31()), Double.parseDouble(atomSites.getFract_transf_matrix32()), Double.parseDouble(atomSites.getFract_transf_matrix33()), Double.parseDouble(atomSites.getFract_transf_vector3()), + 0,0,0,1); + + parsedScaleMatrix = m; + + } catch (NumberFormatException e) { + logger.warn("Some values in _atom_sites.fract_transf_matrix or _atom_sites.fract_transf_vector could not be parsed as numbers. Can't check whether coordinate frame convention is correct! Error: {}", e.getMessage()); + structure.getPDBHeader().getCrystallographicInfo().setNonStandardCoordFrameConvention(false); + + // in this case parsedScaleMatrix stays null and can't be used in documentEnd() + } + } @Override public void newStructRef(StructRef sref) { @@ -1850,8 +1893,6 @@ public List getStructOpers() { return structOpers; } - - @Override public void newPdbxStrucAssembly(PdbxStructAssembly strucAssembly) { strucAssemblies.add(strucAssembly); diff --git a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/SimpleMMcifParser.java b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/SimpleMMcifParser.java index 90b03c8da1..1b6851c6d8 100644 --- a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/SimpleMMcifParser.java +++ b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/SimpleMMcifParser.java @@ -40,6 +40,7 @@ import org.biojava.nbio.structure.io.MMCIFFileReader; import org.biojava.nbio.structure.io.StructureIOFile; import org.biojava.nbio.structure.io.mmcif.model.AtomSite; +import org.biojava.nbio.structure.io.mmcif.model.AtomSites; import org.biojava.nbio.structure.io.mmcif.model.AuditAuthor; import org.biojava.nbio.structure.io.mmcif.model.CIFLabel; import org.biojava.nbio.structure.io.mmcif.model.Cell; @@ -675,6 +676,12 @@ private void endLineChecks(String category,List loopFields, List StructNcsOper.class.getName(), loopFields, lineData, loopWarnings); triggerNewStructNcsOper(sNcsOper); + } else if ( category.equals("_atom_sites")) { + + AtomSites atomSites = (AtomSites) buildObject( + AtomSites.class.getName(), + loopFields, lineData, loopWarnings); + triggerNewAtomSites(atomSites); } else if ( category.equals("_struct_ref")){ StructRef sref = (StructRef) buildObject( @@ -892,6 +899,12 @@ public void triggerNewStructNcsOper(StructNcsOper sNcsOper) { } } + + public void triggerNewAtomSites(AtomSites atomSites) { + for(MMcifConsumer c : consumers){ + c.newAtomSites(atomSites); + } + } /** * Populates a bean object from the {@link org.biojava.nbio.structure.io.mmcif.model} package, diff --git a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/AtomSites.java b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/AtomSites.java new file mode 100644 index 0000000000..d0581402df --- /dev/null +++ b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/model/AtomSites.java @@ -0,0 +1,401 @@ +package org.biojava.nbio.structure.io.mmcif.model; + +/** + * A class containing the _atom_sites data. Equivalent to the SCALE records in PDB files. + * + * + * @author Jose Duarte + * + */ +public class AtomSites extends AbstractBean { + + String entry_id; + + // to my knowledge this field is not used - JD 2016-11-22 + String Cartn_transform_axes; + + @CIFLabel(label="fract_transf_matrix[1][1]") + String fract_transf_matrix11; + + @CIFLabel(label="fract_transf_matrix[1][2]") + String fract_transf_matrix12; + + @CIFLabel(label="fract_transf_matrix[1][3]") + String fract_transf_matrix13; + + + @CIFLabel(label="fract_transf_matrix[2][1]") + String fract_transf_matrix21; + + @CIFLabel(label="fract_transf_matrix[2][2]") + String fract_transf_matrix22; + + @CIFLabel(label="fract_transf_matrix[2][3]") + String fract_transf_matrix23; + + + @CIFLabel(label="fract_transf_matrix[3][1]") + String fract_transf_matrix31; + + @CIFLabel(label="fract_transf_matrix[3][2]") + String fract_transf_matrix32; + + @CIFLabel(label="fract_transf_matrix[3][3]") + String fract_transf_matrix33; + + + @CIFLabel(label="fract_transf_vector[1]") + String fract_transf_vector1; + + @CIFLabel(label="fract_transf_vector[2]") + String fract_transf_vector2; + + @CIFLabel(label="fract_transf_vector[3]") + String fract_transf_vector3; + + // these fields are unusual but appear in some entries like 5e5j - JD 2016-11-22 + @CIFLabel(label="Cartn_transf_matrix[1][1]") + String Cartn_transf_matrix11; + + @CIFLabel(label="Cartn_transf_matrix[1][2]") + String Cartn_transf_matrix12; + + @CIFLabel(label="Cartn_transf_matrix[1][3]") + String Cartn_transf_matrix13; + + @CIFLabel(label="Cartn_transf_matrix[2][1]") + String Cartn_transf_matrix21; + + @CIFLabel(label="Cartn_transf_matrix[2][2]") + String Cartn_transf_matrix22; + + @CIFLabel(label="Cartn_transf_matrix[2][3]") + String Cartn_transf_matrix23; + + @CIFLabel(label="Cartn_transf_matrix[3][1]") + String Cartn_transf_matrix31; + + @CIFLabel(label="Cartn_transf_matrix[3][2]") + String Cartn_transf_matrix32; + + @CIFLabel(label="Cartn_transf_matrix[3][3]") + String Cartn_transf_matrix33; + + @CIFLabel(label="Cartn_transf_vector[1]") + String Cartn_transf_vector1; + + @CIFLabel(label="Cartn_transf_vector[2]") + String Cartn_transf_vector2; + + @CIFLabel(label="Cartn_transf_vector[3]") + String Cartn_transf_vector3; + + + public String getEntry_id() { + return entry_id; + } + public void setEntry_id(String entry_id) { + this.entry_id = entry_id; + } + /** + * @return the cartn_transform_axes + */ + public String getCartn_transform_axes() { + return Cartn_transform_axes; + } + /** + * @param cartn_transform_axes the cartn_transform_axes to set + */ + public void setCartn_transform_axes(String cartn_transform_axes) { + Cartn_transform_axes = cartn_transform_axes; + } + /** + * @return the fract_transf_matrix11 + */ + public String getFract_transf_matrix11() { + return fract_transf_matrix11; + } + /** + * @param fract_transf_matrix11 the fract_transf_matrix11 to set + */ + public void setFract_transf_matrix11(String fract_transf_matrix11) { + this.fract_transf_matrix11 = fract_transf_matrix11; + } + /** + * @return the fract_transf_matrix12 + */ + public String getFract_transf_matrix12() { + return fract_transf_matrix12; + } + /** + * @param fract_transf_matrix12 the fract_transf_matrix12 to set + */ + public void setFract_transf_matrix12(String fract_transf_matrix12) { + this.fract_transf_matrix12 = fract_transf_matrix12; + } + /** + * @return the fract_transf_matrix13 + */ + public String getFract_transf_matrix13() { + return fract_transf_matrix13; + } + /** + * @param fract_transf_matrix13 the fract_transf_matrix13 to set + */ + public void setFract_transf_matrix13(String fract_transf_matrix13) { + this.fract_transf_matrix13 = fract_transf_matrix13; + } + /** + * @return the fract_transf_matrix21 + */ + public String getFract_transf_matrix21() { + return fract_transf_matrix21; + } + /** + * @param fract_transf_matrix21 the fract_transf_matrix21 to set + */ + public void setFract_transf_matrix21(String fract_transf_matrix21) { + this.fract_transf_matrix21 = fract_transf_matrix21; + } + /** + * @return the fract_transf_matrix22 + */ + public String getFract_transf_matrix22() { + return fract_transf_matrix22; + } + /** + * @param fract_transf_matrix22 the fract_transf_matrix22 to set + */ + public void setFract_transf_matrix22(String fract_transf_matrix22) { + this.fract_transf_matrix22 = fract_transf_matrix22; + } + /** + * @return the fract_transf_matrix23 + */ + public String getFract_transf_matrix23() { + return fract_transf_matrix23; + } + /** + * @param fract_transf_matrix23 the fract_transf_matrix23 to set + */ + public void setFract_transf_matrix23(String fract_transf_matrix23) { + this.fract_transf_matrix23 = fract_transf_matrix23; + } + /** + * @return the fract_transf_matrix31 + */ + public String getFract_transf_matrix31() { + return fract_transf_matrix31; + } + /** + * @param fract_transf_matrix31 the fract_transf_matrix31 to set + */ + public void setFract_transf_matrix31(String fract_transf_matrix31) { + this.fract_transf_matrix31 = fract_transf_matrix31; + } + /** + * @return the fract_transf_matrix32 + */ + public String getFract_transf_matrix32() { + return fract_transf_matrix32; + } + /** + * @param fract_transf_matrix32 the fract_transf_matrix32 to set + */ + public void setFract_transf_matrix32(String fract_transf_matrix32) { + this.fract_transf_matrix32 = fract_transf_matrix32; + } + /** + * @return the fract_transf_matrix33 + */ + public String getFract_transf_matrix33() { + return fract_transf_matrix33; + } + /** + * @param fract_transf_matrix33 the fract_transf_matrix33 to set + */ + public void setFract_transf_matrix33(String fract_transf_matrix33) { + this.fract_transf_matrix33 = fract_transf_matrix33; + } + /** + * @return the fract_transf_vector1 + */ + public String getFract_transf_vector1() { + return fract_transf_vector1; + } + /** + * @param fract_transf_vector1 the fract_transf_vector1 to set + */ + public void setFract_transf_vector1(String fract_transf_vector1) { + this.fract_transf_vector1 = fract_transf_vector1; + } + /** + * @return the fract_transf_vector2 + */ + public String getFract_transf_vector2() { + return fract_transf_vector2; + } + /** + * @param fract_transf_vector2 the fract_transf_vector2 to set + */ + public void setFract_transf_vector2(String fract_transf_vector2) { + this.fract_transf_vector2 = fract_transf_vector2; + } + /** + * @return the fract_transf_vector3 + */ + public String getFract_transf_vector3() { + return fract_transf_vector3; + } + /** + * @param fract_transf_vector3 the fract_transf_vector3 to set + */ + public void setFract_transf_vector3(String fract_transf_vector3) { + this.fract_transf_vector3 = fract_transf_vector3; + } + /** + * @return the cartn_transf_matrix11 + */ + public String getCartn_transf_matrix11() { + return Cartn_transf_matrix11; + } + /** + * @param cartn_transf_matrix11 the cartn_transf_matrix11 to set + */ + public void setCartn_transf_matrix11(String cartn_transf_matrix11) { + Cartn_transf_matrix11 = cartn_transf_matrix11; + } + /** + * @return the cartn_transf_matrix12 + */ + public String getCartn_transf_matrix12() { + return Cartn_transf_matrix12; + } + /** + * @param cartn_transf_matrix12 the cartn_transf_matrix12 to set + */ + public void setCartn_transf_matrix12(String cartn_transf_matrix12) { + Cartn_transf_matrix12 = cartn_transf_matrix12; + } + /** + * @return the cartn_transf_matrix13 + */ + public String getCartn_transf_matrix13() { + return Cartn_transf_matrix13; + } + /** + * @param cartn_transf_matrix13 the cartn_transf_matrix13 to set + */ + public void setCartn_transf_matrix13(String cartn_transf_matrix13) { + Cartn_transf_matrix13 = cartn_transf_matrix13; + } + /** + * @return the cartn_transf_matrix21 + */ + public String getCartn_transf_matrix21() { + return Cartn_transf_matrix21; + } + /** + * @param cartn_transf_matrix21 the cartn_transf_matrix21 to set + */ + public void setCartn_transf_matrix21(String cartn_transf_matrix21) { + Cartn_transf_matrix21 = cartn_transf_matrix21; + } + /** + * @return the cartn_transf_matrix22 + */ + public String getCartn_transf_matrix22() { + return Cartn_transf_matrix22; + } + /** + * @param cartn_transf_matrix22 the cartn_transf_matrix22 to set + */ + public void setCartn_transf_matrix22(String cartn_transf_matrix22) { + Cartn_transf_matrix22 = cartn_transf_matrix22; + } + /** + * @return the cartn_transf_matrix23 + */ + public String getCartn_transf_matrix23() { + return Cartn_transf_matrix23; + } + /** + * @param cartn_transf_matrix23 the cartn_transf_matrix23 to set + */ + public void setCartn_transf_matrix23(String cartn_transf_matrix23) { + Cartn_transf_matrix23 = cartn_transf_matrix23; + } + /** + * @return the cartn_transf_matrix31 + */ + public String getCartn_transf_matrix31() { + return Cartn_transf_matrix31; + } + /** + * @param cartn_transf_matrix31 the cartn_transf_matrix31 to set + */ + public void setCartn_transf_matrix31(String cartn_transf_matrix31) { + Cartn_transf_matrix31 = cartn_transf_matrix31; + } + /** + * @return the cartn_transf_matrix32 + */ + public String getCartn_transf_matrix32() { + return Cartn_transf_matrix32; + } + /** + * @param cartn_transf_matrix32 the cartn_transf_matrix32 to set + */ + public void setCartn_transf_matrix32(String cartn_transf_matrix32) { + Cartn_transf_matrix32 = cartn_transf_matrix32; + } + /** + * @return the cartn_transf_matrix33 + */ + public String getCartn_transf_matrix33() { + return Cartn_transf_matrix33; + } + /** + * @param cartn_transf_matrix33 the cartn_transf_matrix33 to set + */ + public void setCartn_transf_matrix33(String cartn_transf_matrix33) { + Cartn_transf_matrix33 = cartn_transf_matrix33; + } + /** + * @return the cartn_transf_vector1 + */ + public String getCartn_transf_vector1() { + return Cartn_transf_vector1; + } + /** + * @param cartn_transf_vector1 the cartn_transf_vector1 to set + */ + public void setCartn_transf_vector1(String cartn_transf_vector1) { + Cartn_transf_vector1 = cartn_transf_vector1; + } + /** + * @return the cartn_transf_vector2 + */ + public String getCartn_transf_vector2() { + return Cartn_transf_vector2; + } + /** + * @param cartn_transf_vector2 the cartn_transf_vector2 to set + */ + public void setCartn_transf_vector2(String cartn_transf_vector2) { + Cartn_transf_vector2 = cartn_transf_vector2; + } + /** + * @return the cartn_transf_vector3 + */ + public String getCartn_transf_vector3() { + return Cartn_transf_vector3; + } + /** + * @param cartn_transf_vector3 the cartn_transf_vector3 to set + */ + public void setCartn_transf_vector3(String cartn_transf_vector3) { + Cartn_transf_vector3 = cartn_transf_vector3; + } + +} diff --git a/biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalBuilder.java b/biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalBuilder.java index 2d0ea1b3b4..f24ea9b4a8 100644 --- a/biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalBuilder.java +++ b/biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalBuilder.java @@ -102,20 +102,34 @@ public CrystalBuilder(Structure structure) { if (structure.isCrystallographic()) { this.isCrystallographic = true; + // we need to check space group not null for the cases where the entry is crystallographic but // the space group is not a standard one recognized by biojava, e.g. 1mnk (SG: 'I 21') - if (this.crystallographicInfo.getSpaceGroup()==null) { - logger.warn("Could not find a space group, will only calculate asymmetric unit interfaces."); + if (this.crystallographicInfo.isNonStandardSg()) { + logger.warn("Space group is non-standard, will only calculate asymmetric unit interfaces."); + this.isCrystallographic = false; + + } else if (this.crystallographicInfo.getSpaceGroup()==null) { + // just in case we still check for space group null (a user pdb file could potentially be crystallographic and have no space group) + logger.warn("Space group is null, will only calculate asymmetric unit interfaces."); this.isCrystallographic = false; } else { this.numOperatorsSg = this.crystallographicInfo.getSpaceGroup().getMultiplicity(); } + // we need to check crystal cell not null for the rare cases where the entry is crystallographic but // the crystal cell is not given, e.g. 2i68, 2xkm, 4bpq if (this.crystallographicInfo.getCrystalCell()==null) { logger.warn("Could not find a crystal cell definition, will only calculate asymmetric unit interfaces."); this.isCrystallographic = false; } + + // check for cases like 4hhb that are in a non-standard coordinate frame convention, see https://github.com/eppic-team/owl/issues/4 + if (this.crystallographicInfo.isNonStandardCoordFrameConvention()) { + logger.warn("Non-standard coordinate frame convention, will only calculate asymmetric unit interfaces."); + this.isCrystallographic = false; + this.numOperatorsSg = 1; // we force here to 1 or otherwise it gets filled from sg above + } } else { this.isCrystallographic = false; diff --git a/biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalCell.java b/biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalCell.java index 95c409d6d5..3850c0b87b 100644 --- a/biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalCell.java +++ b/biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalCell.java @@ -547,9 +547,10 @@ public boolean checkScaleMatrixConsistency(Matrix4d scaleMatrix) { */ public boolean checkScaleMatrix(Matrix4d scaleMatrix) { + Matrix3d mtranspose = getMTranspose(); for (int i=0;i<3;i++) { for (int j=0;j<3;j++) { - if (!deltaComp(getMTranspose().getElement(i, j),scaleMatrix.getElement(i, j))) { + if (!deltaComp(mtranspose.getElement(i, j),scaleMatrix.getElement(i, j))) { //System.out.println("Our value ("+i+","+j+"): "+getM().getElement(i,j)); //System.out.println("Their value ("+i+","+j+"): "+scaleMatrix.getElement(i,j)); return false; diff --git a/biojava-survival/pom.xml b/biojava-survival/pom.xml index 5c87ef8b70..d7c072c558 100644 --- a/biojava-survival/pom.xml +++ b/biojava-survival/pom.xml @@ -4,7 +4,7 @@ org.biojava biojava - 4.2.4 + 4.2.5 biojava-survival diff --git a/biojava-ws/pom.xml b/biojava-ws/pom.xml index f6ef1afbfa..490d79c32d 100644 --- a/biojava-ws/pom.xml +++ b/biojava-ws/pom.xml @@ -3,7 +3,7 @@ biojava org.biojava - 4.2.4 + 4.2.5 biojava-ws biojava-ws @@ -19,7 +19,7 @@ org.biojava biojava-core - 4.2.4 + 4.2.5 compile diff --git a/pom.xml b/pom.xml index 3aa5456d2e..e1daf1fcea 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ org.biojava biojava pom - 4.2.4 + 4.2.5 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 @@ -44,7 +44,7 @@ scm:git:git@github.com:biojava/biojava.git https://github.com/biojava/biojava - biojava-4.2.4 + biojava-4.2.5