Add get_accession_name to use collection name to find commonly used spreadsheet acces...
authorDiane Trout <diane@ghic.org>
Tue, 31 Mar 2015 22:35:52 +0000 (15:35 -0700)
committerDiane Trout <diane@ghic.org>
Tue, 31 Mar 2015 22:35:52 +0000 (15:35 -0700)
htsworkflow/submission/encoded.py

index 83f5826efbaf731ef4639d37c4a146bf0b803a43..26c07f7ab2c1889d60929f1844b417bad10aa07e 100644 (file)
@@ -258,6 +258,23 @@ class ENCODED:
 
         return self.prepare_url(ENCODED_SCHEMA_ROOT + object_type + '.json') + '#'
 
+    def get_accession_name(self, collection):
+        """Lookup common object accession name given a collection name.
+        """
+        collection_to_accession_name = {
+            '/experiments/': 'experiment_accession',
+            '/biosamples/': 'biosample_accession',
+            '/libraries/': 'library_accession',
+            '/replicates/': 'uuid',
+        }
+
+        accession_name = collection_to_accession_name.get(collection, None)
+        if accession_name is None:
+            raise RuntimeError("Update list of collection to accession names for %s",
+                               collection)
+
+        return accession_name
+
     def _is_encoded_object(self, obj):
         '''Test to see if an object is a JSON-LD object