Пример #1
0
    def test_to_vcf_row_from_file(self):
        def _split_multiallelic(rows):
            for row in rows:
                for alt in row.ALT.split(','):
                    kwds = {f:getattr(row,f) for f in VCF_FIELDS}
                    kwds['ALT'] = alt
                    kwds['INFO'] = '.'
                    kwds['FORMAT'] = None
                    kwds['SAMPLES'] = None
                    yield str(VCFRow(**kwds))

        reader = VCFReader(pkg_file('genomvar.test','data/example1.vcf'))
        variants = list(reader.iter_vrt(
            parse_info=False,parse_samples=False))
        rows = [str(self.writer.get_row(v)) for v in variants]
        
        for r1, r2 in zip(
                _split_multiallelic(reader.iter_rows()), rows):
            if 'AG\tAGG' in r1: # stripping 
                continue
            self.assertEqual(r1,r2)
        reader.close()
Пример #2
0
 def test_change_of_attributes(self):
     reader = VCFReader(
         pkg_file('genomvar.test','data/example1.vcf'))
     vrt = list(reader.iter_vrt())[0]
     self.assertEqual(str(self.writer.get_row(vrt)),
                      'chr24\t23\t1\tAG\tA\t100\tPASS\t.')
     vrt2 = copy.deepcopy(vrt)
     vrt2.attrib['id'] = '.'
     vrt2.attrib['qual'] = '.'
     vrt2.attrib['filter'] = '.'
     self.assertEqual(str(self.writer.get_row(vrt2)),
                      'chr24\t23\t.\tAG\tA\t.\t.\t.')
     self.assertEqual(str(self.writer.get_row(vrt2, id='.', qual='.', filter='.')),
                      'chr24\t23\t.\tAG\tA\t.\t.\t.')
     
     vrt3 = copy.deepcopy(vrt)
     vrt3.attrib['id'] = None
     vrt3.attrib['qual'] = None
     vrt3.attrib['filter'] = None
     self.assertEqual(str(self.writer.get_row(vrt3)),
                      'chr24\t23\t.\tAG\tA\t.\t.\t.')
     reader.close()
     reader.close()