#!/usr/bin/env python
# coding: utf-8

import configparser

config = configparser.ConfigParser(allow_no_value=True)

config.add_section('meta_information')
config.set('meta_information', '## data_type = data record type')

config['Plug-in'] = {'name': 'rank_model_cmms',
                     'version': '1.2',
                     }
config['1000GAF'] = {'data_type': 'float',
                      'category': 'allele_frequency',
                      'category_aggregate': 'min',
                      'record_aggregate': 'max',
                      'value-notreported': 'na:na',
                      'value-rare': 'le:0.005',
                      'value-intermediate': 'le:0.02',
                      'value-common': 'gt:0.02',
                      'score-notreported': '3',
                      'score-rare': '2',
                      'score-intermediate': '1',
                      'score-common': '-12',
                      }
config['EXACAF'] = {'data_type': 'float',
                    'category': 'allele_frequency',
                    'category_aggregate': 'min',
                    'record_aggregate': 'max',
                    'value-notreported': 'na:na',
                    'value-rare': 'le:0.005',
                    'value-intermediate': 'le:0.02',
                    'value-common': 'gt:0.02',
                    'score-notreported': '3',
                    'score-rare': '2',
                    'score-intermediate': '1',
                    'score-common': '-12',
                    }
config['PolyPhen'] = {'data_type': 'string',
                      'category': 'Protein_prediction',
                      'category_aggregate': 'sum',
                      'record_aggregate': 'min',
                      'field_separators': ",_:",
                      'value-notreported': 'na',
                      'value-probably_damaging': 'probably_damaging',
                      'value-possibly_damaging': 'possibly_damaging',
                      'value-benign': 'benign',
                      'score-notreported': '0',
                      'score-probably_damaging': '1',
                      'score-possibly_damaging': '1',
                      'score-benign': '0',
                      }
config['Sift'] = {'data_type': 'string',
                  'category': 'Protein_prediction',
                  'category_aggregate': 'sum',
                  'record_aggregate': 'min',
                  'field_separators': ",_:",
                  'value-notreported': 'na',
                  'value-deleterious': 'deleterious',
                  'value-tolerated': 'tolerated',
                  'score-notreported': '0',
                  'score-deleterious': '1',
                  'score-tolerated': '0',
                  }
config['GeneticModels'] = {'data_type': 'string',
                           'category': 'Inheritance_Models',
                           'category_aggregate': 'min',
                           'record_aggregate': 'max',
                           'field_separators': ",",
                           'value-notreported': 'na',
                           'value-ar_hom': 'ar_hom',
                           'value-ar_hom_dn': 'ar_hom_dn',
                           'value-ad': 'ad',
                           'value-ad_dn': 'ad_dn',
                           'value-ar_comp': 'ar_comp',
                           'value-xd': 'xd',
                           'value-xd_dn': 'xd-dn',
                           'value-xr': 'xr',
                           'value-xr_dn': 'xr-dn',
                           'score-notreported': '-12',
                           'score-ar_hom': '1',
                           'score-ar_hom_dn': '1',
                           'score-ad': '1',
                           'score-ad_dn': '1',
                           'score-ar_comp': '1',
                           'score-xd': '1',
                           'score-xd_dn': '1',
                           'score-xr': '1',
                           'score-xr_dn': '1',
                           }
