Skip to content

Commit e7d088c

Browse files
bprize15leexgh
andauthored
flip alleles when using reverse strand (genome-nexus#806)
* flip alleles when using reverse strand * fix reverse strand ref allele verification * Check if strand is null * Fix tests * Update jdk version in dockerfile and tests * Update docker file * Update docker file * Update docker file, clean up circle ci --------- Co-authored-by: Xiang Li <xiangli5699@gmail.com>
1 parent b4bbe24 commit e7d088c

File tree

6 files changed

+91
-16
lines changed

6 files changed

+91
-16
lines changed

.circleci/config.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@ jobs:
1212
# Be sure to update the Docker image tag below to openjdk version of your application.
1313
# A list of available CircleCI Docker Convenience Images are available here: https://circleci.com/developer/images/image/cimg/openjdk
1414
docker:
15-
- image: cimg/openjdk:11.0
15+
- image: cimg/openjdk:21.0
1616
- image: genomenexus/gn-mongo:0.30
1717
steps:
1818
- checkout
1919
- run:
2020
name: Wait for Mongo to be ready
2121
command: dockerize -wait tcp://localhost:27017 -timeout 1m
22+
- run:
23+
name: Build parent project
24+
command: mvn install -N -DskipTests
2225
- run:
2326
name: Build
2427
command: mvn -DskipTests clean install

.github/workflows/test_docker_build.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ jobs:
2121
- name: Set up QEMU
2222
uses: docker/setup-qemu-action@v2
2323
- name: Set up Docker Buildx
24-
uses: docker/setup-buildx-action@v2
25-
24+
uses: docker/setup-buildx-action@v2
2625
- name: Build Docker Image
2726
uses: docker/build-push-action@v3
2827
with:

Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
FROM maven:3-eclipse-temurin-11
1+
FROM maven:3-eclipse-temurin-21
22
RUN mkdir /genome-nexus
33
ADD . /genome-nexus
44
WORKDIR /genome-nexus
5+
# Build the parent project first
6+
# This is necessary to ensure that the parent POM is built before the child modules.
7+
RUN mvn install -N -DskipTests
58
RUN mvn -DskipTests clean install
69

7-
FROM eclipse-temurin:11
10+
FROM eclipse-temurin:21
811
COPY --from=0 /genome-nexus/web/target/*.war /app.war
912
CMD ["java", "-Dspring.data.mongodb.uri=${MONGODB_URI}", "-jar", "/app.war"]

component/src/main/java/org/cbioportal/genome_nexus/util/GenomicLocationUtil.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,23 @@ else if (genomicLocation.getReferenceAllele().length() == 1 && genomicLocation.g
2828
}
2929

3030
}
31+
32+
public static String getReverseStrandAllele(String allele) {
33+
StringBuilder sb = new StringBuilder();
34+
for (int i = 0; i < allele.length(); i++) {
35+
char nucleotide = allele.charAt(i);
36+
if (nucleotide == 'A') {
37+
sb.append('T');
38+
} else if (nucleotide == 'T') {
39+
sb.append('A');
40+
} else if (nucleotide == 'C') {
41+
sb.append('G');
42+
} else if (nucleotide == 'G') {
43+
sb.append('C');
44+
} else {
45+
sb.append(nucleotide);
46+
}
47+
}
48+
return sb.toString();
49+
}
3150
}

service/src/main/java/org/cbioportal/genome_nexus/service/internal/VariantAnnotationService.java

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,32 +32,57 @@
3232

3333
package org.cbioportal.genome_nexus.service.internal;
3434

35+
import java.util.ArrayList;
36+
import java.util.Collections;
37+
import java.util.List;
38+
import java.util.Map;
39+
import java.util.NoSuchElementException;
40+
import java.util.Optional;
41+
import java.util.stream.Collectors;
42+
3543
import org.apache.commons.logging.Log;
3644
import org.apache.commons.logging.LogFactory;
3745
import org.cbioportal.genome_nexus.component.annotation.HugoGeneSymbolResolver;
3846
import org.cbioportal.genome_nexus.component.annotation.IndexBuilder;
3947
import org.cbioportal.genome_nexus.component.annotation.NotationConverter;
4048
import org.cbioportal.genome_nexus.component.annotation.ProteinChangeResolver;
41-
import org.cbioportal.genome_nexus.model.*;
49+
import org.cbioportal.genome_nexus.model.AnnotationField;
50+
import org.cbioportal.genome_nexus.model.Index;
51+
import org.cbioportal.genome_nexus.model.VariantAnnotation;
52+
import org.cbioportal.genome_nexus.model.VariantType;
4253
import org.cbioportal.genome_nexus.persistence.IndexRepository;
43-
import org.cbioportal.genome_nexus.service.*;
44-
54+
import org.cbioportal.genome_nexus.service.CancerHotspotService;
55+
import org.cbioportal.genome_nexus.service.ClinvarVariantAnnotationService;
56+
import org.cbioportal.genome_nexus.service.EnrichmentService;
57+
import org.cbioportal.genome_nexus.service.MutationAssessorService;
58+
import org.cbioportal.genome_nexus.service.MyVariantInfoService;
59+
import org.cbioportal.genome_nexus.service.NucleotideContextService;
60+
import org.cbioportal.genome_nexus.service.OncokbService;
61+
import org.cbioportal.genome_nexus.service.PostTranslationalModificationService;
62+
import org.cbioportal.genome_nexus.service.SignalMutationService;
63+
import org.cbioportal.genome_nexus.service.VariantAnnotationSummaryService;
4564
import org.cbioportal.genome_nexus.service.cached.CachedVariantAnnotationFetcher;
4665
import org.cbioportal.genome_nexus.service.cached.CachedVariantIdAnnotationFetcher;
47-
import org.cbioportal.genome_nexus.service.enricher.*;
66+
import org.cbioportal.genome_nexus.service.enricher.CanonicalTranscriptAnnotationEnricher;
67+
import org.cbioportal.genome_nexus.service.enricher.ClinvarVariantAnnotationEnricher;
68+
import org.cbioportal.genome_nexus.service.enricher.HotspotAnnotationEnricher;
69+
import org.cbioportal.genome_nexus.service.enricher.MutationAssessorEnricher;
70+
import org.cbioportal.genome_nexus.service.enricher.MyVariantInfoAnnotationEnricher;
71+
import org.cbioportal.genome_nexus.service.enricher.NucleotideContextAnnotationEnricher;
72+
import org.cbioportal.genome_nexus.service.enricher.OncokbAnnotationEnricher;
73+
import org.cbioportal.genome_nexus.service.enricher.PostTranslationalModificationEnricher;
74+
import org.cbioportal.genome_nexus.service.enricher.SignalAnnotationEnricher;
4875
import org.cbioportal.genome_nexus.service.exception.ResourceMappingException;
4976
import org.cbioportal.genome_nexus.service.exception.VariantAnnotationNotFoundException;
5077
import org.cbioportal.genome_nexus.service.exception.VariantAnnotationWebServiceException;
5178
import org.cbioportal.genome_nexus.service.factory.IsoformAnnotationEnricherFactory;
79+
import org.cbioportal.genome_nexus.util.GenomicLocationUtil;
5280
import org.springframework.beans.factory.annotation.Value;
5381
import org.springframework.context.annotation.Lazy;
5482
import org.springframework.stereotype.Service;
5583
import org.springframework.web.client.HttpClientErrorException;
5684
import org.springframework.web.client.ResourceAccessException;
5785

58-
import java.util.*;
59-
import java.util.stream.Collectors;
60-
6186
import com.google.gson.Gson;
6287
import com.mongodb.BasicDBObject;
6388
import com.mongodb.DBObject;
@@ -130,13 +155,17 @@ public Index buildIndex(VariantAnnotation variantAnnotation) {
130155
public VariantAnnotation getAnnotation(String variant, VariantType variantType)
131156
throws VariantAnnotationNotFoundException, VariantAnnotationWebServiceException
132157
{
133-
return this.fetchAnnotationExternally(variant, variantType);
158+
VariantAnnotation annotation = this.fetchAnnotationExternally(variant, variantType);
159+
normalizeStrand(annotation);
160+
return annotation;
134161
}
135162

136163
public List<VariantAnnotation> getAnnotations(List<String> variants, VariantType variantType)
137164
{
138165
try {
139-
return this.fetchAnnotationsExternally(variants, variantType);
166+
List<VariantAnnotation> annotations = this.fetchAnnotationsExternally(variants, variantType);
167+
normalizeStrands(annotations);
168+
return annotations;
140169
} catch (VariantAnnotationWebServiceException e) {
141170
LOG.warn(e.getLocalizedMessage());
142171
return Collections.emptyList();
@@ -147,6 +176,8 @@ public VariantAnnotation getAnnotation(String variant, VariantType variantType,
147176
throws VariantAnnotationWebServiceException, VariantAnnotationNotFoundException
148177
{
149178
VariantAnnotation annotation = this.fetchAnnotationExternally(variant, variantType);
179+
normalizeStrand(annotation);
180+
150181
EnrichmentService postEnrichmentService = this.initPostEnrichmentService(isoformOverrideSource, fields, token);
151182

152183
if (annotation != null &&
@@ -162,6 +193,7 @@ public List<VariantAnnotation> getAnnotations(List<String> variants, VariantType
162193
{
163194
try {
164195
List<VariantAnnotation> variantAnnotations = this.fetchAnnotationsExternally(variants, variantType);
196+
normalizeStrands(variantAnnotations);
165197
EnrichmentService postEnrichmentService = this.initPostEnrichmentService(isoformOverrideSource, fields, token);
166198
if (postEnrichmentService != null) {
167199
postEnrichmentService.enrichAnnotations(variantAnnotations);
@@ -402,4 +434,16 @@ private void addAdditionalInformation(VariantAnnotation variantAnnotation, Varia
402434
variantAnnotation.setGenomicLocationExplanation(this.notationConverter.getGenomicLocationExplanation(originalVariantQuery));
403435
}
404436
}
437+
438+
private void normalizeStrand(VariantAnnotation variantAnnotation) {
439+
if (variantAnnotation.getStrand() != null && variantAnnotation.getStrand() == -1) {
440+
variantAnnotation.setAlleleString(GenomicLocationUtil.getReverseStrandAllele(variantAnnotation.getAlleleString()));
441+
}
442+
}
443+
444+
private void normalizeStrands(List<VariantAnnotation> variantAnnotations) {
445+
for (VariantAnnotation annotation : variantAnnotations) {
446+
normalizeStrand(annotation);
447+
}
448+
}
405449
}

service/src/main/java/org/cbioportal/genome_nexus/service/internal/VerifiedVariantAnnotationService.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232

3333
package org.cbioportal.genome_nexus.service.internal;
3434

35-
import java.util.*;
35+
import java.util.List;
36+
import java.util.Map;
3637

3738
import org.apache.commons.logging.Log;
3839
import org.apache.commons.logging.LogFactory;
@@ -43,8 +44,9 @@
4344
import org.cbioportal.genome_nexus.model.VariantType;
4445
import org.cbioportal.genome_nexus.service.exception.VariantAnnotationNotFoundException;
4546
import org.cbioportal.genome_nexus.service.exception.VariantAnnotationWebServiceException;
47+
import org.cbioportal.genome_nexus.util.GenomicLocationUtil;
4648
import org.cbioportal.genome_nexus.util.GenomicVariantUtil;
47-
import org.springframework.beans.factory.annotation.*;
49+
import org.springframework.beans.factory.annotation.Autowired;
4850
import org.springframework.stereotype.Service;
4951

5052
@Service
@@ -123,6 +125,11 @@ private VariantAnnotation verifyOrFailAnnotation(VariantAnnotation annotation, V
123125
ref = notationConverter.parseGenomicLocation(annotation.getOriginalVariantQuery()).getReferenceAllele();
124126
}
125127

128+
if (annotation.getStrand() != null && annotation.getStrand() == -1) {
129+
ref = GenomicLocationUtil.getReverseStrandAllele(ref);
130+
annotation.setStrand(1);
131+
}
132+
126133
if (ref.length() == 0) {
127134
// no comparison possible : allele not specified in query
128135
return annotation;

0 commit comments

Comments
 (0)