use of org.nextprot.api.core.domain.Entry in project nextprot-api by calipho-sib.
the class IsoformUtilsTest method testGetIsoformByAccession.
@Test
public void testGetIsoformByAccession() throws Exception {
Entry entry = entryBuilderService.build(EntryConfig.newConfig("NX_P01308").withTargetIsoforms());
Assert.assertEquals("NX_P01308-1", IsoformUtils.getIsoformByName(entry, "NX_P01308-1").getUniqueName());
}
use of org.nextprot.api.core.domain.Entry in project nextprot-api by calipho-sib.
the class IsoformUtilsTest method testGetOtherIsoforms.
@Test
public void testGetOtherIsoforms() throws Exception {
Entry entry = entryBuilderService.build(EntryConfig.newConfig("NX_P01308").withTargetIsoforms());
Isoform isoform = entry.getIsoforms().get(0);
Assert.assertTrue(IsoformUtils.getOtherIsoforms(entry, isoform.getUniqueName()).isEmpty());
}
use of org.nextprot.api.core.domain.Entry in project nextprot-api by calipho-sib.
the class ExportController method streamEntrySubPart.
@RequestMapping(value = "/export/entry/{entry}/{blockOrSubpart}", method = { RequestMethod.GET })
public void streamEntrySubPart(HttpServletRequest request, HttpServletResponse response, @PathVariable("entry") String entryName, @PathVariable("blockOrSubpart") String blockOrSubpart) {
Entry entry = entryBuilderService.build(EntryConfig.newConfig(entryName).with(blockOrSubpart).withBed(true));
try {
EntryPartWriter writer = EntryPartWriter.valueOf(NextprotMediaType.valueOf(request), EntryPartExporterImpl.fromSubPart(blockOrSubpart), response.getOutputStream());
writer.write(entry);
} catch (IOException e) {
throw new NextProtException("cannot export " + entryName + " " + blockOrSubpart + " in " + NextprotMediaType.valueOf(request) + " format", e);
}
}
use of org.nextprot.api.core.domain.Entry in project nextprot-api by calipho-sib.
the class IsoformSequencePositionMapperIntegrationTest method getErrorsDuringPropagationOnVariantsOfSingleEntry.
public int getErrorsDuringPropagationOnVariantsOfSingleEntry(String entry_ac) throws Exception {
Entry entry = entryBuilderService.build(EntryConfig.newConfig(entry_ac).withTargetIsoforms().withAnnotations());
int delCount = 0;
int subCount = 0;
int insCount = 0;
int otherCount = 0;
int errorCount = 0;
for (Annotation a : entry.getAnnotations()) {
if (a.getAPICategory().equals(AnnotationCategory.VARIANT)) {
// for each variant annotation
String ori = a.getVariant().getOriginal();
String mut = a.getVariant().getVariant();
if (ori.length() == 1 && mut.length() == 1) {
subCount++;
} else if (ori.length() == 1 && mut.length() == 0) {
delCount++;
} else if (ori.length() == 0 && mut.length() == 1) {
insCount++;
} else if (sout) {
System.out.println("Other variant:" + a.getUniqueName());
otherCount++;
}
Map<String, Integer> isoExpectedPos = getExpectedPosForEachIsoform(entry, a);
printExpectedPosForEachIsoform(isoExpectedPos, a);
boolean errorOnVariant = false;
for (String iso1name : isoExpectedPos.keySet()) {
Integer iso1ExpectedPos = isoExpectedPos.get(iso1name);
Isoform iso1 = IsoformUtils.getIsoformByName(entry, iso1name);
if (iso1ExpectedPos != null) {
GeneMasterCodonPosition nuPos = IsoformSequencePositionMapper.getCodonPositionsOnMaster(iso1ExpectedPos, iso1);
if (!nuPos.isValid()) {
errorOnVariant = true;
if (sout)
System.out.println("ERROR1: codon positions not found for " + iso1name + " for variant at position: " + iso1ExpectedPos);
continue;
}
printIsoLengthAndRangesNuCount(iso1.getUniqueName(), iso1.getSequence(), iso1.getMasterMapping());
if (sout) {
System.out.println("Starting variant propagation from isoform " + iso1name + " at position " + iso1ExpectedPos);
System.out.println(getSequenceWithHighlighedPos(iso1.getSequence(), iso1ExpectedPos));
}
for (Isoform iso2 : entry.getIsoforms()) {
String iso2name = iso2.getUniqueName();
if (iso2name.equals(iso1name))
continue;
CodonNucleotideIndices nuIdx = IsoformSequencePositionMapper.getCodonNucleotideIndices(nuPos, iso2);
Integer iso2ActualPos = nuIdx.getAminoAcidPosition();
Integer iso2ExpectedPos = isoExpectedPos.get(iso2name);
if (sout)
System.out.println("Variant " + a.getUniqueName() + " position on isoform " + iso2name + " is " + iso2ActualPos);
printIsoLengthAndRangesNuCount(iso2.getUniqueName(), iso2.getSequence(), iso2.getMasterMapping());
if (iso2ExpectedPos != null)
if (sout)
System.out.println("Expected:" + getSequenceWithHighlighedPos(iso2.getSequence(), iso2ExpectedPos));
if (iso2ActualPos != null)
if (sout)
System.out.println("Actual :" + getSequenceWithHighlighedPos(iso2.getSequence(), iso2ActualPos));
if (iso2ActualPos == null && iso2ExpectedPos == null) {
// OK
} else if (iso2ActualPos == null || iso2ExpectedPos == null) {
errorOnVariant = true;
if (sout)
System.out.println("ERROR2: variant position on isoform " + iso2name + " is " + iso2ActualPos + ", expected " + iso2ExpectedPos);
} else if (!iso2ActualPos.equals(iso2ExpectedPos)) {
errorOnVariant = true;
if (sout)
System.out.println("ERROR3: variant position on isoform " + iso2name + " is " + iso2ActualPos + ", expected " + iso2ExpectedPos);
}
}
}
}
if (errorOnVariant)
errorCount++;
if (errorOnVariant)
break;
}
}
if (sout) {
System.out.println("Summary " + entry.getUniqueName());
System.out.println("insCount:" + insCount);
System.out.println("delCount:" + delCount);
System.out.println("subCount:" + subCount);
System.out.println("otherCount:" + otherCount);
System.out.println("errorCount:" + errorCount);
}
return errorCount;
}
use of org.nextprot.api.core.domain.Entry in project nextprot-api by calipho-sib.
the class IsoformUtilsTest method testGetOtherIsoforms2.
@Test
public void testGetOtherIsoforms2() throws Exception {
Entry entry = entryBuilderService.build(EntryConfig.newConfig("NX_Q9UI33").withTargetIsoforms());
List<Isoform> others = IsoformUtils.getOtherIsoforms(entry, "NX_Q9UI33-1");
Assert.assertEquals(2, others.size());
for (Isoform isoform : others) {
Assert.assertTrue(isoform.getUniqueName().equals("NX_Q9UI33-2") || isoform.getUniqueName().equals("NX_Q9UI33-3"));
}
}
Aggregations