예제 #1
0
 def test_io(self):
     vac_file = self.__build_vac_file()
     self.assertTupleEqual((3, 3), Vac.read_header(vac_file))
     self.assertTupleEqual((2000000000, 0, [3, 2, 1, 0]),
                           Vac.read_snv_record(vac_file))
     self.assertTupleEqual((2000000002, 1, [0, 1, 2, 3]),
                           Vac.read_snv_record(vac_file))
     self.assertTupleEqual((2000000004, 2, [1, 1, 1, 1]),
                           Vac.read_snv_record(vac_file))
     self.assertTupleEqual((2000000001, [10, 1], ['A', 'ATCG']),
                           Vac.read_indel_record(vac_file))
     self.assertTupleEqual((2000000003, [10, 1], ['AT', 'ATCGT']),
                           Vac.read_indel_record(vac_file))
     self.assertTupleEqual((2000000005, [10, 10, 0], ['AAAA', 'ATCG', 'A']),
                           Vac.read_indel_record(vac_file))
     self.assertRaises(EOFError, lambda: Vac.read_snv_record(vac_file))
예제 #2
0
파일: variant.py 프로젝트: rtcz/varlock
    def __init__(self, vac_filename: str, fai: FastaIndex):
        """
        :param vac_filename:
        :param fai:
        does not affect bases listed in VAC file
        """
        with open(vac_filename, 'rb') as vac_file:
            # read header
            self._snv_count, self._indel_count = Vac.read_header(vac_file)

        self._snv_file = open(vac_filename, 'rb')
        self._snv_file.seek(Vac.HEADER_SIZE)

        self._indel_file = open(vac_filename, 'rb')
        self._indel_file.seek(Vac.HEADER_SIZE +
                              self._snv_count * Vac.SNV_RECORD_SIZE)

        self._fai = fai
        self._counter = 0

        # init iteration
        self._snv_variant = self._read_snv()
        self._indel_variant = self._read_indel()