def test_sequences_for_query_string(self): """Check correct parsing when input is a string""" out_tax_dict = sequences_for_query(self.taxonomy_lines, 'Beggiatoa') self.assertEquals(out_tax_dict, {'NZ_ABBZ01000843|640963011': 'VibrioBeggiatoa sp. PS', 'NZ_ABBZ01000613|640963011': 'VibrioBeggiatoa sp. PS', 'NZ_ABBZ01002042|640963011': 'VibrioBeggiatoa sp. PS', 'NZ_ABBY01000503|640963012': 'VibrioBeggiatoa sp. SS', 'NZ_ABBZ01000140|640963011': 'VibrioBeggiatoa sp. PS', 'NZ_ABBY01000221|640963012': 'VibrioBeggiatoa sp. SS', 'NZ_ABBZ01006278|640963011': 'VibrioBeggiatoa sp. PS', 'NZ_ABBZ01005870|640963011': 'VibrioBeggiatoa sp. PS'}) out_tax_dict = sequences_for_query(self.taxonomy_lines, 'Rumba') self.assertEquals(out_tax_dict, {})
def main(): option_parser, opts, args = parse_command_line_parameters(**script_info) taxonomy_fp = opts.taxonomy_fp fasta_fp = opts.fasta_fp query = opts.query output_fp = opts.output_fp # query the taxonomy file for the required sequence identifiers try: taxonomy_dict = sequences_for_query(open(taxonomy_fp, 'U'), query) except (PlatypusValueError, PlatypusParseError), e: option_parser.error(e.message)