Commit 3465a4ff authored by Eric  DEVEAUD's avatar Eric DEVEAUD

initial port to yaml

parent e73dc52d
......@@ -187,31 +187,13 @@ def format_references(ref_lst):
name of unique identifier ressource or None
unique id or None
'''
DOIFLAGS = ['doi', 'pmid', 'pmcid']
tmp = item.lower()
found = False
for flag in DOIFLAGS:
idx = tmp.find(flag)
if idx != -1:
break
if idx == -1:
return item, None, None
citation = item[:idx].strip()
value = tmp[idx+len(flag):].replace(':', '').strip()
return citation, flag, value
ret = []
for ref in ref_lst:
if not ref:
continue
citation, flag, value = extract_doi(ref)
if flag is None:
flag = 'null'
if value is None:
value = 'null'
ret.append({ 'ID': value
, 'IDtype': flag
, 'citation' : citation
ret.append({ 'ID': ref['ID']
, 'IDtype': ref['idType']
, 'citation' : ref['title']
})
return ret
......@@ -311,30 +293,30 @@ def pack2mongo(pack):
returns a mongo package document
'''
#---- get infos from BIODOCS parsed holder
pack_name = pack['NAME']
pack_authors = [auth.strip() for auth in pack['AUTHORS'] if auth]
pack_description = ' '.join(pack['DESCRIPTION'])
pack_refs = format_references(pack['REF'])
pack_library = MTRUE if pack['LIBRARY'] else MFALSE
pack_private = MTRUE if pack['PRIVATE'] else MFALSE
hist = history_maker(pack['HISTORY'])
pack_name = pack['name']
pack_authors = [auth.strip() for auth in pack['authors'] if auth]
pack_description = ' '.join(pack['description'])
pack_refs = format_references(pack['references'])
pack_library = MTRUE if pack['library'] else MFALSE
pack_private = MTRUE if pack['private'] else MFALSE
hist = pack['history']
if hist is None:
error(WARN, pack_name, "invalid history")
hist = []
pack_history = hist
pack_id = "pack%s%s" %(ID_SEPARATOR, pack_name)
pack_collections = getOrigin(pack)
pack_collections = [pack['origin']]
#---- map gensoft Categories to edam relevant operation and topic terms
categories = updateCategories(pack['CATEGORIES'])
# categories = updateCategories(pack['categories'])
mongopack = { '_id': pack_id
, 'type': 'package'
, 'name' : pack_name
, 'description' : pack_description
, 'home' : pack['HOME']
, 'source' : pack['SOURCE']
, 'categories' : categories
, 'home' : pack['home']
, 'source' : pack['sources']
, 'categories' : pack['operations'] + pack['topics']
, 'authors' : pack_authors
, 'references' : pack_refs
, 'library' : pack_library
......@@ -630,17 +612,11 @@ if __name__ == '__main__':
mapper.update(getMapping('gensoft2edam.mapping'))
for biodoc in args:
print biodoc
try:
fh = open(biodoc, 'r')
except IOError as err:
error(WARN, 'biodoc', err)
continue
pack, progs =BiodocParser.Parser(fh)
fh.close()
#pack, progs =BiodocParser.Parser(fh)
pack = BiodocParser.get_packversion(biodoc)
mongo_pack = pack2mongo(pack)
pprint(mongo_pack)
if cmdline.test:
pprint(mongo_pack)
else:
......@@ -658,5 +634,6 @@ if __name__ == '__main__':
print ">>>>>>>>>>>>>>>> m_mobyle"
pprint(m_mobyle)
continue
insert2db(col, m_pack, m_progs, m_mobyle)
else:
insert2db(col, m_pack, m_progs, m_mobyle)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment