Search in sources :

Example 11 with SingleFeatureQuery

use of org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery in project nextprot-api by calipho-sib.

the class IsoformMappingServiceTest method shouldNotMapMet1_Lys170Deletion.

@Test
public void shouldNotMapMet1_Lys170Deletion() throws Exception {
    SingleFeatureQuery query = new SingleFeatureQuery("BARD1-p.Met1_Lys170del", AnnotationCategory.VARIANT.getApiTypeName(), "");
    FeatureQueryResult result = service.propagateFeature(query);
    assertIsoformFeatureValid(result, "NX_Q99728-1", 1, 170, true);
    assertIsoformFeatureValid(result, "NX_Q99728-2", null, null, false);
    assertIsoformFeatureValid(result, "NX_Q99728-3", null, null, false);
    assertIsoformFeatureValid(result, "NX_Q99728-4", null, null, false);
}
Also used : FeatureQueryResult(org.nextprot.api.isoform.mapper.domain.FeatureQueryResult) SingleFeatureQuery(org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery) IsoformMappingBaseTest(org.nextprot.api.isoform.mapper.IsoformMappingBaseTest) Test(org.junit.Test)

Example 12 with SingleFeatureQuery

use of org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery in project nextprot-api by calipho-sib.

the class IsoformMappingServiceTest method shouldNotValidateInvalidPositionVariantIsoform.

@Test
public void shouldNotValidateInvalidPositionVariantIsoform() throws Exception {
    FeatureQueryResult result = service.validateFeature(new SingleFeatureQuery("SCN11A-p.Leu1158999Pro", AnnotationCategory.VARIANT.getApiTypeName(), "NX_Q9UI33"));
    SingleFeatureQuery query = Mockito.mock(SingleFeatureQuery.class);
    when(query.getAccession()).thenReturn("NX_Q9UI33");
    assertIsoformFeatureNotValid((FeatureQueryFailureImpl) result, new OutOfBoundSequencePositionException(query, 1158999));
}
Also used : FeatureQueryResult(org.nextprot.api.isoform.mapper.domain.FeatureQueryResult) SingleFeatureQuery(org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery) IsoformMappingBaseTest(org.nextprot.api.isoform.mapper.IsoformMappingBaseTest) Test(org.junit.Test)

Example 13 with SingleFeatureQuery

use of org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery in project nextprot-api by calipho-sib.

the class IsoformMappingService method handleMultipleQueries.

/**
 * Execute the given single feature query function to each feature query
 * @param multipleFeatureQuery multiple feature query
 * @param function the function that process a FeatureQuery and produces FeatureQueryResult
 * @return a map of results
 */
default Map<String, FeatureQueryResult> handleMultipleQueries(MultipleFeatureQuery multipleFeatureQuery, Function<SingleFeatureQuery, FeatureQueryResult> function) {
    Map<String, FeatureQueryResult> results = new HashMap<>(multipleFeatureQuery.getFeatureList().size() + multipleFeatureQuery.getFeatureMaps().size());
    multipleFeatureQuery.getFeatureList().stream().filter(feature -> !results.containsKey(feature)).forEach(feature -> results.put(feature, function.apply(new SingleFeatureQuery(feature, multipleFeatureQuery.getFeatureType(), multipleFeatureQuery.getAccession()))));
    multipleFeatureQuery.getFeatureMaps().stream().filter(featureQuery -> !results.containsKey(featureQuery.get("feature"))).forEach(featureQuery -> results.put(featureQuery.get("feature"), function.apply(new SingleFeatureQuery(featureQuery.get("feature"), multipleFeatureQuery.getFeatureType(), featureQuery.get("accession")))));
    return results;
}
Also used : FeatureQueryResult(org.nextprot.api.isoform.mapper.domain.FeatureQueryResult) Map(java.util.Map) HashMap(java.util.HashMap) Function(java.util.function.Function) MultipleFeatureQuery(org.nextprot.api.isoform.mapper.domain.MultipleFeatureQuery) SingleFeatureQuery(org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery) FeatureQueryResult(org.nextprot.api.isoform.mapper.domain.FeatureQueryResult) SingleFeatureQuery(org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery) HashMap(java.util.HashMap)

Example 14 with SingleFeatureQuery

use of org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery in project nextprot-api by calipho-sib.

the class FeatureQueryExceptionTest method testInvalidFeatureQueryFormatException.

@Test
public void testInvalidFeatureQueryFormatException() throws FeatureQueryException {
    SingleFeatureQuery query = new SingleFeatureQuery("SCN11A-p.Leu1158Pro", AnnotationCategory.VARIANT.getApiTypeName(), "NX_P01308");
    InvalidFeatureQueryFormatException featureQueryException = new InvalidFeatureQueryFormatException(query, Mockito.mock(ParseException.class));
    Assert.assertEquals("invalid feature format: SCN11A-p.Leu1158Pro", featureQueryException.getReason().getMessage());
}
Also used : SingleFeatureQuery(org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery) ParseException(java.text.ParseException) Test(org.junit.Test) SequenceVariantTest(org.nextprot.api.isoform.mapper.domain.impl.SequenceVariantTest)

Example 15 with SingleFeatureQuery

use of org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery in project nextprot-api by calipho-sib.

the class FeatureQueryExceptionTest method testOutOfBoundSequencePositionException.

@Test
public void testOutOfBoundSequencePositionException() throws FeatureQueryException {
    SingleFeatureQuery query = new SingleFeatureQuery("SCN11A-p.Leu1158Pro", AnnotationCategory.VARIANT.getApiTypeName(), "NX_Q9UI33");
    OutOfBoundSequencePositionException featureQueryException = new OutOfBoundSequencePositionException(query, 23);
    Assert.assertEquals("out of bound sequence position: position 23 of NX_Q9UI33 sequence", featureQueryException.getReason().getMessage());
}
Also used : SingleFeatureQuery(org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery) Test(org.junit.Test) SequenceVariantTest(org.nextprot.api.isoform.mapper.domain.impl.SequenceVariantTest)

Aggregations

SingleFeatureQuery (org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery)41 Test (org.junit.Test)36 FeatureQueryResult (org.nextprot.api.isoform.mapper.domain.FeatureQueryResult)33 IsoformMappingBaseTest (org.nextprot.api.isoform.mapper.IsoformMappingBaseTest)29 SequenceVariantTest (org.nextprot.api.isoform.mapper.domain.impl.SequenceVariantTest)6 FeatureQueryFailureImpl (org.nextprot.api.isoform.mapper.domain.impl.FeatureQueryFailureImpl)3 Isoform (org.nextprot.api.core.domain.Isoform)2 BufferedReader (java.io.BufferedReader)1 FileInputStream (java.io.FileInputStream)1 InputStreamReader (java.io.InputStreamReader)1 PrintWriter (java.io.PrintWriter)1 ParseException (java.text.ParseException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Function (java.util.function.Function)1 Ignore (org.junit.Ignore)1 AminoAcidCode (org.nextprot.api.commons.bio.AminoAcidCode)1 SequenceVariation (org.nextprot.api.commons.bio.variation.prot.SequenceVariation)1 Entry (org.nextprot.api.core.domain.Entry)1 GeneMasterCodonPosition (org.nextprot.api.core.utils.seqmap.GeneMasterCodonPosition)1