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 = []