Skip to content
This repository has been archived by the owner on Jan 24, 2018. It is now read-only.

Commit

Permalink
Bigwig (#1573)
Browse files Browse the repository at this point in the history
* reader working; service added

* server working, commented and tested, except for duplicated FeatureSet tests

* fixed range exception for continuous

* added featureset tests

* updated compliance data

* updated to new datarepo

* flake fixes

* updated code - new repo and attributes

* removed nan from messages

* removed numpy requirement

* added ContinuousSet to index.html

* Update constraints
  • Loading branch information
ejacox authored and david4096 committed Feb 21, 2017
1 parent febbfb8 commit 81078fe
Show file tree
Hide file tree
Showing 29 changed files with 1,156 additions and 3 deletions.
60 changes: 60 additions & 0 deletions ga4gh/server/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,24 @@ def featuresGenerator(self, request):
request, featureSet, parentId)
return iterator

def continuousGenerator(self, request):
"""
Returns a generator over the (continuous, nextPageToken) pairs
defined by the (JSON string) request.
"""
compoundId = None
if request.continuous_set_id != "":
compoundId = datamodel.ContinuousSetCompoundId.parse(
request.continuous_set_id)
if compoundId is None:
raise exceptions.ContinuousSetNotSpecifiedException()

dataset = self.getDataRepository().getDataset(
compoundId.dataset_id)
continuousSet = dataset.getContinuousSet(request.continuous_set_id)
iterator = paging.ContinuousIterator(request, continuousSet)
return iterator

def phenotypesGenerator(self, request):
"""
Returns a generator over the (phenotypes, nextPageToken) pairs
Expand Down Expand Up @@ -489,6 +507,16 @@ def featureSetsGenerator(self, request):
request, dataset.getNumFeatureSets(),
dataset.getFeatureSetByIndex)

def continuousSetsGenerator(self, request):
"""
Returns a generator over the (continuousSet, nextPageToken) pairs
defined by the specified request.
"""
dataset = self.getDataRepository().getDataset(request.dataset_id)
return self._topLevelObjectGenerator(
request, dataset.getNumContinuousSets(),
dataset.getContinuousSetByIndex)

def rnaQuantificationSetsGenerator(self, request):
"""
Returns a generator over the (rnaQuantificationSet, nextPageToken)
Expand Down Expand Up @@ -746,6 +774,15 @@ def runGetFeatureSet(self, id_):
featureSet = dataset.getFeatureSet(id_)
return self.runGetRequest(featureSet)

def runGetContinuousSet(self, id_):
"""
Runs a getContinuousSet request for the specified ID.
"""
compoundId = datamodel.ContinuousSetCompoundId.parse(id_)
dataset = self.getDataRepository().getDataset(compoundId.dataset_id)
continuousSet = dataset.getContinuousSet(id_)
return self.runGetRequest(continuousSet)

def runGetDataset(self, id_):
"""
Runs a getDataset request for the specified ID.
Expand Down Expand Up @@ -929,6 +966,29 @@ def runSearchFeatures(self, request):
protocol.SearchFeaturesResponse,
self.featuresGenerator)

def runSearchContinuousSets(self, request):
"""
Returns a SearchContinuousSetsResponse for the specified
SearchContinuousSetsRequest object.
"""
return self.runSearchRequest(
request, protocol.SearchContinuousSetsRequest,
protocol.SearchContinuousSetsResponse,
self.continuousSetsGenerator)

def runSearchContinuous(self, request):
"""
Returns a SearchContinuousResponse for the specified
SearchContinuousRequest object.
:param request: JSON string representing searchContinuousRequest
:return: JSON string representing searchContinuousResponse
"""
return self.runSearchRequest(
request, protocol.SearchContinuousRequest,
protocol.SearchContinuousResponse,
self.continuousGenerator)

def runSearchGenotypePhenotypes(self, request):
return self.runSearchRequest(
request, protocol.SearchGenotypePhenotypeRequest,
Expand Down
61 changes: 61 additions & 0 deletions ga4gh/server/cli/repomanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import ga4gh.server.datamodel.references as references
import ga4gh.server.datamodel.rna_quantification as rna_quantification
import ga4gh.server.datamodel.sequence_annotations as sequence_annotations
import ga4gh.server.datamodel.continuous as continuous
import ga4gh.server.datamodel.variants as variants
import ga4gh.server.datarepo as datarepo
import ga4gh.server.exceptions as exceptions
Expand Down Expand Up @@ -429,6 +430,38 @@ def func():
self._updateRepo(self._repo.removeFeatureSet, featureSet)
self._confirmDelete("FeatureSet", featureSet.getLocalId(), func)

def addContinuousSet(self):
"""
Adds a new continuous set into this repo
"""
self._openRepo()
dataset = self._repo.getDatasetByName(self._args.datasetName)
filePath = self._getFilePath(self._args.filePath,
self._args.relativePath)
name = getNameFromPath(self._args.filePath)
continuousSet = continuous.FileContinuousSet(dataset, name)
referenceSetName = self._args.referenceSetName
if referenceSetName is None:
raise exceptions.RepoManagerException(
"A reference set name must be provided")
referenceSet = self._repo.getReferenceSetByName(referenceSetName)
continuousSet.setReferenceSet(referenceSet)
continuousSet.populateFromFile(filePath)
self._updateRepo(self._repo.insertContinuousSet, continuousSet)

def removeContinuousSet(self):
"""
Removes a continuous set from this repo
"""
self._openRepo()
dataset = self._repo.getDatasetByName(self._args.datasetName)
continuousSet = dataset.getContinuousSetByName(
self._args.continuousSetName)

def func():
self._updateRepo(self._repo.removeContinuousSet, continuousSet)
self._confirmDelete("ContinuousSet", continuousSet.getLocalId(), func)

def addBiosample(self):
"""
Adds a new biosample into this repo
Expand Down Expand Up @@ -639,6 +672,12 @@ def addFeatureSetNameArgument(cls, subparser):
"featureSetName",
help="the name of the feature set")

@classmethod
def addContinuousSetNameArgument(cls, subparser):
subparser.add_argument(
"continuousSetName",
help="the name of the continuous set")

@classmethod
def addIndividualNameArgument(cls, subparser):
subparser.add_argument(
Expand Down Expand Up @@ -924,6 +963,28 @@ def getParser(cls):
cls.addFeatureSetNameArgument(removeFeatureSetParser)
cls.addForceOption(removeFeatureSetParser)

addContinuousSetParser = common_cli.addSubparser(
subparsers, "add-continuousset",
"Add a continuous set to the data repo")
addContinuousSetParser.set_defaults(runner="addContinuousSet")
cls.addRepoArgument(addContinuousSetParser)
cls.addDatasetNameArgument(addContinuousSetParser)
cls.addRelativePathOption(addContinuousSetParser)
cls.addFilePathArgument(
addContinuousSetParser,
"The path to the file contianing the continuous data ")
cls.addReferenceSetNameOption(addContinuousSetParser, "continuous set")
cls.addClassNameOption(addContinuousSetParser, "continuous set")

removeContinuousSetParser = common_cli.addSubparser(
subparsers, "remove-continuousset",
"Remove a continuous set from the repo")
removeContinuousSetParser.set_defaults(runner="removeContinuousSet")
cls.addRepoArgument(removeContinuousSetParser)
cls.addDatasetNameArgument(removeContinuousSetParser)
cls.addContinuousSetNameArgument(removeContinuousSetParser)
cls.addForceOption(removeContinuousSetParser)

addBiosampleParser = common_cli.addSubparser(
subparsers, "add-biosample", "Add a Biosample to the dataset")
addBiosampleParser.set_defaults(runner="addBiosample")
Expand Down
8 changes: 8 additions & 0 deletions ga4gh/server/datamodel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,14 @@ class FeatureCompoundId(FeatureSetCompoundId):
fields = FeatureSetCompoundId.fields + ['featureId']


class ContinuousSetCompoundId(DatasetCompoundId):
"""
The compound id for a continuous set
"""
fields = DatasetCompoundId.fields + ['continuous_set']
containerIds = DatasetCompoundId.containerIds + [('continuous_set_id', 1)]


class ReadGroupSetCompoundId(DatasetCompoundId):
"""
The compound id for a read group set
Expand Down
Loading

0 comments on commit 81078fe

Please sign in to comment.