Skip to content

Commit

Permalink
Merge pull request #661 from awab-ahmed/fix-long-mnv-bug
Browse files Browse the repository at this point in the history
Fix long mnv bug
  • Loading branch information
julie-sullivan authored Aug 31, 2023
2 parents 3624baf + 34b6b01 commit b73ac42
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cellbase-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.opencb.cellbase</groupId>
<artifactId>cellbase</artifactId>
<version>4.12.3</version>
<version>4.12.4</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion cellbase-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.opencb.cellbase</groupId>
<artifactId>cellbase</artifactId>
<version>4.12.3</version>
<version>4.12.4</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion cellbase-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.opencb.cellbase</groupId>
<artifactId>cellbase</artifactId>
<version>4.12.3</version>
<version>4.12.4</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,10 @@ private ConsequenceTypeCalculator getConsequenceTypeCalculator(Variant variant)
case BREAKEND:
return new ConsequenceTypeBNDCalculator();
default:
logger.error("There is no ConsequenceTypeCalculator for variant %s of type %s",
variant,
VariantAnnotationUtils.getVariantType(variant)
);
throw new UnsupportedURLVariantFormat();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import org.opencb.biodata.models.variant.annotation.ConsequenceTypeMappings;
import org.opencb.biodata.models.variant.annotation.exceptions.SOTermNotAvailableException;
import org.opencb.biodata.models.variant.avro.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.*;

Expand Down Expand Up @@ -146,6 +148,8 @@ public class VariantAnnotationUtils {

public static final String MT = "MT";
public static final String UNKNOWN_AMINOACID = "X";
private static final int MAX_MNV_THRESHOLD = 1000;
private static Logger logger = LoggerFactory.getLogger(VariantAnnotationUtils.class);

static {

Expand Down Expand Up @@ -670,6 +674,12 @@ public static VariantType getVariantType(Variant variant) throws UnsupportedURLV
} else {
return VariantType.MNV;
}
} else if (!variant.isSymbolic() && variant.getReference().length() > 1 && variant.getAlternate().length() > 1) {
if (variant.getReference().length() <= MAX_MNV_THRESHOLD && variant.getAlternate().length() <= MAX_MNV_THRESHOLD) {
return VariantType.MNV;
} else {
logger.warn("Provided alleles for variant are too long to be considered an MNV: %s", variant);
}
}
return variant.getType();
// return getVariantType(variant.getReferenceStart(), variant.getAlternate());
Expand Down
2 changes: 1 addition & 1 deletion cellbase-lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.opencb.cellbase</groupId>
<artifactId>cellbase</artifactId>
<version>4.12.3</version>
<version>4.12.4</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import org.apache.commons.lang3.StringUtils;
import org.hamcrest.CoreMatchers;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -28,6 +29,7 @@
import org.opencb.biodata.models.variant.avro.*;
import org.opencb.cellbase.core.variant.AnnotationBasedPhasedQueryManager;
import org.opencb.cellbase.core.variant.annotation.VariantAnnotationCalculator;
import org.opencb.cellbase.core.variant.annotation.UnsupportedURLVariantFormat;
import org.opencb.cellbase.lib.GenericMongoDBAdaptorTest;
import org.opencb.commons.datastore.core.QueryOptions;
import org.opencb.commons.datastore.core.QueryResult;
Expand All @@ -40,7 +42,6 @@

import static org.junit.Assert.*;


