Class SimpleTsvOutputRenderer
java.lang.Object
org.broadinstitute.hellbender.tools.funcotator.OutputRenderer
org.broadinstitute.hellbender.tools.funcotator.simpletsvoutput.SimpleTsvOutputRenderer
- All Implemented Interfaces:
AutoCloseable
This class is very versatile, but as a result, it must do some lazy loading after it receives the first write command.
IMPORTANT: If this class is not given any command to write(...), the output file will be empty.
This class assumes that funcotation maps will have the same fields regardless of allele.
This class makes no attempt to render VariantContext attribues. Any VC attributes must be converted into a
Funcotation (and added to the FuncotationMap) before calling write(...).
This class will append a funcotation for the locatable data. This will use the field names:
LocatableFuncotationCreator.CONTIG_FIELD_NAME
, LocatableFuncotationCreator.START_FIELD_NAME
, and
LocatableFuncotationCreator.END_FIELD_NAME
If you want the output file to have locatable data in different fields, make sure the alias file maps these to
the preferred field name in the output.
Sorting of columns is based on the config file:
- Columns from the config file in order as appearing in the config file.
- Remaining default, override, and funcotation fields in natural/alphanumberical order (e.g. FIELD1, FIELD2, FIELD10).
Note that remaining funcotation fields will not appear when `isWriteFuncotationFieldsNotInConfig` is `false`
"Remaining" means fields that did not appear in the config file (as a column name nor as an alias)
If this output renderer does not actually render any variants, it will not necessarily have the same columns as
when there actually are variants. Please note that `isWriteFuncotationFieldsNotInConfig` = false will
have the same column list in these cases, but there are other caveats, since leftover funcotation fields will not
be written ever.-
Field Summary
Fields inherited from class org.broadinstitute.hellbender.tools.funcotator.OutputRenderer
dataSourceFactories, manualAnnotations, toolVersion
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close theOutputRenderer
.static LinkedHashMap<String,
List<String>> createColumnNameToAliasesMap
(Path configFile) Create key value pairs where the key is the output column name and the value is a list of possible field names, in order of priority.static SimpleTsvOutputRenderer
createFromFile
(Path outputFilePath, LinkedHashMap<String, String> unaccountedForDefaultAnnotations, LinkedHashMap<String, String> unaccountedForOverrideAnnotations, Set<String> excludedOutputFields, Path configPath, String toolVersion, boolean isWriteColumnsNotInConfig) static SimpleTsvOutputRenderer
createFromResource
(Path outputFilePath, LinkedHashMap<String, String> unaccountedForDefaultAnnotations, LinkedHashMap<String, String> unaccountedForOverrideAnnotations, Set<String> excludedOutputFields, Path resourcePath, String toolVersion, boolean isWriteColumnsNotInConfig) Use when loading the config file from the jar.void
write
(htsjdk.variant.variantcontext.VariantContext variant, FuncotationMap txToFuncotationMap) Write the givenvariant
andtxToFuncotationMap
to the output file.Methods inherited from class org.broadinstitute.hellbender.tools.funcotator.OutputRenderer
createFuncotationFromLinkedHashMap, getDataSourceInfoString, getToolVersion
-
Method Details
-
close
public void close()Description copied from class:OutputRenderer
Close theOutputRenderer
.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in classOutputRenderer
-
write
public void write(htsjdk.variant.variantcontext.VariantContext variant, FuncotationMap txToFuncotationMap) Description copied from class:OutputRenderer
Write the givenvariant
andtxToFuncotationMap
to the output file.- Specified by:
write
in classOutputRenderer
- Parameters:
variant
-VariantContext
to write to the file.txToFuncotationMap
-FuncotationMap
to add to the givenvariant
on output.
-
createColumnNameToAliasesMap
Create key value pairs where the key is the output column name and the value is a list of possible field names, in order of priority.- Parameters:
configFile
- config file that encodes column_name:alias_1,alias_2 ....- Returns:
- mapping of output column names to possible field names in order of priority. Never
null
-
createFromFile
public static SimpleTsvOutputRenderer createFromFile(Path outputFilePath, LinkedHashMap<String, String> unaccountedForDefaultAnnotations, LinkedHashMap<String, String> unaccountedForOverrideAnnotations, Set<String> excludedOutputFields, Path configPath, String toolVersion, boolean isWriteColumnsNotInConfig) - Parameters:
outputFilePath
-Path
to write. Nevernull
unaccountedForDefaultAnnotations
-LinkedHashMap
of default annotations that must be added. Nevernull
unaccountedForOverrideAnnotations
-LinkedHashMap
of override annotations that must be added. Nevernull
excludedOutputFields
-Set
column names that are not to appear in the output file. Use an empty set for no exclusions. Nevernull
configPath
- Configuration file where each key is a column and a comma-separated list of fields acts as a list of possible aliases. Note that the list of the keys is the same order that will be seen in the output.toolVersion
- The version number of the tool used to produce the VCF file. Nevernull
isWriteColumnsNotInConfig
- Whether to write funcotation fields that were present but had no alias, no default value, nor override value.
-
createFromResource
public static SimpleTsvOutputRenderer createFromResource(Path outputFilePath, LinkedHashMap<String, String> unaccountedForDefaultAnnotations, LinkedHashMap<String, String> unaccountedForOverrideAnnotations, Set<String> excludedOutputFields, Path resourcePath, String toolVersion, boolean isWriteColumnsNotInConfig) Use when loading the config file from the jar. SeecreateFromFile(Path, LinkedHashMap, LinkedHashMap, Set, Path, String, boolean)
- Parameters:
outputFilePath
- SeecreateFromFile(Path, LinkedHashMap, LinkedHashMap, Set, Path, String, boolean)
unaccountedForDefaultAnnotations
- SeecreateFromFile(Path, LinkedHashMap, LinkedHashMap, Set, Path, String, boolean)
unaccountedForOverrideAnnotations
- SeecreateFromFile(Path, LinkedHashMap, LinkedHashMap, Set, Path, String, boolean)
excludedOutputFields
- SeecreateFromFile(Path, LinkedHashMap, LinkedHashMap, Set, Path, String, boolean)
resourcePath
- Configuration file (as a Resource). SeecreateFromFile(Path, LinkedHashMap, LinkedHashMap, Set, Path, String, boolean)
toolVersion
- SeecreateFromFile(Path, LinkedHashMap, LinkedHashMap, Set, Path, String, boolean)
isWriteColumnsNotInConfig
- Whether to write funcotation fields that were present but had no alias, no default value, nor override value.
-