use of org.nextprot.api.core.domain.annotation.Annotation in project nextprot-api by calipho-sib.
the class PeptideMappingServiceIntegrationTest method computeCoverage.
private String computeCoverage(Isoform iso, List<Annotation> annotations, boolean proteotypic, boolean sysout) {
String name = iso.getUniqueName();
int isoLength = iso.getSequenceLength();
int[] coverage = new int[isoLength];
for (Annotation annot : annotations) {
if (proteotypic && !isAboutProteotypicPeptide(annot))
continue;
if (!annot.isAnnotationPositionalForIsoform(name))
continue;
int start = annot.getStartPositionForIsoform(name);
int end = annot.getEndPositionForIsoform(name);
for (int i = start; i <= end; i++) coverage[i - 1] = 1;
}
int covered = getCoverageCount(coverage);
float rate = (float) 100.0 * (float) covered / (float) isoLength;
float rateRounded = Math.round(rate * 100.0f) / 100.0f;
String sep = "\t";
String title = proteotypic ? "proteotypic coverage" : "peptide coverage";
if (sysout)
System.out.println(name + sep + title + sep + isoLength + sep + covered + sep + rateRounded);
return (name + " " + title + " iso-length = " + isoLength + " covered = " + covered + " % : " + rateRounded);
// System.out.println(getCoverageString(coverage) + "\n");
}
use of org.nextprot.api.core.domain.annotation.Annotation in project nextprot-api by calipho-sib.
the class PeptideMappingServiceIntegrationTest method getHighlightCoverage.
private int[] getHighlightCoverage(Isoform iso, List<Annotation> annotations) {
String name = iso.getUniqueName();
int isoLength = iso.getSequenceLength();
int[] coverage = new int[isoLength];
// first loop sets aa coverage to 1 if there is a natural peptide on it
for (Annotation annot : annotations) {
if (!annot.isAnnotationPositionalForIsoform(name))
continue;
int start = annot.getStartPositionForIsoform(name);
int end = annot.getEndPositionForIsoform(name);
// System.out.println("first loop: " + start + " " + end);
for (int i = start; i <= end; i++) coverage[i - 1] = 1;
}
// second loop increments aa coverage if peptide is natural and proteotypic
for (Annotation annot : annotations) {
if (!annot.isAnnotationPositionalForIsoform(name))
continue;
if (isAboutProteotypicPeptide(annot)) {
int start = annot.getStartPositionForIsoform(name);
int end = annot.getEndPositionForIsoform(name);
// System.out.println("second loop: " + start + " " + end);
for (int i = start; i <= end; i++) coverage[i - 1] = coverage[i - 1] + 1;
}
}
return coverage;
}
use of org.nextprot.api.core.domain.annotation.Annotation in project nextprot-api by calipho-sib.
the class ByAnnotationVariantComparatorTest method compareVariantsSamePositionDiffVariant.
@Test
public void compareVariantsSamePositionDiffVariant() throws Exception {
ByAnnotationVariantComparator comparator = new ByAnnotationVariantComparator();
Annotation variant1 = mockAnnotationVariant(AnnotationCategory.VARIANT, "A", "W", new ByIsoformPositionComparatorTest.TargetIsoform("NX_P51610-1", 14, 14), new ByIsoformPositionComparatorTest.TargetIsoform("NX_P51610-4", 12, 12));
Annotation variant2 = mockAnnotationVariant(AnnotationCategory.VARIANT, "A", "L", new ByIsoformPositionComparatorTest.TargetIsoform("NX_P51610-1", 14, 14), new ByIsoformPositionComparatorTest.TargetIsoform("NX_P51610-4", 12, 12));
int cmp = comparator.compare(variant1, variant2);
Assert.assertTrue(cmp > 0);
}
use of org.nextprot.api.core.domain.annotation.Annotation in project nextprot-api by calipho-sib.
the class ByAnnotationVariantComparatorTest method comparePositionOfLowestLocatedFeature.
@Test
public void comparePositionOfLowestLocatedFeature() throws Exception {
ByAnnotationVariantComparator comparator = new ByAnnotationVariantComparator();
Annotation variant1 = mockAnnotationVariant(AnnotationCategory.VARIANT, "A", "V", new ByIsoformPositionComparatorTest.TargetIsoform("NX_P51610-1", 1489, 1489), new ByIsoformPositionComparatorTest.TargetIsoform("NX_P51610-4", 12, 36));
Annotation variant2 = mockAnnotationVariant(AnnotationCategory.VARIANT, "A", "V", new ByIsoformPositionComparatorTest.TargetIsoform("NX_P51610-1", 17378, 18000), new ByIsoformPositionComparatorTest.TargetIsoform("NX_P51610-4", 12, 36));
int cmp = comparator.compare(variant1, variant2);
Assert.assertEquals(0, cmp);
}
use of org.nextprot.api.core.domain.annotation.Annotation in project nextprot-api by calipho-sib.
the class ByIsoformPositionComparatorTest method mockAnnotation.
private static Annotation mockAnnotation(long id, AnnotationCategory cat, TargetIsoform... targets) {
Annotation mock = Mockito.mock(Annotation.class);
when(mock.getAnnotationId()).thenReturn(id);
when(mock.getAPICategory()).thenReturn(cat);
Map<String, AnnotationIsoformSpecificity> map = new HashMap<>();
for (TargetIsoform target : targets) {
AnnotationIsoformSpecificity specificity = Mockito.mock(AnnotationIsoformSpecificity.class);
when(specificity.getFirstPosition()).thenReturn(target.getStart());
when(specificity.getLastPosition()).thenReturn(target.getEnd());
when(specificity.getIsoformAccession()).thenReturn(target.getIsoformAccession());
when(specificity.getAnnotationId()).thenReturn(id);
when(mock.getStartPositionForIsoform(target.getIsoformAccession())).thenReturn(target.getStart());
when(mock.getEndPositionForIsoform(target.getIsoformAccession())).thenReturn(target.getEnd());
map.put(target.getIsoformAccession(), specificity);
}
when(mock.getTargetingIsoformsMap()).thenReturn(map);
return mock;
}
Aggregations