config['MostSevereConsequence'] = {'data_type': 'string',
                                   'category': 'Consequence',
                                   'category_aggregate': 'max',
                                   'record_aggregate': 'max',
                                   'field_separators': ",_:",
                                   'score-transcript_ablation': '5',
                                   'score-splice_donor_variant': '4',
                                   'score-splice_acceptor_variant': '4',
                                   'score-stop_gained': '4',
                                   'score-frameshift_variant': '4',
                                   'score-stop_lost': '4',
                                   'score-initiator_codon_variant': '4',
                                   'score-inframe_insertion': '3',
                                   'score-inframe_deletion': '3',
                                   'score-missense_variant': '3',
                                   'score-transcript_amplification': '3',
                                   'score-splice_region_variant': '3',
                                   'score-incomplete_terminal_codon_variant': '3',
                                   'score-synonymous_variant': '1',
                                   'score-stop_retained_variant': '1',
                                   'score-coding_sequence_variant': '1',
                                   'score-mature_miRNA_variant': '1',
                                   'score-5_prime_UTR_variant': '1',
                                   'score-3_prime_UTR_variant': '1',
                                   'score-non_coding_exon_variant': '1',
                                   'score-nc_transcript_variant': '1',
                                   'score-intron_variant': '1',
                                   'score-NMD_transcript_variant': '1',
                                   'score-upstream_gene_variant': '1',
                                   'score-downstream_gene_variant': '1',
                                   'score-TFBS_ablation': '1',
                                   'score-TFBS_amplification': '1',
                                   'score-TF_binding_site_variant': '1',
                                   'score-regulatory_region_variant': '1',
                                   'score-regulatory_region_ablation': '1',
                                   'score-regulatory_region_amplification': '1',
                                   'score-feature_elongation': '1',
                                   'score-feature_truncation': '1',
                                   'score-intergenic_variant': '0',
                                   'score-notreported': '0',
                                   'value-transcript_ablation': 'transcript_ablation',
                                   'value-splice_donor_variant': 'splice_donor_variant',
                                   'value-splice_acceptor_variant': 'splice_acceptor_variant',
                                   'value-stop_gained': 'stop_gained',
                                   'value-frameshift_variant': 'frameshift_variant',
                                   'value-stop_lost': 'stop_lost',
                                   'value-initiator_codon_variant': 'initiator_codon_variant',
                                   'value-inframe_insertion': 'inframe_insertion',
                                   'value-inframe_deletion': 'inframe_deletion',
                                   'value-missense_variant': 'missense_variant',
                                   'value-transcript_amplification': 'transcript_amplification',
                                   'value-splice_region_variant': 'splice_region_variant',
                                   'value-incomplete_terminal_codon_variant': 'incomplete_terminal_codon_variant',
                                   'value-synonymous_variant': 'synonymous_variant',
                                   'value-stop_retained_variant': 'stop_retained_variant',
                                   'value-coding_sequence_variant': 'coding_sequence_variant',
                                   'value-mature_miRNA_variant': 'mature_miRNA_variant',
                                   'value-5_prime_UTR_variant': '5_prime_UTR_variant',
                                   'value-3_prime_UTR_variant': '3_prime_UTR_variant',
                                   'value-non_coding_exon_variant': 'non_coding_exon_variant',
                                   'value-nc_transcript_variant': 'nc_transcript_variant',
                                   'value-intron_variant': 'intron_variant',
                                   'value-NMD_transcript_variant': 'NMD_transcript_variant',
                                   'value-upstream_gene_variant': 'upstream_gene_variant',
                                   'value-downstream_gene_variant': 'downstream_gene_variant',
                                   'value-TFBS_ablation': 'TFBS_ablation',
                                   'value-TFBS_amplification': 'TFBS_amplification',
                                   'value-TF_binding_site_variant': 'TF_binding_site_variant',
                                   'value-regulatory_region_variant': 'regulatory_region_variant',
                                   'value-regulatory_region_ablation': 'regulatory_region_ablation',
                                   'value-regulatory_region_amplification': 'regulatory_region_amplification',
                                   'value-feature_elongation': 'feature_elongation',
                                   'value-feature_truncation': 'feature_truncation',
                                   'value-intergenic_variant': 'intergenic_variant',
                                   'value-notreported': 'na',
                                   }
config['FILTER'] = {'data_type': 'string',
                    'category': 'Variat_call_quality_filter',
                    'category_aggregate': 'min',
                    'record_aggregate': 'max',
                    'score-pass': '3',
                    'score-notreported': '0',
                    'value-pass': 'pass',
                    'value-notreported': 'na',
                    }
config['dbNSFP_GERP++_RS'] = {'data_type': 'float',
                              'category': 'Conservation',
                              'category_aggregate': 'sum',
                              'record_aggregate': 'max',
                              'value-conserved': 'ge:2',
                              'value-notconserved': 'lt:2',
                              'value-notreported': 'na:na',
                              'score-conserved': '1',
                              'score-notconserved': '0',
                              'score-notreported': '0',
                              }
config['dbNSFP_phastCons100way_vertebrate'] = {'data_type': 'float',
                                               'category': 'Conservation',
                                               'category_aggregate': 'sum',
                                               'record_aggregate': 'max',
                                               'value-conserved': 'ge:0.8',
                                               'value-notconserved': 'lt:0.8',
                                               'value-notreported': 'na:na',
                                               'score-conserved': '1',
                                               'score-notconserved': '0',
                                               'score-notreported': '0',
                                               }
config['dbNSFP_phyloP100way_vertebrate'] = {'data_type': 'float',
                                            'category': 'Conservation',
                                            'category_aggregate': 'sum',
                                            'record_aggregate': 'max',
                                            'value-conserved': 'ge:2.5',
                                            'value-notconserved': 'lt:2.5',
                                            'value-notreported': 'na:na',
                                            'score-conserved': '1',
                                            'score-notconserved': '0',
                                            'score-notreported': '0',
                                            }
config['CADD'] = {'data_type': 'float',
                  'category': 'CADD_score',
                  'category_aggregate': 'max',
                  'record_aggregate': 'max',
                  'value-20': 'ge:20',
                  'value-10': 'ge:10',
                  'value-0': 'lt:10',
                  'value-notreported': 'na:na',
                  'score-20': '2',
                  'score-10': '1',
                  'score-0': '0',
                  'score-notreported': '0',
                  }
config['CLNSIG'] = {'data_type': 'float',
                    'category': 'Clinical_significance',
                    'category_aggregate': 'min',
                    'record_aggregate': 'max',
                    'field_separators': "|",
                    'score-pathogenic': '2',
                    'score-likely_pathogenic': '1',
                    'score-other': '0',
                    'score-histocompatibility': '0',
                    'score-drug_response': '0',
                    'score-likely_benign': '0',
                    'score-benign': '-1',
                    'score-not_provided': '0',
                    'score-uncertain_significance': '0',
                    'score-notreported': '0',
                    'value-other': 'e:255',
                    'value-histocompatibility': 'e:7',
                    'value-drug_response': 'e:6',
                    'value-pathogenic': 'e:5',
                    'value-likely_pathogenic': 'e:4',
                    'value-likely_benign': 'e:3',
                    'value-benign': 'e:2',
                    'value-not_provided': 'e:1',
                    'value-uncertain_significance': 'e:0',
                    'value-notreported': 'na:na',
                    }

with open('rank_model_cmms_v1.2.ini', 'w') as configfile:
    config.write(configfile)
