Package org.incenp.obofoundry.sssom
Class TSVWriter
- java.lang.Object
-
- org.incenp.obofoundry.sssom.SSSOMWriter
-
- org.incenp.obofoundry.sssom.TSVWriter
-
public class TSVWriter extends SSSOMWriter
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
Constructors Constructor Description TSVWriter(File file)Creates a new instance that will write data to the specified file in embedded mode (metadata block and TSV section in the same file).TSVWriter(File tsvFile, File metaFile)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.TSVWriter(String filename)Creates a new instance that will write data to a file with the specified filename, in embedded mode.TSVWriter(String tsvFilename, String metaFilename)Creates a new instance that will write data to files with the specified filenames.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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 Detail
-
TSVWriter
public TSVWriter(File tsvFile, File metaFile) throws IOException
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
public TSVWriter(File file) throws IOException
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
public TSVWriter(OutputStream tsvStream, OutputStream metaStream)
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
public TSVWriter(OutputStream stream)
Creates a new instance that will write data to the specified stream in embedded mode.- Parameters:
stream- The stream to write to.
-
TSVWriter
public TSVWriter(String tsvFilename, String metaFilename) throws IOException
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
public TSVWriter(String filename) throws IOException
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 Detail
-
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
protected void doWrite(MappingSet mappingSet) throws IOException
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.
-
-