Search in sources :

Example 1 with FeatureQueryFailureImpl

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

the class IsoformMappingServiceTest method shouldNotValidateInvalidAminoAcidCode.

@Test
public void shouldNotValidateInvalidAminoAcidCode() throws Exception {
    FeatureQueryResult result = service.validateFeature(new SingleFeatureQuery("SCN11A-p.Let1158Pro", AnnotationCategory.VARIANT.getApiTypeName(), "NX_Q9UI33"));
    SingleFeatureQuery query = Mockito.mock(SingleFeatureQuery.class);
    when(query.getFeature()).thenReturn("SCN11A-p.Let1158Pro");
    Assert.assertFalse(result.isSuccess());
    Assert.assertEquals("invalid feature format: SCN11A-p.Let1158Pro", ((FeatureQueryFailureImpl) result).getError().getMessage());
    Assert.assertEquals(1, ((FeatureQueryFailureImpl) result).getError().getCauses().size());
    Assert.assertEquals("Let: invalid AminoAcidCode", ((FeatureQueryFailureImpl) result).getError().getCause(InvalidFeatureQueryFormatException.PARSE_ERROR_MESSAGE));
}
Also used : FeatureQueryResult(org.nextprot.api.isoform.mapper.domain.FeatureQueryResult) SingleFeatureQuery(org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery) FeatureQueryFailureImpl(org.nextprot.api.isoform.mapper.domain.impl.FeatureQueryFailureImpl) IsoformMappingBaseTest(org.nextprot.api.isoform.mapper.IsoformMappingBaseTest) Test(org.junit.Test)

Example 2 with FeatureQueryFailureImpl

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

the class IsoformMappingServiceImpl method validateFeature.

@Override
public BaseFeatureQueryResult validateFeature(SingleFeatureQuery query) {
    try {
        SequenceFeature sequenceFeature = SequenceFeatureBase.newFeature(query);
        if (Strings.isNullOrEmpty(query.getAccession()))
            query.setAccession(findAccessionFromGeneName(query, sequenceFeature.getGeneName()));
        Entry entry = entryBuilderService.build(EntryConfig.newConfig(query.getAccession()).withTargetIsoforms().withOverview());
        SequenceFeatureValidator validator = new SequenceFeatureValidator(entry, query);
        return validator.validate(sequenceFeature);
    } catch (FeatureQueryException e) {
        return new FeatureQueryFailureImpl(e);
    }
}
Also used : Entry(org.nextprot.api.core.domain.Entry) SequenceFeatureValidator(org.nextprot.api.isoform.mapper.service.SequenceFeatureValidator) SequenceFeature(org.nextprot.api.isoform.mapper.domain.SequenceFeature) FeatureQueryException(org.nextprot.api.isoform.mapper.domain.FeatureQueryException) FeatureQueryFailureImpl(org.nextprot.api.isoform.mapper.domain.impl.FeatureQueryFailureImpl)

Example 3 with FeatureQueryFailureImpl

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

the class IsoformMappingServiceTest method validateList.

private static void validateList(String filename, boolean tabSep, IsoformMappingService service) throws Exception {
    FileInputStream is = new FileInputStream(filename);
    BufferedReader br = new BufferedReader(new InputStreamReader(is));
    PrintWriter pw = new PrintWriter(Files.getNameWithoutExtension(filename) + "-results.tsv");
    List<String[]> twoFirstFieldsList = br.lines().map((tabSep) ? to2FirstTabFields : to2FirstCommaFields).collect(toList());
    pw.append("accession\tvariant\tvalid\terror message\n");
    for (String[] twoFields : twoFirstFieldsList) {
        String accession = twoFields[0];
        String feature = twoFields[1];
        FeatureQueryResult result = service.validateFeature(new SingleFeatureQuery(feature, AnnotationCategory.VARIANT.getApiTypeName(), accession));
        pw.append(accession).append("\t").append(feature).append("\t").append(String.valueOf(result.isSuccess()));
        if (result.isSuccess()) {
            pw.append("\t");
        } else {
            FeatureQueryFailureImpl error = (FeatureQueryFailureImpl) result;
            pw.append("\t").append(error.getError().getMessage());
        }
        pw.append("\n");
    }
    pw.close();
}
Also used : FeatureQueryResult(org.nextprot.api.isoform.mapper.domain.FeatureQueryResult) SingleFeatureQuery(org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) FileInputStream(java.io.FileInputStream) FeatureQueryFailureImpl(org.nextprot.api.isoform.mapper.domain.impl.FeatureQueryFailureImpl) PrintWriter(java.io.PrintWriter)

Example 4 with FeatureQueryFailureImpl

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

the class IsoformMappingServiceTest method shouldNotValidateInvalidVariantName.

@Test
public void shouldNotValidateInvalidVariantName() throws Exception {
    FeatureQueryResult result = service.validateFeature(new SingleFeatureQuery("SCN11A-z.Leu1158Pro", AnnotationCategory.VARIANT.getApiTypeName(), "NX_Q9UI33"));
    SingleFeatureQuery query = Mockito.mock(SingleFeatureQuery.class);
    when(query.getFeature()).thenReturn("SCN11A-z.Leu1158Pro");
    Assert.assertFalse(result.isSuccess());
    Assert.assertEquals("invalid feature format: SCN11A-z.Leu1158Pro", ((FeatureQueryFailureImpl) result).getError().getMessage());
    Assert.assertEquals(1, ((FeatureQueryFailureImpl) result).getError().getCauses().size());
    Assert.assertEquals("Cannot separate gene name from variation (missing '-p.')", ((FeatureQueryFailureImpl) result).getError().getCause(InvalidFeatureQueryFormatException.PARSE_ERROR_MESSAGE));
}
Also used : FeatureQueryResult(org.nextprot.api.isoform.mapper.domain.FeatureQueryResult) SingleFeatureQuery(org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery) FeatureQueryFailureImpl(org.nextprot.api.isoform.mapper.domain.impl.FeatureQueryFailureImpl) IsoformMappingBaseTest(org.nextprot.api.isoform.mapper.IsoformMappingBaseTest) Test(org.junit.Test)

Aggregations

FeatureQueryFailureImpl (org.nextprot.api.isoform.mapper.domain.impl.FeatureQueryFailureImpl)4 FeatureQueryResult (org.nextprot.api.isoform.mapper.domain.FeatureQueryResult)3 SingleFeatureQuery (org.nextprot.api.isoform.mapper.domain.SingleFeatureQuery)3 Test (org.junit.Test)2 IsoformMappingBaseTest (org.nextprot.api.isoform.mapper.IsoformMappingBaseTest)2 BufferedReader (java.io.BufferedReader)1 FileInputStream (java.io.FileInputStream)1 InputStreamReader (java.io.InputStreamReader)1 PrintWriter (java.io.PrintWriter)1 Entry (org.nextprot.api.core.domain.Entry)1 FeatureQueryException (org.nextprot.api.isoform.mapper.domain.FeatureQueryException)1 SequenceFeature (org.nextprot.api.isoform.mapper.domain.SequenceFeature)1 SequenceFeatureValidator (org.nextprot.api.isoform.mapper.service.SequenceFeatureValidator)1