<s> """<STR_LIT>""" <EOL> from __future__ import division <EOL> from __future__ import print_function <EOL> from __future__ import unicode_literals <EOL> import argparse <EOL> import logging <EOL> import operator <EOL> import unittest <EOL> import unittest . loader <EOL> import unittest . suite <EOL> import requests <EOL> import ga4gh <EOL> import ga4gh . backend as backend <EOL> import ga4gh . client as client <EOL> import ga4gh . converters as converters <EOL> import ga4gh . frontend as frontend <EOL> import ga4gh . configtest as configtest <EOL> import ga4gh . exceptions as exceptions <EOL> import ga4gh . datarepo as datarepo <EOL> import ga4gh . repo_manager as repo_manager <EOL> import ga4gh . protocol as protocol <EOL> AVRO_LONG_MAX = <NUM_LIT:2> ** <NUM_LIT> - <NUM_LIT:1> <EOL> class SortedHelpFormatter ( argparse . HelpFormatter ) : <EOL> """<STR_LIT>""" <EOL> def add_arguments ( self , actions ) : <EOL> """<STR_LIT>""" <EOL> actions = sorted ( <EOL> actions , key = operator . attrgetter ( '<STR_LIT>' ) ) <EOL> super ( SortedHelpFormatter , self ) . add_arguments ( actions ) <EOL> def _iter_indented_subactions ( self , action ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> get_subactions = action . _get_subactions <EOL> except AttributeError : <EOL> pass <EOL> else : <EOL> self . _indent ( ) <EOL> if isinstance ( action , argparse . _SubParsersAction ) : <EOL> for subaction in sorted ( <EOL> get_subactions ( ) , key = lambda x : x . dest ) : <EOL> yield subaction <EOL> else : <EOL> for subaction in get_subactions ( ) : <EOL> yield subaction <EOL> self . _dedent ( ) <EOL> def addSubparser ( subparsers , subcommand , description ) : <EOL> parser = subparsers . add_parser ( <EOL> subcommand , description = description , help = description ) <EOL> return parser <EOL> def createArgumentParser ( description ) : <EOL> parser = argparse . ArgumentParser ( <EOL> description = description , <EOL> formatter_class = SortedHelpFormatter ) <EOL> return parser <EOL> def addServerOptions ( parser ) : <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , default = <NUM_LIT> , type = int , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , default = "<STR_LIT:127.0.0.1>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT:-c>" , default = '<STR_LIT>' , type = str , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , type = str , default = None , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , action = "<STR_LIT:store_true>" , default = False , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , default = False , action = "<STR_LIT:store_true>" , <EOL> help = "<STR_LIT>" ) <EOL> addVersionArgument ( parser ) <EOL> addDisableUrllibWarningsArgument ( parser ) <EOL> def getServerParser ( ) : <EOL> parser = createArgumentParser ( "<STR_LIT>" ) <EOL> addServerOptions ( parser ) <EOL> return parser <EOL> def server_main ( args = None ) : <EOL> parser = getServerParser ( ) <EOL> parsedArgs = parser . parse_args ( args ) <EOL> if parsedArgs . disable_urllib_warnings : <EOL> requests . packages . urllib3 . disable_warnings ( ) <EOL> frontend . configure ( <EOL> parsedArgs . config_file , parsedArgs . config , parsedArgs . port ) <EOL> sslContext = None <EOL> if parsedArgs . tls or ( "<STR_LIT>" in frontend . app . config ) : <EOL> sslContext = "<STR_LIT>" <EOL> frontend . app . run ( <EOL> host = parsedArgs . host , port = parsedArgs . port , <EOL> use_reloader = not parsedArgs . dont_use_reloader , <EOL> ssl_context = sslContext ) <EOL> def verbosityToLogLevel ( verbosity ) : <EOL> """<STR_LIT>""" <EOL> ret = <NUM_LIT:0> <EOL> if verbosity == <NUM_LIT:1> : <EOL> ret = logging . INFO <EOL> elif verbosity >= <NUM_LIT:2> : <EOL> ret = logging . DEBUG <EOL> return ret <EOL> class AbstractQueryRunner ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> self . _key = args . key <EOL> filePrefix = "<STR_LIT>" <EOL> if args . baseUrl . startswith ( filePrefix ) : <EOL> dataDir = args . baseUrl [ len ( filePrefix ) : ] <EOL> theBackend = backend . Backend ( <EOL> datarepo . FileSystemDataRepository ( dataDir ) ) <EOL> self . _client = client . LocalClient ( theBackend ) <EOL> else : <EOL> self . _client = client . HttpClient ( <EOL> args . baseUrl , verbosityToLogLevel ( args . verbose ) , self . _key ) <EOL> class FormattedOutputRunner ( AbstractQueryRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> super ( FormattedOutputRunner , self ) . __init__ ( args ) <EOL> self . _output = self . _textOutput <EOL> if args . outputFormat == "<STR_LIT>" : <EOL> self . _output = self . _jsonOutput <EOL> def _jsonOutput ( self , gaObjects ) : <EOL> """<STR_LIT>""" <EOL> for gaObject in gaObjects : <EOL> print ( gaObject . toJsonString ( ) ) <EOL> def _textOutput ( self , gaObjects ) : <EOL> """<STR_LIT>""" <EOL> for gaObject in gaObjects : <EOL> if hasattr ( gaObject , '<STR_LIT:name>' ) : <EOL> print ( gaObject . id , gaObject . name , sep = "<STR_LIT:\t>" ) <EOL> else : <EOL> print ( gaObject . id , sep = "<STR_LIT:\t>" ) <EOL> class AbstractGetRunner ( FormattedOutputRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> super ( AbstractGetRunner , self ) . __init__ ( args ) <EOL> self . _id = args . id <EOL> def run ( self ) : <EOL> response = self . _method ( self . _id ) <EOL> self . _output ( [ response ] ) <EOL> class AbstractSearchRunner ( FormattedOutputRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> super ( AbstractSearchRunner , self ) . __init__ ( args ) <EOL> self . _pageSize = args . pageSize <EOL> self . _client . setPageSize ( self . _pageSize ) <EOL> def getAllDatasets ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _client . searchDatasets ( ) <EOL> def getAllVariantSets ( self ) : <EOL> """<STR_LIT>""" <EOL> for dataset in self . getAllDatasets ( ) : <EOL> iterator = self . _client . searchVariantSets ( datasetId = dataset . id ) <EOL> for variantSet in iterator : <EOL> yield variantSet <EOL> def getAllFeatureSets ( self ) : <EOL> """<STR_LIT>""" <EOL> for dataset in self . getAllDatasets ( ) : <EOL> iterator = self . _client . searchFeatureSets ( datasetId = dataset . id ) <EOL> for featureSet in iterator : <EOL> yield featureSet <EOL> def getAllReadGroupSets ( self ) : <EOL> """<STR_LIT>""" <EOL> for dataset in self . getAllDatasets ( ) : <EOL> iterator = self . _client . searchReadGroupSets ( <EOL> datasetId = dataset . id ) <EOL> for readGroupSet in iterator : <EOL> yield readGroupSet <EOL> def getAllReadGroups ( self ) : <EOL> """<STR_LIT>""" <EOL> for dataset in self . getAllDatasets ( ) : <EOL> iterator = self . _client . searchReadGroupSets ( <EOL> datasetId = dataset . id ) <EOL> for readGroupSet in iterator : <EOL> readGroupSet = self . _client . getReadGroupSet ( readGroupSet . id ) <EOL> for readGroup in readGroupSet . readGroups : <EOL> yield readGroup . id <EOL> def getAllReferenceSets ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _client . searchReferenceSets ( ) <EOL> class SearchDatasetsRunner ( AbstractSearchRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> super ( SearchDatasetsRunner , self ) . __init__ ( args ) <EOL> def run ( self ) : <EOL> iterator = self . _client . searchDatasets ( ) <EOL> self . _output ( iterator ) <EOL> class SearchReferenceSetsRunner ( AbstractSearchRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> super ( SearchReferenceSetsRunner , self ) . __init__ ( args ) <EOL> self . _accession = args . accession <EOL> self . _md5checksum = args . md5checksum <EOL> def run ( self ) : <EOL> iterator = self . _client . searchReferenceSets ( <EOL> accession = self . _accession , md5checksum = self . _md5checksum ) <EOL> self . _output ( iterator ) <EOL> class SearchReferencesRunner ( AbstractSearchRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> super ( SearchReferencesRunner , self ) . __init__ ( args ) <EOL> self . _referenceSetId = args . referenceSetId <EOL> self . _accession = args . accession <EOL> self . _md5checksum = args . md5checksum <EOL> def _run ( self , referenceSetId ) : <EOL> iterator = self . _client . searchReferences ( <EOL> accession = self . _accession , md5checksum = self . _md5checksum , <EOL> referenceSetId = referenceSetId ) <EOL> self . _output ( iterator ) <EOL> def run ( self ) : <EOL> if self . _referenceSetId is None : <EOL> for referenceSet in self . getAllReferenceSets ( ) : <EOL> self . _run ( referenceSet . id ) <EOL> else : <EOL> self . _run ( self . _referenceSetId ) <EOL> class SearchVariantSetsRunner ( AbstractSearchRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> super ( SearchVariantSetsRunner , self ) . __init__ ( args ) <EOL> self . _datasetId = args . datasetId <EOL> def _run ( self , datasetId ) : <EOL> iterator = self . _client . searchVariantSets ( datasetId = datasetId ) <EOL> self . _output ( iterator ) <EOL> def run ( self ) : <EOL> if self . _datasetId is None : <EOL> for dataset in self . getAllDatasets ( ) : <EOL> self . _run ( dataset . id ) <EOL> else : <EOL> self . _run ( self . _datasetId ) <EOL> class SearchVariantAnnotationSetsRunner ( AbstractSearchRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> super ( SearchVariantAnnotationSetsRunner , self ) . __init__ ( args ) <EOL> self . _variantSetId = args . variantSetId <EOL> def _run ( self , variantSetId ) : <EOL> iterator = self . _client . searchVariantAnnotationSets ( <EOL> variantSetId = variantSetId ) <EOL> self . _output ( iterator ) <EOL> def run ( self ) : <EOL> self . _run ( self . _variantSetId ) <EOL> class SearchFeatureSetsRunner ( AbstractSearchRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> super ( SearchFeatureSetsRunner , self ) . __init__ ( args ) <EOL> self . _datasetId = args . datasetId <EOL> def _run ( self , datasetId ) : <EOL> iterator = self . _client . searchFeatureSets ( datasetId = datasetId ) <EOL> self . _output ( iterator ) <EOL> def run ( self ) : <EOL> if self . _datasetId is None : <EOL> for dataset in self . getAllDatasets ( ) : <EOL> self . _run ( dataset . id ) <EOL> else : <EOL> self . _run ( self . _datasetId ) <EOL> class SearchReadGroupSetsRunner ( AbstractSearchRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> super ( SearchReadGroupSetsRunner , self ) . __init__ ( args ) <EOL> self . _datasetId = args . datasetId <EOL> self . _name = args . name <EOL> def _run ( self , datasetId ) : <EOL> iterator = self . _client . searchReadGroupSets ( <EOL> datasetId = datasetId , name = self . _name ) <EOL> self . _output ( iterator ) <EOL> def run ( self ) : <EOL> if self . _datasetId is None : <EOL> for dataset in self . getAllDatasets ( ) : <EOL> self . _run ( dataset . id ) <EOL> else : <EOL> self . _run ( self . _datasetId ) <EOL> class SearchCallSetsRunner ( AbstractSearchRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> super ( SearchCallSetsRunner , self ) . __init__ ( args ) <EOL> self . _variantSetId = args . variantSetId <EOL> self . _name = args . name <EOL> def _run ( self , variantSetId ) : <EOL> iterator = self . _client . searchCallSets ( <EOL> variantSetId = variantSetId , name = self . _name ) <EOL> self . _output ( iterator ) <EOL> def run ( self ) : <EOL> if self . _variantSetId is None : <EOL> for variantSet in self . getAllVariantSets ( ) : <EOL> self . _run ( variantSet . id ) <EOL> else : <EOL> self . _run ( self . _variantSetId ) <EOL> class VariantFormatterMixin ( object ) : <EOL> """<STR_LIT>""" <EOL> def _textOutput ( self , gaObjects ) : <EOL> """<STR_LIT>""" <EOL> for variant in gaObjects : <EOL> print ( <EOL> variant . id , variant . variantSetId , variant . names , <EOL> variant . referenceName , variant . start , variant . end , <EOL> variant . referenceBases , variant . alternateBases , <EOL> sep = "<STR_LIT:\t>" , end = "<STR_LIT:\t>" ) <EOL> for key , value in variant . info . items ( ) : <EOL> print ( key , value , sep = "<STR_LIT:=>" , end = "<STR_LIT:;>" ) <EOL> print ( "<STR_LIT:\t>" , end = "<STR_LIT>" ) <EOL> for c in variant . calls : <EOL> print ( <EOL> c . callSetId , c . genotype , c . genotypeLikelihood , c . info , <EOL> c . phaseset , sep = "<STR_LIT::>" , end = "<STR_LIT:\t>" ) <EOL> print ( ) <EOL> class AnnotationFormatterMixin ( object ) : <EOL> """<STR_LIT>""" <EOL> def _textOutput ( self , gaObjects ) : <EOL> """<STR_LIT>""" <EOL> for variantAnnotation in gaObjects : <EOL> print ( <EOL> variantAnnotation . id , variantAnnotation . variantId , <EOL> variantAnnotation . variantAnnotationSetId , <EOL> variantAnnotation . createDateTime , sep = "<STR_LIT:\t>" , end = "<STR_LIT:\t>" ) <EOL> for effect in variantAnnotation . transcriptEffects : <EOL> print ( effect . alternateBases , sep = "<STR_LIT:|>" , end = "<STR_LIT:|>" ) <EOL> for so in effect . effects : <EOL> print ( so . term , sep = "<STR_LIT:&>" , end = "<STR_LIT:|>" ) <EOL> print ( so . id , sep = "<STR_LIT:&>" , end = "<STR_LIT:|>" ) <EOL> print ( effect . hgvsAnnotation . transcript , <EOL> effect . hgvsAnnotation . protein , sep = "<STR_LIT:|>" , end = "<STR_LIT:\t>" ) <EOL> print ( ) <EOL> class FeatureFormatterMixin ( object ) : <EOL> """<STR_LIT>""" <EOL> def _textOutput ( self , gaObjects ) : <EOL> for feature in gaObjects : <EOL> print ( <EOL> feature . id , feature . parentId , feature . featureSetId , <EOL> feature . referenceName , feature . start , feature . end , <EOL> feature . strand , sep = "<STR_LIT:\t>" , end = "<STR_LIT:\t>" ) <EOL> print ( <EOL> "<STR_LIT>" , feature . featureType . id , <EOL> feature . featureType . term , end = "<STR_LIT:\t>" ) <EOL> for attrkey in feature . attributes . vals . keys ( ) : <EOL> print ( <EOL> attrkey , feature . attributes . vals [ attrkey ] , <EOL> sep = "<STR_LIT::>" , end = "<STR_LIT>" ) <EOL> print ( ) <EOL> class SearchVariantsRunner ( VariantFormatterMixin , AbstractSearchRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> super ( SearchVariantsRunner , self ) . __init__ ( args ) <EOL> self . _referenceName = args . referenceName <EOL> self . _variantSetId = args . variantSetId <EOL> self . _start = args . start <EOL> self . _end = args . end <EOL> if args . callSetIds == [ ] : <EOL> self . _callSetIds = [ ] <EOL> elif args . callSetIds == '<STR_LIT:*>' : <EOL> self . _callSetIds = None <EOL> else : <EOL> self . _callSetIds = args . callSetIds . split ( "<STR_LIT:U+002C>" ) <EOL> def _run ( self , variantSetId ) : <EOL> iterator = self . _client . searchVariants ( <EOL> start = self . _start , end = self . _end , <EOL> referenceName = self . _referenceName , <EOL> variantSetId = variantSetId , callSetIds = self . _callSetIds ) <EOL> self . _output ( iterator ) <EOL> def run ( self ) : <EOL> if self . _variantSetId is None : <EOL> for variantSet in self . getAllVariantSets ( ) : <EOL> self . _run ( variantSet . id ) <EOL> else : <EOL> self . _run ( self . _variantSetId ) <EOL> class SearchVariantAnnotationsRunner ( <EOL> AnnotationFormatterMixin , AbstractSearchRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> super ( SearchVariantAnnotationsRunner , self ) . __init__ ( args ) <EOL> self . _referenceName = args . referenceName <EOL> self . _referenceId = args . referenceId <EOL> self . _variantAnnotationSetId = args . variantAnnotationSetId <EOL> self . _start = args . start <EOL> self . _end = args . end <EOL> if args . effects == "<STR_LIT>" : <EOL> self . _effects = [ ] <EOL> else : <EOL> self . _effects = [ ] <EOL> for eff in args . effects . split ( "<STR_LIT:U+002C>" ) : <EOL> term = protocol . OntologyTerm ( ) <EOL> term . id = eff <EOL> self . _effects . append ( term ) <EOL> def _run ( self , variantAnnotationSetId ) : <EOL> iterator = self . _client . searchVariantAnnotations ( <EOL> variantAnnotationSetId = variantAnnotationSetId , <EOL> referenceName = self . _referenceName , referenceId = self . _referenceId , <EOL> start = self . _start , end = self . _end , <EOL> effects = self . _effects ) <EOL> self . _output ( iterator ) <EOL> def getAllAnnotationSets ( self ) : <EOL> """<STR_LIT>""" <EOL> for variantSet in self . getAllVariantSets ( ) : <EOL> iterator = self . _client . searchVariantAnnotationSets ( <EOL> variantSetId = variantSet . id ) <EOL> for variantAnnotationSet in iterator : <EOL> yield variantAnnotationSet <EOL> def run ( self ) : <EOL> if self . _variantAnnotationSetId is None : <EOL> for annotationSet in self . getAllAnnotationSets ( ) : <EOL> self . _run ( annotationSet . id ) <EOL> else : <EOL> self . _run ( self . _variantAnnotationSetId ) <EOL> class SearchFeaturesRunner ( FeatureFormatterMixin , AbstractSearchRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> super ( SearchFeaturesRunner , self ) . __init__ ( args ) <EOL> self . _referenceName = args . referenceName <EOL> self . _featureSetId = args . featureSetId <EOL> self . _parentId = args . parentId <EOL> self . _start = args . start <EOL> self . _end = args . end <EOL> if args . featureTypes == "<STR_LIT>" : <EOL> self . _featureTypes = [ ] <EOL> else : <EOL> self . _featureTypes = args . featureTypes . split ( "<STR_LIT:U+002C>" ) <EOL> def _run ( self , featureSetId ) : <EOL> iterator = self . _client . searchFeatures ( <EOL> start = self . _start , end = self . _end , <EOL> referenceName = self . _referenceName , <EOL> featureSetId = featureSetId , parentId = self . _parentId , <EOL> featureTypes = self . _featureTypes ) <EOL> self . _output ( iterator ) <EOL> def run ( self ) : <EOL> if self . _featureSetId is None and self . _parentId is None : <EOL> for featureSet in self . getAllFeatureSets ( ) : <EOL> self . _run ( featureSet ) <EOL> else : <EOL> self . _run ( self . _featureSetId ) <EOL> class SearchReadsRunner ( AbstractSearchRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> super ( SearchReadsRunner , self ) . __init__ ( args ) <EOL> self . _start = args . start <EOL> self . _end = args . end <EOL> self . _referenceId = args . referenceId <EOL> self . _readGroupIds = None <EOL> if args . readGroupIds is not None : <EOL> self . _readGroupIds = args . readGroupIds . split ( "<STR_LIT:U+002C>" ) <EOL> def _run ( self , referenceGroupId , referenceId = None ) : <EOL> """<STR_LIT>""" <EOL> if referenceId is None : <EOL> referenceId = self . _referenceId <EOL> if referenceId is None : <EOL> rg = self . _client . getReadGroup ( readGroupId = referenceGroupId ) <EOL> iterator = self . _client . searchReferences ( rg . referenceSetId ) <EOL> for reference in iterator : <EOL> self . _run ( referenceGroupId , reference . id ) <EOL> else : <EOL> iterator = self . _client . searchReads ( <EOL> readGroupIds = [ referenceGroupId ] , referenceId = referenceId , <EOL> start = self . _start , end = self . _end ) <EOL> self . _output ( iterator ) <EOL> def run ( self ) : <EOL> """<STR_LIT>""" <EOL> if not self . _readGroupIds : <EOL> for referenceGroupId in self . getAllReadGroups ( ) : <EOL> self . _run ( referenceGroupId ) <EOL> else : <EOL> for referenceGroupId in self . _readGroupIds : <EOL> self . _run ( referenceGroupId ) <EOL> def _textOutput ( self , gaObjects ) : <EOL> """<STR_LIT>""" <EOL> for read in gaObjects : <EOL> print ( read . id ) <EOL> class ListReferenceBasesRunner ( AbstractQueryRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> super ( ListReferenceBasesRunner , self ) . __init__ ( args ) <EOL> self . _referenceId = args . id <EOL> self . _start = args . start <EOL> self . _end = args . end <EOL> self . _outputFormat = args . outputFormat <EOL> def run ( self ) : <EOL> sequence = self . _client . listReferenceBases ( <EOL> self . _referenceId , self . _start , self . _end ) <EOL> if self . _outputFormat == "<STR_LIT:text>" : <EOL> print ( sequence ) <EOL> else : <EOL> start = self . _start if self . _start else "<STR_LIT>" <EOL> end = self . _end if self . _end else "<STR_LIT>" <EOL> print ( "<STR_LIT>" . format ( self . _referenceId , start , end ) ) <EOL> textWidth = <NUM_LIT> <EOL> for index in xrange ( <NUM_LIT:0> , len ( sequence ) , textWidth ) : <EOL> print ( sequence [ index : index + textWidth ] ) <EOL> class GetReferenceSetRunner ( AbstractGetRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> super ( GetReferenceSetRunner , self ) . __init__ ( args ) <EOL> self . _method = self . _client . getReferenceSet <EOL> class GetReferenceRunner ( AbstractGetRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> super ( GetReferenceRunner , self ) . __init__ ( args ) <EOL> self . _method = self . _client . getReference <EOL> class GetReadGroupSetRunner ( AbstractGetRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> super ( GetReadGroupSetRunner , self ) . __init__ ( args ) <EOL> self . _method = self . _client . getReadGroupSet <EOL> class GetReadGroupRunner ( AbstractGetRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> super ( GetReadGroupRunner , self ) . __init__ ( args ) <EOL> self . _method = self . _client . getReadGroup <EOL> class GetCallSetRunner ( AbstractGetRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> super ( GetCallSetRunner , self ) . __init__ ( args ) <EOL> self . _method = self . _client . getCallSet <EOL> class GetDatasetRunner ( AbstractGetRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> super ( GetDatasetRunner , self ) . __init__ ( args ) <EOL> self . _method = self . _client . getDataset <EOL> class GetVariantRunner ( VariantFormatterMixin , AbstractGetRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> super ( GetVariantRunner , self ) . __init__ ( args ) <EOL> self . _method = self . _client . getVariant <EOL> class GetVariantSetRunner ( AbstractGetRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> super ( GetVariantSetRunner , self ) . __init__ ( args ) <EOL> self . _method = self . _client . getVariantSet <EOL> class GetVariantAnnotationSetRunner ( AbstractGetRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> super ( GetVariantAnnotationSetRunner , self ) . __init__ ( args ) <EOL> self . _method = self . _client . getVariantAnnotationSet <EOL> class GetFeatureRunner ( FeatureFormatterMixin , AbstractGetRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> super ( GetFeatureRunner , self ) . __init__ ( args ) <EOL> self . _method = self . _client . getFeature <EOL> class GetFeatureSetRunner ( AbstractGetRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> super ( GetFeatureSetRunner , self ) . __init__ ( args ) <EOL> self . _method = self . _client . getFeatureSet <EOL> def addDisableUrllibWarningsArgument ( parser ) : <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , default = False , action = "<STR_LIT:store_true>" , <EOL> help = "<STR_LIT>" ) <EOL> def addVersionArgument ( parser ) : <EOL> versionString = ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" . format ( <EOL> ga4gh . __version__ , protocol . version ) ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , version = versionString , action = "<STR_LIT:version>" ) <EOL> def addVariantSearchOptions ( parser ) : <EOL> """<STR_LIT>""" <EOL> addVariantSetIdArgument ( parser ) <EOL> addReferenceNameArgument ( parser ) <EOL> addCallSetIdsArgument ( parser ) <EOL> addStartArgument ( parser ) <EOL> addEndArgument ( parser ) <EOL> addPageSizeArgument ( parser ) <EOL> def addAnnotationsSearchOptions ( parser ) : <EOL> """<STR_LIT>""" <EOL> addAnnotationSetIdArgument ( parser ) <EOL> addReferenceNameArgument ( parser ) <EOL> addReferenceIdArgument ( parser ) <EOL> addStartArgument ( parser ) <EOL> addEndArgument ( parser ) <EOL> addEffectsArgument ( parser ) <EOL> addPageSizeArgument ( parser ) <EOL> def addFeaturesSearchOptions ( parser ) : <EOL> """<STR_LIT>""" <EOL> addFeatureSetIdArgument ( parser ) <EOL> addReferenceNameArgument ( parser ) <EOL> addStartArgument ( parser ) <EOL> addEndArgument ( parser ) <EOL> addParentFeatureIdArgument ( parser ) <EOL> addFeatureTypesArgument ( parser ) <EOL> def addVariantSetIdArgument ( parser ) : <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , default = None , <EOL> help = "<STR_LIT>" ) <EOL> def addVariantSetIdMandatoryArgument ( parser ) : <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , help = "<STR_LIT>" ) <EOL> def addAnnotationSetIdArgument ( parser ) : <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , default = None , <EOL> help = "<STR_LIT>" ) <EOL> def addFeatureSetIdArgument ( parser ) : <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , default = None , <EOL> help = "<STR_LIT>" ) <EOL> def addReferenceNameArgument ( parser ) : <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , default = "<STR_LIT:1>" , <EOL> help = "<STR_LIT>" ) <EOL> def addReferenceIdArgument ( parser ) : <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT:-c>" , default = "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> def addCallSetIdsArgument ( parser ) : <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT:-c>" , default = [ ] , <EOL> help = """<STR_LIT>""" ) <EOL> def addFeatureIdsArgument ( parser ) : <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , default = [ ] , <EOL> help = """<STR_LIT>""" ) <EOL> def addEffectsArgument ( parser ) : <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , default = "<STR_LIT>" , <EOL> help = """<STR_LIT>""" ) <EOL> def addFeatureTypesArgument ( parser ) : <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , default = "<STR_LIT>" , <EOL> help = """<STR_LIT>""" ) <EOL> def addParentFeatureIdArgument ( parser ) : <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , default = None , <EOL> help = "<STR_LIT>" ) <EOL> def addStartArgument ( parser ) : <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , default = <NUM_LIT:0> , type = int , <EOL> help = "<STR_LIT>" ) <EOL> def addEndArgument ( parser , defaultValue = AVRO_LONG_MAX ) : <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , default = defaultValue , type = int , <EOL> help = "<STR_LIT>" ) <EOL> def addIdArgument ( parser ) : <EOL> parser . add_argument ( "<STR_LIT:id>" , default = None , help = "<STR_LIT>" ) <EOL> def addGetArguments ( parser ) : <EOL> addUrlArgument ( parser ) <EOL> addIdArgument ( parser ) <EOL> addOutputFormatArgument ( parser ) <EOL> def addUrlArgument ( parser ) : <EOL> """<STR_LIT>""" <EOL> parser . add_argument ( "<STR_LIT>" , help = "<STR_LIT>" ) <EOL> def addOutputFormatArgument ( parser ) : <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , choices = [ '<STR_LIT:text>' , '<STR_LIT>' ] , default = "<STR_LIT:text>" , <EOL> help = ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) ) <EOL> def addAccessionArgument ( parser ) : <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , default = None , <EOL> help = "<STR_LIT>" ) <EOL> def addMd5ChecksumArgument ( parser ) : <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , default = None , <EOL> help = "<STR_LIT>" ) <EOL> def addPageSizeArgument ( parser ) : <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , default = None , type = int , <EOL> help = ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) ) <EOL> def addDatasetIdArgument ( parser ) : <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , default = None , <EOL> help = "<STR_LIT>" ) <EOL> def addReferenceSetIdArgument ( parser ) : <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , default = None , <EOL> help = "<STR_LIT>" ) <EOL> def addNameArgument ( parser ) : <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , default = None , <EOL> help = "<STR_LIT>" ) <EOL> def addClientGlobalOptions ( parser ) : <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , action = '<STR_LIT:count>' , default = <NUM_LIT:0> , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , default = '<STR_LIT>' , <EOL> help = "<STR_LIT>" ) <EOL> addDisableUrllibWarningsArgument ( parser ) <EOL> addVersionArgument ( parser ) <EOL> def addHelpParser ( subparsers ) : <EOL> parser = subparsers . add_parser ( <EOL> "<STR_LIT>" , description = "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> return parser <EOL> def addVariantsSearchParser ( subparsers ) : <EOL> parser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , "<STR_LIT>" ) <EOL> parser . set_defaults ( runner = SearchVariantsRunner ) <EOL> addUrlArgument ( parser ) <EOL> addOutputFormatArgument ( parser ) <EOL> addVariantSearchOptions ( parser ) <EOL> return parser <EOL> def addVariantSetsSearchParser ( subparsers ) : <EOL> parser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , "<STR_LIT>" ) <EOL> parser . set_defaults ( runner = SearchVariantSetsRunner ) <EOL> addOutputFormatArgument ( parser ) <EOL> addUrlArgument ( parser ) <EOL> addPageSizeArgument ( parser ) <EOL> addDatasetIdArgument ( parser ) <EOL> return parser <EOL> def addVariantAnnotationSearchParser ( subparsers ) : <EOL> parser = subparsers . add_parser ( <EOL> "<STR_LIT>" , <EOL> description = "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . set_defaults ( runner = SearchVariantAnnotationsRunner ) <EOL> addUrlArgument ( parser ) <EOL> addOutputFormatArgument ( parser ) <EOL> addAnnotationsSearchOptions ( parser ) <EOL> return parser <EOL> def addVariantAnnotationSetsSearchParser ( subparsers ) : <EOL> parser = subparsers . add_parser ( <EOL> "<STR_LIT>" , <EOL> description = "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . set_defaults ( runner = SearchVariantAnnotationSetsRunner ) <EOL> addOutputFormatArgument ( parser ) <EOL> addUrlArgument ( parser ) <EOL> addPageSizeArgument ( parser ) <EOL> addVariantSetIdMandatoryArgument ( parser ) <EOL> return parser <EOL> def addVariantAnnotationSetsGetParser ( subparsers ) : <EOL> parser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , "<STR_LIT>" ) <EOL> parser . set_defaults ( runner = GetVariantAnnotationSetRunner ) <EOL> addGetArguments ( parser ) <EOL> def addVariantSetsGetParser ( subparsers ) : <EOL> parser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , "<STR_LIT>" ) <EOL> parser . set_defaults ( runner = GetVariantSetRunner ) <EOL> addGetArguments ( parser ) <EOL> def addFeaturesGetParser ( subparsers ) : <EOL> parser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , "<STR_LIT>" ) <EOL> parser . set_defaults ( runner = GetFeatureRunner ) <EOL> addGetArguments ( parser ) <EOL> def addFeatureSetsGetParser ( subparsers ) : <EOL> parser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , "<STR_LIT>" ) <EOL> parser . set_defaults ( runner = GetFeatureSetRunner ) <EOL> addGetArguments ( parser ) <EOL> def addFeaturesSearchParser ( subparsers ) : <EOL> parser = subparsers . add_parser ( <EOL> "<STR_LIT>" , <EOL> description = "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . set_defaults ( runner = SearchFeaturesRunner ) <EOL> addUrlArgument ( parser ) <EOL> addOutputFormatArgument ( parser ) <EOL> addPageSizeArgument ( parser ) <EOL> addFeaturesSearchOptions ( parser ) <EOL> return parser <EOL> def addFeatureSetsSearchParser ( subparsers ) : <EOL> parser = subparsers . add_parser ( <EOL> "<STR_LIT>" , <EOL> description = "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . set_defaults ( runner = SearchFeatureSetsRunner ) <EOL> addOutputFormatArgument ( parser ) <EOL> addUrlArgument ( parser ) <EOL> addPageSizeArgument ( parser ) <EOL> addDatasetIdArgument ( parser ) <EOL> return parser <EOL> def addReferenceSetsSearchParser ( subparsers ) : <EOL> parser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , "<STR_LIT>" ) <EOL> parser . set_defaults ( runner = SearchReferenceSetsRunner ) <EOL> addUrlArgument ( parser ) <EOL> addOutputFormatArgument ( parser ) <EOL> addPageSizeArgument ( parser ) <EOL> addAccessionArgument ( parser ) <EOL> addMd5ChecksumArgument ( parser ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> return parser <EOL> def addReferencesSearchParser ( subparsers ) : <EOL> parser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , "<STR_LIT>" ) <EOL> parser . set_defaults ( runner = SearchReferencesRunner ) <EOL> addUrlArgument ( parser ) <EOL> addOutputFormatArgument ( parser ) <EOL> addPageSizeArgument ( parser ) <EOL> addAccessionArgument ( parser ) <EOL> addMd5ChecksumArgument ( parser ) <EOL> addReferenceSetIdArgument ( parser ) <EOL> return parser <EOL> def addReadGroupSetsSearchParser ( subparsers ) : <EOL> parser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , "<STR_LIT>" ) <EOL> parser . set_defaults ( runner = SearchReadGroupSetsRunner ) <EOL> addUrlArgument ( parser ) <EOL> addOutputFormatArgument ( parser ) <EOL> addPageSizeArgument ( parser ) <EOL> addDatasetIdArgument ( parser ) <EOL> addNameArgument ( parser ) <EOL> return parser <EOL> def addCallSetsSearchParser ( subparsers ) : <EOL> parser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , "<STR_LIT>" ) <EOL> parser . set_defaults ( runner = SearchCallSetsRunner ) <EOL> addUrlArgument ( parser ) <EOL> addOutputFormatArgument ( parser ) <EOL> addPageSizeArgument ( parser ) <EOL> addNameArgument ( parser ) <EOL> addVariantSetIdArgument ( parser ) <EOL> return parser <EOL> def addReadsSearchParser ( subparsers ) : <EOL> parser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , "<STR_LIT>" ) <EOL> parser . set_defaults ( runner = SearchReadsRunner ) <EOL> addOutputFormatArgument ( parser ) <EOL> addReadsSearchParserArguments ( parser ) <EOL> return parser <EOL> def addDatasetsGetParser ( subparsers ) : <EOL> parser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , "<STR_LIT>" ) <EOL> parser . set_defaults ( runner = GetDatasetRunner ) <EOL> addGetArguments ( parser ) <EOL> def addDatasetsSearchParser ( subparsers ) : <EOL> parser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , "<STR_LIT>" ) <EOL> parser . set_defaults ( runner = SearchDatasetsRunner ) <EOL> addUrlArgument ( parser ) <EOL> addPageSizeArgument ( parser ) <EOL> addOutputFormatArgument ( parser ) <EOL> return parser <EOL> def addReadsSearchParserArguments ( parser ) : <EOL> addUrlArgument ( parser ) <EOL> addPageSizeArgument ( parser ) <EOL> addStartArgument ( parser ) <EOL> addEndArgument ( parser ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , default = None , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , default = None , <EOL> help = "<STR_LIT>" ) <EOL> def addReferenceSetsGetParser ( subparsers ) : <EOL> parser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , "<STR_LIT>" ) <EOL> parser . set_defaults ( runner = GetReferenceSetRunner ) <EOL> addGetArguments ( parser ) <EOL> def addReferencesGetParser ( subparsers ) : <EOL> parser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , "<STR_LIT>" ) <EOL> parser . set_defaults ( runner = GetReferenceRunner ) <EOL> addGetArguments ( parser ) <EOL> def addReadGroupSetsGetParser ( subparsers ) : <EOL> parser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , "<STR_LIT>" ) <EOL> parser . set_defaults ( runner = GetReadGroupSetRunner ) <EOL> addGetArguments ( parser ) <EOL> def addReadGroupsGetParser ( subparsers ) : <EOL> parser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , "<STR_LIT>" ) <EOL> parser . set_defaults ( runner = GetReadGroupRunner ) <EOL> addGetArguments ( parser ) <EOL> def addCallSetsGetParser ( subparsers ) : <EOL> parser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , "<STR_LIT>" ) <EOL> parser . set_defaults ( runner = GetCallSetRunner ) <EOL> addGetArguments ( parser ) <EOL> def addVariantsGetParser ( subparsers ) : <EOL> parser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , "<STR_LIT>" ) <EOL> parser . set_defaults ( runner = GetVariantRunner ) <EOL> addGetArguments ( parser ) <EOL> def addReferencesBasesListParser ( subparsers ) : <EOL> parser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , choices = [ '<STR_LIT:text>' , '<STR_LIT>' ] , default = "<STR_LIT:text>" , <EOL> help = ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) ) <EOL> parser . set_defaults ( runner = ListReferenceBasesRunner ) <EOL> addUrlArgument ( parser ) <EOL> addIdArgument ( parser ) <EOL> addStartArgument ( parser ) <EOL> addEndArgument ( parser , defaultValue = None ) <EOL> def getClientParser ( ) : <EOL> parser = createArgumentParser ( "<STR_LIT>" ) <EOL> addClientGlobalOptions ( parser ) <EOL> subparsers = parser . add_subparsers ( title = '<STR_LIT>' , ) <EOL> addHelpParser ( subparsers ) <EOL> addVariantsSearchParser ( subparsers ) <EOL> addVariantSetsSearchParser ( subparsers ) <EOL> addVariantAnnotationSearchParser ( subparsers ) <EOL> addVariantAnnotationSetsSearchParser ( subparsers ) <EOL> addVariantSetsGetParser ( subparsers ) <EOL> addVariantAnnotationSetsGetParser ( subparsers ) <EOL> addFeaturesSearchParser ( subparsers ) <EOL> addFeaturesGetParser ( subparsers ) <EOL> addFeatureSetsGetParser ( subparsers ) <EOL> addFeatureSetsSearchParser ( subparsers ) <EOL> addReferenceSetsSearchParser ( subparsers ) <EOL> addReferencesSearchParser ( subparsers ) <EOL> addReadGroupSetsSearchParser ( subparsers ) <EOL> addCallSetsSearchParser ( subparsers ) <EOL> addReadsSearchParser ( subparsers ) <EOL> addDatasetsSearchParser ( subparsers ) <EOL> addReferenceSetsGetParser ( subparsers ) <EOL> addReferencesGetParser ( subparsers ) <EOL> addReadGroupSetsGetParser ( subparsers ) <EOL> addReadGroupsGetParser ( subparsers ) <EOL> addCallSetsGetParser ( subparsers ) <EOL> addVariantsGetParser ( subparsers ) <EOL> addDatasetsGetParser ( subparsers ) <EOL> addReferencesBasesListParser ( subparsers ) <EOL> return parser <EOL> def client_main ( args = None ) : <EOL> parser = getClientParser ( ) <EOL> parsedArgs = parser . parse_args ( args ) <EOL> if "<STR_LIT>" not in parsedArgs : <EOL> parser . print_help ( ) <EOL> else : <EOL> if parsedArgs . disable_urllib_warnings : <EOL> requests . packages . urllib3 . disable_warnings ( ) <EOL> try : <EOL> runner = parsedArgs . runner ( parsedArgs ) <EOL> runner . run ( ) <EOL> except ( exceptions . BaseClientException , <EOL> requests . exceptions . RequestException ) as exception : <EOL> raise exception <EOL> class Ga2VcfRunner ( SearchVariantsRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> super ( Ga2VcfRunner , self ) . __init__ ( args ) <EOL> self . _outputFile = args . outputFile <EOL> self . _binaryOutput = False <EOL> if args . outputFormat == "<STR_LIT>" : <EOL> self . _binaryOutput = True <EOL> def run ( self ) : <EOL> variantSet = self . _client . getVariantSet ( self . _variantSetId ) <EOL> iterator = self . _client . searchVariants ( <EOL> start = self . _start , end = self . _end , <EOL> referenceName = self . _referenceName , <EOL> variantSetId = self . _variantSetId , <EOL> callSetIds = self . _callSetIds ) <EOL> vcfConverter = converters . VcfConverter ( <EOL> variantSet , iterator , self . _outputFile , self . _binaryOutput ) <EOL> vcfConverter . convert ( ) <EOL> def addOutputFileArgument ( parser ) : <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , default = None , <EOL> help = "<STR_LIT>" ) <EOL> def getGa2VcfParser ( ) : <EOL> parser = createArgumentParser ( ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) ) <EOL> addClientGlobalOptions ( parser ) <EOL> addOutputFileArgument ( parser ) <EOL> addUrlArgument ( parser ) <EOL> parser . add_argument ( "<STR_LIT>" , help = "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , choices = [ '<STR_LIT>' , '<STR_LIT>' ] , default = "<STR_LIT>" , <EOL> help = ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) ) <EOL> addReferenceNameArgument ( parser ) <EOL> addCallSetIdsArgument ( parser ) <EOL> addStartArgument ( parser ) <EOL> addEndArgument ( parser ) <EOL> addPageSizeArgument ( parser ) <EOL> return parser <EOL> def ga2vcf_main ( ) : <EOL> parser = getGa2VcfParser ( ) <EOL> args = parser . parse_args ( ) <EOL> if "<STR_LIT>" not in args : <EOL> parser . print_help ( ) <EOL> else : <EOL> runner = Ga2VcfRunner ( args ) <EOL> runner . run ( ) <EOL> class Ga2SamRunner ( SearchReadsRunner ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , args ) : <EOL> args . readGroupIds = args . readGroupId <EOL> super ( Ga2SamRunner , self ) . __init__ ( args ) <EOL> self . _outputFile = args . outputFile <EOL> self . _binaryOutput = False <EOL> if args . outputFormat == "<STR_LIT>" : <EOL> self . _binaryOutput = True <EOL> def run ( self ) : <EOL> samConverter = converters . SamConverter ( <EOL> self . _client , readGroupId = self . _readGroupIds [ <NUM_LIT:0> ] , <EOL> referenceId = self . _referenceId , start = self . _start , end = self . _end , <EOL> outputFileName = self . _outputFile , binaryOutput = self . _binaryOutput ) <EOL> samConverter . convert ( ) <EOL> def getGa2SamParser ( ) : <EOL> parser = createArgumentParser ( "<STR_LIT>" ) <EOL> addClientGlobalOptions ( parser ) <EOL> addUrlArgument ( parser ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> addPageSizeArgument ( parser ) <EOL> addStartArgument ( parser ) <EOL> addEndArgument ( parser ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , default = None , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , default = "<STR_LIT>" , choices = [ "<STR_LIT>" , "<STR_LIT>" ] , <EOL> help = ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) ) <EOL> addOutputFileArgument ( parser ) <EOL> return parser <EOL> def ga2sam_main ( ) : <EOL> parser = getGa2SamParser ( ) <EOL> args = parser . parse_args ( ) <EOL> if "<STR_LIT>" not in args : <EOL> parser . print_help ( ) <EOL> else : <EOL> runner = Ga2SamRunner ( args ) <EOL> runner . run ( ) <EOL> class SimplerResult ( unittest . TestResult ) : <EOL> """<STR_LIT>""" <EOL> def addError ( self , test , err ) : <EOL> self . errors . append ( ( test , <EOL> "<STR_LIT>" . format ( err [ <NUM_LIT:0> ] . __name__ , err [ <NUM_LIT:1> ] ) ) ) <EOL> def addFailure ( self , test , err ) : <EOL> self . failures . append ( ( test , <EOL> "<STR_LIT>" . format ( err [ <NUM_LIT:0> ] . __name__ , err [ <NUM_LIT:1> ] ) ) ) <EOL> def configtest_main ( parser = None ) : <EOL> if parser is None : <EOL> parser = createArgumentParser ( <EOL> "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT:-c>" , default = '<STR_LIT>' , type = str , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , type = str , default = None , <EOL> help = "<STR_LIT>" ) <EOL> addVersionArgument ( parser ) <EOL> args = parser . parse_args ( ) <EOL> configStr = '<STR_LIT>' . format ( args . config ) <EOL> configtest . TestConfig . configStr = configStr <EOL> configtest . TestConfig . configFile = args . config_file <EOL> configtest . TestConfig . configEnv = "<STR_LIT>" <EOL> loader = unittest . TestLoader ( ) <EOL> tests = loader . loadTestsFromModule ( configtest ) <EOL> results = SimplerResult ( ) <EOL> tests . run ( results ) <EOL> logging . basicConfig ( level = logging . INFO ) <EOL> log = logging . getLogger ( __name__ ) <EOL> log . info ( '<STR_LIT>' . <EOL> format ( results . testsRun , <EOL> len ( results . errors ) , <EOL> len ( results . failures ) , <EOL> len ( results . skipped ) ) ) <EOL> for result in results . errors : <EOL> if result is not None : <EOL> log . critical ( '<STR_LIT>' . format ( result [ <NUM_LIT:0> ] . id ( ) , result [ <NUM_LIT:1> ] ) ) <EOL> for result in results . failures : <EOL> if result is not None : <EOL> log . critical ( '<STR_LIT>' . format ( result [ <NUM_LIT:0> ] . id ( ) , result [ <NUM_LIT:1> ] ) ) <EOL> for result in results . skipped : <EOL> if result is not None : <EOL> log . info ( '<STR_LIT>' . format ( result [ <NUM_LIT:0> ] . id ( ) , result [ <NUM_LIT:1> ] ) ) <EOL> def getRawInput ( displayString ) : <EOL> userResponse = raw_input ( displayString ) <EOL> return userResponse <EOL> class AbstractRepoCommandRunner ( object ) : <EOL> def __init__ ( self , args ) : <EOL> self . args = args <EOL> self . repoPath = args . repoPath <EOL> self . repoManager = repo_manager . RepoManager ( self . repoPath ) <EOL> if '<STR_LIT>' in args : <EOL> self . force = args . force <EOL> def confirmRun ( self , func , deleteString ) : <EOL> if self . force : <EOL> func ( ) <EOL> else : <EOL> displayString = ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" . format ( deleteString ) ) <EOL> userResponse = getRawInput ( displayString ) <EOL> if userResponse . strip ( ) == '<STR_LIT:y>' : <EOL> func ( ) <EOL> else : <EOL> print ( "<STR_LIT>" ) <EOL> class AbstractRepoAddCommandRunner ( AbstractRepoCommandRunner ) : <EOL> def __init__ ( self , args ) : <EOL> super ( AbstractRepoAddCommandRunner , self ) . __init__ ( args ) <EOL> self . filePath = args . filePath <EOL> class AbstractRepoAddMoveCommandRunner ( AbstractRepoAddCommandRunner ) : <EOL> def __init__ ( self , args ) : <EOL> super ( AbstractRepoAddMoveCommandRunner , self ) . __init__ ( args ) <EOL> self . moveMode = args . moveMode <EOL> class AbstractRepoDatasetCommandRunner ( AbstractRepoCommandRunner ) : <EOL> def __init__ ( self , args ) : <EOL> super ( AbstractRepoDatasetCommandRunner , self ) . __init__ ( args ) <EOL> self . datasetName = args . datasetName <EOL> class AbstractRepoDatasetFilepathCommandRunner ( <EOL> AbstractRepoDatasetCommandRunner ) : <EOL> def __init__ ( self , args ) : <EOL> super ( AbstractRepoDatasetFilepathCommandRunner , self ) . __init__ ( args ) <EOL> self . filePath = args . filePath <EOL> self . moveMode = args . moveMode <EOL> class CheckRunner ( AbstractRepoCommandRunner ) : <EOL> def __init__ ( self , args ) : <EOL> super ( CheckRunner , self ) . __init__ ( args ) <EOL> self . doConsistencyCheck = not args . skipConsistencyCheck <EOL> def run ( self ) : <EOL> self . repoManager . check ( self . doConsistencyCheck ) <EOL> class ListRunner ( AbstractRepoCommandRunner ) : <EOL> def __init__ ( self , args ) : <EOL> super ( ListRunner , self ) . __init__ ( args ) <EOL> def run ( self ) : <EOL> self . repoManager . list ( ) <EOL> class DestroyRunner ( AbstractRepoCommandRunner ) : <EOL> def __init__ ( self , args ) : <EOL> super ( DestroyRunner , self ) . __init__ ( args ) <EOL> def run ( self ) : <EOL> def func ( ) : self . repoManager . destroy ( ) <EOL> self . confirmRun ( func , '<STR_LIT>' ) <EOL> class InitRunner ( AbstractRepoCommandRunner ) : <EOL> def __init__ ( self , args ) : <EOL> super ( InitRunner , self ) . __init__ ( args ) <EOL> def run ( self ) : <EOL> self . repoManager . init ( ) <EOL> class AddDatasetRunner ( AbstractRepoDatasetCommandRunner ) : <EOL> def __init__ ( self , args ) : <EOL> super ( AddDatasetRunner , self ) . __init__ ( args ) <EOL> def run ( self ) : <EOL> self . repoManager . addDataset ( self . datasetName ) <EOL> class AddOntologyMapRunner ( AbstractRepoAddMoveCommandRunner ) : <EOL> def __init__ ( self , args ) : <EOL> super ( AddOntologyMapRunner , self ) . __init__ ( args ) <EOL> def run ( self ) : <EOL> self . repoManager . addOntologyMap ( self . filePath , self . moveMode ) <EOL> class RemoveOntologyMapRunner ( AbstractRepoCommandRunner ) : <EOL> def __init__ ( self , args ) : <EOL> super ( RemoveOntologyMapRunner , self ) . __init__ ( args ) <EOL> self . ontologyMapName = args . ontologyMapName <EOL> def run ( self ) : <EOL> def func ( ) : self . repoManager . removeOntologyMap ( self . ontologyMapName ) <EOL> self . confirmRun ( func , '<STR_LIT>' . format ( self . ontologyMapName ) ) <EOL> class RemoveDatasetRunner ( AbstractRepoDatasetCommandRunner ) : <EOL> def __init__ ( self , args ) : <EOL> super ( RemoveDatasetRunner , self ) . __init__ ( args ) <EOL> def run ( self ) : <EOL> def func ( ) : self . repoManager . removeDataset ( self . datasetName ) <EOL> self . confirmRun ( func , '<STR_LIT>' . format ( self . datasetName ) ) <EOL> class AddReferenceSetRunner ( AbstractRepoAddMoveCommandRunner ) : <EOL> def __init__ ( self , args ) : <EOL> super ( AddReferenceSetRunner , self ) . __init__ ( args ) <EOL> self . metadata = { <EOL> '<STR_LIT:description>' : args . description , <EOL> } <EOL> def run ( self ) : <EOL> self . repoManager . addReferenceSet ( <EOL> self . filePath , self . moveMode , self . metadata ) <EOL> class RemoveReferenceSetRunner ( AbstractRepoCommandRunner ) : <EOL> def __init__ ( self , args ) : <EOL> super ( RemoveReferenceSetRunner , self ) . __init__ ( args ) <EOL> self . referenceSetName = args . referenceSetName <EOL> def run ( self ) : <EOL> def func ( ) : <EOL> self . repoManager . removeReferenceSet ( self . referenceSetName ) <EOL> self . confirmRun ( <EOL> func , '<STR_LIT>' . format ( self . referenceSetName ) ) <EOL> class AddReadGroupSetRunner ( AbstractRepoDatasetFilepathCommandRunner ) : <EOL> def __init__ ( self , args ) : <EOL> super ( AddReadGroupSetRunner , self ) . __init__ ( args ) <EOL> def run ( self ) : <EOL> self . repoManager . addReadGroupSet ( <EOL> self . datasetName , self . filePath , self . moveMode ) <EOL> class RemoveReadGroupSetRunner ( AbstractRepoDatasetCommandRunner ) : <EOL> def __init__ ( self , args ) : <EOL> super ( RemoveReadGroupSetRunner , self ) . __init__ ( args ) <EOL> self . readGroupSetName = args . readGroupSetName <EOL> def run ( self ) : <EOL> def func ( ) : <EOL> self . repoManager . removeReadGroupSet ( <EOL> self . datasetName , self . readGroupSetName ) <EOL> self . confirmRun ( <EOL> func , '<STR_LIT>' . format ( self . readGroupSetName ) ) <EOL> class AddVariantSetRunner ( AbstractRepoDatasetFilepathCommandRunner ) : <EOL> def __init__ ( self , args ) : <EOL> super ( AddVariantSetRunner , self ) . __init__ ( args ) <EOL> def run ( self ) : <EOL> self . repoManager . addVariantSet ( <EOL> self . datasetName , self . filePath , self . moveMode ) <EOL> class RemoveVariantSetRunner ( AbstractRepoDatasetCommandRunner ) : <EOL> def __init__ ( self , args ) : <EOL> super ( RemoveVariantSetRunner , self ) . __init__ ( args ) <EOL> self . variantSetName = args . variantSetName <EOL> def run ( self ) : <EOL> def func ( ) : <EOL> self . repoManager . removeVariantSet ( <EOL> self . datasetName , self . variantSetName ) <EOL> self . confirmRun ( func , '<STR_LIT>' . format ( self . variantSetName ) ) <EOL> class AddFeatureSetRunner ( AbstractRepoDatasetFilepathCommandRunner ) : <EOL> def __init__ ( self , args ) : <EOL> super ( AddFeatureSetRunner , self ) . __init__ ( args ) <EOL> def run ( self ) : <EOL> self . repoManager . addFeatureSet ( <EOL> self . datasetName , self . filePath , self . moveMode ) <EOL> class RemoveFeatureSetRunner ( AbstractRepoDatasetCommandRunner ) : <EOL> def __init__ ( self , args ) : <EOL> super ( RemoveFeatureSetRunner , self ) . __init__ ( args ) <EOL> self . featureSetName = args . featureSetName <EOL> def run ( self ) : <EOL> def func ( ) : <EOL> self . repoManager . removeFeatureSet ( <EOL> self . datasetName , self . featureSetName ) <EOL> self . confirmRun ( func , '<STR_LIT>' . format ( self . featureSetName ) ) <EOL> def addRepoArgument ( subparser ) : <EOL> subparser . add_argument ( <EOL> "<STR_LIT>" , help = "<STR_LIT>" ) <EOL> def addSkipConsistencyCheckArgument ( subparser ) : <EOL> subparser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , action = '<STR_LIT:store_true>' , default = False , <EOL> help = "<STR_LIT>" ) <EOL> def addForceArgument ( subparser ) : <EOL> subparser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , action = '<STR_LIT:store_true>' , <EOL> default = False , help = "<STR_LIT>" ) <EOL> def addDatasetNameArgument ( subparser ) : <EOL> subparser . add_argument ( <EOL> "<STR_LIT>" , help = "<STR_LIT>" ) <EOL> def addOntologyNameArgument ( subparser ) : <EOL> subparser . add_argument ( <EOL> "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> def addReadGroupSetNameArgument ( subparser ) : <EOL> subparser . add_argument ( <EOL> "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> def addVariantSetNameArgument ( subparser ) : <EOL> subparser . add_argument ( <EOL> "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> def addFeatureSetNameArgument ( subparser ) : <EOL> subparser . add_argument ( <EOL> "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> def addFilePathArgument ( subparser ) : <EOL> subparser . add_argument ( <EOL> "<STR_LIT>" , help = "<STR_LIT>" ) <EOL> def addMoveModeArgument ( subparser ) : <EOL> subparser . add_argument ( <EOL> "<STR_LIT>" , <EOL> help = "<STR_LIT>" , <EOL> choices = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> default = '<STR_LIT>' ) <EOL> def addReferenceSetMetadataArguments ( subparser ) : <EOL> subparser . add_argument ( <EOL> "<STR_LIT>" , <EOL> help = "<STR_LIT>" , <EOL> default = "<STR_LIT>" ) <EOL> def getRepoParser ( ) : <EOL> parser = createArgumentParser ( <EOL> "<STR_LIT>" ) <EOL> subparsers = parser . add_subparsers ( title = '<STR_LIT>' , ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , default = False , action = "<STR_LIT:store_true>" , <EOL> help = "<STR_LIT>" ) <EOL> addVersionArgument ( parser ) <EOL> initParser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , "<STR_LIT>" ) <EOL> initParser . set_defaults ( runner = InitRunner ) <EOL> addRepoArgument ( initParser ) <EOL> checkParser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , "<STR_LIT>" ) <EOL> checkParser . set_defaults ( runner = CheckRunner ) <EOL> addRepoArgument ( checkParser ) <EOL> addSkipConsistencyCheckArgument ( checkParser ) <EOL> listParser = addSubparser ( <EOL> subparsers , "<STR_LIT:list>" , "<STR_LIT>" ) <EOL> listParser . set_defaults ( runner = ListRunner ) <EOL> addRepoArgument ( listParser ) <EOL> destroyParser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , "<STR_LIT>" ) <EOL> destroyParser . set_defaults ( runner = DestroyRunner ) <EOL> addRepoArgument ( destroyParser ) <EOL> addForceArgument ( destroyParser ) <EOL> addDatasetParser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , "<STR_LIT>" ) <EOL> addDatasetParser . set_defaults ( runner = AddDatasetRunner ) <EOL> addRepoArgument ( addDatasetParser ) <EOL> addDatasetNameArgument ( addDatasetParser ) <EOL> removeDatasetParser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> removeDatasetParser . set_defaults ( runner = RemoveDatasetRunner ) <EOL> addRepoArgument ( removeDatasetParser ) <EOL> addDatasetNameArgument ( removeDatasetParser ) <EOL> addForceArgument ( removeDatasetParser ) <EOL> addReferenceSetParser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> addReferenceSetParser . set_defaults ( runner = AddReferenceSetRunner ) <EOL> addRepoArgument ( addReferenceSetParser ) <EOL> addFilePathArgument ( addReferenceSetParser ) <EOL> addMoveModeArgument ( addReferenceSetParser ) <EOL> addReferenceSetMetadataArguments ( addReferenceSetParser ) <EOL> removeReferenceSetParser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> removeReferenceSetParser . set_defaults ( runner = RemoveReferenceSetRunner ) <EOL> addRepoArgument ( removeReferenceSetParser ) <EOL> removeReferenceSetParser . add_argument ( <EOL> "<STR_LIT>" , <EOL> help = "<STR_LIT>" ) <EOL> addForceArgument ( removeReferenceSetParser ) <EOL> addReadGroupSetParser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> addReadGroupSetParser . set_defaults ( runner = AddReadGroupSetRunner ) <EOL> addRepoArgument ( addReadGroupSetParser ) <EOL> addDatasetNameArgument ( addReadGroupSetParser ) <EOL> addFilePathArgument ( addReadGroupSetParser ) <EOL> addMoveModeArgument ( addReadGroupSetParser ) <EOL> addOntologyMapParser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> addOntologyMapParser . set_defaults ( runner = AddOntologyMapRunner ) <EOL> addRepoArgument ( addOntologyMapParser ) <EOL> addFilePathArgument ( addOntologyMapParser ) <EOL> addMoveModeArgument ( addOntologyMapParser ) <EOL> removeOntologyMapParser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> removeOntologyMapParser . set_defaults ( runner = RemoveOntologyMapRunner ) <EOL> addRepoArgument ( removeOntologyMapParser ) <EOL> addOntologyNameArgument ( removeOntologyMapParser ) <EOL> addForceArgument ( removeOntologyMapParser ) <EOL> removeReadGroupSetParser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> removeReadGroupSetParser . set_defaults ( runner = RemoveReadGroupSetRunner ) <EOL> addRepoArgument ( removeReadGroupSetParser ) <EOL> addDatasetNameArgument ( removeReadGroupSetParser ) <EOL> addReadGroupSetNameArgument ( removeReadGroupSetParser ) <EOL> addForceArgument ( removeReadGroupSetParser ) <EOL> addVariantSetParser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , "<STR_LIT>" ) <EOL> addVariantSetParser . set_defaults ( runner = AddVariantSetRunner ) <EOL> addRepoArgument ( addVariantSetParser ) <EOL> addDatasetNameArgument ( addVariantSetParser ) <EOL> addFilePathArgument ( addVariantSetParser ) <EOL> addMoveModeArgument ( addVariantSetParser ) <EOL> removeVariantSetParser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> removeVariantSetParser . set_defaults ( runner = RemoveVariantSetRunner ) <EOL> addRepoArgument ( removeVariantSetParser ) <EOL> addDatasetNameArgument ( removeVariantSetParser ) <EOL> addVariantSetNameArgument ( removeVariantSetParser ) <EOL> addForceArgument ( removeVariantSetParser ) <EOL> addFeatureSetParser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , "<STR_LIT>" ) <EOL> addFeatureSetParser . set_defaults ( runner = AddFeatureSetRunner ) <EOL> addRepoArgument ( addFeatureSetParser ) <EOL> addDatasetNameArgument ( addFeatureSetParser ) <EOL> addFilePathArgument ( addFeatureSetParser ) <EOL> addMoveModeArgument ( addFeatureSetParser ) <EOL> removeFeatureSetParser = addSubparser ( <EOL> subparsers , "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> removeFeatureSetParser . set_defaults ( runner = RemoveFeatureSetRunner ) <EOL> addRepoArgument ( removeFeatureSetParser ) <EOL> addDatasetNameArgument ( removeFeatureSetParser ) <EOL> addFeatureSetNameArgument ( removeFeatureSetParser ) <EOL> addForceArgument ( removeFeatureSetParser ) <EOL> return parser <EOL> def repo_main ( args = None ) : <EOL> parser = getRepoParser ( ) <EOL> parsedArgs = parser . parse_args ( args ) <EOL> if "<STR_LIT>" not in parsedArgs : <EOL> parser . print_help ( ) <EOL> else : <EOL> runner = parsedArgs . runner ( parsedArgs ) <EOL> try : <EOL> runner . run ( ) <EOL> except exceptions . RepoManagerException as exception : <EOL> print ( exception . message ) <EOL> if parsedArgs . loud : <EOL> raise </s>
