@@ -154,12 +154,13 @@ def dataSource(rowobj):
154154 val = vals [list (vals .keys ())[colnum ]]
155155
156156 datasource_dict = {'GenBank' :{'Replace Example' :'https://www.ncbi.nlm.nih.gov/nuccore/{REPLACE_HERE}' , 'Literal Part' :'TRUE' , 'Namespace' :'https://www.ncbi.nlm.nih.gov/nuccore' , 'Prefix' :'gb' },
157- 'PubMed' :{'Replace Example' :'https://pubmed.ncbi.nlm.nih.gov/{REPLACE_HERE}/' , 'Literal Part' :'FALSE' , 'Namespace' :'' , 'Prefix' :'' },
157+ 'PubMed' :{'Replace Example' :'https://pubmed.ncbi.nlm.nih.gov/{REPLACE_HERE}/' , 'Literal Part' :'FALSE' , 'Namespace' :'' , 'Prefix' :'' , 'derived_from' : '' },
158158 'iGEM registry' :{'Replace Example' :'http://parts.igem.org/Part:{REPLACE_HERE}' , 'Literal Part' :'TRUE' , 'Namespace' :'http://parts.igem.org' , 'Prefix' :'igem' },
159159 'AddGene' :{'Replace Example' :'https://www.addgene.org/{REPLACE_HERE}/' , 'Literal Part' :'FALSE' , 'Namespace' :'' , 'Prefix' :'' },
160160 'Seva plasmids' :{'Replace Example' :'http://www.sevahub.es/public/Canonical/{REPLACE_HERE}/1' , 'Literal Part' :'TRUE' , 'Namespace' :'' , 'Prefix' :'' },
161161 'Tax_id' :{'Replace Example' :'https://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?mode=Info&id={REPLACE_HERE}' , 'Literal Part' :'FALSE' , 'Namespace' :'' , 'Prefix' :'' },
162162 'SynBioHub' :{'Replace Example' :'{REPLACE_HERE}' , 'Literal Part' :'TRUE' , 'Namespace' :'' , 'Prefix' :'' },
163+ 'URL' :{'Replace Example' :'{REPLACE_HERE}' , 'Literal Part' :'FALSE' , 'Namespace' :val , 'Prefix' :'' , 'derived_from' :f'{ val } /{ rowobj .obj .displayId } ' },
163164 'Local Sequence File' :{'Replace Example' :'' , 'Literal Part' :'FALSE' , 'Namespace' :'' , 'Prefix' :'' },
164165 'URL for GenBank file' :{'Replace Example' :'{REPLACE_HERE}' , 'Literal Part' :'TRUE' , 'Namespace' :'' , 'Prefix' :'' },
165166 'URL for FASTA file' :{'Replace Example' :'{REPLACE_HERE}' , 'Literal Part' :'TRUE' , 'Namespace' :'' , 'Prefix' :'' }
@@ -168,28 +169,37 @@ def dataSource(rowobj):
168169 literal = datasource_dict [pref ]['Literal Part' ]
169170
170171 if literal == 'FALSE' :
171- rowobj .obj .wasDerivedFrom = val
172+ if len (datasource_dict [pref ]['derived_from' ]) > 0 :
173+ rowobj .obj .derived_from = [datasource_dict [pref ]['derived_from' ]]
174+ ns = datasource_dict [pref ]['Namespace' ]
175+ if len (ns ) > 0 :
176+ if len (datasource_dict [pref ]['Prefix' ]) > 0 :
177+ if datasource_dict [pref ]['Prefix' ] not in rowobj .doc_pref_terms :
178+ rowobj .doc .bind (datasource_dict [pref ]['Prefix' ], ns )
179+ rowobj .doc_pref_terms .append (datasource_dict [pref ]['Prefix' ])
180+
181+ old_id = rowobj .obj .identity
182+ rowobj .doc .change_object_namespace ([rowobj .obj ], ns )
183+ new_id = rowobj .obj .identity
184+ rowobj .data_source_id_to_update [old_id ] = new_id
172185
173186 else :
174187 ns = datasource_dict [pref ]['Namespace' ]
175188 if len (ns ) > 0 :
176- if datasource_dict [pref ]['Prefix' ] not in rowobj .doc_pref_terms :
177- rowobj .doc .bind (datasource_dict [pref ]['Prefix' ], ns )
178- rowobj .doc_pref_terms .append (datasource_dict [pref ]['Prefix' ])
189+ if len (datasource_dict [pref ]['Prefix' ]) > 0 :
190+ if datasource_dict [pref ]['Prefix' ] not in rowobj .doc_pref_terms :
191+ rowobj .doc .bind (datasource_dict [pref ]['Prefix' ], ns )
192+ rowobj .doc_pref_terms .append (datasource_dict [pref ]['Prefix' ])
179193
180194 old_id = rowobj .obj .identity
181195 rowobj .doc .change_object_namespace ([rowobj .obj ], ns )
182196 new_id = rowobj .obj .identity
183197 rowobj .data_source_id_to_update [old_id ] = new_id
184198 if val != rowobj .obj .display_id :
185- # rowobj.data_source_id_to_update[rowobj.obj.identity] = {'current_id': rowobj.obj.display_id,
186- # 'update_id': val}
187199 new_identity = str (rowobj .obj .identity ).replace (rowobj .obj .display_id , helpers .check_name (val ))
188200 id_map = {rowobj .obj .identity :new_identity }
189- # print(str(id_map))
190201 rowobj .obj .set_identity (new_identity )
191202 rowobj .obj .update_all_dependents (id_map ) # this function doesn't yet do everything it should
192- warnings .warn ('not yet possible to have display id that is different from source value' )
193203 rowobj .data_source_id_to_update [old_id ] = new_identity
194204
195205def sequence (rowobj ):
0 commit comments