You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be useful to have an inverted recursive copy method. What this is used for is when you change an object that is referenced by other objects, it would work backwards on all the references making a copy of the referring objects and updating the references to the new copy. It could copy into a new namespace or a new version. It could also add wasDerivedFrom links to the original. Here is a rough outline of the code (note the map starts with the URI of the old object and the new object that the copy should start from):
UpdateSBOL(SBOLDocument doc, HashMap<URI,URI> map) {
for (ComponentDefinition cd : doc.getRootComponentDefinitions) {
UpdateSBOLRecurse(doc, cd, map);
}
}
UpdateSBOLRecurse(SBOLDocument doc, cd, HashMap<URI,URI> map) {
ComponentDefinition copyCD = null;
for (Component comp : cd.getComponents()) {
if (map.get(comp.getDefinitionURI())!=null) {
if (copyCD == null) {
copyCD = doc.createCopy(cd,boostNamespace,null,null);
// Add wasDerivedFrom / wasGeneratedBy links from copyCD to cd
}
Component copyComp = copyCD.getComponent(comp.getDisplayId());
copyComp.setDefinition(map.get(comp.getDefinitionURI());
map.add(cd.getIdentity(),copyCD.getIdentity());
} else {
UpdateSBOL(doc, comp.getDefinition(), map);
if (map.get(comp.getDefinitionURI())!=null) {
if (copyCD == null) {
copyCD = doc.createCopy(cd,boostNamespace,null,null);
// Add wasDerivedFrom / wasGeneratedBy links from copyCD to cd
}
Component copyComp = copyCD.getComponent(comp.getDisplayId());
copyComp.setDefinition(map.get(comp.getDefinitionURI());
map.add(cd.getIdentity(),copyCD.getIdentity());
}
}
}
If (copyCD != null) {
String newSeq = copyCD.getImpliedNucleicAcidSequence);
Sequence seq = doc.createSequence(…, newSeq)
copyCD.clearSequences();
copyCD.addSequence(seq);
}
}
The text was updated successfully, but these errors were encountered:
It would be useful to have an inverted recursive copy method. What this is used for is when you change an object that is referenced by other objects, it would work backwards on all the references making a copy of the referring objects and updating the references to the new copy. It could copy into a new namespace or a new version. It could also add wasDerivedFrom links to the original. Here is a rough outline of the code (note the map starts with the URI of the old object and the new object that the copy should start from):
UpdateSBOL(SBOLDocument doc, HashMap<URI,URI> map) {
for (ComponentDefinition cd : doc.getRootComponentDefinitions) {
UpdateSBOLRecurse(doc, cd, map);
}
}
UpdateSBOLRecurse(SBOLDocument doc, cd, HashMap<URI,URI> map) {
ComponentDefinition copyCD = null;
for (Component comp : cd.getComponents()) {
if (map.get(comp.getDefinitionURI())!=null) {
if (copyCD == null) {
copyCD = doc.createCopy(cd,boostNamespace,null,null);
// Add wasDerivedFrom / wasGeneratedBy links from copyCD to cd
}
Component copyComp = copyCD.getComponent(comp.getDisplayId());
copyComp.setDefinition(map.get(comp.getDefinitionURI());
map.add(cd.getIdentity(),copyCD.getIdentity());
} else {
UpdateSBOL(doc, comp.getDefinition(), map);
if (map.get(comp.getDefinitionURI())!=null) {
if (copyCD == null) {
copyCD = doc.createCopy(cd,boostNamespace,null,null);
// Add wasDerivedFrom / wasGeneratedBy links from copyCD to cd
}
Component copyComp = copyCD.getComponent(comp.getDisplayId());
copyComp.setDefinition(map.get(comp.getDefinitionURI());
map.add(cd.getIdentity(),copyCD.getIdentity());
}
}
}
If (copyCD != null) {
String newSeq = copyCD.getImpliedNucleicAcidSequence);
Sequence seq = doc.createSequence(…, newSeq)
copyCD.clearSequences();
copyCD.addSequence(seq);
}
}
The text was updated successfully, but these errors were encountered: