Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d3705bf
Try to set up travis to run unit tests
dtenenba Oct 18, 2016
36ab562
add travis build badge to README
dtenenba Oct 18, 2016
9b21ce1
ignore file downloaded for unit tests
dtenenba Oct 18, 2016
e799e40
some unit tests pass in py3 (all still pass in py2)
dtenenba Oct 18, 2016
d88725e
cleanup
dtenenba Oct 18, 2016
e19f835
run test script with -e flag to catch errors
dtenenba Oct 18, 2016
b0fc158
test proper exit (should fail travis build)
dtenenba Oct 18, 2016
a6ca107
test runner script should exit appropriately
dtenenba Oct 18, 2016
3c8b911
test suite exits with appropriate error code, for CI integration
dtenenba Oct 18, 2016
b6a3857
unit tests in py2 really pass now (at least locally)
dtenenba Oct 20, 2016
1d5ab66
fix TestAPIFileUploadMethods_SmallFiles in py3
dtenenba Oct 20, 2016
6b8d50f
add missing exception DownloadFailedException
dtenenba Oct 21, 2016
19c8824
fix some broken unit tests by encoding response to utf-8
dtenenba Oct 21, 2016
07d9850
fix unit tests in TestAPIClientMethods
dtenenba Oct 21, 2016
cb428b3
removed imports which caused a namespcae conflict, fixes TestRunMetho…
dtenenba Oct 21, 2016
d9f71ae
test fix in progress, logging code not cleaned up yet
dtenenba Oct 21, 2016
256cb9a
unit tests pass locally on py 2 and 3
dtenenba Oct 23, 2016
254e6f7
experimental - add pyflakes checking (but do not fail CI if there are…
dtenenba Oct 23, 2016
0da2e44
clean up output
dtenenba Oct 23, 2016
27fd4cc
add a comment
dtenenba Oct 23, 2016
2425fd3
make build report link clickable
dtenenba Oct 27, 2016
8d2e906
fix build image
dtenenba Oct 27, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ parts
var
sdist
/scripts
data/BC-12_S12_L001_R2_001.fastq.gz
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: python
python:
- "2.7"
- "3.5"
install: "cd src && python setup.py install && cd .."
script: ./runtests.sh
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
INTRODUCTION
[![Build Status][travis-image]](https://travis-ci.org/dtenenba/basespace-python-sdk)

[travis-image]: https://img.shields.io/travis/dtenenba/basespace-python-sdk.svg?style=flat&branch=develop

INTRODUCTION
=========================================

BaseSpacePy is a Python based SDK to be used in the development of Apps and scripts for working with Illumina's BaseSpace cloud-computing solution for next-gen sequencing data analysis.
BaseSpacePy is a Python based SDK to be used in the development of Apps and scripts for working with Illumina's BaseSpace cloud-computing solution for next-gen sequencing data analysis.

The primary purpose of the SDK is to provide an easy-to-use Python environment enabling developers to authenticate a user, retrieve data, and upload data/results from their own analysis to BaseSpace.

Expand Down Expand Up @@ -39,7 +43,7 @@ If you do not have root access, you may use the --prefix to specify the install

python setup.py install --prefix=/folder/in/my/pythonpath

For more install options type:
For more install options type:

python setup.py --help

Expand All @@ -53,7 +57,7 @@ or add it to the PYTHONPATH at the top of your Python scripts using BaseSpacePy:
sys.path.append('/my/path/basespace-python-sdk/src')
import BaseSpacePy

To test that everything is working as expected, launch a Python prompt and try importing 'BaseSpacePy':
To test that everything is working as expected, launch a Python prompt and try importing 'BaseSpacePy':

mkallberg@ubuntu:~/$ python
>>> import BaseSpacePy
Expand Down Expand Up @@ -115,7 +119,7 @@ Update to support changes in BaseSpace REST specification version v1pre3. Specif

v 0.1
-----------------------------------------

Initial release of BaseSpacePy

COPYING / LICENSE
Expand Down
16 changes: 8 additions & 8 deletions doc/_update_doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
master_doc = 'index'

# General information about the project.
project = u'BaseSpacePy'
copyright = u'2014, Illumina'
project = 'BaseSpacePy'
copyright = '2014, Illumina'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -183,8 +183,8 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'BaseSpacePy.tex', u'BaseSpacePy Documentation',
u'Illumina', 'manual'),
('index', 'BaseSpacePy.tex', 'BaseSpacePy Documentation',
'Illumina', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -213,8 +213,8 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'basespacepy', u'BaseSpacePy Documentation',
[u'Illumina'], 1)
('index', 'basespacepy', 'BaseSpacePy Documentation',
['Illumina'], 1)
]

