Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import shortcut examples #129

Merged
merged 2 commits into from
Jan 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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**:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe change to "command line"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right, that's the word i was looking for :) thx

[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