Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user to hold control and drag mouse to select multiple options quickly #472

Open
wants to merge 8 commits into
base: feat/string-mut-name
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.mskcc.oncokb.curation.domain.enumeration;

public enum CNAConsequence {
AMPLIFICATION,
DELETION,
GAIN,
LOSS,
UNKNOWN,
CNA_AMPLIFICATION,
CNA_DELETION,
CNA_GAIN,
CNA_LOSS,
CNA_UNKNOWN,
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
package org.mskcc.oncokb.curation.domain.enumeration;

public enum SVConsequence {
DELETION,
TRANSLOCATION,
DUPLICATION,
INSERTION,
INVERSION,
FUSION,
UNKNOWN,
SV_DELETION("Deletion"),
SV_TRANSLOCATION("Translocation"),
SV_DUPLICATION("Duplication"),
SV_INSERTION("Insertion"),
SV_INVERSION("Inversion"),
SV_FUSION("Fusion"),
SV_UNKNOWN("Unknown");

private final String name;

SVConsequence(String name) {
this.name = name;
}

public String getName() {
return name;
}
}
121 changes: 47 additions & 74 deletions src/main/java/org/mskcc/oncokb/curation/service/MainService.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.mskcc.oncokb.curation.domain.dto.HotspotInfoDTO;
import org.mskcc.oncokb.curation.domain.dto.ProteinExonDTO;
import org.mskcc.oncokb.curation.domain.enumeration.*;
import org.mskcc.oncokb.curation.model.IntegerRange;
import org.mskcc.oncokb.curation.service.dto.TranscriptDTO;
import org.mskcc.oncokb.curation.service.mapper.TranscriptMapper;
import org.mskcc.oncokb.curation.util.AlterationUtils;
Expand Down Expand Up @@ -280,87 +279,61 @@ public AlterationAnnotationStatus annotateAlteration(ReferenceGenome referenceGe
}
annotationDTO.setHotspot(hotspotInfoDTO);

if (
annotatedGenes.size() == 1 &&
PROTEIN_CHANGE.equals(alteration.getType()) &&
alteration.getStart() != null &&
alteration.getEnd() != null
) {
Optional<TranscriptDTO> transcriptOptional = transcriptService.findByGeneAndReferenceGenomeAndCanonicalIsTrue(
annotatedGenes.stream().iterator().next(),
referenceGenome
);
if (transcriptOptional.isPresent()) {
List<GenomeFragment> utrs = transcriptOptional.orElseThrow().getUtrs();
List<GenomeFragment> exons = transcriptOptional.orElseThrow().getExons();
exons.sort((o1, o2) -> {
int diff = o1.getStart() - o2.getStart();
if (diff == 0) {
diff = o1.getEnd() - o2.getEnd();
}
if (diff == 0) {
diff = (int) (o1.getId() - o2.getId());
}
return diff;
});

List<GenomeFragment> codingExons = new ArrayList<>();
exons.forEach(exon -> {
Integer start = exon.getStart();
Integer end = exon.getEnd();
for (GenomeFragment utr : utrs) {
if (utr.getStart().equals(exon.getStart())) {
start = utr.getEnd() + 1;
}
if (utr.getEnd().equals(exon.getEnd())) {
end = utr.getStart() - 1;
}
if (annotatedGenes.size() == 1) {
List<ProteinExonDTO> proteinExons = transcriptService.getExons(annotatedGenes.stream().iterator().next(), referenceGenome);
if (PROTEIN_CHANGE.equals(alteration.getType()) && alteration.getStart() != null && alteration.getEnd() != null) {
// Filter exons based on alteration range
List<ProteinExonDTO> overlap = proteinExons
.stream()
.filter(exon -> alteration.getStart() <= exon.getRange().getEnd() && alteration.getEnd() >= exon.getRange().getStart())
.collect(Collectors.toList());
annotationDTO.setExons(overlap);
} else if (AlterationUtils.isExon(alteration.getAlteration())) {
List<ProteinExonDTO> overlap = new ArrayList<>();
List<String> problematicExonAlts = new ArrayList<>();
for (String exonAlterationString : Arrays.asList(alteration.getAlteration().split("\\s*\\+\\s*"))) {
if (AlterationUtils.isAnyExon(exonAlterationString)) {
continue;
}
if (start < end) {
GenomeFragment genomeFragment = new GenomeFragment();
genomeFragment.setType(GenomeFragmentType.EXON);
genomeFragment.setStart(start);
genomeFragment.setEnd(end);
codingExons.add(genomeFragment);
Integer exonNumber = Integer.parseInt(exonAlterationString.replaceAll("\\D*", ""));

Integer minExon = proteinExons
.stream()
.min(Comparator.comparing(ProteinExonDTO::getExon))
.map(ProteinExonDTO::getExon)
.orElse(0);

if (exonNumber >= minExon && exonNumber < minExon + proteinExons.size() + 1) {
overlap.add(proteinExons.get(exonNumber - minExon));
} else {
GenomeFragment genomeFragment = new GenomeFragment();
genomeFragment.setType(GenomeFragmentType.EXON);
genomeFragment.setStart(0);
genomeFragment.setEnd(0);
codingExons.add(genomeFragment);
problematicExonAlts.add(exonAlterationString);
}
});

if (transcriptOptional.orElseThrow().getStrand() == -1) {
Collections.reverse(codingExons);
}

List<ProteinExonDTO> proteinExons = new ArrayList<>();
int startAA = 1;
int previousExonCodonResidues = 0;
for (int i = 0; i < codingExons.size(); i++) {
GenomeFragment genomeFragment = codingExons.get(i);
if (genomeFragment.getStart() == 0) {
continue;
if (problematicExonAlts.isEmpty()) {
overlap.sort(Comparator.comparingInt(ProteinExonDTO::getExon));
Boolean isConsecutiveExonRange =
overlap
.stream()
.map(ProteinExonDTO::getExon)
.reduce((prev, curr) -> (curr - prev == 1) ? curr : Integer.MIN_VALUE)
.orElse(Integer.MIN_VALUE) !=
Integer.MIN_VALUE;
if (isConsecutiveExonRange && overlap.size() > 0) {
alteration.setStart(overlap.get(0).getRange().getStart());
alteration.setEnd(overlap.get(overlap.size() - 1).getRange().getEnd());
}
int proteinLength = (previousExonCodonResidues + (genomeFragment.getEnd() - genomeFragment.getStart() + 1)) / 3;
previousExonCodonResidues = (previousExonCodonResidues + (genomeFragment.getEnd() - genomeFragment.getStart() + 1)) % 3;
ProteinExonDTO proteinExonDTO = new ProteinExonDTO();
proteinExonDTO.setExon(i + 1);
IntegerRange integerRange = new IntegerRange();
integerRange.setStart(startAA);
integerRange.setEnd(startAA + proteinLength - 1 + (previousExonCodonResidues > 0 ? 1 : 0));
proteinExonDTO.setRange(integerRange);
proteinExons.add(proteinExonDTO);
startAA += proteinLength;

annotationDTO.setExons(overlap);
} else {
StringBuilder sb = new StringBuilder();
sb.append("The following exon(s) do not exist: ");
sb.append(problematicExonAlts.stream().collect(Collectors.joining(", ")));
alterationWithStatus.setMessage(sb.toString());
alterationWithStatus.setType(EntityStatusType.ERROR);
}
List<ProteinExonDTO> overlap = proteinExons
.stream()
.filter(exon -> alteration.getStart() <= exon.getRange().getEnd() && alteration.getEnd() >= exon.getRange().getStart())
.collect(Collectors.toList());
annotationDTO.setExons(overlap);
}
}

alterationWithStatus.setAnnotation(annotationDTO);
return alterationWithStatus;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import static org.mskcc.oncokb.curation.config.Constants.ENSEMBL_POST_THRESHOLD;

import java.util.*;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.genome_nexus.ApiException;
Expand All @@ -13,9 +11,11 @@
import org.mskcc.oncokb.curation.config.cache.CacheCategory;
import org.mskcc.oncokb.curation.config.cache.CacheNameResolver;
import org.mskcc.oncokb.curation.domain.*;
import org.mskcc.oncokb.curation.domain.dto.ProteinExonDTO;
import org.mskcc.oncokb.curation.domain.enumeration.GenomeFragmentType;
import org.mskcc.oncokb.curation.domain.enumeration.ReferenceGenome;
import org.mskcc.oncokb.curation.domain.enumeration.SequenceType;
import org.mskcc.oncokb.curation.model.IntegerRange;
import org.mskcc.oncokb.curation.repository.TranscriptRepository;
import org.mskcc.oncokb.curation.service.dto.ClustalOResp;
import org.mskcc.oncokb.curation.service.dto.TranscriptDTO;
Expand Down Expand Up @@ -582,6 +582,77 @@ public List<EnrichedAlignmentResult> getAlignmentResult(
}
}

public List<ProteinExonDTO> getExons(Gene gene, ReferenceGenome referenceGenome) {
Optional<TranscriptDTO> transcriptOptional = this.findByGeneAndReferenceGenomeAndCanonicalIsTrue(gene, referenceGenome);
if (transcriptOptional.isPresent()) {
List<GenomeFragment> utrs = transcriptOptional.orElseThrow().getUtrs();
List<GenomeFragment> exons = transcriptOptional.orElseThrow().getExons();
exons.sort((o1, o2) -> {
int diff = o1.getStart() - o2.getStart();
if (diff == 0) {
diff = o1.getEnd() - o2.getEnd();
}
if (diff == 0) {
diff = (int) (o1.getId() - o2.getId());
}
return diff;
});

List<GenomeFragment> codingExons = new ArrayList<>();
exons.forEach(exon -> {
Integer start = exon.getStart();
Integer end = exon.getEnd();
for (GenomeFragment utr : utrs) {
if (utr.getStart().equals(exon.getStart())) {
start = utr.getEnd() + 1;
}
if (utr.getEnd().equals(exon.getEnd())) {
end = utr.getStart() - 1;
}
}
if (start < end) {
GenomeFragment genomeFragment = new GenomeFragment();
genomeFragment.setType(GenomeFragmentType.EXON);
genomeFragment.setStart(start);
genomeFragment.setEnd(end);
codingExons.add(genomeFragment);
} else {
GenomeFragment genomeFragment = new GenomeFragment();
genomeFragment.setType(GenomeFragmentType.EXON);
genomeFragment.setStart(0);
genomeFragment.setEnd(0);
codingExons.add(genomeFragment);
}
});

if (transcriptOptional.orElseThrow().getStrand() == -1) {
Collections.reverse(codingExons);
}

List<ProteinExonDTO> proteinExons = new ArrayList<>();
int startAA = 1;
int previousExonCodonResidues = 0;
for (int i = 0; i < codingExons.size(); i++) {
GenomeFragment genomeFragment = codingExons.get(i);
if (genomeFragment.getStart() == 0) {
continue;
}
int proteinLength = (previousExonCodonResidues + (genomeFragment.getEnd() - genomeFragment.getStart() + 1)) / 3;
previousExonCodonResidues = (previousExonCodonResidues + (genomeFragment.getEnd() - genomeFragment.getStart() + 1)) % 3;
ProteinExonDTO proteinExonDTO = new ProteinExonDTO();
proteinExonDTO.setExon(i + 1);
IntegerRange integerRange = new IntegerRange();
integerRange.setStart(startAA);
integerRange.setEnd(startAA + proteinLength - 1 + (previousExonCodonResidues > 0 ? 1 : 0));
proteinExonDTO.setRange(integerRange);
proteinExons.add(proteinExonDTO);
startAA += proteinLength;
}
return proteinExons;
}
return new ArrayList<>();
}

private Optional<EnsemblTranscript> getEnsemblTranscriptBySequence(
List<EnsemblTranscript> availableEnsemblTranscripts,
EnsemblSequence sequence
Expand Down
Loading
Loading