# If true, show URL addresses after external links.
Expand All @@ -227,8 +227,8 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'BaseSpacePy', u'BaseSpacePy Documentation',
u'Illumina', 'BaseSpacePy', 'One line description of project.',
('index', 'BaseSpacePy', 'BaseSpacePy Documentation',
'Illumina', 'BaseSpacePy', 'One line description of project.',
'Miscellaneous'),
]

Expand Down
33 changes: 16 additions & 17 deletions examples/0_Browsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -14,11 +14,10 @@
"""

from BaseSpacePy.api.BaseSpaceAPI import BaseSpaceAPI
import os

"""
This script demonstrates basic browsing of BaseSpace objects once an access-token
for global browsing has been obtained.
for global browsing has been obtained.
"""

"""
Expand All @@ -30,8 +29,8 @@
[DEFAULT]
name = my new app
clientKey =
clientSecret =
accessToken =
clientSecret =
accessToken =
appSessionId =
apiServer = https://api.cloud-hoth.illumina.com/
apiVersion = v1pre3
Expand All @@ -49,35 +48,35 @@
myAPI = BaseSpaceAPI(clientKey, clientSecret, apiServer, apiVersion, appSessionId)
else:
myAPI = BaseSpaceAPI(profile='DEFAULT')

# First, let's grab the genome with id=4
myGenome = myAPI.getGenomeById('4')
print "\nThe Genome is " + str(myGenome)
print "We can get more information from the genome object"
print 'Id: ' + myGenome.Id
print 'Href: ' + myGenome.Href
print 'DisplayName: ' + myGenome.DisplayName
print("\nThe Genome is " + str(myGenome))
print("We can get more information from the genome object")
print('Id: ' + myGenome.Id)
print('Href: ' + myGenome.Href)
print('DisplayName: ' + myGenome.DisplayName)

# Get a list of all genomes
allGenomes = myAPI.getAvailableGenomes()
print "\nGenomes \n" + str(allGenomes)
print("\nGenomes \n" + str(allGenomes))

# Let's have a look at the current user
user = myAPI.getUserById('current')
print "\nThe current user is \n" + str(user)
print("\nThe current user is \n" + str(user))

# Now list the projects for this user
myProjects = myAPI.getProjectByUser()
print "\nThe projects for this user are \n" + str(myProjects)
print("\nThe projects for this user are \n" + str(myProjects))

# We can also achieve this by making a call using the 'user instance'
myProjects2 = user.getProjects(myAPI)
print "\nProjects retrieved from the user instance \n" + str(myProjects2)
print("\nProjects retrieved from the user instance \n" + str(myProjects2))

# List the runs available for the current user
runs = user.getRuns(myAPI)
print "\nThe runs for this user are \n" + str(runs)
print("\nThe runs for this user are \n" + str(runs))

# In the same manner we can get a list of accessible user runs
runs = user.getRuns(myAPI)
print "\nRuns retrieved from user instance \n" + str(runs)
print("\nRuns retrieved from user instance \n" + str(runs))
47 changes: 23 additions & 24 deletions examples/1_AccessingFiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -14,16 +14,15 @@
"""

from BaseSpacePy.api.BaseSpaceAPI import BaseSpaceAPI
import os
"""
This script demonstrates how to access Samples and AppResults from a projects and how to work with the available
file data for such instances.
This script demonstrates how to access Samples and AppResults from a projects and how to work with the available
file data for such instances.
"""

"""
NOTE: The coverage and variants API calls below require access to a public
NOTE: The coverage and variants API calls below require access to a public
dataset. Before running the example, first go to cloud-hoth.illumina.com,
login, click on Public Data, select the dataset named 'MiSeq B. cereus demo
login, click on Public Data, select the dataset named 'MiSeq B. cereus demo
data', and click the Import button for the Project named 'BaseSpaceDemo'.
"""

Expand Down Expand Up @@ -51,40 +50,40 @@

# Let's list all the AppResults and samples for these projects
for singleProject in myProjects:
print "# " + str(singleProject)
print("# " + str(singleProject))
appResults = singleProject.getAppResults(myAPI)
print " The App results for project " + str(singleProject) + " are \n\t" + str(appResults)
print(" The App results for project " + str(singleProject) + " are \n\t" + str(appResults))
samples = singleProject.getSamples(myAPI)
print " The samples for project " + str(singleProject) + " are \n\t" + str(samples)
print(" The samples for project " + str(singleProject) + " are \n\t" + str(samples))
#
## we'll take a further look at the files belonging to the sample and
##analyses from the last project in the loop above
## we'll take a further look at the files belonging to the sample and
##analyses from the last project in the loop above
for a in appResults:
print "# " + a.Id
print("# " + a.Id)
ff = a.getFiles(myAPI)
print ff
print(ff)
for s in samples:
print "Sample " + str(s)
print("Sample " + str(s))
ff = s.getFiles(myAPI)
print ff
print(ff)


## Now let's do some work with files
## we'll grab a BAM by id and get the coverage for an interval + accompanying meta-data
## Now let's do some work with files
## we'll grab a BAM by id and get the coverage for an interval + accompanying meta-data
myBam = myAPI.getFileById('9895890')
print myBam
print(myBam)
cov = myBam.getIntervalCoverage(myAPI,'chr','1','100')
print cov
print(cov)
try:
covMeta = myBam.getCoverageMeta(myAPI,'chr')
except Exception as e:
print "Coverage metadata may not be available for this BAM file: %s" % str(e)
print("Coverage metadata may not be available for this BAM file: %s" % str(e))
else:
print covMeta
print(covMeta)
#
## and a vcf file
myVCF = myAPI.getFileById('9895892')
varMeta = myVCF.getVariantMeta(myAPI)
print varMeta
var = myVCF.filterVariant(myAPI,'chr','1', '25000')
print var
print(varMeta)
var = myVCF.filterVariant(myAPI,'chr','1', '25000')
print(var)
46 changes: 22 additions & 24 deletions examples/2_AppTriggering.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -14,11 +14,9 @@
"""

