Esempio n. 1
0
    def test_write(self):
        """
        Check if VCFtools allele frequencies are correctly written to
        the output file.
        """
        with open(self.__input_file) as input_file, open(self.__output_file, "w") as output_file:
            writer = Writer(output_file)
            for record in Reader(input_file).variants():
                writer.write(record)

        # compare the test output file to the original one
        with open(self.__input_file) as input_file, open(self.__output_file) as output_file:
            for x, y in zip(Reader(input_file).variants(), Reader(output_file).variants()):
                self.assertEqual(x, y)

        os.unlink(self.__output_file)
Esempio n. 2
0
    def test_variants(self):
        """
        Check if SortedReader reads and sorts variants.
        """
        with open(self.__unsorted) as unsorted_input, open(self.__output, "w") as sorted_output:
            reader = SortedReader(unsorted_input)
            writer = Writer(sorted_output)
            for chromosome in reader.variants:
                for variant in reader.variants[chromosome]:
                    writer.write(variant)

        # compare the original sorted file and the produced one
        with open(self.__sorted) as original_sorted, open(self.__output) as produced_sorted:
            for x, y in zip(Reader(original_sorted).variants(), Reader(produced_sorted).variants()):
                self.assertEqual(x, y)

        os.unlink(self.__output)
Esempio n. 3
0
    def test_write(self):
        """
        Check if VCFtools allele frequencies are correctly written to
        the output file.
        """
        with open(self.__input_file) as input_file, \
                open(self.__output_file, 'w') as output_file:
            writer = Writer(output_file)
            for record in Reader(input_file).variants():
                writer.write(record)

        # compare the test output file to the original one
        with open(self.__input_file) as input_file, \
                open(self.__output_file) as output_file:
            for x, y in zip(
                    Reader(input_file).variants(),
                    Reader(output_file).variants()):
                self.assertEqual(x, y)
Esempio n. 4
0
    def test_variants(self):
        """
        Check if SortedReader reads and sorts variants.
        """
        with open(self.__unsorted) as unsorted_input, \
                open(self.__output, 'w') as sorted_output:
            reader = SortedReader(unsorted_input)
            writer = Writer(sorted_output)
            for chromosome in reader.variants:
                for variant in reader.variants[chromosome]:
                    writer.write(variant)

        # compare the original sorted file and the produced one
        with open(self.__sorted) as original_sorted, \
                open(self.__output) as produced_sorted:
            for x, y in zip(
                    Reader(original_sorted).variants(),
                    Reader(produced_sorted).variants()):
                self.assertEqual(x, y)