diff --git a/docs/exportdata.rst b/docs/exportdata.rst new file mode 100644 index 00000000..b22d4315 --- /dev/null +++ b/docs/exportdata.rst @@ -0,0 +1,37 @@ +############################### +Exporting data from ISA formats +############################### + +We have provided a number of modules that allow you to export data from ISA formats to formats for well-known +databases or services. + +---------------------------------- +Exporting ISA content to SampleTab +---------------------------------- +To export metadata from SampleTab files (e.g. for EBI BioSamples database), you can do the following to export a +ISA-Tab to SampleTab: + +.. code-block:: python + + from isatools.convert import isatab2sampletab + with open('your/path/to/i_investigation.txt', 'r') as input_investigation_file: + with open('your/path/to/sampletab.txt', 'w') as output_sampletab_file: + isatab2sampletab.convert(input_investigation_file, output_sampletab_file) + +To export an ISA JSON file to SampleTab, you can do: + +.. code-block:: python + + from isatools.convert import isatab2sampletab + with open('your/path/to/i_investigation.txt', 'r') as input_investigation_file: + with open('your/path/to/sampletab.txt', 'w') as output_sampletab_file: + isatab2sampletab.convert(input_investigation_file, output_sampletab_file) + +You can also dump SampleTab content directly from ISA Python objects: + +.. code-block:: python + + from isatools import sampletab + with open('your/path/to/sampletab.txt', 'w') as output_sampletab: + # Note: ISA would be a previously loaded or constructed root Investigation object + sampletab.dump(ISA, output_sampletab) \ No newline at end of file diff --git a/docs/importdata.rst b/docs/importdata.rst index 601104fd..bc3f981c 100644 --- a/docs/importdata.rst +++ b/docs/importdata.rst @@ -99,4 +99,34 @@ tool from https://github.com/ISA-tools/mzml2isa and can be run as follows: .. code-block:: python from isatools.convert import mzml2isa - mzml2isa.convert('your/path/to/mzml/files/', 'tmp/', "My Study ID") \ No newline at end of file + mzml2isa.convert('your/path/to/mzml/files/', 'tmp/', "My Study ID") + + +-------------------------- +Importing SampleTab to ISA +-------------------------- +To import metadata from SampleTab files (e.g. from EBI BioSamples database), you can do the following to import a +SampleTab to ISA-Tab: + +.. code-block:: python + + from isatools.convert import sampletab2isatab + with open('your/path/to/sampletab.txt', 'r') as input_sampletab: + sampletab2isatab.convert(input_sampletab, 'tmp/') + +To import a SampleTab to ISA JSON, you can do: + +.. code-block:: python + + from isatools.convert import sampletab2json + with open('your/path/to/sampletab.txt', 'r') as input_sampletab: + with open('your/path/to/myjson.json', 'w') as output_json:' + sampletab2json.convert(input_sampletab, output_json) + +You can also load SampleTab content directly into ISA Python objects: + +.. code-block:: python + + from isatools import sampletab + with open('your/path/to/sampletab.txt', 'r') as input_sampletab: + ISA = sampletab.load(input_sampletab) \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst index a98f6b99..57554cbd 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -19,6 +19,7 @@ flexible way to build and use ISA content, as well as provide utility functions #. :doc:`Downloading files stored in Github ` #. :doc:`Validating ISA-Tab and ISA JSON ` #. :doc:`Importing data in ISA formats ` +#. :doc:`Exporting data in ISA formats ` #. :doc:`Known Issues ` License @@ -43,4 +44,5 @@ This code is licensed under the `CPAL License Validating ISA-Tab and ISA JSON Importing data in ISA formats + Exporting data from ISA formats Known Issues \ No newline at end of file