from BaseSpacePy.api.BaseSpaceAPI import BaseSpaceAPI
import webbrowser
import time

"""
This script demonstrates how to retrieve the AppSession object produced
This script demonstrates how to retrieve the AppSession object produced
when a user initiates an app. Further it's demonstrated how to automatically
generate the scope strings to request access to the data object (a project or a sample)
that the app was triggered to analyze.
Expand Down Expand Up @@ -51,52 +49,52 @@

# Using the basespaceApi we can request the appSession object corresponding to the AppSession id supplied
myAppSession = myAPI.getAppSession()
print myAppSession
print(myAppSession)

# An app session contains a referal to one or more appLaunchObjects which reference the data module
# the user launched the app on. This can be a list of projects, samples, or a mixture of objects
print "\nType of data the app was triggered on can be seen in 'references'"
print myAppSession.References
# the user launched the app on. This can be a list of projects, samples, or a mixture of objects
print("\nType of data the app was triggered on can be seen in 'references'")
print(myAppSession.References)

# We can also get a handle to the user who started the AppSession
print "\nWe can get a handle for the user who triggered the app\n" + str(myAppSession.UserCreatedBy)
print("\nWe can get a handle for the user who triggered the app\n" + str(myAppSession.UserCreatedBy))

# Let's have a closer look at the appSessionLaunchObject
myReference = myAppSession.References[0]
print "\nWe can get out information such as the href to the launch object:"
print myReference.HrefContent
print "\nand the specific type of that object:"
print myReference.Type
print("\nWe can get out information such as the href to the launch object:")
print(myReference.HrefContent)
print("\nand the specific type of that object:")
print(myReference.Type)


# Now we will want to ask for more permission for the specific reference object
print "\nWe can get out the specific project objects by using 'content':"
print("\nWe can get out the specific project objects by using 'content':")
myReference = myReference.Content
print myReference
print "\nThe scope string for requesting read access to the reference object is:"
print myReference.getAccessStr(scope='write')
print(myReference)
print("\nThe scope string for requesting read access to the reference object is:")
print(myReference.getAccessStr(scope='write'))

# We can easily request write access to the reference object so our App can start contributing analysis
# by default we ask for write permission and authentication for a device
#accessMap = myAPI.getAccess(myReference,accessType='write')
# We may limit our request to read access only if that's all that is needed
#readAccessMaps = myAPI.getAccess(myReference,accessType='read')

#print "\nWe get the following access map for the write request"
#print accessMap
#print("\nWe get the following access map for the write request")
#print(accessMap)

## PAUSE HERE
# Have the user visit the verification uri to grant us access
#print "\nPlease visit the uri within 15 seconds and grant access"
#print accessMap['verification_with_code_uri']
#print("\nPlease visit the uri within 15 seconds and grant access")
#print(accessMap['verification_with_code_uri'])
#webbrowser.open_new(accessMap['verification_with_code_uri'])
#time.sleep(15)
## PAUSE HERE

# Once the user has granted us the access to the object we requested we can
# get the basespace access token and start browsing simply by calling updatePriviliges
# on the baseSpaceApi instance
# on the baseSpaceApi instance
#code = accessMap['device_code']
#myAPI.updatePrivileges(code)
#print "\nThe BaseSpaceAPI instance was update with write privileges"
#print myAPI
#print("\nThe BaseSpaceAPI instance was update with write privileges")
#print(myAPI)
Loading