Skip to content
Snippets Groups Projects
Commit 572ebf46 authored by juanf's avatar juanf
Browse files

SSDM-1922: CORE - YEASTLAB: Delete repeated annotations

SVN: 34069
parent 6682cd3f
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,7 @@ import xml.etree.ElementTree as ET ...@@ -10,7 +10,7 @@ import xml.etree.ElementTree as ET
UPDATES_ENABLED = False UPDATES_ENABLED = False
sampleTypesToVerify = ["YEAST","POMBE"] sampleTypesToVerify = ["YEAST","POMBE"]
logLevelsToPrint = ["ERROR", "REPORT", "MANUAL-FIX", "UPDATED"] #INFO not included, use it for debug only logLevelsToPrint = ["ERROR", "REPORT", "MANUAL-FIX", "UPDATED", "LOSTDEBUG"] #INFO not included, use it for debug only
## ##
## Logging ## Logging
...@@ -93,6 +93,7 @@ def process(tr): ...@@ -93,6 +93,7 @@ def process(tr):
log("REPORT", "UPDATABLE " + str(numberOfCanBeUpdated) + " SAMPLES!") log("REPORT", "UPDATABLE " + str(numberOfCanBeUpdated) + " SAMPLES!")
log("REPORT", "REQUIRED " + str(numberOfManualFixes-1) + " MANUAL FIXES!") #-1 For the Header log("REPORT", "REQUIRED " + str(numberOfManualFixes-1) + " MANUAL FIXES!") #-1 For the Header
log("REPORT", "FINISH VERIFICATION REPORT!") log("REPORT", "FINISH VERIFICATION REPORT!")
# raise Exception("Test");
def verify(tr, sample): def verify(tr, sample):
newAnnotations = []; newAnnotations = [];
...@@ -103,7 +104,7 @@ def verify(tr, sample): ...@@ -103,7 +104,7 @@ def verify(tr, sample):
requiredAnnotationsFromParents = getRequiredAnnotationsFromParents(sample) #To detect case 5 requiredAnnotationsFromParents = getRequiredAnnotationsFromParents(sample) #To detect case 5
if annotationsRoot is not None: if annotationsRoot is not None:
for annotation in annotationsRoot: for annotation in annotationsRoot:
if getValueOrNull(annotation.attrib, "PLASMID_RELATIONSHIP") == "LOT": #Skip auto generated if getValueOrNull(annotation.attrib, "PLASMID_RELATIONSHIP") == "LOT": #Skip auto generated lot
continue; continue;
annotatedSampleIdentifier = annotation.attrib["identifier"] #Identifier from annotated sample annotatedSampleIdentifier = annotation.attrib["identifier"] #Identifier from annotated sample
requiredAnnotationsFound[annotatedSampleIdentifier] = True requiredAnnotationsFound[annotatedSampleIdentifier] = True
...@@ -144,6 +145,7 @@ def verify(tr, sample): ...@@ -144,6 +145,7 @@ def verify(tr, sample):
if lostPermId is None: if lostPermId is None:
raise Exception("Lost PermId Not Found"); raise Exception("Lost PermId Not Found");
newAnnotations.append({ "permId" : lostPermId, "identifier" : parentAnnotationIdentifier, "PLASMID_RELATIONSHIP" : "LOT" }); newAnnotations.append({ "permId" : lostPermId, "identifier" : parentAnnotationIdentifier, "PLASMID_RELATIONSHIP" : "LOT" });
log("LOSTDEBUG", "Lost debug " + str(requiredAnnotationsFromParents));
log("AUTO-FIX-2", "CASE 2 - MISSING LOST ANNOTATIONS ON SAMPLE: " + sample.getSampleIdentifier() + " FOR LOST ANNOTATION: " + parentAnnotationIdentifier + " PRESENT INTO ONE OF THE PARENTS") log("AUTO-FIX-2", "CASE 2 - MISSING LOST ANNOTATIONS ON SAMPLE: " + sample.getSampleIdentifier() + " FOR LOST ANNOTATION: " + parentAnnotationIdentifier + " PRESENT INTO ONE OF THE PARENTS")
#4 Check parents from contained #4 Check parents from contained
expectedParents = getContainedFromAnnotations(sample) expectedParents = getContainedFromAnnotations(sample)
...@@ -159,7 +161,7 @@ def verify(tr, sample): ...@@ -159,7 +161,7 @@ def verify(tr, sample):
if newAnnotationsReady and UPDATES_ENABLED: if newAnnotationsReady and UPDATES_ENABLED:
global numberOfCanBeUpdated; global numberOfCanBeUpdated;
numberOfCanBeUpdated = numberOfCanBeUpdated + 1; numberOfCanBeUpdated = numberOfCanBeUpdated + 1;
log("UPDATED", str(newAnnotations)) log("UPDATED", "Updated: " + sample.getSampleIdentifier() + " - "+ str(newAnnotations))
sample = tr.makeSampleMutable(sample); sample = tr.makeSampleMutable(sample);
#1. Create new annotations XML #1. Create new annotations XML
newAnnotationsRoot = ET.Element("root"); newAnnotationsRoot = ET.Element("root");
...@@ -168,8 +170,16 @@ def verify(tr, sample): ...@@ -168,8 +170,16 @@ def verify(tr, sample):
for newAttribute in newAnnotation: for newAttribute in newAnnotation:
newAnnotationsNode.attrib[newAttribute] = newAnnotation[newAttribute]; newAnnotationsNode.attrib[newAttribute] = newAnnotation[newAttribute];
if getValueOrNull(newAnnotation, "PLASMID_RELATIONSHIP") == "LOT": #2. Add LOST parents if getValueOrNull(newAnnotation, "PLASMID_RELATIONSHIP") == "LOT": #2. Add LOST parents
sample.getParentSampleIdentifiers().add(newAnnotation["identifier"]); log("LOSTDEBUG", "Adding lost Parent " + newAnnotation["identifier"]);
parents = sample.getParentSampleIdentifiers();
parents.add(newAnnotation["identifier"]);
sample.setParentSampleIdentifiers(parents);
log("LOSTDEBUG", "Adding lost Parent list" + str(sample.getParentSampleIdentifiers()));
sample.setPropertyValue("ANNOTATIONS_STATE", ET.tostring(newAnnotationsRoot, encoding='utf-8')); sample.setPropertyValue("ANNOTATIONS_STATE", ET.tostring(newAnnotationsRoot, encoding='utf-8'));
elif not newAnnotationsReady:
log("UPDATED", "Not ready for update: " + sample.getSampleIdentifier());
else:
log("UPDATED", "Not updated but ready:" + sample.getSampleIdentifier() + " - "+ str(newAnnotations))
def areAnnotationDuplicated(sample): def areAnnotationDuplicated(sample):
annotated = {}; #They should be parents of the sample and not been missing annotated = {}; #They should be parents of the sample and not been missing
...@@ -223,7 +233,8 @@ def getRequiredAnnotationsFromParents(sample): ...@@ -223,7 +233,8 @@ def getRequiredAnnotationsFromParents(sample):
if parentAnnotationsRoot is not None: if parentAnnotationsRoot is not None:
for parentAnnotation in parentAnnotationsRoot: for parentAnnotation in parentAnnotationsRoot:
parentAnnotationIdentifier = parentAnnotation.attrib["identifier"] parentAnnotationIdentifier = parentAnnotation.attrib["identifier"]
if "/FRP" in parentAnnotationIdentifier: #Only require Plasmids annotationType = getValueOrNull(parentAnnotation.attrib, "PLASMID_RELATIONSHIP");
if "/FRP" in parentAnnotationIdentifier and ((annotationType is None) or (annotationType is not "LOT")): #Only require Plasmids not LOT
requiredAnnotationsFromParents[parentAnnotationIdentifier] = False requiredAnnotationsFromParents[parentAnnotationIdentifier] = False
return requiredAnnotationsFromParents return requiredAnnotationsFromParents
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment