def main(args):
    """
    Prints a human readable output of a genome properties assignment file.
    :param args: The command line arguments.
    """

    genome_property_flat_file_path = sanitize_cli_path(
        args.input_genome_properties_flat_file)
    json_output_path = sanitize_cli_path(args.output_file_path)
    assignment_file_paths = (
        sanitize_cli_path(path)
        for path in args.input_genome_properties_assignment_files)

    with open(genome_property_flat_file_path) as genome_property_file:
        genome_properties_tree = parse_genome_property_file(
            genome_property_file)

    leaf_assignments = []
    for path in assignment_file_paths:
        with open(path) as assignment_file:
            leaf_assignments.append(
                parse_genome_property_longform_file(assignment_file))

    results = GenomePropertiesResults(
        *leaf_assignments, genome_properties_tree=genome_properties_tree)

    with open(json_output_path, 'w') as json_file:
        results.to_json(json_file)
Exemplo n.º 2
0
def main(args):
    """
    Creates a JSON file representing genome property assignments.
    :param args: The command line arguments.
    """

    genome_property_flat_file_path = sanitize_cli_path(
        args.input_genome_properties_flat_file)
    json_output_path = sanitize_cli_path(args.output_file_path)
    interproscan_file_path = (sanitize_cli_path(path)
                              for path in args.input_interproscan_tsv_files)

    with open(genome_property_flat_file_path) as genome_property_file:
        genome_properties_tree = parse_genome_property_file(
            genome_property_file)

    interproscan_assignments = []
    for path in interproscan_file_path:
        with open(path) as interproscan_file:
            interproscan_assignments.append(
                parse_interproscan_file(interproscan_file))

    results = GenomePropertiesResults(
        *interproscan_assignments,
        genome_properties_tree=genome_properties_tree)

    with open(json_output_path, 'w') as json_file:
        results.to_json(json_file)
Exemplo n.º 3
0
    def test_parse_genome_property_file(self):
        """Test if a physical genome properties file can be parsed."""
        genome_property_flat_file_path = 'pygenprop/testing/test_constants/test_genome_properties.txt'

        with open(genome_property_flat_file_path) as genome_property_file:
            properties = parse_genome_property_file(genome_property_file)

        self.assertEqual(len(properties), 4)
def main(args):
    """
    Prints a human readable output of a genome properties flat file.
    :param args: The command line arguments.
    """

    genome_property_flat_file_path = sanitize_cli_path(args.input_genome_properties_file)

    with open(genome_property_flat_file_path) as genome_property_file:
        properties = parse_genome_property_file(genome_property_file)

    if properties is not None:
        print(str(len(properties)) + ' properties have been parsed.')
    else:
        print('Properties parsing has failed.')
        sys.exit(1)
Exemplo n.º 5
0
    def setUpClass(cls):
        """Set up testing data for testing."""

        with open('pygenprop/testing/test_constants/C_chlorochromatii_CaD3.txt'
                  ) as assignment_file_one:
            properties_one = parse_genome_property_longform_file(
                assignment_file_one)

        with open('pygenprop/testing/test_constants/C_luteolum_DSM_273.txt'
                  ) as assignment_file_two:
            properties_two = parse_genome_property_longform_file(
                assignment_file_two)

        with open(
                'pygenprop/testing/test_constants/test_genome_properties_two.txt'
        ) as test_genome_properties_file:
            genome_properties_tree = parse_genome_property_file(
                test_genome_properties_file)

        cls.test_genome_property_results = [properties_one, properties_two]
        cls.test_tree = genome_properties_tree