Generate a gerald config file, even if the genome is unknown
authorDiane Trout <diane@caltech.edu>
Wed, 18 Mar 2009 19:20:49 +0000 (19:20 +0000)
committerDiane Trout <diane@caltech.edu>
Wed, 18 Mar 2009 19:20:49 +0000 (19:20 +0000)
as it makes it easier to edit the wrong config file and manually launch
an analysis.

htsworkflow/pipelines/genome_mapper.py

index a8ea871609d8842cede6097cd91f970e121d4a61..d29e44640b233c6cdc201e24c26ae5c781ae2891 100644 (file)
@@ -80,24 +80,28 @@ class constructMapperDict(object):
         Return the best match for key
         """
         elements = re.split("\|", key)
-          
-        if len(elements) == 1:
-            # we just the species name
-            # get the set of builds
-            builds = self.genome_dict[elements[0]]
+        
+        try:  
+            if len(elements) == 1:
+                # we just the species name
+                # get the set of builds
+                builds = self.genome_dict[elements[0]]
             
-            # sort build names the way humans would
-            keys = builds.keys()
-            keys.sort(cmp=alphanum)
+                # sort build names the way humans would
+                keys = builds.keys()
+                keys.sort(cmp=alphanum)
             
-            # return the path from the 'last' build name
-            return builds[keys[-1]]
+                # return the path from the 'last' build name
+                return builds[keys[-1]]
                         
-        elif len(elements) == 2:
-            # we have species, and build name
-            return self.genome_dict[elements[0]][elements[1]]
-        else:
-            raise KeyError("Unrecognized key")
+            elif len(elements) == 2:
+                # we have species, and build name
+                return self.genome_dict[elements[0]][elements[1]]
+            else:
+                raise KeyError("Unrecognized key")
+        except KeyError, e:
+            logging.error('Unrecognized genome identifier: %s' % str((elements),))
+            return "NoGenomeAvailable"
         
     def keys(self):
         keys = []