Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inverted recursive copy method #553

Open
cjmyers opened this issue Jul 19, 2018 · 0 comments
Open

Inverted recursive copy method #553

cjmyers opened this issue Jul 19, 2018 · 0 comments
Assignees
Labels
Milestone

Comments

@cjmyers
Copy link
Contributor

cjmyers commented Jul 19, 2018

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);
}
}

@cjmyers cjmyers self-assigned this Apr 7, 2019
@cjmyers cjmyers added the feature label Apr 7, 2019
@cjmyers cjmyers added this to the SBOL 2.5 milestone Apr 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant