idx int64 0 251k | question stringlengths 53 3.53k | target stringlengths 5 1.23k | len_question int64 20 893 | len_target int64 3 238 |
|---|---|---|---|---|
5,000 | def count_by_type ( self ) : pistack = defaultdict ( int ) for contact in self . timeseries : #count by residue name not by proteinring pkey = ( contact . ligandring , contact . type , contact . resid , contact . resname , contact . segid ) pistack [ pkey ] += 1 dtype = [ ( "ligand_ring_ids" , list ) , ( "type" , "|U4"... | Count how many times each individual pi - pi interaction occured throughout the simulation . Returns numpy array . | 225 | 21 |
5,001 | def main ( master_dsn , slave_dsn , tables , blocking = False ) : # currently only supports mysql master assert master_dsn . startswith ( "mysql" ) logger = logging . getLogger ( __name__ ) logger . info ( "replicating tables: %s" % ", " . join ( tables ) ) repl_db_sub ( master_dsn , slave_dsn , tables ) mysql_pub ( ma... | DB Replication app . | 105 | 5 |
5,002 | def get_text_position_in_ax_coord ( ax , pos , scale = default_text_relative_padding ) : ratio = get_axes_ratio ( ax ) x , y = scale , scale if ratio > 1 : # vertical is longer y /= ratio elif 0 < ratio : # 0 < ratio <= 1 x *= ratio pos = pos . lower ( ) if pos == 'nw' : y = 1 - y elif pos == 'ne' : x , y = 1 - x , 1 -... | Return text position corresponding to given pos . The text alignment in the bounding box should be set accordingly in order to have a good - looking layout . This corresponding text alignment can be obtained by get_text_alignment or get_text_position_and_inner_alignment function . | 164 | 59 |
5,003 | def get_text_position_and_inner_alignment ( ax , pos , scale = default_text_relative_padding , with_transAxes_kwargs = True ) : xy = get_text_position_in_ax_coord ( ax , pos , scale = scale ) alignment_fontdict = get_text_alignment ( pos ) if with_transAxes_kwargs : alignment_fontdict = { * * alignment_fontdict , * * {... | Return text position and its alignment in its bounding box . The returned position is given in Axes coordinate as defined in matplotlib documentation on transformation . | 122 | 31 |
5,004 | def get_text_position ( fig , ax , ha = 'left' , va = 'top' , pad_scale = 1.0 ) : ## Check and preprocess input arguments try : pad_scale = float ( pad_scale ) except : raise TypeError ( "'pad_scale should be of type 'float'" ) for arg in [ va , ha ] : assert type ( arg ) is str arg = arg . lower ( ) # Make it lowercas... | Return text position inside of the given axis | 528 | 8 |
5,005 | def create_app ( config = None , config_obj = None ) : app = Flask ( __name__ ) # configure application from external configs configure_app ( app , config = config , config_obj = config_obj ) # register different parts of the application register_blueprints ( app ) # setup extensions bind_extensions ( app ) return app | Flask app factory function . | 75 | 6 |
5,006 | def configure_app ( app , config = None , config_obj = None ) : app . config . from_object ( config_obj or BaseConfig ) if config is not None : app . config . from_pyfile ( config ) | Configure application instance . | 50 | 5 |
5,007 | def bind_extensions ( app ) : # bind plugin to app object app . db = app . config [ 'PUZZLE_BACKEND' ] app . db . init_app ( app ) # bind bootstrap blueprints bootstrap . init_app ( app ) markdown ( app ) @ app . template_filter ( 'islist' ) def islist ( object ) : return isinstance ( object , ( tuple , list ) ) | Configure extensions . | 93 | 4 |
5,008 | def find_donors_and_acceptors_in_ligand ( self ) : atom_names = [ x . name for x in self . topology_data . universe . ligand ] try : for atom in self . topology_data . mol . GetSubstructMatches ( self . HDonorSmarts , uniquify = 1 ) : self . donors . append ( atom_names [ atom [ 0 ] ] ) for atom in self . topology_data... | Since MDAnalysis a pre - set list for acceptor and donor atoms for proteins and solvents from specific forcefields it is necessary to find donor and acceptor atoms for the ligand molecule . This function uses RDKit and searches through ligand atoms to find matches for pre - set list of possible donor and acceptor atoms... | 375 | 84 |
5,009 | def count_by_type ( self , table , timesteps ) : hbonds = defaultdict ( int ) for contact in table : #count by residue name not by proteinring pkey = ( contact . donor_idx , contact . acceptor_idx , contact . donor_atom , contact . acceptor_atom , contact . donor_resnm , contact . donor_resid , contact . acceptor_resnm... | Count how many times each individual hydrogen bonds occured throughout the simulation . Returns numpy array . | 320 | 19 |
5,010 | def determine_hbonds_for_drawing ( self , analysis_cutoff ) : self . frequency = defaultdict ( int ) for traj in self . hbonds_by_type : for bond in self . hbonds_by_type [ traj ] : # frequency[(residue_atom_idx,ligand_atom_name,residue_atom_name)]=frequency # residue atom name will be used to determine if hydrogen bon... | Since plotting all hydrogen bonds could lead to a messy plot a cutoff has to be imple - mented . In this function the frequency of each hydrogen bond is summated and the total compared against analysis cutoff - a fraction multiplied by trajectory count . Those hydrogen bonds that are present for longer than analysis cu... | 560 | 68 |
5,011 | def convert2dbus ( value , signature ) : if len ( signature ) == 2 and signature . startswith ( 'a' ) : return dbus . Array ( value , signature = signature [ - 1 ] ) dbus_string_type = dbus . String if PY3 else dbus . UTF8String type_map = { 'b' : dbus . Boolean , 'y' : dbus . Byte , 'n' : dbus . Int16 , 'i' : dbus . I... | Converts value type from python to dbus according signature . | 203 | 12 |
5,012 | def convert ( dbus_obj ) : _isinstance = partial ( isinstance , dbus_obj ) ConvertType = namedtuple ( 'ConvertType' , 'pytype dbustypes' ) pyint = ConvertType ( int , ( dbus . Byte , dbus . Int16 , dbus . Int32 , dbus . Int64 , dbus . UInt16 , dbus . UInt32 , dbus . UInt64 ) ) pybool = ConvertType ( bool , ( dbus . Boo... | Converts dbus_obj from dbus type to python type . | 370 | 14 |
5,013 | def converter ( f ) : @ wraps ( f ) def wrapper ( * args , * * kwds ) : return convert ( f ( * args , * * kwds ) ) return wrapper | Decorator to convert value from dbus type to python type . | 41 | 14 |
5,014 | def exception_wrapper ( f ) : @ wraps ( f ) def wrapper ( * args , * * kwds ) : try : return f ( * args , * * kwds ) except dbus . exceptions . DBusException as err : _args = err . args raise PyMPRISException ( * _args ) return wrapper | Decorator to convert dbus exception to pympris exception . | 71 | 15 |
5,015 | def available_players ( ) : bus = dbus . SessionBus ( ) players = set ( ) for name in filter ( lambda item : item . startswith ( MPRIS_NAME_PREFIX ) , bus . list_names ( ) ) : owner_name = bus . get_name_owner ( name ) players . add ( convert ( owner_name ) ) return players | Searchs and returns set of unique names of objects which implements MPRIS2 interfaces . | 82 | 18 |
5,016 | def signal_wrapper ( f ) : @ wraps ( f ) def wrapper ( * args , * * kwds ) : args = map ( convert , args ) kwds = { convert ( k ) : convert ( v ) for k , v in kwds . items ( ) } return f ( * args , * * kwds ) return wrapper | Decorator converts function s arguments from dbus types to python . | 75 | 14 |
5,017 | def filter_properties_signals ( f , signal_iface_name ) : @ wraps ( f ) def wrapper ( iface , changed_props , invalidated_props , * args , * * kwargs ) : if iface == signal_iface_name : f ( changed_props , invalidated_props ) return wrapper | Filters signals by iface name . | 76 | 8 |
5,018 | def distance_function_match ( l1 , l2 , thresh , dist_fn , norm_funcs = [ ] ) : common = [ ] # We will keep track of the global index in the source list as we # will successively reduce their sizes. l1 = list ( enumerate ( l1 ) ) l2 = list ( enumerate ( l2 ) ) # Use the distance function and threshold on hints given by... | Returns pairs of matching indices from l1 and l2 . | 616 | 12 |
5,019 | def _match_by_norm_func ( l1 , l2 , norm_fn , dist_fn , thresh ) : common = [ ] l1_only_idx = set ( range ( len ( l1 ) ) ) l2_only_idx = set ( range ( len ( l2 ) ) ) buckets_l1 = _group_by_fn ( enumerate ( l1 ) , lambda x : norm_fn ( x [ 1 ] ) ) buckets_l2 = _group_by_fn ( enumerate ( l2 ) , lambda x : norm_fn ( x [ 1 ... | Matches elements in l1 and l2 using normalization functions . | 474 | 14 |
5,020 | def _match_munkres ( l1 , l2 , dist_matrix , thresh ) : equal_dist_matches = set ( ) m = Munkres ( ) indices = m . compute ( dist_matrix ) for l1_idx , l2_idx in indices : dst = dist_matrix [ l1_idx ] [ l2_idx ] if dst > thresh : continue for eq_l2_idx , eq_val in enumerate ( dist_matrix [ l1_idx ] ) : if abs ( dst - e... | Matches two lists using the Munkres algorithm . | 274 | 11 |
5,021 | def add_suspect ( self , case_obj , variant_obj ) : new_suspect = Suspect ( case = case_obj , variant_id = variant_obj . variant_id , name = variant_obj . display_name ) self . session . add ( new_suspect ) self . save ( ) return new_suspect | Link a suspect to a case . | 78 | 7 |
5,022 | def delete_suspect ( self , suspect_id ) : suspect_obj = self . suspect ( suspect_id ) logger . debug ( "Deleting suspect {0}" . format ( suspect_obj . name ) ) self . session . delete ( suspect_obj ) self . save ( ) | De - link a suspect from a case . | 63 | 9 |
5,023 | def configure_stream ( level = 'WARNING' ) : # get the root logger root_logger = logging . getLogger ( ) # set the logger level to the same as will be used by the handler root_logger . setLevel ( level ) # customize formatter, align each column template = "[%(asctime)s] %(name)-25s %(levelname)-8s %(message)s" formatte... | Configure root logger using a standard stream handler . | 151 | 10 |
5,024 | def _is_same_type_as_root ( self , obj ) : if not self . ALLOWS_SAME_TYPE_AS_ROOT_COLLECT : obj_model = get_model_from_instance ( obj ) obj_key = get_key_from_instance ( obj ) is_same_type_as_root = obj_model == self . root_obj_model and obj_key != self . root_obj_key if is_same_type_as_root : self . emit_event ( type ... | Testing if we try to collect an object of the same type as root . This is not really a good sign because it means that we are going to collect a whole new tree that will maybe collect a new tree that will ... | 145 | 45 |
5,025 | def initialize ( self , data ) : for item in data : if hasattr ( self , item ) : setattr ( self , item , data [ item ] ) | initialize variable from loaded data | 34 | 6 |
5,026 | def _add_transcripts ( self , variant_obj , info_dict ) : vep_string = info_dict . get ( 'CSQ' ) #Check if snpeff annotation: snpeff_string = info_dict . get ( 'ANN' ) # We check one of these. # VEP has presedence over snpeff if vep_string : #Get the vep annotations vep_info = get_vep_info ( vep_string = vep_string , v... | Return all transcripts sound in the vcf file | 255 | 9 |
5,027 | def _get_vep_transcript ( self , transcript_info ) : transcript = Transcript ( hgnc_symbol = transcript_info . get ( 'SYMBOL' ) , transcript_id = transcript_info . get ( 'Feature' ) , ensembl_id = transcript_info . get ( 'Gene' ) , biotype = transcript_info . get ( 'BIOTYPE' ) , consequence = transcript_info . get ( 'C... | Create a Transcript based on the vep annotation | 239 | 9 |
5,028 | def _get_snpeff_transcript ( self , transcript_info ) : transcript = Transcript ( hgnc_symbol = transcript_info . get ( 'Gene_Name' ) , transcript_id = transcript_info . get ( 'Feature' ) , ensembl_id = transcript_info . get ( 'Gene_ID' ) , biotype = transcript_info . get ( 'Transcript_BioType' ) , consequence = transc... | Create a transcript based on the snpeff annotation | 162 | 10 |
5,029 | def _makes_clone ( _func , * args , * * kw ) : self = args [ 0 ] . _clone ( ) _func ( self , * args [ 1 : ] , * * kw ) return self | A decorator that returns a clone of the current object so that we can re - use the object for similar requests . | 48 | 24 |
5,030 | def _handle_response ( self , response , data ) : # Content-Type headers can include additional parameters(RFC 1521), so # we split on ; to match against only the type/subtype if data and response . get ( 'content-type' , '' ) . split ( ';' ) [ 0 ] in ( 'application/json' , 'application/x-javascript' , 'text/javascript... | Deserializes JSON if the content - type matches otherwise returns the response body as is . | 117 | 18 |
5,031 | def get_url ( self , * paths , * * params ) : path_stack = self . _attribute_stack [ : ] if paths : path_stack . extend ( paths ) u = self . _stack_collapser ( path_stack ) url = self . _url_template % { "domain" : self . _api_url , "generated_url" : u , } if self . _params or params : internal_params = self . _params ... | Returns the URL for this request . | 128 | 7 |
5,032 | def _clone ( self ) : cls = self . __class__ q = cls . __new__ ( cls ) q . __dict__ = self . __dict__ . copy ( ) q . _params = self . _params . copy ( ) q . _headers = self . _headers . copy ( ) q . _attribute_stack = self . _attribute_stack [ : ] return q | Clones the state of the current operation . | 86 | 9 |
5,033 | def delete ( ctx , family_id , individual_id , root ) : root = root or ctx . obj . get ( 'root' ) or os . path . expanduser ( "~/.puzzle" ) if os . path . isfile ( root ) : logger . error ( "'root' can't be a file" ) ctx . abort ( ) logger . info ( "Root directory is: {}" . format ( root ) ) db_path = os . path . join ... | Delete a case or individual from the database . | 345 | 9 |
5,034 | def variants ( case_id ) : filters = parse_filters ( ) values = [ value for key , value in iteritems ( filters ) if not isinstance ( value , dict ) and key != 'skip' ] is_active = any ( values ) variants , nr_of_variants = app . db . variants ( case_id , skip = filters [ 'skip' ] , filters = { 'gene_ids' : filters [ 'g... | Show all variants for a case . | 520 | 7 |
5,035 | def variant ( case_id , variant_id ) : case_obj = app . db . case ( case_id ) variant = app . db . variant ( case_id , variant_id ) if variant is None : return abort ( 404 , "variant not found" ) comments = app . db . comments ( variant_id = variant . md5 ) template = 'sv_variant.html' if app . db . variant_type == 'sv... | Show a single variant . | 134 | 5 |
5,036 | def parse_filters ( ) : genes_str = request . args . get ( 'gene_symbol' ) filters = { } for key in ( 'frequency' , 'cadd' , 'sv_len' ) : try : filters [ key ] = float ( request . args . get ( key ) ) except ( ValueError , TypeError ) : pass filters [ 'gene_symbols' ] = genes_str . split ( ',' ) if genes_str else None ... | Parse variant filters from the request object . | 439 | 9 |
5,037 | def suspects ( case_id , variant_id ) : case_obj = app . db . case ( case_id ) variant_obj = app . db . variant ( case_id , variant_id ) app . db . add_suspect ( case_obj , variant_obj ) return redirect ( request . referrer ) | Pin a variant as a suspect for a given case . | 70 | 11 |
5,038 | def queries ( ) : query = request . form [ 'query' ] name = request . form . get ( 'name' ) app . db . add_gemini_query ( name , query ) return redirect ( request . referrer ) | Store a new GEMINI query . | 50 | 9 |
5,039 | def load ( fp , object_pairs_hook = dict ) : return object_pairs_hook ( ( k , v ) for k , v , _ in parse ( fp ) if k is not None ) | Parse the contents of the ~io . IOBase . readline - supporting file - like object fp as a simple line - oriented . properties file and return a dict of the key - value pairs . | 47 | 43 |
5,040 | def loads ( s , object_pairs_hook = dict ) : fp = BytesIO ( s ) if isinstance ( s , binary_type ) else StringIO ( s ) return load ( fp , object_pairs_hook = object_pairs_hook ) | Parse the contents of the string s as a simple line - oriented . properties file and return a dict of the key - value pairs . | 60 | 28 |
5,041 | def _extractClipData ( self , audioClipSpec , showLogs = False ) : command = [ self . _ffmpegPath ] if not showLogs : command += [ '-nostats' , '-loglevel' , '0' ] command += [ '-i' , self . _audioFilePath , '-ss' , '%.3f' % audioClipSpec . start , '-t' , '%.3f' % audioClipSpec . duration ( ) , '-c' , 'copy' , '-map' ,... | Extracts a single clip according to audioClipSpec . | 254 | 13 |
5,042 | def add_phenotype ( self , ind_obj , phenotype_id ) : if phenotype_id . startswith ( 'HP:' ) or len ( phenotype_id ) == 7 : logger . debug ( 'querying on HPO term' ) hpo_results = phizz . query_hpo ( [ phenotype_id ] ) else : logger . debug ( 'querying on OMIM term' ) hpo_results = phizz . query_disease ( [ phenotype_i... | Add a phenotype term to the case . | 296 | 8 |
5,043 | def update_hpolist ( self , case_obj ) : hpo_list = self . case_genelist ( case_obj ) hpo_results = hpo_genes ( case_obj . phenotype_ids ( ) , * self . phenomizer_auth ) if hpo_results is None : pass # Why raise here? # raise RuntimeError("couldn't link to genes, try again") else : gene_ids = [ result [ 'gene_id' ] for... | Update the HPO gene list for a case based on current terms . | 140 | 14 |
5,044 | def remove_phenotype ( self , ind_obj , phenotypes = None ) : if phenotypes is None : logger . info ( "delete all phenotypes related to %s" , ind_obj . ind_id ) self . query ( PhenotypeTerm ) . filter_by ( ind_id = ind_obj . id ) . delete ( ) else : for term in ind_obj . phenotypes : if term . phenotype_id in phenotype... | Remove multiple phenotypes from an individual . | 173 | 8 |
5,045 | def match ( mode_lst : list , obj : 'object that has __destruct__ method' ) : # noinspection PyUnresolvedReferences try : # noinspection PyUnresolvedReferences structure = obj . __destruct__ ( ) except AttributeError : return False n = len ( mode_lst ) if n > len ( structure ) : return False for i in range ( n ) : mode... | >>> from Redy . ADT . Core import match data P >>> from Redy . ADT . traits import ConsInd Discrete >>> | 176 | 28 |
5,046 | def gemini_query ( self , query_id ) : logger . debug ( "Looking for query with id {0}" . format ( query_id ) ) return self . query ( GeminiQuery ) . filter_by ( id = query_id ) . first ( ) | Return a gemini query | 57 | 5 |
5,047 | def add_gemini_query ( self , name , query ) : logger . info ( "Adding query {0} with text {1}" . format ( name , query ) ) new_query = GeminiQuery ( name = name , query = query ) self . session . add ( new_query ) self . save ( ) return new_query | Add a user defined gemini query | 72 | 7 |
5,048 | def delete_gemini_query ( self , query_id ) : query_obj = self . gemini_query ( query_id ) logger . debug ( "Delete query: {0}" . format ( query_obj . name_query ) ) self . session . delete ( query_obj ) self . save ( ) | Delete a gemini query | 68 | 5 |
5,049 | def distance_to ( self , point , unit = 'km' ) : assert isinstance ( point , GeoPoint ) , ( 'Other point should also be a Point instance.' ) if self == point : return 0.0 coefficient = 69.09 theta = self . longitude - point . longitude unit = unit . lower ( ) if unit else None distance = math . degrees ( math . acos ( ... | Calculate distance in miles or kilometers between current and other passed point . | 172 | 15 |
5,050 | def rad_latitude ( self ) : if self . _rad_latitude is None : self . _rad_latitude = math . radians ( self . latitude ) return self . _rad_latitude | Lazy conversion degrees latitude to radians . | 45 | 9 |
5,051 | def rad_longitude ( self ) : if self . _rad_longitude is None : self . _rad_longitude = math . radians ( self . longitude ) return self . _rad_longitude | Lazy conversion degrees longitude to radians . | 46 | 10 |
5,052 | def send ( term , stream ) : payload = erlang . term_to_binary ( term ) header = struct . pack ( '!I' , len ( payload ) ) stream . write ( header ) stream . write ( payload ) stream . flush ( ) | Write an Erlang term to an output stream . | 54 | 10 |
5,053 | def recv ( stream ) : header = stream . read ( 4 ) if len ( header ) != 4 : return None # EOF ( length , ) = struct . unpack ( '!I' , header ) payload = stream . read ( length ) if len ( payload ) != length : return None term = erlang . binary_to_term ( payload ) return term | Read an Erlang term from an input stream . | 78 | 10 |
5,054 | def recv_loop ( stream ) : message = recv ( stream ) while message : yield message message = recv ( stream ) | Yield Erlang terms from an input stream . | 28 | 10 |
5,055 | def _add_genotype_calls ( self , variant_obj , variant_line , case_obj ) : variant_line = variant_line . split ( '\t' ) #if there is gt calls we have no individuals to add if len ( variant_line ) > 8 : gt_format = variant_line [ 8 ] . split ( ':' ) for individual in case_obj . individuals : sample_id = individual . ind... | Add the genotype calls for the variant | 283 | 8 |
5,056 | def with_prefix ( self , root_path ) : return Conflict ( self . conflict_type , root_path + self . path , self . body ) | Returns a new conflict with a prepended prefix as a path . | 33 | 13 |
5,057 | def to_json ( self ) : # map ConflictType to json-patch operator path = self . path if self . conflict_type in ( 'REORDER' , 'SET_FIELD' ) : op = 'replace' elif self . conflict_type in ( 'MANUAL_MERGE' , 'ADD_BACK_TO_HEAD' ) : op = 'add' path += ( '-' , ) elif self . conflict_type == 'REMOVE_FIELD' : op = 'remove' else... | Deserializes conflict to a JSON object . | 250 | 9 |
5,058 | def dump ( props , fp , separator = '=' , comments = None , timestamp = True , sort_keys = False ) : if comments is not None : print ( to_comment ( comments ) , file = fp ) if timestamp is not None and timestamp is not False : print ( to_comment ( java_timestamp ( timestamp ) ) , file = fp ) for k , v in itemize ( prop... | Write a series of key - value pairs to a file in simple line - oriented . properties format . | 120 | 20 |
5,059 | def dumps ( props , separator = '=' , comments = None , timestamp = True , sort_keys = False ) : s = StringIO ( ) dump ( props , s , separator = separator , comments = comments , timestamp = timestamp , sort_keys = sort_keys ) return s . getvalue ( ) | Convert a series of key - value pairs to a text string in simple line - oriented . properties format . | 67 | 22 |
5,060 | def join_key_value ( key , value , separator = '=' ) : # Escapes `key` and `value` the same way as java.util.Properties.store() return escape ( key ) + separator + re . sub ( r'^ +' , lambda m : r'\ ' * m . end ( ) , _base_escape ( value ) ) | r Join a key and value together into a single line suitable for adding to a simple line - oriented . properties file . No trailing newline is added . | 82 | 31 |
5,061 | def GetPlaylists ( self , start , max_count , order , reversed ) : cv = convert2dbus return self . iface . GetPlaylists ( cv ( start , 'u' ) , cv ( max_count , 'u' ) , cv ( order , 's' ) , cv ( reversed , 'b' ) ) | Gets a set of playlists . | 77 | 8 |
5,062 | def init_app ( self , app ) : self . algorithm = app . config . get ( 'HASHING_METHOD' , 'sha256' ) if self . algorithm not in algs : raise ValueError ( '{} not one of {}' . format ( self . algorithm , algs ) ) self . rounds = app . config . get ( 'HASHING_ROUNDS' , 1 ) if not isinstance ( self . rounds , int ) : raise... | Initializes the Flask application with this extension . It grabs the necessary configuration values from app . config those being HASHING_METHOD and HASHING_ROUNDS . HASHING_METHOD defaults to sha256 but can be any one of hashlib . algorithms . HASHING_ROUNDS specifies the number of times to hash the input with the spe... | 117 | 82 |
5,063 | def hash_value ( self , value , salt = '' ) : def hashit ( value , salt ) : h = hashlib . new ( self . algorithm ) tgt = salt + value h . update ( tgt ) return h . hexdigest ( ) def fix_unicode ( value ) : if VER < 3 and isinstance ( value , unicode ) : value = str ( value ) elif VER >= 3 and isinstance ( value , str )... | Hashes the specified value combined with the specified salt . The hash is done HASHING_ROUNDS times as specified by the application configuration . | 147 | 30 |
5,064 | def check_value ( self , value_hash , value , salt = '' ) : h = self . hash_value ( value , salt = salt ) return h == value_hash | Checks the specified hash value against the hash of the provided salt and value . | 38 | 16 |
5,065 | def AddTrack ( self , uri , after_track , set_as_current ) : self . iface . AddTrack ( uri , convert2dbus ( after_track , 'o' ) , convert2dbus ( set_as_current , 'b' ) ) | Adds a URI in the TrackList . | 61 | 8 |
5,066 | def delete_gene ( self , * gene_ids ) : self . gene_ids = [ gene_id for gene_id in self . gene_ids if gene_id not in gene_ids ] | Delete one or more gene ids form the list . | 44 | 11 |
5,067 | def healthy_update_timer ( self ) : state = None if self . update_status_timer and self . update_status_timer . is_alive ( ) : _LOGGER . debug ( "Timer: healthy" ) state = True else : _LOGGER . debug ( "Timer: not healthy" ) state = False return state | Check state of update timer . | 72 | 6 |
5,068 | def initialize ( self ) : self . network_status = self . get_network_status ( ) self . name = self . network_status . get ( 'network_name' , 'Unknown' ) self . location_info = self . get_location_info ( ) self . device_info = self . get_device_info ( ) self . device_id = ( self . device_info . get ( 'device_id' ) if se... | initialize the object | 127 | 4 |
5,069 | def initialize_socket ( self ) : try : _LOGGER . debug ( "Trying to open socket." ) self . _socket = socket . socket ( socket . AF_INET , # IPv4 socket . SOCK_DGRAM # UDP ) self . _socket . bind ( ( '' , self . _udp_port ) ) except socket . error as err : raise err else : _LOGGER . debug ( "Socket open." ) socket_threa... | initialize the socket | 148 | 4 |
5,070 | def initialize_worker ( self ) : worker_thread = threading . Thread ( name = "WorkerThread" , target = message_worker , args = ( self , ) ) worker_thread . setDaemon ( True ) worker_thread . start ( ) | initialize the worker thread | 55 | 5 |
5,071 | def initialize_zones ( self ) : zone_list = self . location_info . get ( 'zone_list' , { 'main' : True } ) for zone_id in zone_list : if zone_list [ zone_id ] : # Location setup is valid self . zones [ zone_id ] = Zone ( self , zone_id = zone_id ) else : # Location setup is not valid _LOGGER . debug ( "Ignoring zone: %... | initialize receiver zones | 107 | 4 |
5,072 | def handle_status ( self ) : status = self . get_status ( ) if status : # Update main-zone self . zones [ 'main' ] . update_status ( status ) | Handle status from device | 40 | 4 |
5,073 | def handle_netusb ( self , message ) : # _LOGGER.debug("message: {}".format(message)) needs_update = 0 if self . _yamaha : if 'play_info_updated' in message : play_info = self . get_play_info ( ) # _LOGGER.debug(play_info) if play_info : new_media_status = MediaStatus ( play_info , self . _ip_address ) if self . _yamah... | Handles netusb in message | 291 | 6 |
5,074 | def handle_features ( self , device_features ) : self . device_features = device_features if device_features and 'zone' in device_features : for zone in device_features [ 'zone' ] : zone_id = zone . get ( 'id' ) if zone_id in self . zones : _LOGGER . debug ( "handle_features: %s" , zone_id ) input_list = zone . get ( '... | Handles features of the device | 126 | 6 |
5,075 | def handle_event ( self , message ) : # _LOGGER.debug(message) needs_update = 0 for zone in self . zones : if zone in message : _LOGGER . debug ( "Received message for zone: %s" , zone ) self . zones [ zone ] . update_status ( message [ zone ] ) if 'netusb' in message : needs_update += self . handle_netusb ( message [ ... | Dispatch all event messages | 132 | 4 |
5,076 | def update_status ( self , reset = False ) : if self . healthy_update_timer and not reset : return # get device features only once if not self . device_features : self . handle_features ( self . get_features ( ) ) # Get status from device to register/keep alive UDP self . handle_status ( ) # Schedule next execution sel... | Update device status . | 84 | 4 |
5,077 | def setup_update_timer ( self , reset = False ) : _LOGGER . debug ( "Timer: firing again in %d seconds" , self . _interval ) self . update_status_timer = threading . Timer ( self . _interval , self . update_status , [ True ] ) self . update_status_timer . setDaemon ( True ) self . update_status_timer . start ( ) | Schedule a Timer Thread . | 92 | 7 |
5,078 | def set_playback ( self , playback ) : req_url = ENDPOINTS [ "setPlayback" ] . format ( self . _ip_address ) params = { "playback" : playback } return request ( req_url , params = params ) | Send Playback command . | 58 | 5 |
5,079 | def build_gemini_query ( self , query , extra_info ) : if 'WHERE' in query : return "{0} AND {1}" . format ( query , extra_info ) else : return "{0} WHERE {1}" . format ( query , extra_info ) | Append sql to a gemini query | 60 | 8 |
5,080 | def variants ( self , case_id , skip = 0 , count = 1000 , filters = None ) : filters = filters or { } logger . debug ( "Looking for variants in {0}" . format ( case_id ) ) limit = count + skip gemini_query = filters . get ( 'gemini_query' ) or "SELECT * from variants v" any_filter = False if filters . get ( 'frequency'... | Return count variants for a case . | 782 | 7 |
5,081 | def _variants ( self , case_id , gemini_query ) : individuals = [ ] # Get the individuals for the case case_obj = self . case ( case_id ) for individual in case_obj . individuals : individuals . append ( individual ) self . db = case_obj . variant_source self . variant_type = case_obj . variant_type gq = GeminiQuery ( ... | Return variants found in the gemini database | 237 | 8 |
5,082 | def _format_variant ( self , case_id , gemini_variant , individual_objs , index = 0 , add_all_info = False ) : chrom = gemini_variant [ 'chrom' ] if chrom . startswith ( 'chr' ) or chrom . startswith ( 'CHR' ) : chrom = chrom [ 3 : ] variant_dict = { 'CHROM' : chrom , 'POS' : str ( gemini_variant [ 'start' ] ) , 'ID' :... | Make a puzzle variant from a gemini variant | 758 | 9 |
5,083 | def _is_variant ( self , gemini_variant , ind_objs ) : indexes = ( ind . ind_index for ind in ind_objs ) #Check if any individual have a heterozygous or homozygous variant call for index in indexes : gt_call = gemini_variant [ 'gt_types' ] [ index ] if ( gt_call == 1 or gt_call == 3 ) : return True return False | Check if the variant is a variation in any of the individuals | 99 | 12 |
5,084 | def is_affected ( self ) : phenotype = self . phenotype if phenotype == '1' : return False elif phenotype == '2' : return True else : return False | Boolean for telling if the sample is affected . | 36 | 10 |
5,085 | def gene_list ( self , list_id ) : return self . query ( GeneList ) . filter_by ( list_id = list_id ) . first ( ) | Get a gene list from the database . | 37 | 8 |
5,086 | def add_genelist ( self , list_id , gene_ids , case_obj = None ) : new_genelist = GeneList ( list_id = list_id ) new_genelist . gene_ids = gene_ids if case_obj : new_genelist . cases . append ( case_obj ) self . session . add ( new_genelist ) self . save ( ) return new_genelist | Create a new gene list and optionally link to cases . | 90 | 11 |
5,087 | def remove_genelist ( self , list_id , case_obj = None ) : gene_list = self . gene_list ( list_id ) if case_obj : # remove a single link between case and gene list case_ids = [ case_obj . id ] else : # remove all links and the list itself case_ids = [ case . id for case in gene_list . cases ] self . session . delete ( ... | Remove a gene list and links to cases . | 169 | 9 |
5,088 | def case_genelist ( self , case_obj ) : list_id = "{}-HPO" . format ( case_obj . case_id ) gene_list = self . gene_list ( list_id ) if gene_list is None : gene_list = GeneList ( list_id = list_id ) case_obj . gene_lists . append ( gene_list ) self . session . add ( gene_list ) return gene_list | Get or create a new case specific gene list record . | 98 | 11 |
5,089 | def add_bigger_box ( self ) : start1 = "width='" + str ( int ( self . molecule . molsize1 ) ) + "px' height='" + str ( int ( self . molecule . molsize2 ) ) + "px' >" start2 = "<rect style='opacity:1.0;fill:#FFFFFF;stroke:none' width='" + str ( int ( self . molecule . molsize1 ) ) + "' height='" + str ( int ( self . mol... | Sets the size of the figure by expanding the space of molecule . svg file . These dimension have been previously determined . Also makes the lines of the molecule thicker . | 656 | 34 |
5,090 | def extend_with ( func ) : if not func . __name__ in ArgParseInator . _plugins : ArgParseInator . _plugins [ func . __name__ ] = func | Extends with class or function | 42 | 6 |
5,091 | def arg ( * args , * * kwargs ) : def decorate ( func ) : """ Decorate """ # we'll set the command name with the passed cmd_name argument, if # exist, else the command name will be the function name func . __cmd_name__ = kwargs . pop ( 'cmd_name' , getattr ( func , '__cmd_name__' , func . __name__ ) ) # retrieve the cl... | Dcorates a function or a class method to add to the argument parser | 467 | 15 |
5,092 | def class_args ( cls ) : # get the Singleton ap_ = ArgParseInator ( skip_init = True ) # collect special vars (really need?) utils . collect_appendvars ( ap_ , cls ) # set class reference cls . __cls__ = cls cmds = { } # get eventual class arguments cls . __arguments__ = getattr ( cls , '__arguments__' , [ ] ) # cycle ... | Decorates a class to handle the arguments parser . | 370 | 11 |
5,093 | def cmd_auth ( auth_phrase = None ) : def decorate ( func ) : """ decorates the funcion """ # get the Singleton ap_ = ArgParseInator ( skip_init = True ) # set the authorization name auth_name = id ( func ) if auth_phrase is None : # if we don't have a specific auth_phrase we set the # **authorization needed** to True ... | set authorization for command or subcommand . | 142 | 8 |
5,094 | def parse_args ( self ) : # compile the parser self . _compile ( ) # clear the args self . args = None self . _self_event ( 'before_parse' , 'parse' , * sys . argv [ 1 : ] , * * { } ) # list commands/subcommands in argv cmds = [ cmd for cmd in sys . argv [ 1 : ] if not cmd . startswith ( "-" ) ] if ( len ( cmds ) > 0 a... | Parse our arguments . | 438 | 5 |
5,095 | def check_auth ( self , name ) : if name in self . auths : # if the command name is in the **need authorization list** # get the authorization for the command auth = self . auths [ name ] if self . args . auth is None : # if we didn't pass the authorization phrase raise the # appropriate exception raise exceptions . Ar... | Check the authorization for the command | 140 | 6 |
5,096 | def check_command ( self , * * new_attributes ) : # let's parse arguments if we didn't before. if not self . _is_parsed : self . parse_args ( ) if not self . commands : # if we don't have commands raise an Exception raise exceptions . ArgParseInatorNoCommandsFound elif self . _single : # if we have a single function we... | Check if was passed a valid action in the command line and if so executes it by passing parameters and returning the result . | 260 | 24 |
5,097 | def _call_event ( self , event_name , cmd , pargs , kwargs , * * kws ) : def get_result_params ( res ) : """return the right list of params""" if not isinstance ( res , ( list , tuple ) ) : return res , pargs , kwargs elif len ( res ) == 2 : return res , pargs , kwargs return res [ 0 ] , ( pargs [ 0 ] , ) + tuple ( res... | Try to call events for cmd . | 244 | 7 |
5,098 | def _self_event ( self , event_name , cmd , * pargs , * * kwargs ) : if hasattr ( self , event_name ) : getattr ( self , event_name ) ( cmd , * pargs , * * kwargs ) | Call self event | 58 | 3 |
5,099 | def write ( self , * string ) : self . _output . write ( ' ' . join ( [ six . text_type ( s ) for s in string ] ) ) return self | Writes to the output | 39 | 5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.