Initial port to python3
[htsworkflow.git] / htsworkflow / pipelines / genomemap.py
index 0dc4919aaff4208c2254e77ba6d178caa6515f65..87d65eba01ff3ba51e906398b26cc385a5985c81 100644 (file)
@@ -3,6 +3,7 @@
 from glob import glob
 import os
 import collections
+from htsworkflow.pipelines import ElementTree
 
 vldInfo = collections.namedtuple('vldInfo', 'name is_link')
 
@@ -16,7 +17,7 @@ class GenomeMap(collections.MutableMapping):
         return len(self._contigs)
 
     def __iter__(self):
-        return self._contigs.iterkeys()
+        return iter(self._contigs.keys())
 
     def __getitem__(self, name):
         return self._contigs[name]
@@ -67,7 +68,7 @@ class GenomeMap(collections.MutableMapping):
 
         genome = guess_genome(sizes)
 
-        for contig, basese in sizes.items():
+        for contig, basese in list(sizes.items()):
             name = filenames[contig]
             self._contigs[name] = genome + '/' + name
 
@@ -77,8 +78,13 @@ def guess_genome(contig_sizes):
 
     genomes = {'chr1': {197195432: 'mm9',
                         247249719: 'hg19',
+                        200994015: 'galGal3',
                         },
-               'chrI': {230218, 'sacCer3'},
+               'chrI': {230218: 'sacCer3',
+                        15072421: 'elegans190'},
+               '1': {60348388: 'danRe6'},
+               'chr2L': { 23011544: 'dm3' },
+
                }
 
     for key in genomes:
@@ -87,6 +93,6 @@ def guess_genome(contig_sizes):
             return genomes[key][size]
 
     if len(contig_sizes) == 1:
-        return os.path.splitext(contig_sizes.keys()[0])[0]
+        return os.path.splitext(list(contig_sizes.keys())[0])[0]
 
     raise RuntimeError("Unrecognized genome type, update detection code.")