Skip to content

Commit beaa810

Browse files
author
Marina Selivanova
committed
replace publish plugin in cqp-api
1 parent a4d8249 commit beaa810

File tree

6 files changed

+397
-186
lines changed

6 files changed

+397
-186
lines changed

cqp-api/build.gradle.kts

Lines changed: 4 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -1,187 +1,25 @@
1-
import java.net.HttpURLConnection
2-
import kotlin.io.encoding.Base64
3-
import kotlin.io.encoding.ExperimentalEncodingApi
4-
51
plugins {
62
`java-library`
7-
`maven-publish`
8-
signing
93
id("com.diffplug.spotless") version "7.0.2"
4+
id("com.quantori.cqp-build")
105
}
116

127
group = "com.quantori"
13-
description = "Chem query platform. Compound quick search"
14-
version = "0.0.10"
8+
description = "Chem query platform. Storage API"
9+
version = "0.0.11"
1510

1611
repositories {
1712
mavenLocal()
1813
mavenCentral()
1914
}
2015

21-
java {
22-
toolchain {
23-
languageVersion = JavaLanguageVersion.of(17)
24-
}
25-
withSourcesJar()
26-
withJavadocJar()
27-
}
28-
29-
publishing {
30-
publications {
31-
create<MavenPublication>("mavenJava") {
32-
from(components["java"])
33-
34-
pom {
35-
artifactId = "cqp-api"
36-
name = project.name
37-
description = project.description
38-
packaging = "jar"
39-
url = "https://github.com/quantori/chem-query-platform"
40-
41-
licenses {
42-
license {
43-
name = "The Apache License, Version 2.0"
44-
url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
45-
}
46-
}
47-
48-
developers {
49-
developer {
50-
id = "artem.chukin"
51-
name = "Artem Chukin"
52-
email = "artem.chukin@quantori.com"
53-
}
54-
developer {
55-
id = "dmitriy gusev"
56-
name = "Dmitriy Gusev"
57-
email = "dmitriy.gusev@quantori.com"
58-
}
59-
60-
developer {
61-
id = "valeriy burmistrov"
62-
name = "Valeriy Burmistrov"
63-
email = "valeriy.burmistrov@quantori.com"
64-
}
65-
66-
developer {
67-
id = "boris sukhodoev"
68-
name = "Boris Sukhodoev"
69-
email = "boris.sukhodoev@quantori.com"
70-
}
71-
}
72-
73-
scm {
74-
connection = "scm:git:git://github.com/quantori/chem-query-platform.git"
75-
developerConnection = "scm:git:ssh://github.com/quantori/chem-query-platform.git"
76-
url = "https://github.com/quantori/chem-query-platform"
77-
}
78-
}
79-
}
80-
}
81-
repositories {
82-
maven {
83-
name = "localStaging"
84-
// change URLs to point to your repos, e.g. http://my.org/repo
85-
val releasesRepoUrl = uri(layout.buildDirectory.dir("repos/releases"))
86-
val snapshotsRepoUrl = uri(layout.buildDirectory.dir("repos/snapshots"))
87-
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
88-
}
89-
}
90-
}
91-
92-
tasks.test {
93-
useJUnitPlatform()
94-
testLogging {
95-
events("passed", "skipped", "failed")
96-
}
97-
}
98-
99-
artifacts {
100-
archives(tasks.named("javadocJar"))
101-
archives(tasks.named("sourcesJar"))
102-
}
103-
104-
signing {
105-
setRequired {
106-
!version.toString().endsWith("SNAPSHOT") && gradle.taskGraph.hasTask("publish")
107-
}
108-
val signingSecretKey = findProperty("signing.secretKey") as String? ?: System.getenv("GPG_SIGNING_SECRET_KEY")
109-
val signingPassword = findProperty("signing.password") as String? ?: System.getenv("GPG_SIGNING_PASSWORD")
110-
111-
useInMemoryPgpKeys(signingSecretKey, signingPassword)
112-
sign(publishing.publications["mavenJava"])
113-
sign(configurations.archives.get())
114-
}
115-
116-
// Fix Javadoc warnings on JDK 9+ (optional but recommended)
117-
if (JavaVersion.current().isJava9Compatible) {
118-
tasks.withType<Javadoc>().configureEach {
119-
(options as StandardJavadocDocletOptions).addStringOption("Xdoclint:none", "-quiet")
120-
(options as StandardJavadocDocletOptions).addBooleanOption("html5", true)
121-
}
122-
}
123-
124-
@OptIn(ExperimentalEncodingApi::class)
125-
fun String.toBase64(): String {
126-
return Base64.encode(this.toByteArray(Charsets.UTF_8))
127-
}
128-
129-
val publishToLocalStaging = tasks.getByName("publishMavenJavaPublicationToLocalStagingRepository")
130-
131-
publishToLocalStaging.outputs.dir(layout.buildDirectory.dir("repos/releases"))
132-
133-
val zipBundle by tasks.registering(Zip::class) {
134-
archiveFileName = "central-bundle.zip"
135-
destinationDirectory = project.layout.buildDirectory.dir("distributions")
136-
inputs.files(publishToLocalStaging.outputs.files)
137-
from(publishToLocalStaging.outputs.files.files)
138-
}
139-
140-
val uploadToMavenCentral by tasks.registering {
141-
val url = uri("https://central.sonatype.com/api/v1/publisher/upload").toURL()
142-
val boundary = "----WebKitFormBoundary7MA4YWxkTrZu0gW"
143-
inputs.file(zipBundle.map { it.archiveFile }.get())
144-
doLast {
145-
val file = zipBundle.get().archiveFile.get().asFile
146-
val mavenCentralUsername =
147-
findProperty("mavenCentralUsername") as String? ?: System.getenv("MAVEN_CENTRAL_USERNAME")
148-
val mavenCentralPassword =
149-
findProperty("mavenCentralPassword") as String? ?: System.getenv("MAVEN_CENTRAL_PASSWORD")
150-
val token = "$mavenCentralUsername:$mavenCentralPassword\n".toBase64()
151-
152-
val connection = (url.openConnection() as HttpURLConnection).apply {
153-
requestMethod = "POST"
154-
doOutput = true
155-
setRequestProperty("Authorization", "Bearer $token")
156-
setRequestProperty("Content-Type", "multipart/form-data; boundary=$boundary")
157-
}
158-
159-
val outputStream = connection.outputStream
160-
outputStream.bufferedWriter().use { writer ->
161-
writer.append("--$boundary\r\n")
162-
writer.append("Content-Disposition: form-data; name=\"bundle\"; filename=\"${file.name}\"\r\n")
163-
writer.append("Content-Type: application/octet-stream\r\n\r\n")
164-
writer.flush()
165-
166-
file.inputStream().use { it.copyTo(outputStream) }
167-
168-
writer.append("\r\n--$boundary--\r\n")
169-
writer.flush()
170-
}
171-
172-
val responseCode = connection.responseCode
173-
println("Response Code: $responseCode")
174-
println("Response Message: ${connection.inputStream.bufferedReader().readText()}")
175-
}
176-
}
177-
17816
dependencies {
17917
implementation("commons-codec:commons-codec:1.15")
180-
compileOnly(libs.jackson)
18118

18219
implementation(libs.javax.validation)
18320
implementation(libs.bundles.indigo)
18421
implementation(libs.common.text)
22+
compileOnly(libs.jackson)
18523

18624
compileOnly(libs.lombok)
18725
annotationProcessor(libs.lombok)
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
package com.quantori.cqp.api;
2+
3+
import static org.junit.Assert.assertTrue;
4+
5+
import com.epam.indigo.Indigo;
6+
import com.quantori.cqp.api.indigo.IndigoMatcher;
7+
import com.quantori.cqp.api.indigo.IndigoProvider;
8+
import com.quantori.cqp.api.model.ExactParams;
9+
import com.quantori.cqp.api.model.SubstructureParams;
10+
import org.junit.jupiter.params.ParameterizedTest;
11+
import org.junit.jupiter.params.provider.ValueSource;
12+
13+
class ProcessChiralStructuresTest {
14+
15+
private final IndigoProvider indigoProvider = new IndigoProvider(100, 5);
16+
17+
@ParameterizedTest
18+
@ValueSource(strings = {
19+
"C1C=CC=C2C=CC=CC=12",
20+
"N1([C@@]2(SC(=N1)C(=O)C)N(N=C(c1ccc(cc1)Br)CC2)c1ccccc1)c1c(cc(cc1)Cl)Cl",
21+
"""
22+
X-17641
23+
MACCS-II09195910443D 1 0.00000 0.00000 0
24+
MOE2004 3D
25+
38 42 0 0 0 0 999 V2000 \s
26+
9.7920 2.1040 0.0000 C 0 0 0 0 0
27+
4.2870 7.1000 0.0000 C 0 0 0 0 0
28+
8.5870 7.0150 0.0000 C 0 0 0 0 0
29+
7.3550 2.1040 0.0000 N 0 0 0 0 0
30+
7.3550 4.9100 0.0000 C 0 0 0 0 0
31+
8.5660 4.2090 0.0000 C 0 0 0 0 0
32+
9.7920 6.3200 0.0000 C 0 0 0 0 0
33+
8.5660 8.4170 0.0000 O 0 0 0 0 0
34+
8.5660 0.0070 0.0000 N 0 0 0 0 0
35+
8.5660 2.8130 0.0000 C 0 0 2 0 0
36+
7.3550 9.1050 0.0000 C 0 0 0 0 0
37+
12.2010 2.1040 0.0000 O 0 0 0 0 0
38+
0.7160 3.5140 0.0000 C 0 0 0 0 0
39+
6.0370 0.2620 0.0000 S 0 0 0 0 0
40+
4.2020 4.7400 0.0000 F 0 0 0 0 0
41+
2.7850 4.7400 0.0000 C 0 0 0 0 0
42+
11.0040 0.0000 0.0000 C 0 0 0 0 0
43+
11.0040 4.2090 0.0000 O 0 0 0 0 0
44+
5.5900 3.8690 0.0000 O 0 0 0 0 0
45+
5.0160 9.2460 0.0000 C 0 0 0 0 0
46+
2.0830 5.9520 0.0000 C 0 0 0 0 0
47+
5.6970 7.0850 0.0000 O 0 0 0 0 0
48+
7.3550 6.2990 0.0000 C 0 0 0 0 0
49+
9.7920 4.9100 0.0000 C 0 0 0 0 0
50+
3.8690 8.4250 0.0000 C 0 0 0 0 0
51+
0.0140 2.3030 0.0000 Cl 0 0 0 0 0
52+
6.0370 2.5300 0.0000 C 0 0 0 0 0
53+
3.8050 1.4030 0.0000 C 0 0 0 0 0
54+
6.1570 8.3960 0.0000 C 0 0 0 0 0
55+
2.0830 3.5290 0.0000 C 0 0 0 0 0
56+
5.2010 1.4030 0.0000 C 0 0 0 0 0
57+
9.7920 0.6870 0.0000 C 0 0 0 0 0
58+
13.4130 2.8060 0.0000 C 0 0 0 0 0
59+
11.0040 2.8060 0.0000 C 0 0 0 0 0
60+
0.0000 4.7400 0.0000 C 0 0 0 0 0
61+
7.3550 0.6870 0.0000 C 0 0 0 0 0
62+
0.7160 5.9590 0.0000 C 0 0 0 0 0
63+
7.3550 10.5010 0.0000 O 0 0 0 0 0
64+
4 36 1 0 0 0
65+
4 27 1 0 0 0
66+
4 10 1 0 0 0
67+
36 9 2 0 0 0
68+
36 14 1 0 0 0
69+
1 10 1 0 0 0
70+
1 32 2 0 0 0
71+
1 34 1 0 0 0
72+
27 31 1 0 0 0
73+
27 19 2 0 0 0
74+
31 14 1 0 0 0
75+
31 28 2 0 0 0
76+
9 32 1 0 0 0
77+
10 6 1 0 0 0
78+
32 17 1 0 0 0
79+
28 30 1 0 0 0
80+
30 13 2 0 0 0
81+
30 16 1 0 0 0
82+
11 29 1 0 0 0
83+
11 8 1 0 0 0
84+
11 38 2 0 0 0
85+
34 18 2 0 0 0
86+
34 12 1 0 0 0
87+
29 22 1 0 0 0
88+
29 20 2 0 0 0
89+
6 24 2 0 0 0
90+
6 5 1 0 0 0
91+
8 3 1 0 0 0
92+
22 2 1 0 0 0
93+
13 26 1 0 0 0
94+
13 35 1 0 0 0
95+
16 15 1 0 0 0
96+
16 21 2 0 0 0
97+
20 25 1 0 0 0
98+
2 25 2 0 0 0
99+
24 7 1 0 0 0
100+
5 23 2 0 0 0
101+
3 23 1 0 0 0
102+
3 7 2 0 0 0
103+
12 33 1 0 0 0
104+
37 21 1 0 0 0
105+
37 35 2 0 0 0
106+
M END
107+
"""
108+
})
109+
void test_exact_match(String structure) {
110+
var indigoObject = new Indigo().loadMolecule(structure);
111+
var exactParams = ExactParams.builder().searchQuery(structure).build();
112+
assertTrue(new IndigoMatcher(indigoProvider).isExactMatch(indigoObject.serialize(), exactParams));
113+
}
114+
115+
@ParameterizedTest
116+
@ValueSource(strings = {
117+
"N1([C@@](C=C(C1=O)Nc1ccc(I)cc1)(C(=O)OCC)C)c1ccc(cc1)I",
118+
"N1([C@@]2(SC(=N1)C(=O)C)N(N=C(c1ccc(cc1)Br)CC2)c1ccccc1)c1c(cc(cc1)Cl)Cl",
119+
"c1(c(c2c([nH]c1=O)ccc(c2)Cl)c1ccccc1)C1=NN(C(Nc2ccccc2)=S)[C@H](C1)c1ccc(cc1)OC",
120+
"c1(c(c2c([nH]c1=O)ccc(c2)Cl)c1ccccc1)C1=NN([C@H](C1)c1cc(c(cc1)OC)OC)C(=O)CCC(=O)O",
121+
"N1(N=C(c2c(c3c(nc2C)ccc(c3)Br)c2ccccc2)C[C@H]1c1ccc(cc1)C)C(=O)CCC(=O)O",
122+
"c12n(c(c3c(n1c(nn2)SCC(c1ccc(cc1)Cl)=O)sc1c3CC[C@H](C1)C(C)(C)C)=O)c1c(C)cccc1",
123+
"c12n([C@H](C(F)(F)F)C[C@H](N2)c2ccc(cc2)Br)ncc1C(Nc1cc(c(c(c1)OC)OC)OC)=O"
124+
})
125+
void test_sub_search(String structure) {
126+
var indigoObject = new Indigo().loadMolecule(structure);
127+
var substructureParams = SubstructureParams.builder().searchQuery(structure).heteroatoms(false).build();
128+
assertTrue(new IndigoMatcher(indigoProvider).isSubstructureMatch(indigoObject.serialize(), substructureParams));
129+
}
130+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package com.quantori.cqp.api;
2+
3+
import com.quantori.cqp.api.indigo.IndigoMatcher;
4+
import com.quantori.cqp.api.indigo.IndigoProvider;
5+
import com.quantori.cqp.api.model.SubstructureParams;
6+
import org.junit.jupiter.api.Assertions;
7+
import org.junit.jupiter.params.ParameterizedTest;
8+
import org.junit.jupiter.params.provider.Arguments;
9+
import org.junit.jupiter.params.provider.MethodSource;
10+
11+
import java.util.stream.Stream;
12+
13+
class ProcessStructureTest {
14+
15+
private static Stream<Arguments> molecules() {
16+
return Stream.of(
17+
Arguments.of("C1C=CC=C2CCC=12>>C1CCC1",
18+
"[NH2:1][C:2]1=[CH:3][CH:4]=[C:5]([C:8]2=[CH:9][N:10]=[C:11]([C:13]3([CH2:14][CH2:15][CH2:16]3)[O:17]"
19+
+ "[CH2:18][C:19](=[O:20])[O:21]C)[S:12]2)[CH:6]=[CH:7]1.[CH:23]1([CH2:24][C:25]2=[C:26]1[CH:27]="
20+
+ "[CH:28][CH:29]=[CH:30]2)[C:31](=[O:32])O.CN1CCOCC1.O.ON1N=NC2=C1C=CC=C2.Cl.C(C)N=C=NCCCN(C)C>CN(C=O)"
21+
+ "C>[C:25]12=[CH:30][CH:29]=[CH:28][CH:27]=[C:26]1[CH:23]([C:31](=[O:32])[NH:1][C:2]1=[CH:3][CH:4]"
22+
+ "=[C:5]([C:8]3=[CH:9][N:10]=[C:11]([C:13]4([CH2:14][CH2:15][CH2:16]4)[O:17][CH2:18][C:19](=[O:20])"
23+
+ "[OH:21])[S:12]3)[CH:6]=[CH:7]1)[CH2:24]2 |f:3.4,5.6|"),
24+
25+
Arguments.of("C1C=CC=C2CCC=12>>C1CCC1",
26+
"[NH2:1][C:2]1=[CH:3][CH:4]=[C:5]([C:8]2=[CH:9][N:10]=[C:11]([C:13]3([CH2:14][CH2:15][CH2:16]3)[O:17]"
27+
+ "[CH2:18][C:19](=[O:20])[O:21]C)[S:12]2)[CH:6]=[CH:7]1.[CH:23]1([CH2:24][C:25]2=[C:26]1[CH:27]="
28+
+ "[CH:28][CH:29]=[CH:30]2)[C:31](=[O:32])O.CN1CCOCC1.O.ON1N=NC2=C1C=CC=C2.Cl.C(C)N=C=NCCCN(C)C>CN(C=O)"
29+
+ "C>[C:25]12=[CH:30][CH:29]=[CH:28][CH:27]=[C:26]1[CH:23]([C:31](=[O:32])[NH:1][C:2]1=[CH:3][CH:4]="
30+
+ "[C:5]([C:8]3=[CH:9][N:10]=[C:11]([C:13]4([CH2:14][CH2:15][CH2:16]4)[O:17][CH2:18][C:19](=[O:20])"
31+
+ "[OH:21])[S:12]3)[CH:6]=[CH:7]1)[CH2:24]2 |f:3.4,5.6|"),
32+
33+
Arguments.of("C1C=CC=C2CCC=12>>C1CCC1",
34+
"[NH2:1][C:2]1=[CH:3][CH:4]=[C:5]([C:8]2=[CH:9][N:10]=[C:11]([C:13]3([CH2:14][CH2:15][CH2:16]3)[O:17]"
35+
+ "[CH2:18][C:19](=[O:20])[O:21]C)[S:12]2)[CH:6]=[CH:7]1.[CH:23]1([CH2:24][C:25]2=[C:26]1[CH:27]="
36+
+ "[CH:28][CH:29]=[CH:30]2)[C:31](=[O:32])O.CN1CCOCC1.O.ON1N=NC2=C1C=CC=C2.Cl.C(C)N=C=NCCCN(C)C>CN(C=O)"
37+
+ "C>[C:25]12=[CH:30][CH:29]=[CH:28][CH:27]=[C:26]1[CH:23]([C:31](=[O:32])[NH:1][C:2]1=[CH:3][CH:4]="
38+
+ "[C:5]([C:8]3=[CH:9][N:10]=[C:11]([C:13]4([CH2:14][CH2:15][CH2:16]4)[O:17][CH2:18][C:19](=[O:20])"
39+
+ "[OH:21])[S:12]3)[CH:6]=[CH:7]1)[CH2:24]2 |f:3.4,5.6|\n"),
40+
41+
Arguments.of("C1C=CC=[C:3]2[CH2:8][CH2:7][C:2]=12>>[CH2:2]1[CH2:7][CH2:8][CH2:3]1",
42+
"[NH2:1][C:2]1=[CH:3][CH:4]=[C:5]([C:8]2=[CH:9][N:10]=[C:11]([C:13]3([CH2:14][CH2:15][CH2:16]3)[O:17]"
43+
+ "[CH2:18][C:19](=[O:20])[O:21]C)[S:12]2)[CH:6]=[CH:7]1.[CH:23]1([CH2:24][C:25]2=[C:26]1[CH:27]="
44+
+ "[CH:28][CH:29]=[CH:30]2)[C:31](=[O:32])O.CN1CCOCC1.O.ON1N=NC2=C1C=CC=C2.Cl.C(C)N=C=NCCCN(C)C>CN(C=O)"
45+
+ "C>[C:25]12=[CH:30][CH:29]=[CH:28][CH:27]=[C:26]1[CH:23]([C:31](=[O:32])[NH:1][C:2]1=[CH:3][CH:4]="
46+
+ "[C:5]([C:8]3=[CH:9][N:10]=[C:11]([C:13]4([CH2:14][CH2:15][CH2:16]4)[O:17][CH2:18][C:19](=[O:20])"
47+
+ "[OH:21])[S:12]3)[CH:6]=[CH:7]1)[CH2:24]2 |f:3.4,5.6|\n"),
48+
49+
Arguments.of("C1C=CC=[C:3]2[CH2:8][CH2:7][C:2]=12>>[CH2:2]1[CH2:7][CH2:8][CH2:3]1",
50+
"[NH2:1][C:2]1=[CH:3][CH:4]=[C:5]([C:8]2=[CH:9][N:10]=[C:11]([C:13]3([CH2:14][CH2:15][CH2:16]3)[O:17]"
51+
+ "[CH2:18][C:19](=[O:20])[O:21]C)[S:12]2)[CH:6]=[CH:7]1.[CH:23]1([CH2:24][C:25]2=[C:26]1[CH:27]="
52+
+ "[CH:28][CH:29]=[CH:30]2)[C:31](=[O:32])O.CN1CCOCC1.O.ON1N=NC2=C1C=CC=C2.Cl.C(C)N=C=NCCCN(C)C>CN(C=O)"
53+
+ "C>[C:25]12=[CH:30][CH:29]=[CH:28][CH:27]=[C:26]1[CH:23]([C:31](=[O:32])[NH:1][C:2]1=[CH:3][CH:4]="
54+
+ "[C:5]([C:8]3=[CH:9][N:10]=[C:11]([C:13]4([CH2:14][CH2:15][CH2:16]4)[O:17][CH2:18][C:19](=[O:20])"
55+
+ "[OH:21])[S:12]3)[CH:6]=[CH:7]1)[CH2:24]2 |f:3.4,5.6|")
56+
);
57+
}
58+
59+
@ParameterizedTest
60+
@MethodSource("molecules")
61+
void test(String source, String target) {
62+
var substructureParams = SubstructureParams.builder().searchQuery(source).heteroatoms(false).build();
63+
Assertions.assertTrue(new IndigoMatcher(new IndigoProvider(100, 5)).isReactionSubstructureMatch(target, substructureParams));
64+
}
65+
}

0 commit comments

Comments
 (0)