Exemple #1
0
    def test_format_map_file(self):
        """format_map_file should produce correct result"""

        desc_key = "Description"
        sample_id = "SampleID"
        headers = ['SampleID', 'a', 'Description', 'b']
        id_map = {'x': {'a': 3, 'b': 4}, 'y': {'a': 5, 'b': 6}}
        desc_map = {'x': 'sample x', 'y': 'sample y'}
        run_desc = 'run desc'
        self.assertEqual(
            format_map_file(headers, id_map, desc_key, sample_id, desc_map,
                            run_desc), """#SampleID\ta\tb\tDescription
#run desc
x\t3\t4\tsample x
y\t5\t6\tsample y""")
Exemple #2
0
    def test_format_map_file(self):
        """format_map_file should produce correct result"""
        
        desc_key = "Description"
        sample_id = "SampleID"
        headers = ['SampleID', 'a', 'Description', 'b']
        id_map = {'x':{'a':3,'b':4}, 'y':{'a':5,'b':6}}
        desc_map = {'x':'sample x','y':'sample y'}
        run_desc = 'run desc'
        self.assertEqual(format_map_file(headers, id_map, desc_key, sample_id,\
         desc_map, run_desc),
"""#SampleID\ta\tb\tDescription
#run desc
x\t3\t4\tsample x
y\t5\t6\tsample y""")
Exemple #3
0
    def test_format_map_file(self):
        """format_map_file should produce correct result"""

        desc_key = "Description"
        sample_id = "SampleID"
        headers = ["SampleID", "a", "Description", "b"]
        id_map = {"x": {"a": 3, "b": 4}, "y": {"a": 5, "b": 6}}
        desc_map = {"x": "sample x", "y": "sample y"}
        run_desc = "run desc"
        self.assertEqual(
            format_map_file(headers, id_map, desc_key, sample_id, desc_map, run_desc),
            """#SampleID\ta\tb\tDescription
#run desc
x\t3\t4\tsample x
y\t5\t6\tsample y""",
        )
Exemple #4
0
def write_corrected_file(headers, id_map, description_map, run_description, \
output_filepath, chars_replaced=False):
    """ Writes corrected mapping file with illegal characters replaced """

    outf = open(output_filepath, 'w')

    if chars_replaced:
        outfile_data=format_map_file(headers, id_map, DESC_KEY, SAMPLE_ID_KEY,\
         description_map, run_description)
    else:
        outfile_data="# No invalid characters were found and replaced.\n"+\
        "# Note that non-IUPAC DNA characters found in primer or barcode\n"+\
        "# sequences are not replaced but will be listed in the .log file."

    for data in outfile_data:
        outf.write(data)

    return
def write_corrected_file(headers, id_map, description_map, run_description, output_filepath, chars_replaced=False):
    """ Writes corrected mapping file with illegal characters replaced """

    outf = open(output_filepath, "w")

    if chars_replaced:
        outfile_data = format_map_file(headers, id_map, DESC_KEY, SAMPLE_ID_KEY, description_map, run_description)
    else:
        outfile_data = (
            "# No invalid characters were found and replaced.\n"
            + "# Note that non-IUPAC DNA characters found in primer or barcode\n"
            + "# sequences are not replaced but will be listed in the .log file."
        )

    for data in outfile_data:
        outf.write(data)

    return