Beispiel #1
0
def main():
    import subprocess
    from nasp.nasp_objects import Genome, GenomeMeta

    commandline_args = _parse_args()
    external_nickname = commandline_args.name if commandline_args.name else GenomeMeta.generate_nickname_from_filename(
        commandline_args.external)
    #external_genome = Genome()
    #external_genome.import_fasta_file(commandline_args.external)
    generate_delta_file(commandline_args.nucmerpath,
                        commandline_args.nucmerargs,
                        commandline_args.deltafilterpath,
                        commandline_args.deltafilterargs, external_nickname,
                        commandline_args.reference, commandline_args.external)
    #franken_genome = Genome()
    #parse_delta_file(( external_nickname + ".filtered.delta" ), franken_genome, external_genome)
    #franken_genome.write_to_fasta_file(external_nickname + ".frankenfasta", "franken::")

    import pkg_resources
    nasptool_path = pkg_resources.resource_filename('nasp',
                                                    'nasptool_linux_64')
    with open(external_nickname + ".frankenfasta", 'w') as handle:
        return_code = subprocess.call([
            nasptool_path, "frankenfasta",
            external_nickname + ".filtered.delta"
        ],
                                      stdout=handle)
def main():
    import subprocess
    from nasp.nasp_objects import Genome, GenomeMeta

    commandline_args = _parse_args()
    external_nickname = commandline_args.name if commandline_args.name else GenomeMeta.generate_nickname_from_filename(
        commandline_args.external)
    #external_genome = Genome()
    #external_genome.import_fasta_file(commandline_args.external)
    generate_delta_file(commandline_args.nucmerpath, commandline_args.nucmerargs, commandline_args.deltafilterpath,
                        commandline_args.deltafilterargs, external_nickname, commandline_args.reference,
                        commandline_args.external)
    #franken_genome = Genome()
    #parse_delta_file(( external_nickname + ".filtered.delta" ), franken_genome, external_genome)
    #franken_genome.write_to_fasta_file(external_nickname + ".frankenfasta", "franken::")

    import pkg_resources
    nasptool_path = pkg_resources.resource_filename('nasp', 'nasptool_linux_64')
    with open(external_nickname + ".frankenfasta", 'w') as handle:
        return_code = subprocess.call([nasptool_path, "frankenfasta", external_nickname + ".filtered.delta"], stdout=handle)
Beispiel #3
0
class GenomeMetaTestCase(unittest.TestCase):
    def setUp(self):
        self.genome = GenomeMeta()

    # TODO: Should the side effect of setting an undefined nickname be tested?
    def test_set_file_path(self):
        expected = "foo"
        self.genome.set_file_path(expected)
        self.assertEqual(expected, self.genome.file_path())

    def test_set_file_type(self):
        expected = "foo"
        self.genome.set_file_type(expected)
        self.assertEqual(expected, self.genome.file_type())

    def test_set_nickname(self):
        expected = "foo"
        self.genome.set_nickname(expected)
        self.assertEqual(expected, self.genome.nickname())

    @unittest.skip("Not Implemented")
    def test_add_generators(self):
        pass

    def test_file_path(self):
        expected = "foo"
        self.assertIsNone(self.genome.file_path())
        self.genome.set_file_path(expected)
        self.assertEqual(expected, self.genome.file_path())

    def test_file_type(self):
        expected = "foo"
        self.assertIsNone(self.genome.file_type())
        self.genome.set_file_type(expected)
        self.assertEqual(expected, self.genome.file_type())

    def test_nickname(self):
        expected = "foo"
        self.assertIsNone(self.genome.nickname())
        self.genome.set_nickname(expected)
        self.assertEqual(expected, self.genome.nickname())
        pass

    def test_identifier(self):
        generators = ["bar", "baz", "quox"]
        nickname = "foo"
        self.assertIsNone(self.genome.identifier())
        self.genome.set_nickname(nickname)
        self.assertEqual(nickname, self.genome.identifier())
        self.genome.add_generators(generators)
        self.assertEqual(nickname + "::" + ",".join(generators), self.genome.identifier())

    def test_generate_nickname_from_filename(self):
        expected = "foo"
        paths = ["", "/", "/bar/baz/quox/" "bar/baz/quox/"]
        extensions = [".fRaNkEnFaStA", ".FaStA", ".fAs", ".VcF"]
        for extension in extensions:
            filename = expected + extension
            self.assertEqual(expected, self.genome.generate_nickname_from_filename(filename))

        for path in paths:
            filename = path + expected + ".vcf"
            self.assertEqual(expected, self.genome.generate_nickname_from_filename(filename))

    @unittest.skip("Duplicate of Genome.reverse_complement")
    def test_reverse_complement(dna_string):
        pass
Beispiel #4
0
class GenomeMetaTestCase(unittest.TestCase):
    def setUp(self):
        self.genome = GenomeMeta()

    # TODO: Should the side effect of setting an undefined nickname be tested?
    def test_set_file_path(self):
        expected = 'foo'
        self.genome.set_file_path(expected)
        self.assertEqual(expected, self.genome.file_path())

    def test_set_file_type(self):
        expected = 'foo'
        self.genome.set_file_type(expected)
        self.assertEqual(expected, self.genome.file_type())

    def test_set_nickname(self):
        expected = 'foo'
        self.genome.set_nickname(expected)
        self.assertEqual(expected, self.genome.nickname())

    @unittest.skip("Not Implemented")
    def test_add_generators(self):
        pass

    def test_file_path(self):
        expected = 'foo'
        self.assertIsNone(self.genome.file_path())
        self.genome.set_file_path(expected)
        self.assertEqual(expected, self.genome.file_path())

    def test_file_type(self):
        expected = 'foo'
        self.assertIsNone(self.genome.file_type())
        self.genome.set_file_type(expected)
        self.assertEqual(expected, self.genome.file_type())

    def test_nickname(self):
        expected = 'foo'
        self.assertIsNone(self.genome.nickname())
        self.genome.set_nickname(expected)
        self.assertEqual(expected, self.genome.nickname())
        pass

    def test_identifier(self):
        generators = ['bar', 'baz', 'quox']
        nickname = 'foo'
        self.assertIsNone(self.genome.identifier())
        self.genome.set_nickname(nickname)
        self.assertEqual(nickname, self.genome.identifier())
        self.genome.add_generators(generators)
        self.assertEqual(nickname + '::' + ','.join(generators),
                         self.genome.identifier())

    def test_generate_nickname_from_filename(self):
        expected = 'foo'
        paths = ['', '/', '/bar/baz/quox/' 'bar/baz/quox/']
        extensions = ['.fRaNkEnFaStA', '.FaStA', '.fAs', '.VcF']
        for extension in extensions:
            filename = expected + extension
            self.assertEqual(
                expected,
                self.genome.generate_nickname_from_filename(filename))

        for path in paths:
            filename = path + expected + '.vcf'
            self.assertEqual(
                expected,
                self.genome.generate_nickname_from_filename(filename))

    @unittest.skip("Duplicate of Genome.reverse_complement")
    def test_reverse_complement(dna_string):
        pass