-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #398 from ncats/springBoot27x_temp
Is this right? Merge master into springBoot27x_temp to fix merge conflict.
- Loading branch information
Showing
13 changed files
with
350 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
gsrs-module-substance-example/src/test/java/example/chem/InchiFunctionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package example.chem; | ||
|
||
import ix.core.models.Structure; | ||
import ix.core.util.pojopointer.extensions.InChIFullRegisteredFunction; | ||
import ix.core.util.pojopointer.extensions.InChIRegisteredFunction; | ||
import ix.ginas.models.v1.GinasChemicalStructure; | ||
import org.apache.commons.io.IOUtils; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
import java.io.IOException; | ||
import java.util.Optional; | ||
import java.util.function.BiFunction; | ||
import java.util.stream.Stream; | ||
|
||
public class InchiFunctionTest { | ||
|
||
@ParameterizedTest | ||
@MethodSource("inputData") | ||
void testInchi(String molname, String description, Structure.Stereo stereo, boolean expectDelimiter) throws IOException { | ||
String molfileText = IOUtils.toString( | ||
this.getClass().getResourceAsStream("/molfiles/" + molname + ".mol"), | ||
"UTF-8" | ||
); | ||
GinasChemicalStructure structure = new GinasChemicalStructure(); | ||
structure.molfile = molfileText; | ||
structure.stereoChemistry = stereo; | ||
InChIFullRegisteredFunction functionHolder = new InChIFullRegisteredFunction(); | ||
BiFunction<InChIFullRegisteredFunction.InChIFullPath, Structure, Optional<String>> fun = functionHolder.getOperation(); | ||
Optional<String> result =fun.apply(new InChIFullRegisteredFunction.InChIFullPath(), structure); | ||
System.out.printf("InChIs for %s: %s\n", description, result.get()); | ||
Assertions.assertEquals(expectDelimiter, result.get().contains(InChIFullRegisteredFunction.MULTIPLE_VALUE_DELIMITER)); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("inputData") | ||
void testInchiKey(String molname, String description, Structure.Stereo stereo, boolean expectDelimiter) throws IOException { | ||
String molfileText = IOUtils.toString( | ||
this.getClass().getResourceAsStream("/molfiles/" + molname + ".mol"), | ||
"UTF-8" | ||
); | ||
GinasChemicalStructure structure = new GinasChemicalStructure(); | ||
structure.molfile = molfileText; | ||
structure.stereoChemistry = stereo; | ||
InChIRegisteredFunction functionHolder = new InChIRegisteredFunction(); | ||
BiFunction<InChIRegisteredFunction.InChIPath, Structure, Optional<String>> fun = functionHolder.getOperation(); | ||
Optional<String> result =fun.apply(new InChIRegisteredFunction.InChIPath(), structure); | ||
System.out.printf("InChIKeys for %s: %s\n", description, result.get()); | ||
Assertions.assertEquals(expectDelimiter, result.get().contains(InChIRegisteredFunction.MULTIPLE_VALUE_DELIMITER)); | ||
} | ||
|
||
private static Stream<Arguments> inputData() { | ||
return Stream.of( | ||
Arguments.of("N9Y5G2T2T5", "N9Y5G2T2T5 with unknown stereo", Structure.Stereo.UNKNOWN, false), | ||
Arguments.of("N9Y5G2T2T5", "N9Y5G2T2T5 with racemic stereo", Structure.Stereo.RACEMIC, true), | ||
Arguments.of("N9Y5G2T2T5", "N9Y5G2T2T5 with epimeric stereo", Structure.Stereo.EPIMERIC, true), | ||
Arguments.of("SV1ATP0KYY", "SV1ATP0KYY with unknown stereo", Structure.Stereo.UNKNOWN, false), | ||
Arguments.of("SV1ATP0KYY", "SV1ATP0KYY with racemic stereo", Structure.Stereo.RACEMIC, true), | ||
Arguments.of("SV1ATP0KYY", "SV1ATP0KYY with epimeric stereo", Structure.Stereo.EPIMERIC, true) | ||
|
||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
gsrs-module-substance-example/src/test/java/example/substance/StructureMethodTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package example.substance; | ||
|
||
import ix.core.models.Structure; | ||
import ix.ginas.models.v1.GinasChemicalStructure; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.File; | ||
import java.nio.file.Files; | ||
import java.util.List; | ||
|
||
public class StructureMethodTest { | ||
|
||
@Test | ||
void testGetInchiSet() throws Exception { | ||
File molfile =new File(getClass().getResource("/molfiles/SV1ATP0KYY.mol").getFile()); | ||
Structure testStructure = new GinasChemicalStructure(); | ||
testStructure.stereoChemistry = Structure.Stereo.EPIMERIC; | ||
testStructure.molfile = Files.readString(molfile.toPath()); | ||
List<String> inchiKeys=testStructure.getInChIKeysAndThrow(); | ||
Assertions.assertEquals(2, inchiKeys.size()); | ||
inchiKeys.forEach(r-> System.out.printf("inchikey: %s\n", r)); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
gsrs-module-substance-example/src/test/resources/molfiles/N9Y5G2T2T5.mol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
|
||
JSDraw201032415472D | ||
|
||
29 31 0 0 0 0 0 V2000 | ||
20.2131 -5.2149 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0 | ||
20.2131 -6.7749 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 | ||
21.5640 -7.5549 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 | ||
22.9151 -6.7749 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 | ||
24.2661 -7.5549 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 | ||
24.2661 -9.1149 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 | ||
25.6171 -6.7749 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0 | ||
26.9681 -7.5549 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 | ||
26.9681 -9.1149 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 | ||
28.3201 -9.8949 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 | ||
28.3201 -11.4549 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 | ||
26.9681 -12.2349 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 | ||
25.6161 -11.4549 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 | ||
25.6161 -9.8949 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 | ||
28.5044 -7.8258 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 | ||
29.5073 -6.6298 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 | ||
31.0436 -6.9006 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 | ||
31.5769 -8.3675 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 | ||
30.5741 -9.5635 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 | ||
29.0378 -9.2927 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 | ||
27.5016 -6.0890 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 | ||
26.4979 -4.8936 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 | ||
27.0315 -3.4276 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 | ||
28.5687 -3.1571 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 | ||
29.5725 -4.3525 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 | ||
29.0388 -5.8184 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 | ||
18.8621 -7.5549 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 | ||
17.5111 -6.7749 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 | ||
18.8621 -9.1149 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 | ||
2 1 1 0 0 0 0 | ||
2 3 1 0 0 0 0 | ||
3 4 1 0 0 0 0 | ||
4 5 1 0 0 0 0 | ||
5 6 2 0 0 0 0 | ||
5 7 1 0 0 0 0 | ||
7 8 1 0 0 0 0 | ||
8 9 1 0 0 0 0 | ||
9 10 2 0 0 0 0 | ||
10 11 1 0 0 0 0 | ||
11 12 2 0 0 0 0 | ||
12 13 1 0 0 0 0 | ||
13 14 2 0 0 0 0 | ||
9 14 1 0 0 0 0 | ||
8 15 1 0 0 0 0 | ||
15 16 2 0 0 0 0 | ||
16 17 1 0 0 0 0 | ||
17 18 2 0 0 0 0 | ||
18 19 1 0 0 0 0 | ||
19 20 2 0 0 0 0 | ||
15 20 1 0 0 0 0 | ||
8 21 1 0 0 0 0 | ||
21 22 2 0 0 0 0 | ||
22 23 1 0 0 0 0 | ||
23 24 2 0 0 0 0 | ||
24 25 1 0 0 0 0 | ||
25 26 2 0 0 0 0 | ||
21 26 1 0 0 0 0 | ||
2 27 1 0 0 0 0 | ||
27 28 1 0 0 0 0 | ||
27 29 2 0 0 0 0 | ||
M END |
29 changes: 29 additions & 0 deletions
29
gsrs-module-substance-example/src/test/resources/molfiles/SV1ATP0KYY.mol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
.alpha.-D-Allopyranose | ||
Marvin 01132101232D | ||
|
||
12 12 0 0 1 0 999 V2000 | ||
16.3342 -4.8950 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 | ||
17.0487 -4.4824 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 | ||
15.6197 -4.4824 0.0000 C 0 0 2 0 0 0 0 0 0 0 0 0 | ||
14.9053 -4.8950 0.0000 C 0 0 1 0 0 0 0 0 0 0 0 0 | ||
14.9053 -5.7200 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 | ||
14.1907 -4.4824 0.0000 C 0 0 1 0 0 0 0 0 0 0 0 0 | ||
13.4763 -4.8950 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 | ||
14.1907 -3.6574 0.0000 C 0 0 2 0 0 0 0 0 0 0 0 0 | ||
14.9053 -3.2450 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 | ||
15.6197 -3.6574 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 | ||
14.9053 -2.4200 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 | ||
13.4763 -3.2450 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 | ||
1 2 1 0 0 0 0 | ||
3 1 1 6 0 0 0 | ||
3 4 1 0 0 0 0 | ||
4 5 1 1 0 0 0 | ||
4 6 1 0 0 0 0 | ||
6 7 1 1 0 0 0 | ||
6 8 1 0 0 0 0 | ||
9 8 1 0 0 0 0 | ||
10 9 1 0 0 0 0 | ||
3 10 1 0 0 0 0 | ||
9 11 1 0 0 0 0 | ||
8 12 1 1 0 0 0 | ||
M END |
1 change: 1 addition & 0 deletions
1
...ces-core/src/main/java/gsrs/module/substance/controllers/GsrsSubstanceControllerUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.