Package org.incenp.obofoundry.sssom
Class TSVWriter
java.lang.Object
org.incenp.obofoundry.sssom.SSSOMWriter
org.incenp.obofoundry.sssom.TSVWriter
A writer to serialise a SSSOM mapping set into the TSV format.
If the mapping set has a CURIE map (MappingSet.getCurieMap()), it is
automatically used to shorten identifiers when they are written to the file.
Usage:
MappingSet mappingSet = ...;
try {
TSVWriter writer = new TSVWriter("my-mappings.sssom.tsv");
writer.write(mappingSet);
} catch ( IOException ioe ) {
// Generic I/O error
}
-
Field Summary
Fields inherited from class org.incenp.obofoundry.sssom.SSSOMWriter
condensationPolicy, extensionManager, extraPolicy, prefixManager, targetVersion -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance that will write data to the specified file in embedded mode (metadata block and TSV section in the same file).Creates a new instance that will write data to the specified files.TSVWriter(OutputStream stream) Creates a new instance that will write data to the specified stream in embedded mode.TSVWriter(OutputStream tsvStream, OutputStream metaStream) Creates a new instance that will write data to the specified streams.Creates a new instance that will write data to a file with the specified filename, in embedded mode.Creates a new instance that will write data to files with the specified filenames. -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoWrite(MappingSet mappingSet) Actually serialises a mapping set.voidenableCSV(boolean csv) Enables CSV mode.Methods inherited from class org.incenp.obofoundry.sssom.SSSOMWriter
condenseSet, getUsedPrefixes, getUsedPrefixes, setCondensationEnabled, setCurieMap, setExtraMetadataPolicy, setSortingEnabled, setTargetVersion, write
-
Constructor Details
-
TSVWriter
Creates a new instance that will write data to the specified files.- Parameters:
tsvFile- The file to write the TSV section to.metaFile- The file to write the metadata block to. Ifnull, the metadata block will be embedded in the same file as the TSV section.- Throws:
IOException- If any of the files cannot be opened for any reason.
-
TSVWriter
Creates a new instance that will write data to the specified file in embedded mode (metadata block and TSV section in the same file).- Parameters:
file- The file to write to.- Throws:
IOException- If the file cannot be opened for any reason.
-
TSVWriter
Creates a new instance that will write data to the specified streams.- Parameters:
tsvStream- The stream to write the TSV section to.metaStream- The stream to write the metadata block to. Ifnull, the metadata block will be embedded in the same stream as the TSV section.
-
TSVWriter
Creates a new instance that will write data to the specified stream in embedded mode.- Parameters:
stream- The stream to write to.
-
TSVWriter
Creates a new instance that will write data to files with the specified filenames.- Parameters:
tsvFilename- The name of the file to write the TSV section to.metaFilename- The name of the file to write the metadata block to. Ifnull, the metadata block will be embedded in the same file as the TSV section.- Throws:
IOException- If any of the files cannot be opened for any reason.
-
TSVWriter
Creates a new instance that will write data to a file with the specified filename, in embedded mode.- Parameters:
filename- The name of the file to write to.- Throws:
IOException- If the file cannot be opened for any reason.
-
-
Method Details
-
enableCSV
public void enableCSV(boolean csv) Enables CSV mode. This makes the writer use a comma to separate columns, rather than a tab.This is not officially supported by the SSSOM specification, which only specifies the tab-separated format. But the comma-separated variant is accepted by SSSOM-Py.
- Parameters:
csv- Iftrue, the writer will produce a CSV file.
-
doWrite
Description copied from class:SSSOMWriterActually serialises a mapping set. This method should be overridden by derived classes to implement the serialisation in a specific format.- Specified by:
doWritein classSSSOMWriter- Parameters:
mappingSet- The mapping set to serialise.- Throws:
IOException- If an I/O error occurs.
-