[med-svn] r22176 - trunk/community/edam

Steffen Möller moeller at moszumanska.debian.org
Wed Jun 22 21:33:01 UTC 2016


Author: moeller
Date: 2016-06-22 21:33:01 +0000 (Wed, 22 Jun 2016)
New Revision: 22176

Modified:
   trunk/community/edam/registry-tool.py
Log:
Increased flexibility for metadata reference YAML format representation

Modified: trunk/community/edam/registry-tool.py
===================================================================
--- trunk/community/edam/registry-tool.py	2016-06-22 20:26:23 UTC (rev 22175)
+++ trunk/community/edam/registry-tool.py	2016-06-22 21:33:01 UTC (rev 22176)
@@ -15,7 +15,8 @@
            'rdfs':"http://www.w3.org/2000/01/rdf-schema#",
            'oboInOwl': "http://www.geneontology.org/formats/oboInOwl#"}
 
-EDAM_DOC = doc = etree.parse("/home/hmenager/edamontology/EDAM_1.13_dev.owl")
+#EDAM_DOC = doc = etree.parse("/home/hmenager/edamontology/EDAM_1.13_dev.owl")
+EDAM_DOC = doc = etree.parse("EDAM.owl")
 
 def check_id(label, axis):
     xpath_query = "//owl:Class[translate(rdfs:label/text(),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')=translate('" + label\
@@ -46,18 +47,43 @@
     m = re.match('^([0-9]+:)?(.*)-[^-]+$', version_debian)
     version_upstream = m.groups()[m.lastindex-1]
     edam = yaml.load(open(edam_path))
-    metadata = yaml.load(open(metadata_path))
     resource = {'name': control.get('Source'),
                 'homepage': control.get('Homepage'),
                 'version': version_debian,
-                'collection': 'debian',
+                'collection': 'DebianMed',
                 'interface': {}, #TODO
                 'description': control.get('Description'),
                 'topic': [{'uri':check_id(topic_label,'topic')} for topic_label in edam.get('topic')],
                 'sourceRegistry': '',
-                'publications': [{'publicationsOtherID': [i['DOI'] for i in metadata['Reference']]}],
                 'function': []
                }
+    metadata = yaml.load(open(metadata_path))
+    resource['publications'] = {}
+
+    try:
+        print "@@@@@@@@@@@@@@@"
+	print metadata['Reference']['DOI']
+        print "@@@@@@@@@@@@@@@"
+        resource['publications']['publicationsPrimaryID'] = metadata['Reference']['DOI'],
+        print "@@@@@@@@@@@@@@@"
+        print resource['publications']['publicationsPrimaryID']
+        print "@@@@@@@@@@@@@@@"
+    except TypeError:
+        print "TypeError 1"
+        try:
+            resource['publications']['publicationsPrimaryID'] = metadata['Reference'][0]['DOI'],
+	    if len( metadata['Reference'])>1:
+                resource['publications']['publicationsOtherID'] = []
+                for pos in range(1,len(metadata['Reference'])):
+                    try:
+                        resource['publications']['publicationsOtherID'] = metadata['Reference'][pos]['DOI']
+                    except KeyError:
+                        print "No DOI at pos %d\n" % pos
+        except KeyError:
+            resource['publications']['publicationsPrimaryID'] = "None"
+    except KeyError:
+        resource['publications']['publicationsPrimaryID'] = "None"
+
     for scope in edam['scopes']:
         function = {}
         function['functionHandle'] = scope['name']




More information about the debian-med-commit mailing list