use of org.nextprot.api.core.domain.annotation.Annotation in project nextprot-api by calipho-sib.
the class AnnotationUtils method filterAnnotationsBetweenPositions.
public static List<Annotation> filterAnnotationsBetweenPositions(int start, int end, List<Annotation> annotations, String isoform) {
if (annotations == null)
return null;
List<Annotation> finalAnnotations = new ArrayList<>();
for (Annotation annot : annotations) {
if (annot.isAnnotationPositionalForIsoform(isoform)) {
int isoStartPosition, isoEndPosition;
isoStartPosition = annot.getStartPositionForIsoform(isoform);
isoEndPosition = annot.getEndPositionForIsoform(isoform);
if ((isoStartPosition >= start) && (isoEndPosition <= end)) {
finalAnnotations.add(annot);
}
}
}
return finalAnnotations;
}
use of org.nextprot.api.core.domain.annotation.Annotation in project nextprot-api by calipho-sib.
the class AnnotationUtils method containsAtLeast2NonInclusivePeptides.
// related to rule to PE1 upgrade
private static boolean containsAtLeast2NonInclusivePeptides(List<Annotation> list, int peptideMinSize, int minCoverage, boolean debug) {
if (list == null)
return false;
for (Annotation a : list) {
if (a.getAPICategory() != AnnotationCategory.PEPTIDE_MAPPING)
continue;
Map<String, AnnotationIsoformSpecificity> timA = a.getTargetingIsoformsMap();
for (String aIsoAC : timA.keySet()) {
AnnotationIsoformSpecificity aSpec = timA.get(aIsoAC);
String aName = getPeptideName(a);
if (aName == null)
continue;
int aP1 = aSpec.getFirstPosition();
int aP2 = aSpec.getLastPosition();
int aPepSize = aP2 - aP1 + 1;
// if < min size => ignore
if (aPepSize < peptideMinSize)
continue;
for (Annotation b : list) {
if (b.getAPICategory() != AnnotationCategory.PEPTIDE_MAPPING)
continue;
Map<String, AnnotationIsoformSpecificity> timB = b.getTargetingIsoformsMap();
if (timB.containsKey(aIsoAC)) {
AnnotationIsoformSpecificity bSpec = timB.get(aIsoAC);
String bName = getPeptideName(b);
if (bName == null || aName.equals(bName))
continue;
int bP1 = bSpec.getFirstPosition();
int bP2 = bSpec.getLastPosition();
int bPepSize = bP2 - bP1 + 1;
// if < min size => ignore
if (bPepSize < peptideMinSize)
continue;
// if b is on the left side of a with or without overlap
if (aP1 > bP1 && aP2 > bP2) {
int overlap = bP2 - aP1 + 1;
if (overlap < 0)
overlap = 0;
if (aPepSize + bPepSize - overlap >= minCoverage) {
if (debug == true) {
System.out.println("Found 2 non inclusive peptides on " + aIsoAC + ":" + aName + " at " + aP1 + "-" + aP2 + " and " + bName + " at " + bP1 + "-" + bP2 + " with overlap " + overlap + " and coverage " + (aPepSize + bPepSize - overlap));
}
return true;
}
}
// we get here in the following cases:
// 1) a includes b or a is included in b => ignore
// or
// 2) b is on the right side of a with or without overlap
// this case is met later on going iterating until a and b are swapped
// (symmetric situation for a and b)
}
}
}
}
return false;
}
use of org.nextprot.api.core.domain.annotation.Annotation in project nextprot-api by calipho-sib.
the class HashableAnnotationComparator method compare.
@Override
public int compare(final Annotation a1, final Annotation a2) {
if (getReferencedAnnotationContainer(a1) == null || getReferencedAnnotationContainer(a2) == null) {
if (getReferencedAnnotationContainer(a1) == getReferencedAnnotationContainer(a2))
return 0;
else if (getReferencedAnnotationContainer(a1) == null)
return 1;
else
return -1;
}
Annotation refAnnot1 = getReferencedAnnotation(getAnnotationHash(a1));
Annotation refAnnot2 = getReferencedAnnotation(getAnnotationHash(a2));
return referencedAnnotationComparator.compare(refAnnot1, refAnnot2);
}
use of org.nextprot.api.core.domain.annotation.Annotation in project nextprot-api by calipho-sib.
the class AnnotationUtilsTest method shouldcomputeIsoformsDisplayedAsSpecificForNonBinaryInteractionCase3.
@Test
public void shouldcomputeIsoformsDisplayedAsSpecificForNonBinaryInteractionCase3() {
// BinaryInteraction with 1 isoform, 1 targetingIsoform record => should return 0 isoformDiplayed as specific
int isoCount = 1;
Map<String, AnnotationIsoformSpecificity> targetIsoformMap = new HashMap<>();
AnnotationIsoformSpecificity spec1 = new AnnotationIsoformSpecificity();
spec1.setIsoformAccession("iso1");
spec1.setSpecificity("SPECIFIC");
targetIsoformMap.put("iso1", spec1);
Annotation annot = mock(Annotation.class);
when(annot.getAPICategory()).thenReturn(AnnotationCategory.GO_MOLECULAR_FUNCTION);
when(annot.getTargetingIsoformsMap()).thenReturn(targetIsoformMap);
List<String> result = AnnotationUtils.computeIsoformsDisplayedAsSpecific(annot, isoCount);
assertEquals(0, result.size());
}
use of org.nextprot.api.core.domain.annotation.Annotation in project nextprot-api by calipho-sib.
the class AnnotationUtilsTest method shouldNotReturnAnnotationIfOusideTheRange.
@Test
public void shouldNotReturnAnnotationIfOusideTheRange() {
String isoName = "iso-1";
Annotation a1 = mock(Annotation.class);
when(a1.isAnnotationPositionalForIsoform(isoName)).thenReturn(true);
when(a1.getStartPositionForIsoform(isoName)).thenReturn(5);
when(a1.getEndPositionForIsoform(isoName)).thenReturn(9);
assertTrue(AnnotationUtils.filterAnnotationsBetweenPositions(10, 20, Arrays.asList(a1), isoName).isEmpty());
}
Aggregations