idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
39,800 | def get_url_authcode_flow_user ( client_id , redirect_uri , display = "page" , scope = None , state = None ) : url = "https://oauth.vk.com/authorize" params = { "client_id" : client_id , "redirect_uri" : redirect_uri , "display" : display , "response_type" : "code" } if scope : params [ 'scope' ] = scope if state : par... | Authorization Code Flow for User Access Token |
39,801 | def get_fake_data ( * a ) : d [ 'x' ] = _n . linspace ( 0 , 10 , 100 ) d [ 'y' ] = _n . cos ( d [ 'x' ] ) + 0.1 * _n . random . rand ( 100 ) c . setData ( d [ 'x' ] , d [ 'y' ] ) | Called whenever someone presses the fire button . |
39,802 | def selectNumber ( self ) : le = self . lineEdit ( ) text = asUnicode ( le . text ( ) ) if self . opts [ 'suffix' ] == '' : le . setSelection ( 0 , len ( text ) ) else : try : index = text . index ( ' ' ) except ValueError : return le . setSelection ( 0 , index ) | Select the numerical portion of the text to allow quick editing by the user . |
39,803 | def value ( self ) : if self . opts [ 'int' ] : return int ( self . val ) else : return float ( self . val ) | Return the value of this SpinBox . |
39,804 | def interpret ( self ) : strn = self . lineEdit ( ) . text ( ) suf = self . opts [ 'suffix' ] if len ( suf ) > 0 : if strn [ - len ( suf ) : ] != suf : return False strn = strn [ : - len ( suf ) ] try : val = fn . siEval ( strn ) except : return False return val | Return value of text . Return False if text is invalid raise exception if text is intermediate |
39,805 | def editingFinishedEvent ( self ) : if asUnicode ( self . lineEdit ( ) . text ( ) ) == self . lastText : return try : val = self . interpret ( ) except : return if val is False : return if val == self . val : return self . setValue ( val , delaySignal = False ) | Edit has finished ; set value . |
39,806 | def make_factory ( self , cls , count ) : field_names = cls . _meta . get_all_field_names ( ) fields = { } text = [ ] finalizer = None scaffold = scaffolding . scaffold_for_model ( cls ) for field_name in field_names : generator = getattr ( scaffold , field_name , None ) if generator : if hasattr ( generator , 'set_up'... | Get the generators from the Scaffolding class within the model . |
39,807 | def compute_indel_length ( fs_df ) : indel_len = pd . Series ( index = fs_df . index ) indel_len [ fs_df [ 'Reference_Allele' ] == '-' ] = fs_df [ 'Tumor_Allele' ] [ fs_df [ 'Reference_Allele' ] == '-' ] . str . len ( ) indel_len [ fs_df [ 'Tumor_Allele' ] == '-' ] = fs_df [ 'Reference_Allele' ] [ fs_df [ 'Tumor_Allele... | Computes the indel length accounting for wether it is an insertion or deletion . |
39,808 | def keep_indels ( mut_df , indel_len_col = True , indel_type_col = True ) : mut_df = mut_df [ is_indel_annotation ( mut_df ) ] if indel_len_col : mut_df . loc [ : , 'indel len' ] = compute_indel_length ( mut_df ) if indel_type_col : is_ins = mut_df [ 'Reference_Allele' ] == '-' is_del = mut_df [ 'Tumor_Allele' ] == '-'... | Filters out all mutations that are not indels . |
39,809 | def keep_frameshifts ( mut_df , indel_len_col = True ) : mut_df = mut_df [ is_frameshift_annotation ( mut_df ) ] if indel_len_col : mut_df . loc [ : , 'indel len' ] = compute_indel_length ( mut_df ) return mut_df | Filters out all mutations that are not frameshift indels . |
39,810 | def is_frameshift_len ( mut_df ) : if 'indel len' in mut_df . columns : indel_len = mut_df [ 'indel len' ] else : indel_len = compute_indel_length ( mut_df ) is_fs = ( indel_len % 3 ) > 0 is_indel = ( mut_df [ 'Reference_Allele' ] == '-' ) | ( mut_df [ 'Tumor_Allele' ] == '-' ) is_fs [ ~ is_indel ] = False return is_fs | Simply returns a series indicating whether each corresponding mutation is a frameshift . |
39,811 | def get_frameshift_lengths ( num_bins ) : fs_len = [ ] i = 1 tmp_bins = 0 while ( tmp_bins < num_bins ) : if i % 3 : fs_len . append ( i ) tmp_bins += 1 i += 1 return fs_len | Simple function that returns the lengths for each frameshift category if num_bins number of frameshift categories are requested . |
39,812 | def random_context_pos ( self , num , num_permutations , context ) : if not self . is_valid_context ( context ) : error_msg = 'Context ({0}) was never seen in sequence.' . format ( context ) raise ValueError ( error_msg ) if num < 1 : error_msg = ( 'There must be at least one sample (specified {0}) ' 'for a context' . ... | Samples with replacement available positions matching the sequence context . |
39,813 | def retrieve_scores ( gname , sdir , codon_pos , germ_aa , somatic_aa , default_mga = 5. , default_vest = 0 , no_file_flag = - 1 ) : mga_path = os . path . join ( sdir , gname + ".mgaentropy.pickle" ) if os . path . exists ( mga_path ) : if sys . version_info < ( 3 , ) : with open ( mga_path ) as handle : mga_ent = pic... | Retrieves scores from pickle files . |
39,814 | def read_vest_pickle ( gname , score_dir ) : vest_path = os . path . join ( score_dir , gname + ".vest.pickle" ) if os . path . exists ( vest_path ) : if sys . version_info < ( 3 , ) : with open ( vest_path ) as handle : gene_vest = pickle . load ( handle ) else : with open ( vest_path , 'rb' ) as handle : gene_vest = ... | Read in VEST scores for given gene . |
39,815 | def compute_vest_stat ( vest_dict , ref_aa , somatic_aa , codon_pos , stat_func = np . mean , default_val = 0.0 ) : if vest_dict is None : return default_val myscores = fetch_vest_scores ( vest_dict , ref_aa , somatic_aa , codon_pos ) if myscores : score_stat = stat_func ( myscores ) else : score_stat = default_val ret... | Compute missense VEST score statistic . |
39,816 | def compute_mga_entropy_stat ( mga_vec , codon_pos , stat_func = np . mean , default_val = 0.0 ) : if mga_vec is None : return default_val myscores = fetch_mga_scores ( mga_vec , codon_pos ) if myscores is not None and len ( myscores ) : score_stat = stat_func ( myscores ) else : score_stat = default_val return score_s... | Compute MGA entropy conservation statistic |
39,817 | def fetch_vest_scores ( vest_dict , ref_aa , somatic_aa , codon_pos , default_vest = 0.0 ) : vest_score_list = [ ] for i in range ( len ( somatic_aa ) ) : if codon_pos [ i ] is not None : tmp_score = vest_dict . get ( codon_pos [ i ] + 1 , { } ) . get ( ref_aa [ i ] , { } ) . get ( somatic_aa [ i ] , default_vest ) els... | Get VEST scores from pre - computed scores in dictionary . |
39,818 | def fetch_mga_scores ( mga_vec , codon_pos , default_mga = None ) : len_mga = len ( mga_vec ) good_codon_pos = [ p for p in codon_pos if p < len_mga ] if good_codon_pos : mga_ent_scores = mga_vec [ good_codon_pos ] else : mga_ent_scores = None return mga_ent_scores | Get MGAEntropy scores from pre - computed scores in array . |
39,819 | def read_neighbor_graph_pickle ( gname , graph_dir ) : graph_path = os . path . join ( graph_dir , gname + ".pickle" ) if os . path . exists ( graph_path ) : with open ( graph_path ) as handle : gene_graph = pickle . load ( handle ) return gene_graph else : return None | Read in neighbor graph for given gene . |
39,820 | def compute_ng_stat ( gene_graph , pos_ct , alpha = .5 ) : if not len ( pos_ct ) : return 1.0 , 0 max_pos = max ( gene_graph ) codon_vals = np . zeros ( max_pos + 1 ) for pos in pos_ct : mut_count = pos_ct [ pos ] neighbors = list ( gene_graph [ pos ] ) num_neighbors = len ( neighbors ) codon_vals [ neighbors ] += alph... | Compute the clustering score for the gene on its neighbor graph . |
39,821 | def count_frameshift_total ( mut_df , bed_path , use_unmapped = False , to_zero_based = False ) : if to_zero_based : mut_df [ 'Start_Position' ] = mut_df [ 'Start_Position' ] - 1 fs_cts = { } fs_df = indel . keep_frameshifts ( mut_df ) for bed in utils . bed_generator ( bed_path ) : gene_df = fs_df [ fs_df [ 'Gene' ] =... | Count frameshifts for each gene . |
39,822 | def _fetch_3ss_fasta ( fasta , gene_name , exon_num , chrom , strand , start , end ) : if strand == '-' : ss_seq = fasta . fetch ( reference = chrom , start = end - 1 , end = end + 3 ) ss_seq = utils . rev_comp ( ss_seq ) elif strand == '+' : ss_seq = fasta . fetch ( reference = chrom , start = start - 3 , end = start ... | Retreives the 3 SS sequence flanking the specified exon . |
39,823 | def fetch_gene_fasta ( gene_bed , fasta_obj ) : gene_fasta = '' strand = gene_bed . strand exons = gene_bed . get_exons ( ) if strand == '-' : exons . reverse ( ) for i , exon in enumerate ( exons ) : exon_seq = fasta_obj . fetch ( reference = gene_bed . chrom , start = exon [ 0 ] , end = exon [ 1 ] ) . upper ( ) if st... | Retreive gene sequences in FASTA format . |
39,824 | def _reset_seq ( self ) : exon_seq_list , five_ss_seq_list , three_ss_seq_list = self . _fetch_seq ( ) self . exon_seq = '' . join ( exon_seq_list ) self . three_prime_seq = three_ss_seq_list self . five_prime_seq = five_ss_seq_list self . _to_upper ( ) | Updates attributes for gene represented in the self . bed attribute . |
39,825 | def add_germline_variants ( self , germline_nucs , coding_pos ) : if len ( germline_nucs ) != len ( coding_pos ) : raise ValueError ( 'Each germline nucleotide should have a coding position' ) es = list ( self . exon_seq ) for i in range ( len ( germline_nucs ) ) : gl_nuc , cpos = germline_nucs [ i ] . upper ( ) , codi... | Add potential germline variants into the nucleotide sequence . |
39,826 | def _to_upper ( self ) : self . exon_seq = self . exon_seq . upper ( ) self . three_prime_seq = [ s . upper ( ) for s in self . three_prime_seq ] self . five_prime_seq = [ s . upper ( ) for s in self . five_prime_seq ] | Convert sequences to upper case . |
39,827 | def _fetch_seq ( self ) : exons = [ ] three_prime_ss = [ ] five_prime_ss = [ ] num_exons = self . bed . get_num_exons ( ) for i in range ( num_exons ) : tmp_id = '{0};exon{1}' . format ( self . bed . gene_name , i ) tmp_exon = self . fasta . fetch ( reference = tmp_id ) exons . append ( tmp_exon ) tmp_id_3ss = '{0};3SS... | Fetches gene sequence from PySAM fasta object . |
39,828 | def correct_chrom_names ( chroms ) : chrom_list = [ ] for chrom in chroms : chrom = str ( chrom ) chrom = chrom . replace ( '23' , 'X' ) chrom = chrom . replace ( '24' , 'Y' ) chrom = chrom . replace ( '25' , 'Mt' ) if not chrom . startswith ( 'chr' ) : chrom = 'chr' + chrom chrom_list . append ( chrom ) return chrom_l... | Make sure chromosome names follow UCSC chr convention . |
39,829 | def fishers_method ( pvals ) : pvals = np . asarray ( pvals ) degrees_of_freedom = 2 * pvals . size chisq_stat = np . sum ( - 2 * np . log ( pvals ) ) fishers_pval = stats . chi2 . sf ( chisq_stat , degrees_of_freedom ) return fishers_pval | Fisher s method for combining independent p - values . |
39,830 | def cummin ( x ) : for i in range ( 1 , len ( x ) ) : if x [ i - 1 ] < x [ i ] : x [ i ] = x [ i - 1 ] return x | A python implementation of the cummin function in R |
39,831 | def bh_fdr ( pval ) : pval_array = np . array ( pval ) sorted_order = np . argsort ( pval_array ) original_order = np . argsort ( sorted_order ) pval_array = pval_array [ sorted_order ] n = float ( len ( pval ) ) pval_adj = np . zeros ( int ( n ) ) i = np . arange ( 1 , int ( n ) + 1 , dtype = float ) [ : : - 1 ] pval_... | A python implementation of the Benjamani - Hochberg FDR method . |
39,832 | def calc_deleterious_p_value ( mut_info , unmapped_mut_info , sc , gs , bed , num_permutations , stop_thresh , del_threshold , pseudo_count , seed = None ) : if len ( mut_info ) > 0 : mut_info [ 'Coding Position' ] = mut_info [ 'Coding Position' ] . astype ( int ) mut_info [ 'Context' ] = mut_info [ 'Coding Position' ]... | Calculates the p - value for the number of inactivating SNV mutations . |
39,833 | def calc_protein_p_value ( mut_info , unmapped_mut_info , sc , gs , bed , graph_dir , num_permutations , stop_thresh , min_recurrent , min_fraction ) : if len ( mut_info ) > 0 : mut_info [ 'Coding Position' ] = mut_info [ 'Coding Position' ] . astype ( int ) mut_info [ 'Context' ] = mut_info [ 'Coding Position' ] . app... | Computes the p - value for clustering on a neighbor graph composed of codons connected with edges if they are spatially near in 3D protein structure . |
39,834 | def shannon_entropy ( p ) : return - np . sum ( np . where ( p != 0 , p * np . log2 ( p ) , 0 ) ) | Calculates shannon entropy in bits . |
39,835 | def js_divergence ( p , q ) : m = .5 * ( p + q ) js_div = .5 * kl_divergence ( p , m ) + .5 * kl_divergence ( q , m ) return js_div | Compute the Jensen - Shannon Divergence between two discrete distributions . |
39,836 | def js_distance ( p , q ) : js_dist = np . sqrt ( js_divergence ( p , q ) ) return js_dist | Compute the Jensen - Shannon distance between two discrete distributions . |
39,837 | def _init_exons ( self ) : exon_starts = [ self . chrom_start + int ( s ) for s in self . bed_tuple . blockStarts . strip ( ',' ) . split ( ',' ) ] exon_sizes = list ( map ( int , self . bed_tuple . blockSizes . strip ( ',' ) . split ( ',' ) ) ) exons = [ ( exon_starts [ i ] , exon_starts [ i ] + exon_sizes [ i ] ) for... | Sets a list of position intervals for each exon . |
39,838 | def init_genome_coordinates ( self ) : self . seqpos2genome = { } seq_pos = 0 for estart , eend in self . exons : for genome_pos in range ( estart , eend ) : if self . strand == '+' : self . seqpos2genome [ seq_pos ] = genome_pos elif self . strand == '-' : tmp = self . cds_len - seq_pos - 1 self . seqpos2genome [ tmp ... | Creates the self . seqpos2genome dictionary that converts positions relative to the sequence to genome coordinates . |
39,839 | def query_position ( self , strand , chr , genome_coord ) : pos = None if chr != self . chrom : pass if type ( genome_coord ) is list : pos_left = self . query_position ( strand , chr , genome_coord [ 0 ] ) pos_right = self . query_position ( strand , chr , genome_coord [ 1 ] ) if pos_left is not None or pos_right is n... | Provides the relative position on the coding sequence for a given genomic position . |
39,840 | def start_logging ( log_file = '' , log_level = 'INFO' , verbose = False ) : if not log_file : log_dir = os . path . abspath ( 'log' ) + '/' if not os . path . isdir ( log_dir ) : os . mkdir ( log_dir ) log_file = log_dir + 'log.run.' + str ( datetime . datetime . now ( ) ) . replace ( ':' , '.' ) + '.txt' lvl = loggin... | Start logging information into the log directory . |
39,841 | def log_error_decorator ( f ) : @ wraps ( f ) def wrapper ( * args , ** kwds ) : try : result = f ( * args , ** kwds ) return result except KeyboardInterrupt : logger . info ( 'Ctrl-C stopped a process.' ) except Exception as e : logger . exception ( e ) raise return wrapper | Writes exception to log file if occured in decorated function . |
39,842 | def filter_list ( mylist , bad_ixs ) : bad_ixs = sorted ( bad_ixs , reverse = True ) for i in bad_ixs : mylist . pop ( i ) return mylist | Removes indices from a list . |
39,843 | def rev_comp ( seq ) : rev_seq = seq [ : : - 1 ] rev_comp_seq = '' . join ( [ base_pairing [ s ] for s in rev_seq ] ) return rev_comp_seq | Get reverse complement of sequence . |
39,844 | def bed_generator ( bed_path ) : with open ( bed_path ) as handle : bed_reader = csv . reader ( handle , delimiter = '\t' ) for line in bed_reader : yield BedLine ( line ) | Iterates through a BED file yielding parsed BED lines . |
39,845 | def read_bed ( file_path , restricted_genes = None ) : bed_dict = OrderedDict ( ) for bed_row in bed_generator ( file_path ) : is_restrict_flag = restricted_genes is None or bed_row . gene_name in restricted_genes if is_restrict_flag : bed_dict . setdefault ( bed_row . chrom , [ ] ) bed_dict [ bed_row . chrom ] . appen... | Reads BED file and populates a dictionary separating genes by chromosome . |
39,846 | def _fix_mutation_df ( mutation_df , only_unique = False ) : orig_len = len ( mutation_df ) mutation_df = mutation_df [ mutation_df . Variant_Classification . isin ( variant_snv ) ] type_len = len ( mutation_df ) log_msg = ( 'Dropped {num_dropped} mutations after only keeping ' '{mut_types}. Indels are processed separa... | Drops invalid mutations and corrects for 1 - based coordinates . |
39,847 | def calc_windowed_sum ( aa_mut_pos , germ_aa , somatic_aa , window = [ 3 ] ) : pos_ctr , pos_sum = { } , { w : { } for w in window } num_pos = len ( aa_mut_pos ) for i in range ( num_pos ) : pos = aa_mut_pos [ i ] if germ_aa [ i ] and somatic_aa [ i ] and germ_aa [ i ] != '*' and somatic_aa [ i ] != '*' and germ_aa [ i... | Calculate the sum of mutations within a window around a particular mutated codon . |
39,848 | def get_all_context_names ( context_num ) : if context_num == 0 : return [ 'None' ] elif context_num == 1 : return [ 'A' , 'C' , 'T' , 'G' ] elif context_num == 1.5 : return [ 'C*pG' , 'CpG*' , 'TpC*' , 'G*pA' , 'A' , 'C' , 'T' , 'G' ] elif context_num == 2 : dinucs = list ( set ( [ d1 + d2 for d1 in 'ACTG' for d2 in '... | Based on the nucleotide base context number return a list of strings representing each context . |
39,849 | def get_chasm_context ( tri_nuc ) : if len ( tri_nuc ) != 3 : raise ValueError ( 'Chasm context requires a three nucleotide string ' '(Provided: "{0}")' . format ( tri_nuc ) ) if tri_nuc [ 1 : ] == 'CG' : return 'C*pG' elif tri_nuc [ : 2 ] == 'CG' : return 'CpG*' elif tri_nuc [ : 2 ] == 'TC' : return 'TpC*' elif tri_nu... | Returns the mutation context acording to CHASM . |
39,850 | def get_aa_mut_info ( coding_pos , somatic_base , gene_seq ) : if not somatic_base : aa_info = { 'Reference Codon' : [ ] , 'Somatic Codon' : [ ] , 'Codon Pos' : [ ] , 'Reference Nuc' : [ ] , 'Reference AA' : [ ] , 'Somatic AA' : [ ] } return aa_info ref_codon , codon_pos , pos_in_codon , ref_nuc = zip ( * [ cutils . po... | Retrieves relevant information about the effect of a somatic SNV on the amino acid of a gene . |
39,851 | def handle_tsg_results ( permutation_result ) : permutation_df = pd . DataFrame ( sorted ( permutation_result , key = lambda x : x [ 2 ] if x [ 2 ] is not None else 1.1 ) , columns = [ 'gene' , 'inactivating count' , 'inactivating p-value' , 'Total SNV Mutations' , 'SNVs Unmapped to Ref Tx' ] ) permutation_df [ 'inacti... | Handles result from TSG results . |
39,852 | def get_frameshift_info ( fs_df , bins ) : fs_df = compute_indel_length ( fs_df ) num_indels = [ ] indel_len = [ ] num_categories = 0 i = 1 while ( num_categories < bins ) : if i % 3 : if num_categories != bins - 1 : tmp_num = len ( fs_df [ fs_df [ 'indel len' ] == i ] ) else : tmp_num = len ( fs_df [ ( fs_df [ 'indel ... | Counts frameshifts stratified by a given length . |
39,853 | def set_mutation_type ( self , mut_type = '' ) : if mut_type : self . mutation_type = mut_type else : if not self . is_valid : self . mutation_type = 'not valid' elif self . unknown_effect : self . mutation_type = 'unknown effect' elif self . is_no_protein : self . mutation_type = 'no protein' elif self . is_missing_in... | Sets the mutation type attribute to a single label based on attribute flags . |
39,854 | def set_amino_acid ( self , aa ) : aa = aa . upper ( ) aa = aa [ 2 : ] if aa . startswith ( 'P.' ) else aa self . __set_mutation_status ( ) self . __parse_hgvs_syntax ( aa ) | Set amino acid change and position . |
39,855 | def __set_missense_status ( self , hgvs_string ) : if re . search ( '^[A-Z?]\d+[A-Z?]$' , hgvs_string ) : self . is_missense = True self . is_non_silent = True else : self . is_missense = False | Sets the self . is_missense flag . |
39,856 | def __set_lost_start_status ( self , hgvs_string ) : mymatch = re . search ( '^([A-Z?])(\d+)([A-Z?])$' , hgvs_string ) if mymatch : grps = mymatch . groups ( ) if int ( grps [ 1 ] ) == 1 and grps [ 0 ] != grps [ 2 ] : self . is_lost_start = True self . is_non_silent = True else : self . is_lost_start = False else : sel... | Sets the self . is_lost_start flag . |
39,857 | def __set_frame_shift_status ( self ) : if 'fs' in self . hgvs_original : self . is_frame_shift = True self . is_non_silent = True elif re . search ( '[A-Z]\d+[A-Z]+\*' , self . hgvs_original ) : self . is_frame_shift = True self . is_non_silent = True else : self . is_frame_shift = False | Check for frame shift and set the self . is_frame_shift flag . |
39,858 | def __set_lost_stop_status ( self , hgvs_string ) : lost_stop_pattern = '^\*\d+[A-Z?]+\*?$' if re . search ( lost_stop_pattern , hgvs_string ) : self . is_lost_stop = True self . is_non_silent = True else : self . is_lost_stop = False | Check if the stop codon was mutated to something other than a stop codon . |
39,859 | def __set_premature_stop_codon_status ( self , hgvs_string ) : if re . search ( '.+\*(\d+)?$' , hgvs_string ) : self . is_premature_stop_codon = True self . is_non_silent = True if hgvs_string . endswith ( '*' ) : self . is_nonsense_mutation = True else : self . is_nonsense_mutation = False else : self . is_premature_s... | Set whether there is a premature stop codon . |
39,860 | def __set_indel_status ( self ) : if "ins" in self . hgvs_original : self . is_insertion = True self . is_deletion = False self . is_indel = True self . is_non_silent = True elif "del" in self . hgvs_original : self . is_deletion = True self . is_insertion = False self . is_indel = True self . is_non_silent = True else... | Sets flags related to the mutation being an indel . |
39,861 | def __set_unkown_effect ( self , hgvs_string ) : unknown_effect_list = [ '?' , '(=)' , '=' ] if hgvs_string in unknown_effect_list : self . unknown_effect = True elif "(" in hgvs_string : self . unknown_effect = True else : self . unknown_effect = False if "?" in hgvs_string : self . is_missing_info = True else : self ... | Sets a flag for unkown effect according to HGVS syntax . The COSMIC database also uses unconventional questionmarks to denote missing information . |
39,862 | def deleterious_permutation ( obs_del , context_counts , context_to_mut , seq_context , gene_seq , num_permutations = 10000 , stop_criteria = 100 , pseudo_count = 0 , max_batch = 25000 ) : mycontexts = context_counts . index . tolist ( ) somatic_base = [ base for one_context in mycontexts for base in context_to_mut [ o... | Performs null - permutations for deleterious mutation statistics in a single gene . |
39,863 | def protein_permutation ( graph_score , num_codons_obs , context_counts , context_to_mut , seq_context , gene_seq , gene_graph , num_permutations = 10000 , stop_criteria = 100 , pseudo_count = 0 ) : mycontexts = context_counts . index . tolist ( ) somatic_base = [ base for one_context in mycontexts for base in context_... | Performs null - simulations for position - based mutation statistics in a single gene . |
39,864 | def effect_permutation ( context_counts , context_to_mut , seq_context , gene_seq , num_permutations = 10000 , pseudo_count = 0 ) : mycontexts = context_counts . index . tolist ( ) somatic_base = [ base for one_context in mycontexts for base in context_to_mut [ one_context ] ] tmp_contxt_pos = seq_context . random_pos ... | Performs null - permutations for effect - based mutation statistics in a single gene . |
39,865 | def non_silent_ratio_permutation ( context_counts , context_to_mut , seq_context , gene_seq , num_permutations = 10000 ) : mycontexts = context_counts . index . tolist ( ) somatic_base = [ base for one_context in mycontexts for base in context_to_mut [ one_context ] ] tmp_contxt_pos = seq_context . random_pos ( context... | Performs null - permutations for non - silent ratio across all genes . |
39,866 | def summary_permutation ( context_counts , context_to_mut , seq_context , gene_seq , score_dir , num_permutations = 10000 , min_frac = 0.0 , min_recur = 2 , drop_silent = False ) : mycontexts = context_counts . index . tolist ( ) somatic_base = [ base for one_context in mycontexts for base in context_to_mut [ one_conte... | Performs null - permutations and summarizes the results as features over the gene . |
39,867 | def maf_permutation ( context_counts , context_to_mut , seq_context , gene_seq , num_permutations = 10000 , drop_silent = False ) : mycontexts = context_counts . index . tolist ( ) somatic_base , base_context = zip ( * [ ( base , one_context ) for one_context in mycontexts for base in context_to_mut [ one_context ] ] )... | Performs null - permutations across all genes and records the results in a format like a MAF file . This could be useful for examining the null permutations because the alternative approaches always summarize the results . With the simulated null - permutations novel metrics can be applied to create an empirical null -... |
39,868 | def editor_js_initialization ( selector , ** extra_settings ) : init_template = loader . get_template ( settings . MARKDOWN_EDITOR_INIT_TEMPLATE ) options = dict ( previewParserPath = reverse ( 'django_markdown_preview' ) , ** settings . MARKDOWN_EDITOR_SETTINGS ) options . update ( extra_settings ) ctx = dict ( select... | Return script tag with initialization code . |
39,869 | def preview ( request ) : if settings . MARKDOWN_PROTECT_PREVIEW : user = getattr ( request , 'user' , None ) if not user or not user . is_staff : from django . contrib . auth . views import redirect_to_login return redirect_to_login ( request . get_full_path ( ) ) return render ( request , settings . MARKDOWN_PREVIEW_... | Render preview page . |
39,870 | def register ( ) : admin . site . unregister ( FlatPage ) admin . site . register ( FlatPage , LocalFlatPageAdmin ) | Register markdown for flatpages . |
39,871 | def markdown_editor ( selector ) : return dict ( selector = selector , extra_settings = mark_safe ( simplejson . dumps ( dict ( previewParserPath = reverse ( 'django_markdown_preview' ) ) ) ) ) | Enable markdown editor for given textarea . |
39,872 | def markdown_media_css ( ) : return dict ( CSS_SET = posixpath . join ( settings . MARKDOWN_SET_PATH , settings . MARKDOWN_SET_NAME , 'style.css' ) , CSS_SKIN = posixpath . join ( 'django_markdown' , 'skins' , settings . MARKDOWN_EDITOR_SKIN , 'style.css' ) ) | Add css requirements to HTML . |
39,873 | def convert ( source , to , format = None , extra_args = ( ) , encoding = 'utf-8' ) : return _convert ( _read_file , _process_file , source , to , format , extra_args , encoding = encoding ) | Convert given source from format to another . |
39,874 | def get_pandoc_formats ( ) : try : p = subprocess . Popen ( [ 'pandoc' , '-h' ] , stdin = subprocess . PIPE , stdout = subprocess . PIPE ) except OSError : raise OSError ( "You probably do not have pandoc installed." ) help_text = p . communicate ( ) [ 0 ] . decode ( ) . splitlines ( False ) txt = ' ' . join ( help_tex... | Dynamic preprocessor for Pandoc formats . |
39,875 | def render ( self , name , value , attrs = None , renderer = None ) : html = super ( MarkdownWidget , self ) . render ( name , value , attrs , renderer ) attrs = self . build_attrs ( attrs ) html += editor_js_initialization ( "#%s" % attrs [ 'id' ] ) return mark_safe ( html ) | Render widget . |
39,876 | def extendMarkdown ( self , md , md_globals ) : md . registerExtension ( self ) md . preprocessors . add ( 'graphviz_block' , InlineGraphvizPreprocessor ( md ) , "_begin" ) | Add InlineGraphvizPreprocessor to the Markdown instance . |
39,877 | def run ( self , lines ) : text = "\n" . join ( lines ) while 1 : m = BLOCK_RE . search ( text ) if m : command = m . group ( 'command' ) if command not in SUPPORTED_COMMAMDS : raise Exception ( 'Command not supported: %s' % command ) filename = m . group ( 'filename' ) content = m . group ( 'content' ) filetype = file... | Match and generate dot code blocks . |
39,878 | def post ( self , command , data = None ) : now = calendar . timegm ( datetime . datetime . now ( ) . timetuple ( ) ) if now > self . expiration : auth = self . __open ( "/oauth/token" , data = self . oauth ) self . __sethead ( auth [ 'access_token' ] ) return self . __open ( "%s%s" % ( self . api , command ) , headers... | Post data to API . |
39,879 | def __sethead ( self , access_token ) : self . access_token = access_token now = calendar . timegm ( datetime . datetime . now ( ) . timetuple ( ) ) self . expiration = now + 1800 self . head = { "Authorization" : "Bearer %s" % access_token , "User-Agent" : self . user_agent } | Set HTTP header . |
39,880 | def __open ( self , url , headers = None , data = None , baseurl = "" ) : headers = headers or { } if not baseurl : baseurl = self . baseurl req = Request ( "%s%s" % ( baseurl , url ) , headers = headers ) _LOGGER . debug ( url ) try : req . data = urlencode ( data ) . encode ( 'utf-8' ) except TypeError : pass opener ... | Use raw urlopen command . |
39,881 | def update ( self ) : self . _controller . update ( self . _id , wake_if_asleep = False ) data = self . _controller . get_drive_params ( self . _id ) if data : if not data [ 'shift_state' ] or data [ 'shift_state' ] == 'P' : self . __state = True else : self . __state = False | Update the parking brake sensor . |
39,882 | def update ( self ) : self . _controller . update ( self . _id , wake_if_asleep = False ) data = self . _controller . get_climate_params ( self . _id ) if data : if time . time ( ) - self . __manual_update_time > 60 : self . __is_auto_conditioning_on = ( data [ 'is_auto_conditioning_on' ] ) self . __is_climate_on = dat... | Update the HVAC state . |
39,883 | def set_temperature ( self , temp ) : temp = round ( temp , 1 ) self . __manual_update_time = time . time ( ) data = self . _controller . command ( self . _id , 'set_temps' , { "driver_temp" : temp , "passenger_temp" : temp } , wake_if_asleep = True ) if data [ 'response' ] [ 'result' ] : self . __driver_temp_setting =... | Set both the driver and passenger temperature to temp . |
39,884 | def set_status ( self , enabled ) : self . __manual_update_time = time . time ( ) if enabled : data = self . _controller . command ( self . _id , 'auto_conditioning_start' , wake_if_asleep = True ) if data [ 'response' ] [ 'result' ] : self . __is_auto_conditioning_on = True self . __is_climate_on = True else : data = ... | Enable or disable the HVAC . |
39,885 | def update ( self ) : self . _controller . update ( self . _id , wake_if_asleep = False ) data = self . _controller . get_climate_params ( self . _id ) if data : self . __inside_temp = ( data [ 'inside_temp' ] if data [ 'inside_temp' ] else self . __inside_temp ) self . __outside_temp = ( data [ 'outside_temp' ] if dat... | Update the temperature . |
39,886 | def update ( self ) : self . _controller . update ( self . _id , wake_if_asleep = False ) data = self . _controller . get_charging_params ( self . _id ) if data and ( time . time ( ) - self . __manual_update_time > 60 ) : if data [ 'charging_state' ] != "Charging" : self . __charger_state = False else : self . __charge... | Update the charging state of the Tesla Vehicle . |
39,887 | def start_charge ( self ) : if not self . __charger_state : data = self . _controller . command ( self . _id , 'charge_start' , wake_if_asleep = True ) if data and data [ 'response' ] [ 'result' ] : self . __charger_state = True self . __manual_update_time = time . time ( ) | Start charging the Tesla Vehicle . |
39,888 | def stop_charge ( self ) : if self . __charger_state : data = self . _controller . command ( self . _id , 'charge_stop' , wake_if_asleep = True ) if data and data [ 'response' ] [ 'result' ] : self . __charger_state = False self . __manual_update_time = time . time ( ) | Stop charging the Tesla Vehicle . |
39,889 | def update ( self ) : self . _controller . update ( self . _id , wake_if_asleep = False ) data = self . _controller . get_charging_params ( self . _id ) if data and ( time . time ( ) - self . __manual_update_time > 60 ) : self . __maxrange_state = data [ 'charge_to_max_range' ] | Update the status of the range setting . |
39,890 | def set_max ( self ) : if not self . __maxrange_state : data = self . _controller . command ( self . _id , 'charge_max_range' , wake_if_asleep = True ) if data [ 'response' ] [ 'result' ] : self . __maxrange_state = True self . __manual_update_time = time . time ( ) | Set the charger to max range for trips . |
39,891 | def set_standard ( self ) : if self . __maxrange_state : data = self . _controller . command ( self . _id , 'charge_standard' , wake_if_asleep = True ) if data and data [ 'response' ] [ 'result' ] : self . __maxrange_state = False self . __manual_update_time = time . time ( ) | Set the charger to standard range for daily commute . |
39,892 | def unlock ( self ) : if self . __lock_state : data = self . _controller . command ( self . _id , 'door_unlock' , wake_if_asleep = True ) if data [ 'response' ] [ 'result' ] : self . __lock_state = False self . __manual_update_time = time . time ( ) | Unlock the doors and extend handles where applicable . |
39,893 | def lock ( self ) : if not self . __lock_state : data = self . _controller . command ( self . _id , 'charge_port_door_close' , wake_if_asleep = True ) if data [ 'response' ] [ 'result' ] : self . __lock_state = True self . __manual_update_time = time . time ( ) | Close the charger door . |
39,894 | def wake_up ( func ) : @ wraps ( func ) def wrapped ( * args , ** kwargs ) : def valid_result ( result ) : try : return ( result is not None and result is not False and ( result is True or ( isinstance ( result , dict ) and isinstance ( result [ 'response' ] , dict ) and ( 'result' in result [ 'response' ] and result [... | Wrap a API f so it will attempt to wake the vehicle if asleep . |
39,895 | def post ( self , vehicle_id , command , data = None , wake_if_asleep = True ) : data = data or { } return self . __connection . post ( 'vehicles/%i/%s' % ( vehicle_id , command ) , data ) | Send post command to the vehicle_id . |
39,896 | def get ( self , vehicle_id , command , wake_if_asleep = False ) : return self . __connection . get ( 'vehicles/%i/%s' % ( vehicle_id , command ) ) | Send get command to the vehicle_id . |
39,897 | def data_request ( self , vehicle_id , name , wake_if_asleep = False ) : return self . get ( vehicle_id , 'vehicle_data/%s' % name , wake_if_asleep = wake_if_asleep ) [ 'response' ] | Get requested data from vehicle_id . |
39,898 | def command ( self , vehicle_id , name , data = None , wake_if_asleep = True ) : data = data or { } return self . post ( vehicle_id , 'command/%s' % name , data , wake_if_asleep = wake_if_asleep ) | Post name command to the vehicle_id . |
39,899 | def update ( self , car_id = None , wake_if_asleep = False , force = False ) : cur_time = time . time ( ) with self . __lock : last_update = self . _last_attempted_update_time if ( force or cur_time - last_update > self . update_interval ) : cars = self . get_vehicles ( ) for car in cars : self . car_online [ car [ 'id... | Update all vehicle attributes in the cache . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.