def test_reconstruct_annotation_str_missing_annotation_names(self):
        str_builder = annotation_parser.AnnotationStrBuilder(None)
        annotation_maps = [{u'Consequence': u'upstream_gene_variant'}]
        with self.assertRaises(ValueError):
            list(str_builder.reconstruct_annotation_str(
                'CSQ', annotation_maps))

        str_builder = annotation_parser.AnnotationStrBuilder(
            {'CSQ2': ['Consequence', 'AF']})
        annotation_maps = [{u'Consequence': u'upstream_gene_variant'}]
        with self.assertRaises(ValueError):
            list(str_builder.reconstruct_annotation_str(
                'CSQ', annotation_maps))
    def __init__(self, annotation_id_to_annotation_names=None):
        # type: (Dict[str, List[str]]) -> None
        """Initializes an object of `VariantGenerator`.

    Args:
      annotation_id_to_annotation_names: A map where the key is the annotation
        id (e.g., `CSQ`) and the value is a list of annotation names (e.g.,
        ['allele', 'Consequence', 'IMPACT', 'SYMBOL']). The annotation str
        (e.g., 'A|upstream_gene_variant|MODIFIER|PSMF1|||||') is reconstructed
        in the same order as the annotation names.
    """
        self._annotation_str_builder = annotation_parser.AnnotationStrBuilder(
            annotation_id_to_annotation_names)
    def test_reconstruct_annotation_str(self):
        str_builder = annotation_parser.AnnotationStrBuilder({
            'CSQ': ['allele', 'Consequence', 'AF', 'IMPACT'],
            'CSQ_2': ['allele', 'Consequence', 'IMPACT']
        })
        annotation_maps = [{
            u'allele': u'G',
            u'Consequence': u'upstream_gene_variant',
            u'AF': u'',
            u'IMPACT': u'MODIFIER'
        }, {
            u'allele': u'G',
            u'Consequence': u'upstream_gene_variant',
            u'AF': u'0.1',
            u'IMPACT': u''
        }]

        expected_annotation_strs = [
            'G|upstream_gene_variant||MODIFIER', 'G|upstream_gene_variant|0.1|'
        ]
        self.assertEqual(
            expected_annotation_strs,
            list(str_builder.reconstruct_annotation_str(
                'CSQ', annotation_maps)))