Skip to content

Commit

Permalink
Add component retrieval by local identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
pablocarb committed Jan 17, 2020
1 parent 86984b1 commit 1c2b5b7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions synbioParts.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ def _defineParts(doc,parts,getSequences=True,backtranslate=True,codontable='Eeco
promoter.roles = sboldef[ptype]
promoter.setPropertyValue('http://purl.org/dc/terms/description',part)
try:
promoter = doc.getComponentDefinition(part)
if part not in doc.componentDefinitions:
promoter = doc.getComponentDefinition(part)
except:
doc.addComponentDefinition(promoter)
try:
Expand All @@ -134,12 +135,13 @@ def _defineParts(doc,parts,getSequences=True,backtranslate=True,codontable='Eeco
origin.setPropertyValue('http://purl.org/dc/terms/description',part)
origin.name = name
try:
origin = doc.getComponentDefinition(part)
if part not in doc.componentDefinitions:
origin = doc.getComponentDefinition(part)
except:
doc.addComponentDefinition(origin)
elif ptype == 'gene' or ptype == 'resistance':
if getSequences:
# try to get the part from the repository
# try to get the part from the repository by its URI, if given
try:
repo.pull(part,doc)
origin = doc.getComponentDefinition(part)
Expand Down Expand Up @@ -178,7 +180,9 @@ def _defineParts(doc,parts,getSequences=True,backtranslate=True,codontable='Eeco
origin.setPropertyValue('http://purl.org/dc/terms/description',part)
origin.name = name
try:
origin = doc.getComponentDefinition(part)
# Check if already exists, using either the identifier or the URI
if part not in doc.componentDefinitions:
origin = doc.getComponentDefinition(part)
except:
doc.addComponentDefinition(origin)
return doc
Expand Down

0 comments on commit 1c2b5b7

Please sign in to comment.