public class VariantAnnotationCalculatorTest extends GenericMongoDBAdaptorTest {

ObjectMapper jsonObjectMapper;
Expand Down Expand Up @@ -2379,7 +2380,53 @@ public void testSpliceAnnotation() throws Exception {
"splice_acceptor_variant"))
);
}
@Test
public void testLongMNVConsequenceTypes() throws Exception {
Variant variant = new Variant("22", 17668822, "TCTCTACTAAAAATACAAAAAATTAGCCAGGCGTGGTGGCAGGTGCCTGTAGTAC", "CC");
QueryOptions queryOptions = new QueryOptions("useCache", false);
queryOptions.put("include", "consequenceType");
queryOptions.put("skipDecompose", true);
QueryResult<VariantAnnotation> queryResult = variantAnnotationCalculator
.getAnnotationByVariant(variant, queryOptions);
List<ConsequenceType> consequenceTypeList = queryResult.getResult().get(0).getConsequenceTypes();
assertFalse(consequenceTypeList.isEmpty());
String sequenceOntologyTerms = getSequenceOntologyTerms("ENST00000399839", consequenceTypeList);
assertEquals("[{\"accession\": \"SO:0001627\", \"name\": \"intron_variant\"}]", sequenceOntologyTerms);

// Deletion instead of MNV produces feature_truncation in addition to intron_variant
variant = new Variant("22", 17668822, "TCTCTACTAAAAATACAAAAAATTAGCCAGGCGTGGTGGCAGGTGCCTGTAGTAC", "");
queryResult = variantAnnotationCalculator
.getAnnotationByVariant(variant, queryOptions);
consequenceTypeList = queryResult.getResult().get(0).getConsequenceTypes();
assertFalse(consequenceTypeList.isEmpty());
sequenceOntologyTerms = getSequenceOntologyTerms("ENST00000399839", consequenceTypeList);
assertEquals("[{\"accession\": \"SO:0001906\", \"name\": \"feature_truncation\"}, {\"accession\": \"SO:0001627\", \"name\": \"intron_variant\"}]", sequenceOntologyTerms);
}

@Test(expected = UnsupportedURLVariantFormat.class)
public void testLongMNVConsequenceTypesFailsForAboveThresholdLength() throws Exception {
QueryOptions queryOptions = new QueryOptions("useCache", false);
queryOptions.put("include", "consequenceType");
queryOptions.put("skipDecompose", true);
// Very long MNV > MAX_MNV_THRESHOLD should return no consequence type
String alt = "C" + StringUtils.repeat('A', 1001);
Variant aboveThresholdVariant = new Variant("22", 17668822, "TCTCTACTAAAAATACAAAAAATTAGCCAGGCGTGGTGGCAGGTGCCTGTAGTAC",alt);
QueryResult<VariantAnnotation> queryResult = variantAnnotationCalculator
.getAnnotationByVariant(aboveThresholdVariant, queryOptions);
List<ConsequenceType> consequenceTypeList = queryResult.getResult().get(0).getConsequenceTypes();
assertTrue(consequenceTypeList.isEmpty());
// Very long MNV > MAX_MNV_THRESHOLD throws UnsupportedURLVariantFormat
variantAnnotationCalculator.getAllConsequenceTypesByVariant(aboveThresholdVariant, queryOptions);
}

public String getSequenceOntologyTerms(String transcriptID, List<ConsequenceType> consequenceTypeList){
for (ConsequenceType consequenceType : consequenceTypeList) {
if (consequenceType.getEnsemblTranscriptId().equals("ENST00000399839")){
return consequenceType.getSequenceOntologyTerms().toString();
};
}
return null;
}
private <T> void assertObjectListEquals(String expectedConsequenceTypeJson, List<T> actualList,
Class<T> clazz) throws IOException {
ObjectReader reader = jsonObjectMapper
Expand Down
2 changes: 1 addition & 1 deletion cellbase-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.opencb.cellbase</groupId>
<artifactId>cellbase</artifactId>
<version>4.12.3</version>
<version>4.12.4</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion cellbase-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<groupId>org.opencb.cellbase</groupId>
<artifactId>cellbase-test</artifactId>
<version>4.12.3</version>
<version>4.12.4</version>
<packaging>pom</packaging>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.opencb.cellbase</groupId>
<artifactId>cellbase</artifactId>
<version>4.12.3</version>
<version>4.12.4</version>
<packaging>pom</packaging>

<name>CellBase project</name>
Expand Down

0 comments on commit b73ac42

Please sign in to comment.