Exemplo n.º 1
0
    def testReversedIntegration(self):
        # Reverse-complement the genome, insert stages in the reverse direction
        # and check that the product is still the same
        spec = dict.copy(self.spec)
        genome = SeqIO.read(spec['genome']['filename'], 'genbank')

        # Won't work on Windows - it won't allow the open file to be opened again
        rev_genome_file = tempfile.NamedTemporaryFile(delete=True)

        SeqIO.write(genome.reverse_complement(), rev_genome_file, 'genbank')
        rev_genome_file.flush()
        spec['genome']['filename'] = rev_genome_file.name

        # Calculate target location in reversed genome. Input locations are
        # 1-indexed, so need to add 1 to find equivalent reverse location.
        old_start_loc = spec['genome']['start']
        spec['genome']['start'] = len(genome) - spec['genome']['end'] + 1
        spec['genome']['end'] = len(genome) - old_start_loc + 1
        spec['genome']['strand'] = -spec['genome']['strand']

        assembly = InchwormAssembly.from_spec(spec)

        # Check that genome is reversed correctly
        self.assertEqual(str(assembly.genome.reverse_complement().seq.upper()),
                         str(self.assembly.genome.seq.upper()))

        # Check that the predicted product is correct
        for stage_num in range(5+1):
            self.assertEqual(' '.join(str(assembly.product(stage_num).reverse_complement().seq.upper())),
                             ' '.join(str(self.assembly.product(stage_num).seq.upper())))

        # Check that the generated product matches the predicted product
        # Equivalent to TestInchwormAssembly.testRunStages()
        run_stages_output = assembly.run_stages()
        for stage in range(1, 5+1):
            run_stages_product = run_stages_output[stage-1]['genome'].seq.upper()
            expected_product = assembly.product(stage).seq.upper()
            self.assertEqual(str(run_stages_product), str(expected_product))
Exemplo n.º 2
0
 def setUp(self):
     os.chdir(os.path.dirname(os.path.realpath(__file__)))
     self.spec = yaml.load(open('vioABEDC_input.yaml'))
     self.assembly = InchwormAssembly.from_spec(self.spec)