本文整理汇总了Python中oncotator.utils.ConfigUtils.ConfigUtils.createConfigParser方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigUtils.createConfigParser方法的具体用法?Python ConfigUtils.createConfigParser怎么用?Python ConfigUtils.createConfigParser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oncotator.utils.ConfigUtils.ConfigUtils
的用法示例。
在下文中一共展示了ConfigUtils.createConfigParser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from oncotator.utils.ConfigUtils import ConfigUtils [as 别名]
# 或者: from oncotator.utils.ConfigUtils.ConfigUtils import createConfigParser [as 别名]
def __init__(self, filename, configFile="tcgaVCF1.1_output.config", otherOptions=None):
self._filename = filename
self.logger = logging.getLogger(__name__)
self.config = ConfigUtils.createConfigParser(configFile)
self.alternativeDictionary = ConfigUtils.buildAlternateKeyDictionaryFromConfig(self.config)
self.seenDbSNPs = dict()
self.fieldMap = {}
示例2: __init__
# 需要导入模块: from oncotator.utils.ConfigUtils import ConfigUtils [as 别名]
# 或者: from oncotator.utils.ConfigUtils.ConfigUtils import createConfigParser [as 别名]
def __init__(self, filename, configFile="tcgaMAF2.4_output.config", other_options=None):
"""
"""
options = dict() if other_options is None else other_options
self._filename = filename
self.logger = logging.getLogger(__name__)
self.config = ConfigUtils.createConfigParser(configFile)
self.logger.info("Building alternative keys dictionary...")
self.alternativeDictionary = ConfigUtils.buildAlternateKeyDictionaryFromConfig(self.config)
self.options = options
self._prepend = self.config.get("general", "prepend")
if self.options.get(OptionConstants.NO_PREPEND, False):
self._prepend = ""
# _is_reannotating is a flag to determine whether we should give precendence to annotations that were not
# annotated as part of the INPUT.
self._is_reannotating = options.get(OptionConstants.REANNOTATE_TCGA_MAF_COLS, False)
self._is_splitting_allelic_depth = self.options.get(OptionConstants.SPLIT_ALLELIC_DEPTH, True)
self.exposedColumns = set(self.config.get("general", "exposedColumns").split(','))
self._is_entrez_id_message_logged = False
self._is_collapsing_number_cols = options.get(OptionConstants.COLLAPSE_NUMBER_ANNOTATIONS, False)
self._column_collapser = None
self._column_collapser_suffix = None
if self._is_collapsing_number_cols:
self._column_collapser = ColumnCollapser()
self._column_collapser_suffix = "_full"
示例3: testCreateDatasourceWithMissingValues
# 需要导入模块: from oncotator.utils.ConfigUtils import ConfigUtils [as 别名]
# 或者: from oncotator.utils.ConfigUtils.ConfigUtils import createConfigParser [as 别名]
def testCreateDatasourceWithMissingValues(self):
"""
"""
dsFile = os.path.join("testdata", "ESP6500SI-V2.chr1.snps_indels.head.25.missing.txt")
destDir = "out"
datasourceFilename = "ESP6500SI-V2.chr1.snps_indels.head.25.missing.tabix_indexed.txt.gz"
indexColumnNames = "CHROM,POS,POS"
dataSourceType = "indexed_tsv"
dataSourceName = "ESP"
dataSourceVersion = "6500SI-V2"
dataSourceMatchMode = "overlap"
annotationColumnNames = "EA_GTC,DP"
configFilename = os.path.join("out", "esp_coverage.missing.config")
datasourceBuilder = TabixIndexedTsvDatasourceCreator()
datasourceBuilder.createDatasource(destDir, dsFile, indexColumnNames, configFilename, dataSourceType, dataSourceName,
dataSourceVersion, dataSourceMatchMode, annotationColumnNames,
DatasourceInstallUtils.getIndexCols(dataSourceType, indexColumnNames))
configParser = ConfigUtils.createConfigParser(configFilename)
self.assertEqual(configParser.get("general", "src_file"), datasourceFilename,
"Expected data source src_file is %s but was %s."
% (datasourceFilename, configParser.get("general", "src_file")))
self.assertEqual(configParser.get("data_types", "EA_GTC"), "Float",
"Expected EA_GTC data type is %s but was %s."
% ("Float", configParser.get("data_types", "EA_GTC")))
self.assertEqual(configParser.get("data_types", "DP"), "Integer",
"Expected DP data type is %s but was %s."
% ("Integer", configParser.get("data_types", "DP")))
示例4: test_intitialize
# 需要导入模块: from oncotator.utils.ConfigUtils import ConfigUtils [as 别名]
# 或者: from oncotator.utils.ConfigUtils.ConfigUtils import createConfigParser [as 别名]
def test_intitialize(self):
"""Test a simple initialization of an ensembl datasource """
base_config_location = "testdata/ensembl/saccer/"
config_parser = ConfigUtils.createConfigParser(base_config_location + "ensembl.config")
title = config_parser.get("general", "title")
version = config_parser.get("general", "version")
src_file = config_parser.get("general", "src_file")
ensembl_ds = EnsemblTranscriptDatasource(title=title, version=version, src_file=src_file)
self.assertIsNotNone(ensembl_ds)
ensembl_ds.set_tx_mode(TranscriptProvider.TX_MODE_BEST_EFFECT)
self.assertTrue(TranscriptProvider.TX_MODE_BEST_EFFECT == ensembl_ds.get_tx_mode())
示例5: testCreateGPTsvDatasource
# 需要导入模块: from oncotator.utils.ConfigUtils import ConfigUtils [as 别名]
# 或者: from oncotator.utils.ConfigUtils.ConfigUtils import createConfigParser [as 别名]
def testCreateGPTsvDatasource(self):
"""
"""
datasourceFilename = "testdata/small_genome_position_tsv_ds/oreganno_trim.hg19.txt"
datasourceType = "gp_tsv"
datasourceName = "ORegAnno"
datasourceFoldername = "ORegAnno"
datasourceVersion = "UCSC Track"
genomeBuild = "hg19"
genomicPositionColumnNames = "hg19.oreganno.chrom,hg19.oreganno.chromStart,hg19.oreganno.chromEnd"
tmpDir = tempfile.mkdtemp()
destDir = os.path.join(*[tmpDir, datasourceFoldername, genomeBuild])
os.makedirs(destDir)
DatasourceInstallUtils.create_datasource(destDir, datasourceFilename, datasourceFoldername, datasourceName,
datasourceType, datasourceVersion, genomicPositionColumnNames)
datasourceFilename = "oreganno_trim.hg19.txt"
configFilename = os.path.join(*[destDir, "ORegAnno.config"])
configParser = ConfigUtils.createConfigParser(configFilename)
self.assertTrue(configParser.has_section("general"), "general section is missing.")
self.assertTrue(configParser.has_option("general", "type"), "type option is missing in general section.")
self.assertTrue(configParser.has_option("general", "src_file"),
"src_file option is missing in general section.")
self.assertTrue(configParser.has_option("general", "title"), "title option is missing in general section.")
self.assertTrue(configParser.has_option("general", "version"), "version option is missing in general section.")
self.assertTrue(configParser.has_option("general", "genomic_position_cols"),
"genomic_position_cols option is missing in general section.")
self.assertEqual(configParser.get("general", "type"), datasourceType,
"Expected data source type is %s but was %s."
% (datasourceType, configParser.get("general", "type")))
self.assertEqual(configParser.get("general", "src_file"), datasourceFilename,
"Expected data source src_file is %s but was %s."
% (datasourceFilename, configParser.get("general", "src_file")))
self.assertEqual(configParser.get("general", "title"), datasourceName,
"Expected data source title is %s but was %s."
% (datasourceName, configParser.get("general", "title")))
self.assertEqual(configParser.get("general", "version"), datasourceVersion,
"Expected data source version is %s but was %s."
% (datasourceVersion, configParser.get("general", "version")))
self.assertEqual(configParser.get("general", "genomic_position_cols"), genomicPositionColumnNames,
"Expected data source genomic_position_cols is %s but was %s."
% (genomicPositionColumnNames, configParser.get("general", "genomic_position_cols")))
self.assertTrue(os.path.exists(os.path.join(*[tmpDir, datasourceFoldername, genomeBuild + ".md5"])),
"No md5 file was generated.")
MutUtils.removeDir(tmpDir)
示例6: __init__
# 需要导入模块: from oncotator.utils.ConfigUtils import ConfigUtils [as 别名]
# 或者: from oncotator.utils.ConfigUtils.ConfigUtils import createConfigParser [as 别名]
def __init__(self, mut, configFile="sample_name_selection.config", section="SAMPLE_NAME"):
config = ConfigUtils.createConfigParser(configFile)
self.logger = logging.getLogger(__name__)
aliases = ConfigUtils.buildAlternateKeyDictionaryFromConfig(config, section)
self.configFile=configFile
sampleAnnotation = self._getAnnotationFromAliases(mut, aliases["sample_name"])
tumorAnnotation = self._getAnnotationFromAliases(mut, aliases["sample_tumor_name"])
normalAnnotation = self._getAnnotationFromAliases(mut, aliases["sample_normal_name"])
source_column = self._getSourceColumn(sampleAnnotation,tumorAnnotation,normalAnnotation)
self._logSampleNameColumnDescription(source_column, sampleAnnotation, tumorAnnotation, normalAnnotation)
self.sampleNameGrabber = self._getSampleNameGrabber(source_column, sampleAnnotation, tumorAnnotation, normalAnnotation)
self.outputAnnotationName = self._deriveOutputAnnotationName(sampleAnnotation)
self.annotationSource = self._deriveAnnotationSource(source_column)
示例7: testCreateIndexedVcfDatasource
# 需要导入模块: from oncotator.utils.ConfigUtils import ConfigUtils [as 别名]
# 或者: from oncotator.utils.ConfigUtils.ConfigUtils import createConfigParser [as 别名]
def testCreateIndexedVcfDatasource(self):
datasourceFilename = "testdata/vcf/example.vcf"
datasourceFoldername = "1000Genomes"
datasourceName = "1000Genomes"
datasourceType = "indexed_vcf"
datasourceVersion = "V4.1"
genomeBuild = "hg19"
tmpDir = tempfile.mkdtemp()
destDir = os.path.join(*[tmpDir, datasourceFoldername, genomeBuild])
os.makedirs(destDir)
DatasourceInstallUtils.create_datasource(destDir, datasourceFilename, datasourceFoldername, datasourceName,
datasourceType, datasourceVersion)
datasourceFilename = "example.tabix_indexed.vcf.gz"
configFilename = os.path.join(*[destDir, "1000Genomes.config"])
configParser = ConfigUtils.createConfigParser(configFilename)
self.assertTrue(configParser.has_section("general"), "general section is missing.")
self.assertTrue(configParser.has_option("general", "type"), "type option is missing in general section.")
self.assertTrue(configParser.has_option("general", "src_file"),
"src_file option is missing in general section.")
self.assertTrue(configParser.has_option("general", "title"), "title option is missing in general section.")
self.assertTrue(configParser.has_option("general", "version"), "version option is missing in general section.")
self.assertEqual(configParser.get("general", "type"), datasourceType,
"Expected data source type is %s but was %s."
% (datasourceType, configParser.get("general", "type")))
self.assertEqual(configParser.get("general", "src_file"), datasourceFilename,
"Expected data source src_file is %s but was %s."
% (datasourceFilename, configParser.get("general", "src_file")))
self.assertEqual(configParser.get("general", "title"), datasourceName,
"Expected data source title is %s but was %s."
% (datasourceName, configParser.get("general", "title")))
self.assertEqual(configParser.get("general", "version"), datasourceVersion,
"Expected data source version is %s but was %s."
% (datasourceVersion, configParser.get("general", "version")))
self.assertTrue(os.path.exists(os.path.join(*[tmpDir, datasourceFoldername, genomeBuild + ".md5"])),
"No md5 file was generated.")
# Data source was created correctly
tabixIndexedFilename = os.path.join(*[destDir, "example.tabix_indexed.vcf.gz"])
self.assertTrue(os.path.exists(tabixIndexedFilename), "No index file was generated.")
vcfReader = vcf.Reader(filename=tabixIndexedFilename, compressed=True, strict_whitespace=True)
vcfRecords = vcfReader.fetch(chrom=20, start=1230237, end=1230237)
for vcfRecord in vcfRecords:
self.assertEqual(vcfRecord.INFO["NS"], 3, "Expected %s but got %s." % (3, vcfRecord.INFO["NS"]))
self.assertEqual(vcfRecord.INFO["DP"], 13, "Expected %s but got %s." % (13, vcfRecord.INFO["DP"]))
MutUtils.removeDir(tmpDir)
示例8: getConfigTable
# 需要导入模块: from oncotator.utils.ConfigUtils import ConfigUtils [as 别名]
# 或者: from oncotator.utils.ConfigUtils.ConfigUtils import createConfigParser [as 别名]
def getConfigTable(self, configFilename, filename=None):
"""
:param configFilename:
:param filename:
:return:
"""
configParser = ConfigUtils.createConfigParser(configFilename, ignoreCase=False)
configTable = VcfOutputConfigTable()
self.createConfigTableKeys(configParser=configParser, configTable=configTable)
return configTable
示例9: getConfigTable
# 需要导入模块: from oncotator.utils.ConfigUtils import ConfigUtils [as 别名]
# 或者: from oncotator.utils.ConfigUtils.ConfigUtils import createConfigParser [as 别名]
def getConfigTable(self, configFilename, filename):
"""
:return:
"""
configParser = ConfigUtils.createConfigParser(configFilename, ignoreCase=False)
configTable = VcfInputConfigTable()
vcfReader = vcf.Reader(filename=filename, strict_whitespace=True)
self.createConfigTableKeys(configParser=configParser, configTable=configTable)
self.createConfigTable(vcfReader=vcfReader, configTable=configTable)
return configTable
示例10: _validateTcgaMafContents
# 需要导入模块: from oncotator.utils.ConfigUtils import ConfigUtils [as 别名]
# 或者: from oncotator.utils.ConfigUtils.ConfigUtils import createConfigParser [as 别名]
def _validateTcgaMafContents(self, filename):
""" This is a utility, private method for unit tests to get a semblance that a valid maf file was created.
Note: This method has nothing to do with the TCGA validator.
"""
configFile = ConfigUtils.createConfigParser(os.path.join("configs", "tcgaMAF2.4_output.config"))
statinfo = os.stat(filename)
self.assertTrue(statinfo.st_size > 0, "Generated MAF file (" + filename + ") is empty.")
tsvReader = GenericTsvReader(filename)
self.assertTrue(tsvReader.getComments().find('#version') != -1, "First line did not specify a version number")
ctr = 1
for lineDict in tsvReader:
# TODO: Re-enable when GENCODE and HGNC datasources are concordant (or Entrez_Gene_ID is in the gencode gtf)
# if lineDict['Entrez_Gene_Id'] == "0":
# self.assertTrue(lineDict['Hugo_Symbol'] == "Unknown", "Entrez_Gene_Id was zero, but Hugo Symbol was not 'Unknown'. Line: " + str(ctr))
unknownKeys = []
self.assertTrue(lineDict["Tumor_Seq_Allele1"] != lineDict["Tumor_Seq_Allele2"], "Reference and alternate were equal in TCGA MAF output on line %d (%s)" % (ctr, lineDict["Tumor_Seq_Allele1"]))
self.assertTrue(lineDict["Tumor_Seq_Allele1"] == lineDict["Reference_Allele"], "Reference Allele should match Tumor_Seq_Allele1 on line " + str(ctr))
uniprot_aa_xform_counter = 0
for k in lineDict.keys():
if lineDict[k] == "__UNKNOWN__":
unknownKeys.append(k)
self.assertTrue('\r' not in lineDict[k], "Carriage return character found in an annotation value.")
requiredColumns = configFile.get("general", "requiredColumns")
optionalColumns = configFile.get("general", "optionalColumns")
exposedColumns = configFile.get("general", "exposedColumns")
if (k not in requiredColumns) and (k not in optionalColumns) and (k not in exposedColumns):
self.assertTrue(k.startswith("i_"), "Internal column was not prepended with 'i_'")
if lineDict['UniProt_AApos'] == "0":
uniprot_aa_xform_counter += 1
if lineDict["Variant_Type"] == VariantClassification.VT_DEL:
self.assertTrue(lineDict["Tumor_Seq_Allele2"] == "-")
if lineDict["Variant_Type"] == VariantClassification.VT_INS:
self.assertTrue(lineDict["Reference_Allele"] == "-")
unknownKeys.sort()
self.assertTrue(len(unknownKeys) == 0, "__UNKNOWN__ values (" + str(len(unknownKeys)) + ") seen on line " + str(ctr) + ", in fields: " + ", ".join(unknownKeys))
self.assertTrue(uniprot_aa_xform_counter < 10, "Too many uniprot aa xform values are zero (" + str(uniprot_aa_xform_counter) + "). This is probably an error.")
ctr += 1
示例11: __init__
# 需要导入模块: from oncotator.utils.ConfigUtils import ConfigUtils [as 别名]
# 或者: from oncotator.utils.ConfigUtils.ConfigUtils import createConfigParser [as 别名]
def __init__(self, filename, mutation_data_factory=None, configFile='maflite_input.config', genomeBuild="hg19", other_options=None):
"""
Constructor
"""
super(MafliteInputMutationCreator, self).__init__(filename, mutation_data_factory, configFile, genomeBuild, other_options)
self.logger = logging.getLogger(__name__)
self.config = ConfigUtils.createConfigParser(configFile)
self._tsvReader = GenericTsvReader(filename)
# Key is the required columns and the values are a list of valid alternative headers.
# Key is column name to an alternative.
self._alternativeDict = ConfigUtils.buildAlternateKeyDictionaryFromConfig(self.config)
self._reverseAlternativeDict = ConfigUtils.buildReverseAlternativeDictionary(self._alternativeDict)
missingRequiredHeaders = []
required_columns = sorted(self.config.get("general", "required_headers").split(","))
self._build = genomeBuild
self.logger.info("Initializing a maflite file with the following header: " + str(self._tsvReader.getFieldNames()))
# The specified fields are those that were given in the input.
self._specified_fields = self._tsvReader.getFieldNames()
for col in required_columns:
if col not in self._specified_fields:
isAltFound = False
for alt in self._alternativeDict.get(col, []):
if alt in self._specified_fields:
isAltFound = True
break
if not isAltFound:
# build is optional.
if col != "build":
missingRequiredHeaders.append(col)
missingRequiredHeaders.sort()
if len(missingRequiredHeaders) > 0:
raise MafliteMissingRequiredHeaderException("Specified maflite file (" + filename + ") missing required headers: " + ",".join(missingRequiredHeaders) )
示例12: test_simple_annotate
# 需要导入模块: from oncotator.utils.ConfigUtils import ConfigUtils [as 别名]
# 或者: from oncotator.utils.ConfigUtils.ConfigUtils import createConfigParser [as 别名]
def test_simple_annotate(self):
""" Annotate a simple example.
"""
base_config_location = "testdata/ensembl/saccer/"
config_parser = ConfigUtils.createConfigParser(base_config_location + "ensembl.config")
title = config_parser.get("general", "title")
version = config_parser.get("general", "version")
src_file = config_parser.get("general", "src_file")
ensembl_ds = EnsemblTranscriptDatasource(title=title, version=version, src_file=src_file)
m = MutationData()
m.chr = "22"
m.start = "22161963"
m.end = "22161963"
m.ref_allele = "C"
m.alt_allele = "A"
m2 = ensembl_ds.annotate_mutation(m)
示例13: _validateTcgaMafContents
# 需要导入模块: from oncotator.utils.ConfigUtils import ConfigUtils [as 别名]
# 或者: from oncotator.utils.ConfigUtils.ConfigUtils import createConfigParser [as 别名]
def _validateTcgaMafContents(self, filename):
"""
This is a utility, private method for unit tests to get a semblance that a valid maf file was created.
Note: This method has nothing to do with the TCGA validator.
TODO: This is code duplication from TCGA MAF Output RendererTest. This should be refactored into a base class
(to preserve self.assertTrue, etc).
"""
statinfo = os.stat(filename)
self.assertTrue(statinfo.st_size > 0, "Generated MAF file (" + filename + ") is empty.")
tsvReader = GenericTsvReader(filename)
self.assertTrue(tsvReader.getComments().find('#version') <> -1, "First line did not specify a version number")
ctr = 1
for lineDict in tsvReader:
if lineDict['Entrez_Gene_Id'] == "0":
self.assertTrue(lineDict['Hugo_Symbol'] == "Unknown",
"Entrez_Gene_Id was zero, but Hugo Symbol was not 'Unknown'. Line: " + str(ctr))
unknownKeys = []
for k in lineDict.keys():
if lineDict[k] == "__UNKNOWN__":
unknownKeys.append(k)
self.assertTrue('\r' not in lineDict[k], "Carriage return character found in an annotation value.")
configFile = ConfigUtils.createConfigParser('configs/tcgaMAF2.3_output.config')
requiredColumns = configFile.get("general", "requiredColumns")
optionalColumns = configFile.get("general", "optionalColumns")
if (k not in requiredColumns) and (k not in optionalColumns):
self.assertTrue(k.startswith("i_"), "Internal column was not prepended with 'i_'")
unknownKeys.sort()
self.assertTrue(len(unknownKeys) == 0,
"__UNKNOWN__ values (" + str(len(unknownKeys)) + ") seen on line " + str(
ctr) + ", in fields: " + ", ".join(unknownKeys))
ctr += 1
示例14: testCreateGPTsvConfigFile
# 需要导入模块: from oncotator.utils.ConfigUtils import ConfigUtils [as 别名]
# 或者: from oncotator.utils.ConfigUtils.ConfigUtils import createConfigParser [as 别名]
def testCreateGPTsvConfigFile(self):
configFilename = "out/ccle_by_gp.config"
datasourceFilename = "ccle_results_by_pos.hg19.import.txt"
dataSourceType = "gp_tsv"
dataSourceName = "CCLE_By_GP"
dataSourceVersion = "09292010"
genomicPositionColumnNames = "chr,start,end"
datasourceBuilder = GenericTsvDatasourceCreator()
datasourceBuilder._createConfigFile(configFilename=configFilename, baseDSFile=datasourceFilename,
ds_name=dataSourceName, ds_type=dataSourceType, ds_version=dataSourceVersion,
indexCols=DatasourceInstallUtils.getIndexCols("gp_tsv",
genomicPositionColumnNames))
configParser = ConfigUtils.createConfigParser(configFilename)
self.assertTrue(configParser.has_section("general"), "general section is missing.")
self.assertTrue(configParser.has_option("general", "type"), "type option is missing in general section.")
self.assertTrue(configParser.has_option("general", "src_file"),
"src_file option is missing in general section.")
self.assertTrue(configParser.has_option("general", "title"), "title option is missing in general section.")
self.assertTrue(configParser.has_option("general", "version"), "version option is missing in general section.")
self.assertTrue(configParser.has_option("general", "genomic_position_cols"),
"genomic_position_cols option is missing in general section.")
self.assertEqual(configParser.get("general", "type"), dataSourceType,
"Expected data source type is %s but was %s."
% (dataSourceType, configParser.get("general", "type")))
self.assertEqual(configParser.get("general", "src_file"), datasourceFilename,
"Expected data source src_file is %s but was %s."
% (datasourceFilename, configParser.get("general", "src_file")))
self.assertEqual(configParser.get("general", "title"), dataSourceName,
"Expected data source title is %s but was %s."
% (dataSourceName, configParser.get("general", "title")))
self.assertEqual(configParser.get("general", "version"), dataSourceVersion,
"Expected data source version is %s but was %s."
% (dataSourceVersion, configParser.get("general", "version")))
self.assertEqual(configParser.get("general", "genomic_position_cols"), genomicPositionColumnNames,
"Expected data source genomic_position_cols is %s but was %s."
% (genomicPositionColumnNames, configParser.get("general", "genomic_position_cols")))
示例15: __init__
# 需要导入模块: from oncotator.utils.ConfigUtils import ConfigUtils [as 别名]
# 或者: from oncotator.utils.ConfigUtils.ConfigUtils import createConfigParser [as 别名]
def __init__(self, filename, configFile='maflite_input.config', genomeBuild="hg19", other_options=None):
"""
Constructor
Currently, this InputCreator does not support any other options. The parameter is ignored.
"""
self.logger = logging.getLogger(__name__)
self.config = ConfigUtils.createConfigParser(configFile)
self._tsvReader = GenericTsvReader(filename)
# Key is the required columns and the values are a list of valid alternative headers.
# Key is column name to an alternative.
self._alternativeDict = ConfigUtils.buildAlternateKeyDictionaryFromConfig(self.config)
self._reverseAlternativeDict = ConfigUtils.buildReverseAlternativeDictionary(self._alternativeDict)
missingRequiredHeaders = []
specifiedFields = self._tsvReader.getFieldNames()
required_columns = sorted(self.config.get("general", "required_headers").split(","))
self._build = genomeBuild
for col in required_columns:
if col not in specifiedFields:
isAltFound = False
for alt in self._alternativeDict.get(col, []):
if alt in specifiedFields:
isAltFound = True
break
if not isAltFound:
# build is optional.
if col != "build":
missingRequiredHeaders.append(col)
missingRequiredHeaders.sort()
self.logger.info("Initializing a maflite file with the following header: " + str(self._tsvReader.getFieldNames()))
if len(missingRequiredHeaders) > 0:
raise MafliteMissingRequiredHeaderException("Specified maflite file (" + filename + ") missing required headers: " + ",".join(missingRequiredHeaders) )