<s> """<STR_LIT>""" <EOL> from __future__ import division <EOL> from __future__ import print_function <EOL> from __future__ import unicode_literals <EOL> import ga4gh . datarepo as datarepo <EOL> import ga4gh . datamodel as datamodel <EOL> import ga4gh . datamodel . datasets as datasets <EOL> import ga4gh . datamodel . sequenceAnnotations as sequenceAnnotations <EOL> import ga4gh . protocol as protocol <EOL> import tests . datadriven as datadriven <EOL> _datasetName = "<STR_LIT>" <EOL> _discontinuousTestData = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT:30> , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : protocol . Strand . POS_STRAND , <EOL> "<STR_LIT>" : <NUM_LIT:2> , <EOL> "<STR_LIT>" : [ <NUM_LIT:0> , <NUM_LIT:2> ** <NUM_LIT:32> ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" , ] , <EOL> "<STR_LIT>" : <NUM_LIT:3> <EOL> } <EOL> _gencodeV21Set1TestData = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : protocol . Strand . POS_STRAND , <EOL> "<STR_LIT>" : <NUM_LIT:5> , <EOL> "<STR_LIT>" : [ <NUM_LIT:0> , <NUM_LIT:2> ** <NUM_LIT:32> ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" , ] , <EOL> "<STR_LIT>" : <NUM_LIT> <EOL> } <EOL> _sacCerTestTestData = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : None , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : protocol . Strand . NEG_STRAND , <EOL> "<STR_LIT>" : <NUM_LIT:20> , <EOL> "<STR_LIT>" : [ <NUM_LIT:0> , <NUM_LIT:2> ** <NUM_LIT:32> ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" , ] , <EOL> "<STR_LIT>" : <NUM_LIT:11> <EOL> } <EOL> _specialCasesTestTestData = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT:4> , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : None , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT>" : protocol . Strand . NEG_STRAND , <EOL> "<STR_LIT>" : <NUM_LIT:2> , <EOL> "<STR_LIT>" : [ <NUM_LIT:0> , <NUM_LIT:2> ** <NUM_LIT:32> ] , <EOL> "<STR_LIT>" : [ "<STR_LIT>" , ] , <EOL> "<STR_LIT>" : <NUM_LIT:0> <EOL> } <EOL> _testDataForFeatureSetName = { <EOL> "<STR_LIT>" : _discontinuousTestData , <EOL> "<STR_LIT>" : _gencodeV21Set1TestData , <EOL> "<STR_LIT>" : _sacCerTestTestData , <EOL> "<STR_LIT>" : _specialCasesTestTestData <EOL> } <EOL> def _getFeatureCompoundId ( dataSetName , featureSetName , featureId ) : <EOL> splits = [ dataSetName , featureSetName , str ( featureId ) ] <EOL> joined = datamodel . CompoundId . join ( splits ) <EOL> obfuscated = datamodel . CompoundId . obfuscate ( joined ) <EOL> return obfuscated <EOL> def testFeatureSets ( ) : <EOL> testDataDir = "<STR_LIT>" <EOL> for test in datadriven . makeTests ( testDataDir , FeatureSetTests , "<STR_LIT>" ) : <EOL> yield test <EOL> class FeatureSetTests ( datadriven . DataDrivenTest ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , featureSetLocalName , dataPath ) : <EOL> """<STR_LIT>""" <EOL> self . _dataset = datasets . AbstractDataset ( _datasetName ) <EOL> self . _datarepo = datarepo . FileSystemDataRepository ( "<STR_LIT>" ) <EOL> featureSetLocalName = featureSetLocalName [ : - <NUM_LIT:3> ] <EOL> self . _testData = _testDataForFeatureSetName [ featureSetLocalName ] <EOL> super ( FeatureSetTests , self ) . __init__ ( featureSetLocalName , dataPath ) <EOL> def getProtocolClass ( self ) : <EOL> return protocol . FeatureSet <EOL> def getDataModelInstance ( self , localId , dataPath ) : <EOL> return sequenceAnnotations . Gff3DbFeatureSet ( <EOL> self . _dataset , localId , dataPath , self . _datarepo ) <EOL> def testGetFeatureById ( self ) : <EOL> idString = _getFeatureCompoundId ( <EOL> _datasetName , <EOL> self . _testData [ "<STR_LIT>" ] , <EOL> self . _testData [ "<STR_LIT>" ] ) <EOL> compoundId = datamodel . FeatureCompoundId . parse ( idString ) <EOL> feature = self . _gaObject . getFeature ( compoundId ) <EOL> self . assertIsNotNone ( feature ) <EOL> self . assertEqual ( feature . id , idString ) <EOL> if self . _testData [ "<STR_LIT>" ] is not None : <EOL> self . assertEqual ( <EOL> datamodel . FeatureCompoundId . parse ( <EOL> feature . parentId ) . featureId , <EOL> str ( self . _testData [ "<STR_LIT>" ] ) ) <EOL> else : <EOL> self . assertEqual ( feature . parentId , '<STR_LIT>' ) <EOL> self . assertEqual ( <EOL> feature . referenceName , <EOL> self . _testData [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( <EOL> feature . start , <EOL> self . _testData [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( <EOL> feature . end , <EOL> self . _testData [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( <EOL> feature . strand , <EOL> self . _testData [ "<STR_LIT>" ] ) <EOL> def testFetchAllFeaturesInRegion ( self ) : <EOL> features = [ ] <EOL> nextPageTokens = [ ] <EOL> for ( feature , nextPageToken ) in self . _gaObject . getFeatures ( <EOL> self . _testData [ "<STR_LIT>" ] , <EOL> self . _testData [ "<STR_LIT>" ] [ <NUM_LIT:0> ] , <EOL> self . _testData [ "<STR_LIT>" ] [ <NUM_LIT:1> ] , <EOL> None , <NUM_LIT:1000> ) : <EOL> features . append ( feature ) <EOL> nextPageTokens . append ( nextPageToken ) <EOL> self . assertEqual ( len ( features ) , self . _testData [ "<STR_LIT>" ] ) <EOL> self . assertIsNone ( nextPageTokens [ - <NUM_LIT:1> ] ) <EOL> def testFetchFeaturesRestrictedByOntology ( self ) : <EOL> features = [ ] <EOL> for ( feature , _ ) in self . _gaObject . getFeatures ( <EOL> self . _testData [ "<STR_LIT>" ] , <EOL> self . _testData [ "<STR_LIT>" ] [ <NUM_LIT:0> ] , <EOL> self . _testData [ "<STR_LIT>" ] [ <NUM_LIT:1> ] , <EOL> None , <NUM_LIT:1000> , <EOL> featureTypes = self . _testData [ "<STR_LIT>" ] ) : <EOL> features . append ( feature ) <EOL> self . assertEqual ( len ( features ) , <EOL> self . _testData [ "<STR_LIT>" ] ) <EOL> def testFetchFeaturesRestrictedByParent ( self ) : <EOL> parentId = "<STR_LIT>" <EOL> if self . _testData [ "<STR_LIT>" ] is not None : <EOL> parentIdString = _getFeatureCompoundId ( <EOL> _datasetName , <EOL> self . _testData [ "<STR_LIT>" ] , <EOL> self . _testData [ "<STR_LIT>" ] ) <EOL> parentId = datamodel . FeatureCompoundId . parse ( <EOL> parentIdString ) . featureId <EOL> features = [ ] <EOL> for ( feature , _ ) in self . _gaObject . getFeatures ( <EOL> self . _testData [ "<STR_LIT>" ] , <EOL> self . _testData [ "<STR_LIT>" ] [ <NUM_LIT:0> ] , <EOL> self . _testData [ "<STR_LIT>" ] [ <NUM_LIT:1> ] , <EOL> None , <NUM_LIT:1000> , <EOL> parentId = parentId ) : <EOL> features . append ( feature ) <EOL> self . assertEqual ( len ( features ) , <EOL> self . _testData [ "<STR_LIT>" ] ) </s>
