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));
}
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);
}
}
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();
}
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));
}
Aggregations