PoonLab / covizu

Rapid analysis and visualization of coronavirus genome variation
https://filogeneti.ca/CoVizu/
MIT License
45 stars 20 forks source link

Error while running testGetMutations #454

Closed SandeepThokala closed 1 year ago

SandeepThokala commented 1 year ago
======================================================================
ERROR: testGetMutations (tests.test_batch_utils.TestGetMutations)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/sandeep/covizu/tests/test_batch_utils.py", line 105, in testGetMutations
    results = get_mutations(by_lineage)
  File "/home/sandeep/covizu/covizu/utils/batch_utils.py", line 263, in get_mutations
    samples = unpack_records(records)
  File "/home/sandeep/covizu/covizu/utils/batch_utils.py", line 26, in unpack_records
    for key, variant in records.items():
AttributeError: 'list' object has no attribute 'items'

----------------------------------------------------------------------

Tried to fix the above error by making the following changes

     def testGetMutations(self):
-        by_lineage = {
-            'B.1.1.171': [{
-                'covv_virus_name' : '',
-                'covv_accession_id' : '',
-                'covv_collection_date': '',
-                'covv_lineage' : 'B.1.1.171',
-                'diffs' : [
-                    tuple(['~', 240, 'T']),
-                    tuple(['~', 1436, 'T']),
-                ],
-                'missing' : []
-            }],
-            'B.1.265': [
-                {
-                    'covv_virus_name' : '',
-                    'covv_accession_id' : '',
-                    'covv_collection_date': '',
-                    'covv_lineage' : 'B.1.265',
-                    'diffs' : [
-                        tuple(['~', 240, 'T']),
-                        tuple(['~', 240, 'T']),
-                        tuple(['~', 240, 'T']),
-                        tuple(['~', 1436, 'T']),
-                    ],
-                    'missing' : []
-                },
-                {
-                    'covv_virus_name' : '',
-                    'covv_accession_id' : '',
-                    'covv_collection_date': '',
-                    'covv_lineage' : 'B.1.1.171',
-                    'diffs' : [
-                        tuple(['~', 240, 'T']),
-                        tuple(['~', 1436, 'T']),
-                    ],
-                    'missing' : []
-                }
-            ]
+        by_lineage = \
+        {'B.1.1.171':
+            {'~|240|T,~|1436|T':
+                [{'covv_virus_name' : '',
+                  'covv_accession_id' : '',
+                  'covv_collection_date': '',
+                  'covv_lineage' : 'B.1.1.171',
+                  'diffs' : [
+                      tuple(['~', 240, 'T']),
+                      tuple(['~', 1436, 'T']),
+                  ],
+                  'missing' : []
+                }]
+            },
+         'B.1.265':
+            {'~|240|T,~|1436|T':
+                [{'covv_virus_name' : '',
+                  'covv_accession_id' : '',
+                  'covv_collection_date': '',
+                  'covv_lineage' : 'B.1.265',
+                  'diffs' : [
+                      tuple(['~', 240, 'T']),
+                      tuple(['~', 240, 'T']),
+                      tuple(['~', 240, 'T']),
+                      tuple(['~', 1436, 'T']),
+                  ],
+                  'missing' : []
+                 },
+                 {'covv_virus_name' : '',
+                  'covv_accession_id' : '',
+                  'covv_collection_date': '',
+                  'covv_lineage' : 'B.1.1.171',
+                  'diffs' : [
+                      tuple(['~', 240, 'T']),
+                      tuple(['~', 1436, 'T']),
+                  ],
+                  'missing' : []
+                }]
+            }
         }

         results = get_mutations(by_lineage)

But faced the following error

======================================================================
FAIL: testGetMutations (tests.test_batch_utils.TestGetMutations)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/sandeep/covizu/tests/test_batch_utils.py", line 107, in testGetMutations
    self.assertEqual(self.expected, results)
AssertionError: {'B.1.1.171': [('~', 240, 'T'), ('~', 1436, 'T')], 'B.1[38 chars]T')]} != {'B.1.1.171': {('~', 240, 'T'): 1.0, ('~', 1436, 'T'): [58 chars]1.0}}
- {'B.1.1.171': [('~', 240, 'T'), ('~', 1436, 'T')],
?               ^                                 ^

+ {'B.1.1.171': {('~', 240, 'T'): 1.0, ('~', 1436, 'T'): 1.0},
?               ^               +++++                  ^^^^^^

-  'B.1.265': [('~', 240, 'T'), ('~', 1436, 'T')]}
?             ^                                 ^

+  'B.1.265': {('~', 240, 'T'): 1.0, ('~', 1436, 'T'): 1.0}}
?             ^               +++++                  ^^^^^ +

----------------------------------------------------------------------
ArtPoon commented 1 year ago

fix was merged into dev branch with recent PR