Exemplo n.º 1
0
 def test_is_comment_string(self):
     # a sting is considered a comment if it non empty first char is "#"
     self.assertTrue(GRIMMReader.is_comment_string("#"))
     self.assertTrue(GRIMMReader.is_comment_string("     #"))
     self.assertTrue(GRIMMReader.is_comment_string("#    "))
     self.assertTrue(GRIMMReader.is_comment_string("     #    "))
     self.assertTrue(GRIMMReader.is_comment_string("#  aaa  "))
     self.assertFalse(GRIMMReader.is_comment_string("a# "))
     self.assertTrue(GRIMMReader.is_comment_string("    ##  "))
Exemplo n.º 2
0
    logger.setLevel(args.c_logging_level)
    logger.addHandler(ch)
    logger.info(full_description)
    logger.info(parser.format_values())
    ch.setFormatter(logging.Formatter(args.c_logging_formatter_entry))
    logger.info("Starting the converting process")

    genomes = defaultdict(list)
    for file_name in args.grimm:
        logger.info(
            "Processing file \"{file_name}\"".format(file_name=file_name))
        with open(file_name, "rt") as source:
            current_genome = None
            for line in source:
                line = line.strip()
                if len(line) == 0 or GRIMMReader.is_comment_string(
                        data_string=line):
                    continue
                if GRIMMReader.is_genome_declaration_string(data_string=line):
                    current_genome = GRIMMReader.parse_genome_declaration_string(
                        data_string=line).name
                    if args.trim_names:
                        current_genome = current_genome.split(
                            args.trimmer_char, 1)[0]
                elif current_genome is not None:
                    current_chromosome = []
                    chr_type, blocks = GRIMMReader.parse_data_string(
                        data_string=line)
                    genomes[current_genome].append((chr_type, blocks))
    if args.good_genomes != "":
        good_genomes = args.good_genomes.split(",")
        if args.trim_names:
Exemplo n.º 3
0
    ch.setLevel(args.c_logging_level)
    logger.setLevel(args.c_logging_level)
    logger.addHandler(ch)
    logger.info(full_description)
    logger.info(parser.format_values())
    ch.setFormatter(logging.Formatter(args.c_logging_formatter_entry))
    logger.info("Starting the converting process")

    genomes = defaultdict(list)
    for file_name in args.grimm:
        logger.info("Processing file \"{file_name}\"".format(file_name=file_name))
        with open(file_name, "rt") as source:
            current_genome = None
            for line in source:
                line = line.strip()
                if len(line) == 0 or GRIMMReader.is_comment_string(data_string=line):
                    continue
                if GRIMMReader.is_genome_declaration_string(data_string=line):
                    current_genome = GRIMMReader.parse_genome_declaration_string(data_string=line).name
                    if args.trim_names:
                        current_genome = current_genome.split(args.trimmer_char, 1)[0]
                elif current_genome is not None:
                    current_chromosome = []
                    chr_type, blocks = GRIMMReader.parse_data_string(data_string=line)
                    genomes[current_genome].append((chr_type, blocks))
    if args.good_genomes != "":
        good_genomes = args.good_genomes.split(",")
        if args.trim_names:
            good_genomes = [genome_name.split(args.trimmer_char, 1)[0] for genome_name in good_genomes]
        for genome_name in list(genomes.keys()):
            if genome_name not in good_genomes: