Skip to content

Commit

Permalink
Merge pull request #129 from solvebio/import-examples
Browse files Browse the repository at this point in the history
import shortcut examples
  • Loading branch information
dandanxu committed Jan 25, 2017
2 parents 5c4e9c3 + 2e980ac commit 00c3c8b
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 4 deletions.
21 changes: 18 additions & 3 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
SolveBio Python Examples
======================

Please start with the [basic Python tutorial](https://docs.solvebio.com/docs/tutorial).
Complete beginner? Please start with the [basic Python tutorial](https://docs.solvebio.com/docs/tutorial).

Advanced Examples
-----------------
## Importing data

There are many ways to import data into SolveBio.

**Web**:
You can import VCF & JSON files directly via the [SolveBio web interface](https://my.solvebio.com/files) ([web import documentation](https://support.solvebio.com/hc/en-us/articles/218889718-Importing-VCF-and-JSON-Data
)).

**SolveBio Python client shortcut**:
[Handy dandy command line shortcut](https://github.com/solvebio/solvebio-python/blob/master/examples/import/README.md) built into the SolveBio Python client.

**Python script**:
Or use an
[example simple Python script](https://github.com/solvebio/solvebio-python/blob/master/examples/import_data.py).


## Advanced Examples

IPython/Jupyter notebooks do not load embedded graphs in the GitHub viewer.
For optimal experience, please use these links:
Expand Down
25 changes: 25 additions & 0 deletions examples/import/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
SolveBio Import Shortcut Example
======================

Make sure you're using the newest version of SolveBio with `pip install solvebio --upgrade`

The SolveBio Python client provides a simple command line shortcut to import data.

Your DOMAIN is the subdomain of your SolveBio account. You can find your domain by going to [SolveBio](https://my.solvebio.com/organization/people) - your organization name is your domain.

To run the example commands, download the [example_input.json](https://github.com/solvebio/solvebio-python/blob/master/examples/import/example_input.json) and [example_template.json](https://github.com/solvebio/solvebio-python/blob/master/examples/import/example_template.json) files.

In your command line:
```bash
solvebio import DOMAIN:ExampleDepo/1.0.0/ExampleDataset example_input.json --create-dataset --auto-approve
```

If you want to add SolveBio entities to your data, you can with a template file (you can also do it later on the SolveBio web interface).
```
solvebio import DOMAIN:ExampleDepo/1.0.0/ExampleEntityDataset example_input.json --create-dataset --auto-approve --template-file example_template.json
```

To get a full list of the arguments options available, try
```
solvebio import -h
```
3 changes: 3 additions & 0 deletions examples/import/example_input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{"aa": "p.T235M", "classification": "missense", "solvebio_variant_id": "GRCh37-1-155932911-155932911-A", "transcript": "ENST00000313695", "genomic_coordinates": {"start": 155932911, "stop": 155932911, "build": "GRCh37", "chromosome": "1"}, "gene_id": "ARHGEF2", "cosmic_id": "998184", "cdna": "c.704C>T","hgvs_g": "NC_000001.10:g.155932911G>A", "hgvs_c": "ENST00000313695:c.704C>T"}
{"aa": "p.A185T", "classification": "missense", "solvebio_variant_id": "GRCh37-1-155934866-155934866-T", "transcript": "ENST00000313695", "genomic_coordinates": {"start": 155934866, "stop": 155934866, "build": "GRCh37", "chromosome": "1"}, "gene_id": "ARHGEF2", "cosmic_id": "998184", "cdna": "c.553G>A","hgvs_g": "NC_000001.10:g.155934866C>T", "hgvs_c": "ENST00000313695:c.553G>A"}
{"aa": "p.A77T", "classification": "missense", "solvebio_variant_id": "GRCh37-1-155936237-155936237-T", "transcript": "ENST00000313695", "genomic_coordinates": {"start": 155936237, "stop": 155936237, "build": "GRCh37", "chromosome": "1"}, "gene_id": "ARHGEF2", "cosmic_id": "998184", "cdna": "c.229G>A","hgvs_g": "NC_000001.10:g.155936237C>T", "hgvs_c": "ENST00000313695:c.229G>A"}
13 changes: 13 additions & 0 deletions examples/import/example_template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "Example SolveBio import template",
"fields": [
{
"name": "gene_id",
"entity_type": "gene"
},
{
"name": "solvebio_variant_id",
"entity_type": "variant"
}
]
}
7 changes: 6 additions & 1 deletion examples/import_data.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import solvebio

# find your solvebio domain
solvebio.login()
user = solvebio.User.retrieve()
my_domain = user['account']['domain']

# create a dataset
dataset_name = '{0}:SampleImport/1.0.0/SampleImport'.format('your-domain')
dataset_name = '{0}:SampleImport/1.0.0/SampleImport'.format(my_domain)
dataset = solvebio.Dataset.get_or_create_by_full_name(dataset_name)

# create a manifest object and a file to it
Expand Down

0 comments on commit 00c3c8b

Please sign in to comment.