Skip to content

Commit c58967b

Browse files
author
fkaiser
committed
Merge branch 'alignment-algorithms'
2 parents c052bd9 + 596c089 commit c58967b

File tree

11 files changed

+147
-33
lines changed

11 files changed

+147
-33
lines changed

singa-all/pom.xml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66

@@ -101,6 +101,19 @@
101101
</configuration>
102102
<version>3.6.1</version>
103103
</plugin>
104+
<plugin>
105+
<groupId>org.apache.maven.plugins</groupId>
106+
<artifactId>maven-source-plugin</artifactId>
107+
<version>3.0.1</version>
108+
<executions>
109+
<execution>
110+
<id>attach-sources</id>
111+
<goals>
112+
<goal>jar</goal>
113+
</goals>
114+
</execution>
115+
</executions>
116+
</plugin>
104117
<plugin>
105118
<groupId>org.apache.maven.plugins</groupId>
106119
<artifactId>maven-surefire-plugin</artifactId>

singa-chemistry/src/main/java/de/bioforscher/singa/chemistry/algorithms/superimposition/consensus/ConsensusAlignment.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ public class ConsensusAlignment {
6161
private ConsensusContainer currentConsensus;
6262
private double clusterCutoff;
6363
private List<BinaryTree<ConsensusContainer>> clusters;
64-
6564
ConsensusAlignment(ConsensusBuilder.Builder builder) {
6665

6766
// convert given input structures to data model
@@ -130,6 +129,10 @@ private static ConsensusContainer toContainer(StructuralMotif structuralMotif) {
130129
return new ConsensusContainer(structuralMotif.getCopy(), false);
131130
}
132131

132+
public List<Double> getAlignmentTrace() {
133+
return alignmentTrace;
134+
}
135+
133136
public List<BinaryTree<ConsensusContainer>> getClusters() {
134137
return this.clusters;
135138
}

singa-chemistry/src/main/java/de/bioforscher/singa/chemistry/parser/pdb/structures/StructureParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,8 @@ protected static class Reducer {
393393
int modelIdentifier;
394394
String chainIdentifier;
395395

396-
boolean allModels;
397-
boolean allChains;
396+
boolean allModels = true;
397+
boolean allChains = true;
398398
boolean parseMapping = false;
399399

400400
StructureParserOptions options = new StructureParserOptions();

singa-chemistry/src/main/java/de/bioforscher/singa/chemistry/physical/families/MatcherFamily.java

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@ public enum MatcherFamily implements StructuralFamily<MatcherFamily> {
1515
ALL(EnumSet.allOf(AminoAcidFamily.class), "*", "ALL"),
1616

1717
/**
18-
* The following types are according to Gutteridge, A. and Thornton, J. M.: Understanding
19-
* nature's catalytic toolkit Trends in biochemical sciences, Elsevier, 2005, 30, 622-629.
18+
* The following types are grouped according to
19+
* <p>
20+
* <pre>
21+
* Gutteridge, A. and Thornton, J. M.:
22+
* Understanding nature's catalytic toolkit Trends in biochemical sciences, Elsevier, 2005, 30, 622-629.
23+
* </pre>
2024
*/
2125
GUTTERIDGE_IMIDAZOLE(EnumSet.of(AminoAcidFamily.HISTIDINE), "i", "IMI"),
2226
GUTTERIDGE_AMINE(EnumSet.of(AminoAcidFamily.LYSINE), "n", "AMN"),
@@ -27,12 +31,35 @@ public enum MatcherFamily implements StructuralFamily<MatcherFamily> {
2731
GUTTERIDGE_GUANIDIUM(EnumSet.of(AminoAcidFamily.ARGININE), "g", "GND"),
2832
GUTTERIDGE_OTHERS(EnumSet.of(AminoAcidFamily.ALANINE, AminoAcidFamily.GLYCINE, AminoAcidFamily.ISOLEUCINE,
2933
AminoAcidFamily.LEUCINE, AminoAcidFamily.METHIONINE, AminoAcidFamily.PHENYLALANINE, AminoAcidFamily.PROLINE,
30-
AminoAcidFamily.TRYPTOPHAN, AminoAcidFamily.VALINE), "o", "OTH");
34+
AminoAcidFamily.TRYPTOPHAN, AminoAcidFamily.VALINE), "o", "OTH"),
35+
/**
36+
* The following ypes are grouped according to functional chemical groups:
37+
* <p>
38+
* <pre>
39+
* aromatic (a) F,Y,W
40+
* negatively charged (n) D,E
41+
* positively charged (p) K,R,H
42+
* polar, uncharged (o) P,N,Q,C,T,S
43+
* nonpolar, aliphatic (i) G,A,V,L,M,I
44+
* </pre>
45+
* <p>
46+
*/
47+
FUNCTIONAL_AROMATIC(EnumSet.of(AminoAcidFamily.PHENYLALANINE, AminoAcidFamily.TYROSINE, AminoAcidFamily.TRYPTOPHAN), "a", "ARO"),
48+
FUNCTIONAL_NEGATIVE(EnumSet.of(AminoAcidFamily.ASPARTIC_ACID, AminoAcidFamily.GLUTAMIC_ACID), "e", "NEG"),
49+
FUNCTIONAL_POSITIVE(EnumSet.of(AminoAcidFamily.LYSINE, AminoAcidFamily.ARGININE, AminoAcidFamily.HISTIDINE), "p", "POS"),
50+
FUNCTIONAL_POLAR(EnumSet.of(AminoAcidFamily.PROLINE, AminoAcidFamily.ASPARAGINE, AminoAcidFamily.GLUTAMINE,
51+
AminoAcidFamily.CYSTEINE, AminoAcidFamily.THREONINE, AminoAcidFamily.SERINE), "p", "POL"),
52+
FUNCTIONAL_UNPOLAR(EnumSet.of(AminoAcidFamily.GLYCINE, AminoAcidFamily.ALANINE, AminoAcidFamily.VALINE,
53+
AminoAcidFamily.LEUCINE, AminoAcidFamily.METHIONINE, AminoAcidFamily.ISOLEUCINE), "u", "UPO");
54+
3155

3256
public static EnumSet<MatcherFamily> GUTTERIDGE = EnumSet.of(GUTTERIDGE_AMIDE, GUTTERIDGE_AMINE,
3357
GUTTERIDGE_CARBOXYLATE, GUTTERIDGE_GUANIDIUM, GUTTERIDGE_HYDROXYL, GUTTERIDGE_IMIDAZOLE, GUTTERIDGE_OTHERS,
3458
GUTTERIDGE_THIOL);
3559

60+
public static EnumSet<MatcherFamily> FUNCTIONAL = EnumSet.of(FUNCTIONAL_AROMATIC, FUNCTIONAL_NEGATIVE,
61+
FUNCTIONAL_POSITIVE, FUNCTIONAL_POLAR, FUNCTIONAL_UNPOLAR);
62+
3663
private EnumSet<AminoAcidFamily> members;
3764
private String oneLetterCode;
3865
private String threeLetterCode;

singa-chemistry/src/main/java/de/bioforscher/singa/chemistry/physical/model/Structure.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package de.bioforscher.singa.chemistry.physical.model;
22

33
import de.bioforscher.singa.chemistry.physical.atoms.Atom;
4+
import de.bioforscher.singa.chemistry.physical.atoms.AtomName;
45
import de.bioforscher.singa.chemistry.physical.branches.BranchSubstructure;
56
import de.bioforscher.singa.chemistry.physical.branches.Chain;
67
import de.bioforscher.singa.chemistry.physical.branches.StructuralModel;
@@ -111,6 +112,14 @@ public List<Atom> getAllAtoms() {
111112
.collect(Collectors.toList());
112113
}
113114

115+
public Set<AtomName> getUniqueAtomNames() {
116+
return getAllAtoms().stream()
117+
.map(Atom::getAtomNameString)
118+
.map(AtomName::getAtomNameFromString)
119+
.distinct()
120+
.collect(Collectors.toSet());
121+
}
122+
114123
public String getPdbIdentifier() {
115124
return this.pdbIdentifier;
116125
}

singa-chemistry/src/main/java/de/bioforscher/singa/chemistry/physical/model/Structures.java

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import de.bioforscher.singa.chemistry.physical.branches.StructuralMotif;
44
import de.bioforscher.singa.chemistry.physical.leaves.LeafSubstructure;
5+
import de.bioforscher.singa.chemistry.physical.model.StructuralEntityFilter.AtomFilter;
56
import de.bioforscher.singa.mathematics.matrices.LabeledSymmetricMatrix;
67
import de.bioforscher.singa.mathematics.metrics.model.VectorMetricProvider;
78

@@ -58,7 +59,8 @@ private Structures() {
5859
* Returns the distance matrix of the given {@link StructuralEntity} object.
5960
* <p>
6061
* TODO This should be the only generic method to calculate distance matrices.
61-
* @param <T> The Type of the structural entity.
62+
*
63+
* @param <T> The Type of the structural entity.
6264
* @param structuralEntities The list of {@link StructuralEntity} objects for which a distance matrix should be obtained.
6365
* @return The distance matrix of the {@link StructuralEntity} objects.
6466
*/
@@ -76,7 +78,7 @@ public static <T extends StructuralEntity<T>> LabeledSymmetricMatrix<T> calculat
7678
* <p>
7779
* TODO This should be the only generic method to calculate distance matrices.
7880
*
79-
* @param <T> The Type of the structural entity.
81+
* @param <T> The Type of the structural entity.
8082
* @param structuralEntities The list of {@link StructuralEntity} objects for which a distance matrix should be obtained.
8183
* @return The squared distance matrix of the {@link StructuralEntity} objects.
8284
*/
@@ -97,4 +99,31 @@ public static <T extends StructuralEntity<T>> LabeledSymmetricMatrix<T> calculat
9799
// labeledDistances.setRowLabels(atoms);
98100
// return labeledDistances;
99101
// }
102+
103+
/**
104+
* Returns true iff the given {@link Structure} consists only of alpha carbon atoms
105+
* (<b>this may include hydrogen atoms</b>).
106+
*
107+
* @param structure The {@link Structure} to check.
108+
* @return True iff structure contains only alpha carbon atoms.
109+
*/
110+
public static boolean isAlphaCarbonStructure(Structure structure) {
111+
return structure.getAllAtoms().stream()
112+
.noneMatch(AtomFilter.isAlphaCarbon().negate()
113+
.and(AtomFilter.isHydrogen().negate()));
114+
}
115+
116+
/**
117+
* Returns true iff the given {@link Structure} consists only of backbone atoms
118+
* (<b>this may include beta carbon and hydrogen atoms</b>).
119+
*
120+
* @param structure The {@link Structure} to check.
121+
* @return True iff structure contains only backbone and hydrogen atoms.
122+
*/
123+
public static boolean isBackboneStructure(Structure structure) {
124+
return structure.getAllAtoms().stream()
125+
.noneMatch(AtomFilter.isBackbone().negate()
126+
.and(AtomFilter.isHydrogen().negate())
127+
.and(AtomFilter.isBetaCarbon().negate()));
128+
}
100129
}

singa-chemistry/src/test/java/de/bioforscher/singa/chemistry/parser/pdb/structures/StructureParserTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,5 +156,12 @@ public void shouldThrowErrorWhenFileDoesNotExist() {
156156
.parse();
157157
}
158158

159+
@Test
160+
public void shouldParseAllChainsFromLocalFile() {
161+
StructureParser.local()
162+
.fileLocation(TestUtils.getResourceAsFilepath("1GL0_HDS_intra_E-H57_E-D102_E-S195.pdb"))
163+
.allChains()
164+
.parse();
165+
}
159166

160167
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package de.bioforscher.singa.chemistry.physical.model;
2+
3+
import de.bioforscher.singa.chemistry.parser.pdb.structures.StructureParser;
4+
import org.junit.Test;
5+
6+
import static org.junit.Assert.assertTrue;
7+
8+
/**
9+
* @author fk
10+
*/
11+
public class StructuresTest {
12+
@Test
13+
public void testIsAlphaCarbonStructure() throws Exception {
14+
Structure alphaCarbonStructure = StructureParser.online()
15+
.pdbIdentifier("1zlg")
16+
.parse();
17+
assertTrue(Structures.isAlphaCarbonStructure(alphaCarbonStructure));
18+
}
19+
20+
@Test
21+
public void testIsBackboneOnlyStructure() {
22+
Structure alphaCarbonStructure = StructureParser.online()
23+
.pdbIdentifier("2plp")
24+
.parse();
25+
assertTrue(Structures.isBackboneStructure(alphaCarbonStructure));
26+
}
27+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package de.bioforscher.singa.javafx.renderer.graphs;
2+
3+
import de.bioforscher.singa.mathematics.geometry.faces.Rectangle;
4+
import de.bioforscher.singa.mathematics.graphs.model.Graph;
5+
import de.bioforscher.singa.mathematics.graphs.util.GraphFactory;
6+
import javafx.application.Application;
7+
8+
/**
9+
* @author fk
10+
*/
11+
public class GraphViewerPlayground {
12+
public static void main(String[] args) {
13+
Graph graph = GraphFactory.buildGridGraph(2, 3, new Rectangle(200, 200), false);
14+
GraphDisplayApplication.graph = graph;
15+
Application.launch(GraphDisplayApplication.class);
16+
}
17+
}

singa-javafx/src/main/java/de/bioforscher/singa/javafx/renderer/molecules/MoleculeGraphRenderer.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ protected void drawNode(MoleculeAtom atom) {
2828
circlePoint(atom.getPosition(), getRenderingOptions().getNodeDiameter());
2929
// draw text
3030
getGraphicsContext().setFill(getRenderingOptions().getIdentifierTextColor());
31-
drawTextCenteredOnPoint(atom.getElement().toString()+"."+atom.getIdentifier(), atom.getPosition());
31+
drawTextCenteredOnPoint(atom.getElement().toString() + "." + atom.getIdentifier(), atom.getPosition());
3232
}
3333

3434
@Override
@@ -45,17 +45,17 @@ private void drawBond(MoleculeBond bond) {
4545
LineSegment connectingSegment = new LineSegment(bond.getSource().getPosition(), bond.getTarget().getPosition());
4646
if (bond.getType() == MoleculeBondType.DOUBLE_BOND) {
4747
// draw upper parallel
48-
LineSegment upperParallelSegment = connectingSegment.getParallelSegment((getRenderingOptions().getNodeDiameter()/2.0)*0.5);
48+
LineSegment upperParallelSegment = connectingSegment.getParallelSegment((getRenderingOptions().getNodeDiameter() / 2.0) * 0.5);
4949
drawLineSegment(upperParallelSegment);
5050
// draw lower parallel
51-
LineSegment lowerParallelSegment = connectingSegment.getParallelSegment((-getRenderingOptions().getNodeDiameter()/2.0)*0.5);
51+
LineSegment lowerParallelSegment = connectingSegment.getParallelSegment((-getRenderingOptions().getNodeDiameter() / 2.0) * 0.5);
5252
drawLineSegment(lowerParallelSegment);
5353
} else if (bond.getType() == MoleculeBondType.AROMATIC_BOND) {
5454
// draw upper parallel
55-
LineSegment upperParallelSegment = connectingSegment.getParallelSegment((getRenderingOptions().getNodeDiameter()/2.0)*0.5);
55+
LineSegment upperParallelSegment = connectingSegment.getParallelSegment((getRenderingOptions().getNodeDiameter() / 2.0) * 0.5);
5656
drawLineSegment(upperParallelSegment);
5757
// draw lower parallel
58-
LineSegment lowerParallelSegment = connectingSegment.getParallelSegment((-getRenderingOptions().getNodeDiameter()/2.0)*0.5);
58+
LineSegment lowerParallelSegment = connectingSegment.getParallelSegment((-getRenderingOptions().getNodeDiameter() / 2.0) * 0.5);
5959
dashLineSegment(lowerParallelSegment, 2d, 4d);
6060
} else {
6161
// draw single bond

0 commit comments

Comments
 (0)