-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
1,404 additions
and
653 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from isatools import isatab, sampletab | ||
import logging | ||
|
||
logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', level=logging.INFO) | ||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def convert(source_inv_fp, target_fp): | ||
""" Converter for ISA-Tab to SampleTab. | ||
:param source_inv_fp: File descriptor of input investigation file | ||
:param target_fp: File descriptor to write output SampleTab to (must be writeable) | ||
""" | ||
ISA = isatab.load(source_inv_fp) | ||
sampletab.dump(ISA, target_fp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from isatools import isajson, sampletab | ||
import logging | ||
|
||
logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', level=logging.INFO) | ||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def convert(source_json_fp, target_fp): | ||
""" Converter for ISA-JSON to SampleTab. | ||
:param source_json_fp: File descriptor of input ISA JSON file | ||
:param target_fp: File descriptor to write output SampleTab to (must be writeable) | ||
""" | ||
ISA = isajson.load(source_json_fp) | ||
sampletab.dump(ISA, target_fp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from isatools import sampletab, isatab | ||
import logging | ||
|
||
logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', level=logging.INFO) | ||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def convert(source_sampletab_fp, target_dir): | ||
""" Converter for ISA-JSON to SampleTab. | ||
:param source_sampletab_fp: File descriptor of input SampleTab file | ||
:param target_dir: Path to write out ISA-Tab files to | ||
""" | ||
ISA = sampletab.load(source_sampletab_fp) | ||
isatab.dump(ISA, target_dir) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from isatools import sampletab | ||
from isatools.isajson import ISAJSONEncoder | ||
import json | ||
import logging | ||
|
||
logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', level=logging.INFO) | ||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def convert(source_sampletab_fp, target_json_fp): | ||
""" Converter for ISA-JSON to SampleTab. | ||
:param source_sampletab_fp: File descriptor of input SampleTab file | ||
:param target_json_fp: File descriptor to write output ISA JSON (must be writeable) | ||
""" | ||
ISA = sampletab.load(source_sampletab_fp) | ||
json.dump(ISA, fp=target_json_fp, cls=ISAJSONEncoder) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.