sequence
stringlengths
492
15.9k
code
stringlengths
75
8.58k
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:databasesKEGG; 3, parameters; 3, 4; 3, 5; 4, identifier:organism; 5, identifier:ens_ids; 6, block; 6, 7; 6, 20; 6, 29; 6, 33; 6, 171; 6, 182; 6, 193; 6, 210; 6, 219; 6, 281; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifi...
def databasesKEGG(organism,ens_ids): all_genes=urlopen("http://rest.kegg.jp/list/"+organism).read() all_genes=all_genes.split("\n") dbs=[] while len(dbs) == 0: for g in all_genes: if len(dbs) == 0: kid = g.split("\t")[0] gene=urlopen("http://rest.kegg....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:process; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:form; 6, identifier:post; 7, block; 7, 8; 7, 21; 7, 30; 7, 36; 7, 416; 7, 436; 8, if_statement; 8, 9; 8, 15; 9, not_operator; 9, 10; 10, call; 10, 11; 10, 12; 11, ident...
def process(self, form, post): if not isinstance(form, FormMeta): raise TypeError('Given form is not a valid WTForm.') re_field_name = re.compile(r'\%([a-zA-Z0-9_]*)\%') class F(form): pass for field, data in post.iteritems(): if field in F(): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:distinct_values; 3, parameters; 3, 4; 3, 5; 4, identifier:t_old; 5, identifier:t_new; 6, block; 6, 7; 6, 11; 6, 19; 6, 118; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:res; 10, list:[]; 11, expression_statement; 11,...
def distinct_values(t_old, t_new): res = [] res.append([' -- NOT IN check -- ']) for new_col in t_new.header: dist_new = t_new.get_distinct_values_from_cols([new_col]) for old_col in t_old.header: if old_col == new_col: dist_old = t_old.get_distinct_values_from...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:most_similar_catchments; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 4, identifier:self; 5, identifier:subject_catchment; 6, identifier:similarity_dist_function; 7, default_parameter; 7, 8; 7, 9; 8, identifier:records_limit; 9, integer:500; ...
def most_similar_catchments(self, subject_catchment, similarity_dist_function, records_limit=500, include_subject_catchment='auto'): if include_subject_catchment not in ['auto', 'force', 'exclude']: raise ValueError("Parameter `include_subject_catchment={}` invalid."....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:readSAM; 3, parameters; 3, 4; 3, 5; 4, identifier:SAMfile; 5, default_parameter; 5, 6; 5, 7; 6, identifier:header; 7, False; 8, block; 8, 9; 8, 57; 8, 75; 8, 97; 8, 111; 8, 117; 8, 127; 8, 139; 8, 149; 8, 205; 8, 222; 9, if_statement; 9, 10; 9,...
def readSAM(SAMfile,header=False): if header==True: f=open(SAMfile,"r+") head=[] for line in f.readlines(): if line[0]=="@": head.append(line) else: continue f.close() sam=pd.read_table(SAMfile,sep="this_gives_one_column",co...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:SAMflags; 3, parameters; 3, 4; 4, identifier:x; 5, block; 5, 6; 5, 10; 5, 25; 5, 32; 5, 47; 5, 54; 5, 69; 5, 76; 5, 91; 5, 98; 5, 113; 5, 120; 5, 135; 5, 142; 5, 157; 5, 164; 5, 179; 5, 186; 5, 201; 5, 208; 5, 223; 5, 230; 5, 245; 5, 252; 5, 26...
def SAMflags(x): flags=[] if x & 1: l="1: Read paired" else: l="0: Read unpaired" flags.append(l) if x & 2 : l="1: Read mapped in proper pair" else: l="0: Read not mapped in proper pair" flags.append(l) if x & 4 : l="1: Read unmapped" else: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 74; 2, function_name:BLASTquery; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 11; 3, 14; 3, 17; 3, 18; 3, 21; 3, 24; 3, 25; 3, 28; 3, 31; 3, 32; 3, 35; 3, 38; 3, 39; 3, 42; 3, 43; 3, 46; 3, 49; 3, 50; 3, 53; 3, 56; 3, 57; 3, 60; 3, 63; 3, 64; 3, 67; 3, 70; 3, ...
def BLASTquery(query,database,program,filter=None,\ format_type=None, expect=None,\ nucl_reward=None, nucl_penalty=None,\ gapcosts=None, matrix=None,\ hitlist_size=None, descriptions=None,\ alignments=None,\ ncbi_gi=None, threshol...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:run_star; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:job; 5, identifier:fastqs; 6, identifier:univ_options; 7, identifier:star_options; 8, block; 8, 9; 8, 17; 8, 25; 8, 44; 8, 56; 8, 68; 8, 99; 8, 111; 8, 125; 8, 141; 8, 163; 8, 224; ...
def run_star(job, fastqs, univ_options, star_options): assert star_options['type'] in ('star', 'starlong') work_dir = os.getcwd() input_files = { 'rna_cutadapt_1.fastq': fastqs[0], 'rna_cutadapt_2.fastq': fastqs[1], 'star_index.tar.gz': star_options['index']} input_files = get_fi...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:sort_and_index_star; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:job; 5, identifier:star_bams; 6, identifier:univ_options; 7, identifier:star_options; 8, block; 8, 9; 8, 19; 8, 47; 8, 82; 8, 89; 8, 96; 9, expression_statement; 9, 10; 1...
def sort_and_index_star(job, star_bams, univ_options, star_options): star_options['samtools']['n'] = star_options['n'] sort = job.wrapJobFn(sort_bamfile, star_bams['rnaAligned.out.bam'], 'rna', univ_options, samtools_options=star_options['samtools'], disk=Promis...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:evaluate; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 14; 5, 67; 5, 84; 5, 88; 5, 191; 5, 204; 5, 212; 5, 229; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:ops; 9, list:[]; 10, expression_statem...
def evaluate(self): ops = [] rpn = [] for token in self.expr: if isinstance(token, int): while len(ops) and token <= ops[-1]: rpn.append(ops.pop()) ops.append(token) else: rpn.append(token) while ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:_ensure_patient_group_is_ok; 3, parameters; 3, 4; 3, 5; 4, identifier:patient_object; 5, default_parameter; 5, 6; 5, 7; 6, identifier:patient_name; 7, None; 8, block; 8, 9; 8, 16; 8, 29; 8, 36; 8, 70; 9, import_from_statement; 9, 10; 9, 14; 10,...
def _ensure_patient_group_is_ok(patient_object, patient_name=None): from protect.addons.common import TCGAToGTEx assert isinstance(patient_object, (set, dict)), '%s,%s' % (patient_object, patient_name) test_set = set(patient_object) if 'tumor_type' not in patient_object: raise ParameterError(('T...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_add_default_entries; 3, parameters; 3, 4; 3, 5; 4, identifier:input_dict; 5, identifier:defaults_dict; 6, block; 6, 7; 6, 93; 7, for_statement; 7, 8; 7, 11; 7, 16; 8, pattern_list; 8, 9; 8, 10; 9, identifier:key; 10, identifier:value; 11, call...
def _add_default_entries(input_dict, defaults_dict): for key, value in defaults_dict.iteritems(): if key == 'patients': print('Cannot default `patients`.') continue if isinstance(value, dict): if key not in input_dict or input_dict[key] is None: in...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:main; 3, parameters; 4, block; 4, 5; 4, 24; 4, 35; 4, 56; 4, 78; 4, 105; 4, 115; 4, 250; 5, expression_statement; 5, 6; 6, assignment; 6, 7; 6, 8; 7, identifier:parser; 8, call; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:argparse; ...
def main(): parser = argparse.ArgumentParser(prog='ProTECT', description='Prediction of T-Cell Epitopes for Cancer Therapy', epilog='Contact Arjun Rao (aarao@ucsc.edu) if you encounter ' 'any problems whil...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:align_dna; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:job; 5, identifier:fastqs; 6, identifier:sample_type; 7, identifier:univ_options; 8, identifier:bwa_options; 9, block; 9, 10; 9, 43; 9, 78; 9, 113; 9, 148; 9, 183; 9, 221; 9,...
def align_dna(job, fastqs, sample_type, univ_options, bwa_options): bwa = job.wrapJobFn(run_bwa, fastqs, sample_type, univ_options, bwa_options, disk=PromisedRequirement(bwa_disk, fastqs, bwa_options['index']), memory=univ_options['java_Xmx'], ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:create; 3, parameters; 3, 4; 3, 5; 4, identifier:cls; 5, identifier:entry; 6, block; 6, 7; 6, 73; 6, 80; 6, 104; 6, 119; 7, try_statement; 7, 8; 7, 16; 7, 40; 8, block; 8, 9; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, i...
def create(cls, entry): try: module = import_module(entry) except ImportError: module = None mod_path, _, cls_name = entry.rpartition('.') if not mod_path: raise else: try: entry = module.default_bot ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:populate; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:installed_bots; 7, None; 8, block; 8, 9; 8, 15; 9, if_statement; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, iden...
def populate(self, installed_bots=None): if self.ready: return with self._lock: if self.ready: return if self.loading: raise RuntimeError("populate() isn't re-entrant") self.loading = True for entry in installed_...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:get_initkwargs; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 17; 4, identifier:cls; 5, identifier:form_list; 6, default_parameter; 6, 7; 6, 8; 7, identifier:initial_dict; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:i...
def get_initkwargs(cls, form_list, initial_dict=None, instance_dict=None, condition_dict=None, *args, **kwargs): kwargs.update({ 'initial_dict': initial_dict or {}, 'instance_dict': instance_dict or {}, 'condition_dict': condition_dict or {}, }) init_f...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:post; 3, parameters; 3, 4; 3, 5; 3, 7; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:args; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 24; 9, 86; 9, 102; 9, 115; 9, 123; 9, 149; 9, 171; 9, 247; ...
def post(self, *args, **kwargs): wizard_prev_step = self.request.POST.get('wizard_prev_step', None) if wizard_prev_step and wizard_prev_step in self.get_form_list(): self.storage.current_step = wizard_prev_step form = self.get_form( data=self.storage.get_step_data...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:parse_config_file; 3, parameters; 3, 4; 3, 5; 4, identifier:job; 5, identifier:config_file; 6, block; 6, 7; 6, 16; 6, 27; 6, 45; 6, 51; 6, 57; 6, 63; 6, 229; 6, 244; 6, 260; 6, 280; 6, 300; 7, expression_statement; 7, 8; 8, call; 8, 9; 8, 14; 9...
def parse_config_file(job, config_file): job.fileStore.logToMaster('Parsing config file') config_file = os.path.abspath(config_file) if not os.path.exists(config_file): raise ParameterError('The config file was not found at specified location. Please verify ' + 'and retr...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:run_star; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:job; 5, identifier:fastqs; 6, identifier:univ_options; 7, identifier:star_options; 8, block; 8, 9; 8, 17; 8, 30; 8, 40; 8, 59; 8, 71; 8, 108; 8, 153; 8, 159; 8, 185; 8, 196; 8, 207;...
def run_star(job, fastqs, univ_options, star_options): assert star_options['type'] in ('star', 'starlong') job.fileStore.logToMaster('Running STAR on %s' %univ_options['patient']) work_dir = job.fileStore.getLocalTempDir() input_files = { 'rna_cutadapt_1.fastq': fastqs['rna_cutadapt_1.fastq'], ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:run_bwa; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:job; 5, identifier:fastqs; 6, identifier:sample_type; 7, identifier:univ_options; 8, identifier:bwa_options; 9, block; 9, 10; 9, 25; 9, 35; 9, 44; 9, 71; 9, 83; 9, 113; 9, 155;...
def run_bwa(job, fastqs, sample_type, univ_options, bwa_options): job.fileStore.logToMaster('Running bwa on %s:%s' % (univ_options['patient'], sample_type)) work_dir = job.fileStore.getLocalTempDir() fq_extn = '.gz' if fastqs['gzipped'] else '' input_files = { 'dna_1.fastq' + fq_extn: fastqs[sam...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:merge_radia; 3, parameters; 3, 4; 3, 5; 4, identifier:job; 5, identifier:perchrom_rvs; 6, block; 6, 7; 6, 16; 6, 26; 6, 49; 6, 61; 6, 87; 6, 233; 6, 270; 6, 276; 6, 306; 7, expression_statement; 7, 8; 8, call; 8, 9; 8, 14; 9, attribute; 9, 10; ...
def merge_radia(job, perchrom_rvs): job.fileStore.logToMaster('Running merge_radia') work_dir = job.fileStore.getLocalTempDir() input_files = {filename: jsid for perchrom_files in perchrom_rvs.values() for filename, jsid in perchrom_files.items()} input_files = get_files_from_filestor...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:merge_mutect; 3, parameters; 3, 4; 3, 5; 4, identifier:job; 5, identifier:perchrom_rvs; 6, block; 6, 7; 6, 16; 6, 26; 6, 49; 6, 61; 6, 87; 6, 328; 6, 341; 7, expression_statement; 7, 8; 8, call; 8, 9; 8, 14; 9, attribute; 9, 10; 9, 13; 10, attr...
def merge_mutect(job, perchrom_rvs): job.fileStore.logToMaster('Running merge_mutect') work_dir = job.fileStore.getLocalTempDir() input_files = {filename: jsid for perchrom_files in perchrom_rvs.values() for filename, jsid in perchrom_files.items()} input_files = get_files_from_filest...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:run_mutation_aggregator; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:job; 5, identifier:fusion_output; 6, identifier:radia_output; 7, identifier:mutect_output; 8, identifier:indel_output; 9, identifier:univ_options; 10, bl...
def run_mutation_aggregator(job, fusion_output, radia_output, mutect_output, indel_output, univ_options): job.fileStore.logToMaster('Aggregating mutations for %s' % univ_options['patient']) work_dir = job.fileStore.getLocalTempDir() input_files = { 'mutect.vcf': mutect_ou...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:merge_phlat_calls; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:job; 5, identifier:tumor_phlat; 6, identifier:normal_phlat; 7, identifier:rna_phlat; 8, block; 8, 9; 8, 18; 8, 28; 8, 41; 8, 50; 8, 131; 8, 285; 8, 291; 8, 318; 9, expressi...
def merge_phlat_calls(job, tumor_phlat, normal_phlat, rna_phlat): job.fileStore.logToMaster('Merging Phlat calls') work_dir = job.fileStore.getLocalTempDir() input_files = { 'tumor_dna': tumor_phlat, 'normal_dna': normal_phlat, 'tumor_rna': rna_phlat} input_files = get_files_from...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 2, function_name:docker_call; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 4, identifier:tool; 5, identifier:tool_parameters; 6, identifier:work_dir; 7, default_parameter; 7, 8; 7, 9; 8, identifier:java_opts; 9, None; 10, default_parameter; 10, ...
def docker_call(tool, tool_parameters, work_dir, java_opts=None, outfile=None, dockerhub='aarjunrao', interactive=False): if outfile: assert isinstance(outfile, file), 'outfile was not passsed a file' assert outfile.mode in ['w', 'a', 'wb', 'ab'], 'outfile not writeable' asse...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:get_file_from_gdc; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:job; 5, identifier:gdc_url; 6, identifier:gdc_download_token; 7, default_parameter; 7, 8; 7, 9; 8, identifier:write_to_jobstore; 9, True; 10, block; 10, 11; 10, 21; 10, 28...
def get_file_from_gdc(job, gdc_url, gdc_download_token, write_to_jobstore=True): work_dir = job.fileStore.getLocalTempDir() parsed_url = urlparse(gdc_url) assert parsed_url.scheme == 'gdc', 'Unexpected url scheme: %s' % gdc_url file_dir = '/'.join([work_dir, parsed_url.netloc]) currwd = os.getcwd() ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:make_key_hippie; 3, parameters; 3, 4; 3, 5; 4, identifier:obj; 5, default_parameter; 5, 6; 5, 7; 6, identifier:typed; 7, True; 8, block; 8, 9; 8, 19; 8, 32; 8, 46; 8, 67; 8, 102; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 1...
def make_key_hippie(obj, typed=True): ftype = type if typed else lambda o: None if is_hashable(obj): return obj, ftype(obj) if isinstance(obj, set): obj = sorted(obj) if isinstance(obj, (list, tuple)): return tuple(make_key_hippie(e, typed) for e in obj) if isinstance(obj, di...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:run_radia; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:job; 5, identifier:rna_bam; 6, identifier:tumor_bam; 7, identifier:normal_bam; 8, identifier:univ_options; 9, identifier:radia_options; 10, block; 10, 11; 10, 48; 10, ...
def run_radia(job, rna_bam, tumor_bam, normal_bam, univ_options, radia_options): if 'rna_genome' in rna_bam.keys(): rna_bam = rna_bam['rna_genome'] elif set(rna_bam.keys()) == {'rna_genome_sorted.bam', 'rna_genome_sorted.bam.bai'}: pass else: raise RuntimeError('An improperly formatt...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:sort_bamfile; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:job; 5, identifier:bamfile; 6, identifier:sample_type; 7, identifier:univ_options; 8, identifier:samtools_options; 9, block; 9, 10; 9, 18; 9, 29; 9, 40; 9, 47; 9, 59; 9, 8...
def sort_bamfile(job, bamfile, sample_type, univ_options, samtools_options): work_dir = os.getcwd() in_bamfile = ''.join([sample_type, '.bam']) out_bamfile = '_'.join([sample_type, 'sorted.bam']) input_files = { in_bamfile: bamfile} input_files = get_files_from_filestore(job, input_files, wo...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:recursive_sort; 3, parameters; 3, 4; 4, identifier:data_structure; 5, block; 5, 6; 5, 175; 6, if_statement; 6, 7; 6, 13; 7, not_operator; 7, 8; 8, call; 8, 9; 8, 10; 9, identifier:isinstance; 10, argument_list; 10, 11; 10, 12; 11, identifier:da...
def recursive_sort(data_structure): if not isinstance(data_structure, _primitive_types): is_meta = isinstance(data_structure, Meta) was_dict = isinstance(data_structure, WasDict) if not (is_meta or was_dict): was_dict = isinstance(data_structure, dict) if not was_dict...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:tree_diff; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:a; 5, identifier:b; 6, default_parameter; 6, 7; 6, 8; 7, identifier:n; 8, integer:5; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sort; 11, False; 12, block; 12, 13; 12, 20;...
def tree_diff(a, b, n=5, sort=False): a = dump(a) b = dump(b) if not sort: a = vformat(a).split("\n") b = vformat(b).split("\n") else: a = vformat(recursive_sort(a)).split("\n") b = vformat(recursive_sort(b)).split("\n") return "\n".join(difflib.unified_diff(a, b, n=n...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:merge_perchrom_mutations; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:job; 5, identifier:chrom; 6, identifier:mutations; 7, identifier:univ_options; 8, block; 8, 9; 8, 17; 8, 24; 8, 31; 8, 38; 8, 45; 8, 52; 8, 59; 8, 69; 8, 79; 8, 107;...
def merge_perchrom_mutations(job, chrom, mutations, univ_options): work_dir = os.getcwd() from protect.mutation_calling.muse import process_muse_vcf from protect.mutation_calling.mutect import process_mutect_vcf from protect.mutation_calling.radia import process_radia_vcf from protect.mutation_calli...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:check; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:domain; 5, identifier:prefix; 6, identifier:code; 7, default_parameter; 7, 8; 7, 9; 8, identifier:strategies; 9, string:'*'; 10, block; 10, 11; 10, 30; 10, 49; 10, 68; 10, 87; 11, if_...
def check(domain, prefix, code, strategies='*'): if strategies == '*' or 'dns_txt' in strategies: if check_dns_txt(domain, prefix, code): return True if strategies == '*' or 'dns_cname' in strategies: if check_dns_cname(domain, prefix, code): return True if strategies...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:register_cache_buster; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:app; 6, default_parameter; 6, 7; 6, 8; 7, identifier:config; 8, None; 9, block; 9, 10; 9, 28; 9, 32; 9, 36; 9, 45; 9, 159; 9, 168; 9, 181; 9, 194; 9, 221;...
def register_cache_buster(self, app, config=None): if not (config is None or isinstance(config, dict)): raise ValueError("`config` must be an instance of dict or None") bust_map = {} unbust_map = {} app.logger.debug('Starting computing hashes for static assets') for d...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:parse_inventory; 3, parameters; 3, 4; 4, default_parameter; 4, 5; 4, 6; 5, identifier:inventory_output; 6, None; 7, block; 7, 8; 7, 27; 7, 34; 7, 38; 7, 42; 7, 100; 7, 113; 7, 132; 7, 145; 7, 164; 7, 177; 7, 191; 7, 204; 7, 218; 7, 231; 7, 249;...
def parse_inventory(inventory_output=None): udi = { "name": "", "description": "", "pid": "", "vid": "", "sn": "" } if inventory_output is None: return udi capture_next = False chassis_udi_text = None for line in inventory_output.split('\n'): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:yaml_file_to_dict; 3, parameters; 3, 4; 3, 5; 4, identifier:script_name; 5, default_parameter; 5, 6; 5, 7; 6, identifier:path; 7, None; 8, block; 8, 9; 8, 46; 8, 102; 8, 118; 8, 132; 8, 153; 8, 160; 8, 189; 8, 212; 8, 240; 9, function_definitio...
def yaml_file_to_dict(script_name, path=None): def load_yaml(file_path): with open(file_path, 'r') as yamlfile: try: dictionary = yaml.load(yamlfile) except yaml.YAMLError: return {} return dictionary def merge(user, default): if is...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:make_hop_info_from_url; 3, parameters; 3, 4; 3, 5; 4, identifier:url; 5, default_parameter; 5, 6; 5, 7; 6, identifier:verify_reachability; 7, None; 8, block; 8, 9; 8, 16; 8, 32; 8, 48; 8, 70; 8, 91; 8, 100; 9, expression_statement; 9, 10; 10, a...
def make_hop_info_from_url(url, verify_reachability=None): parsed = urlparse(url) username = None if parsed.username is None else unquote(parsed.username) password = None if parsed.password is None else unquote(parsed.password) try: enable_password = parse_qs(parsed.query)["enable_password"][0] ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:sendmail; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 11; 4, identifier:self; 5, identifier:sender; 6, identifier:recipients; 7, identifier:message; 8, default_parameter; 8, 9; 8, 10; 9, identifier:mail_options; 10, None; 11, default_param...
async def sendmail( self, sender, recipients, message, mail_options=None, rcpt_options=None ): if isinstance(recipients, str): recipients = [recipients] if mail_options is None: mail_options = [] if rcpt_options is None: rcpt_options = [] a...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:run_fsm; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, identifier:self; 5, identifier:name; 6, identifier:command; 7, identifier:events; 8, identifier:transitions; 9, identifier:timeout; 10, default_parameter; 10, 11; 10, 12; 11...
def run_fsm(self, name, command, events, transitions, timeout, max_transitions=20): return self._chain.target_device.run_fsm(name, command, events, transitions, timeout, max_transitions)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_get_view_details; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:urlpatterns; 6, default_parameter; 6, 7; 6, 8; 7, identifier:parent; 8, string:''; 9, block; 9, 10; 10, for_statement; 10, 11; 10, 12; 10, 13; 11, identifier:...
def _get_view_details(self, urlpatterns, parent=''): for pattern in urlpatterns: if isinstance(pattern, (URLPattern, RegexURLPattern)): try: d = describe_pattern(pattern) docstr = pattern.callback.__doc__ method = None ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:scan_module; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:modpath; 6, identifier:node; 7, block; 7, 8; 7, 22; 7, 89; 7, 184; 7, 230; 7, 261; 7, 267; 7, 273; 7, 313; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 1...
def scan_module(self, modpath, node): used_origins = self.map.setdefault(modpath, set()) def get_origins(modpath, name): origins = set() def walk_origins(modpath, name): for origin in self.import_map.get_origins(modpath, name): if origin not in...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:operations; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:op_types; 7, None; 8, block; 8, 9; 8, 22; 9, if_statement; 9, 10; 9, 12; 10, not_operator; 10, 11; 11, identifier:op_types; 12, block; 12...
def operations(self, op_types=None): if not op_types: op_types = ['message', 'action', 'sync', 'viewlock', 'savedchapter'] while self._handle.tell() < self._eof: current_time = mgz.util.convert_to_timestamp(self._time / 1000) try: operation = mgz.body....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:run; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 20; 5, 24; 5, 30; 5, 44; 5, 402; 5, 409; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:ctx; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, ide...
def run(self): ctx = FSM.Context(self.name, self.device) transition_counter = 0 timeout = self.timeout self.log("{} Start".format(self.name)) while transition_counter < self.max_transitions: transition_counter += 1 try: start_time = time() ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:build; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:port; 6, integer:8000; 7, default_parameter; 7, 8; 7, 9; 8, identifier:fixtures; 9, None; 10, block; 10, 11; 10, 17; 10, 27; 10, 33; 10, 39; 10, 46; 10, 55; 10, ...
def build(port=8000, fixtures=None): extractor = Extractor() parser = Parser(extractor.url_details, fixtures) parser.parse() url_details = parser.results _store = get_store(url_details) store = json.dumps(_store) variables = str(Variable('let', 'store', store)) functions = DATA_FINDER + ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:gpg_decrypt; 3, parameters; 3, 4; 3, 5; 4, identifier:cfg; 5, default_parameter; 5, 6; 5, 7; 6, identifier:gpg_config; 7, None; 8, block; 8, 9; 8, 217; 8, 304; 9, function_definition; 9, 10; 9, 11; 9, 13; 10, function_name:decrypt; 11, paramete...
def gpg_decrypt(cfg, gpg_config=None): def decrypt(obj): if isinstance(obj, list): res_v = [] for item in obj: res_v.append(decrypt(item)) return res_v elif isinstance(obj, dict): if '_gpg' in obj: try: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_teams; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 19; 5, 23; 5, 192; 5, 200; 6, if_statement; 6, 7; 6, 12; 7, subscript; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:_cache; 11, string:'teams';...
def get_teams(self): if self._cache['teams']: return self._cache['teams'] teams = [] for j, player in enumerate(self._header.initial.players): added = False for i in range(0, len(self._header.initial.players)): if player.attributes.my_diplomacy...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_settings; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:postgame; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, ident...
def get_settings(self): postgame = self.get_postgame() return { 'type': ( self._header.lobby.game_type_id, self._header.lobby.game_type ), 'difficulty': ( self._header.scenario.game_settings.difficulty_id, ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_map; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 19; 5, 31; 5, 43; 5, 62; 5, 72; 5, 76; 5, 80; 5, 84; 5, 88; 5, 166; 5, 205; 5, 213; 5, 221; 5, 254; 5, 264; 5, 268; 5, 283; 5, 292; 5, 296; 5, 320; 5, 344; 5, 389; 6, if_state...
def get_map(self): if self._cache['map']: return self._cache['map'] map_id = self._header.scenario.game_settings.map_id instructions = self._header.scenario.messages.instructions size = mgz.const.MAP_SIZES.get(self._header.map_info.size_x) dimension = self._header.map...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:update; 3, parameters; 3, 4; 3, 5; 3, 7; 3, 12; 4, identifier:self; 5, list_splat_pattern; 5, 6; 6, identifier:sources; 7, typed_default_parameter; 7, 8; 7, 9; 7, 11; 8, identifier:follow_symlinks; 9, type; 9, 10; 10, identifier:bool; 11, Fals...
def update(self, *sources, follow_symlinks: bool=False, maximum_depth: int=20): for source in sources: if isinstance(source, self.klass): self.path_map[source.this.name.value] = source self.class_cache[source.this.name.value] = source co...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:error_view; 3, parameters; 3, 4; 4, default_parameter; 4, 5; 4, 6; 5, identifier:template_dir; 6, None; 7, block; 7, 8; 7, 16; 7, 22; 7, 212; 8, if_statement; 8, 9; 8, 11; 9, not_operator; 9, 10; 10, identifier:template_dir; 11, block; 11, 12; ...
def error_view(template_dir=None): if not template_dir: template_dir = "Pylot/Error" template_page = "%s/index.html" % template_dir class Error(Pylot): @classmethod def register(cls, app, **kwargs): super(cls, cls).register(app, **kwargs) @app.errorhandler(400...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:update_device_list; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:sessions; 6, block; 6, 7; 6, 20; 6, 24; 6, 28; 6, 32; 6, 217; 6, 262; 7, if_statement; 7, 8; 7, 11; 8, comparison_operator:is; 8, 9; 8, 10; 9, identifier:sessions;...
def update_device_list(self, sessions): if sessions is None: _LOGGER.error('Error updating Emby devices.') return new_devices = [] active_devices = [] dev_update = False for device in sessions: dev_name = '{}.{}'.format(device['DeviceId'], devi...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:main; 3, parameters; 4, block; 4, 5; 4, 11; 4, 19; 4, 25; 4, 33; 4, 43; 4, 53; 4, 140; 4, 181; 4, 194; 4, 200; 4, 296; 4, 327; 4, 338; 4, 353; 5, expression_statement; 5, 6; 6, assignment; 6, 7; 6, 8; 7, identifier:parser; 8, call; 8, 9; 8, 10;...
def main(): parser = get_parser() args = parser.parse_args() ARCHIVE = args.archive_path archive = (not args.no_archive) os.environ['F2FORMAT_VERSION'] = args.python os.environ['F2FORMAT_ENCODING'] = args.encoding def find(root): flst = list() temp = os.listdir(root) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:random_useragent; 3, parameters; 3, 4; 4, default_parameter; 4, 5; 4, 6; 5, identifier:filename; 6, True; 7, block; 7, 8; 7, 11; 7, 17; 7, 35; 7, 47; 7, 90; 7, 205; 8, import_statement; 8, 9; 9, dotted_name; 9, 10; 10, identifier:random; 11, ex...
def random_useragent(filename=True): import random default_ua = 'urlfetch/%s' % __version__ if isinstance(filename, basestring): filenames = [filename] else: filenames = [] if filename and UAFILE: filenames.append(UAFILE) for filename in filenames: try: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:encode_multipart; 3, parameters; 3, 4; 3, 5; 4, identifier:data; 5, identifier:files; 6, block; 6, 7; 6, 13; 6, 19; 6, 28; 6, 39; 6, 153; 6, 329; 6, 343; 6, 349; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:body; 10,...
def encode_multipart(data, files): body = BytesIO() boundary = choose_boundary() part_boundary = b('--%s\r\n' % boundary) writer = codecs.lookup('utf-8')[3] if isinstance(data, dict): for name, values in data.items(): if not isinstance(values, (list, tuple, set)): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:assemble; 3, parameters; 3, 4; 4, identifier:code; 5, block; 5, 6; 5, 10; 5, 158; 5, 162; 5, 166; 5, 195; 5, 199; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:final; 9, list:[]; 10, for_statement; 10, 11; 10, 12; 10, ...
def assemble(code): final = [] for line in code: if isinstance(line, Label): final.append(line) continue mnemonic, operands = line[0], line[1:] operand_fmts = opcode_table[mnemonic]['operands'] final_operands = [] for i, operand in enumerate(operan...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_add_new; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:host_object; 6, block; 6, 7; 6, 16; 6, 43; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:i; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 1...
def _add_new(self, host_object): i = self._get_insertion_point(host_object) for listed in self[i:]: if not listed.is_subdomain(host_object): break self.hosts.pop(i) self.hosts.insert(i, host_object.to_unicode())
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:write_instruction; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:fout; 5, identifier:start_pos; 6, identifier:ins; 7, block; 7, 8; 7, 20; 7, 28; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 13; 10, pattern_list; 10, 11; 10, 12; 11, ...
def write_instruction(fout, start_pos, ins): opcode, operands = ins.opcode, ins.operands fmt_operands = opcode_table[opcode]['operands'] if ins.wide: fout.write(pack('>B', 0xC4)) fout.write(pack('>B', opcode)) fout.write(pack('>H', operands[0].value)) if opcode == 0x84: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:read_instruction; 3, parameters; 3, 4; 3, 5; 4, identifier:fio; 5, identifier:start_pos; 6, block; 6, 7; 6, 16; 6, 22; 6, 29; 6, 35; 6, 41; 6, 47; 6, 51; 6, 401; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:op; 10, c...
def read_instruction(fio, start_pos): op = fio.read(1) if not op: return None op = ord(op) ins = opcode_table[op] operands = ins['operands'] name = ins['mnemonic'] final_operands = [] if operands: for fmt, type_ in operands: final_operands.append( ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:sort_by_type; 3, parameters; 3, 4; 4, identifier:file_list; 5, block; 5, 6; 5, 13; 5, 45; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:ret_dict; 9, call; 9, 10; 9, 11; 10, identifier:defaultdict; 11, argument_list; 11...
def sort_by_type(file_list): ret_dict = defaultdict(list) for filepath in file_list: _, ext = os.path.splitext(filepath) ret_dict[ext.replace('.', '')].append(filepath) return ret_dict
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_check_triple; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:triple; 6, block; 6, 7; 6, 14; 6, 40; 6, 44; 6, 53; 6, 62; 6, 83; 6, 95; 6, 114; 6, 146; 6, 155; 6, 169; 6, 181; 6, 188; 6, 199; 6, 211; 6, 223; 6, 235; 6, 246; 6, 253;...
def _check_triple(self, triple): subj, pred, obj = triple if self._should_ignore_predicate(pred): log.info("Ignoring triple with predicate '{}'" .format(self._field_name_from_uri(pred))) return classes = [] log.warning("Possible member %s foun...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:parse_ontology; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 27; 5, 159; 5, 172; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:start; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, iden...
def parse_ontology(self): start = time.clock() log.info("Parsing ontology file for %s" % self.__class__.__name__) for subj, pred, obj in self._schema_nodes(): if subj not in self.attributes_by_class: if obj == rt.URIRef(self.lexicon['class']) and \ ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:new_frame_event; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 25; 5, 29; 5, 106; 5, 195; 6, for_statement; 6, 7; 6, 8; 6, 15; 7, identifier:out_pool; 8, call; 8, 9; 8, 14; 9, attribute; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12...
def new_frame_event(self): for out_pool in self.outframe_pool.values(): if not out_pool.available(): return frame_nos = {} for in_buff in self.input_buffer.values(): if not in_buff.available(): return in_frame = in_buff.peek() ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:GaussianFilterCore; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:x_sigma; 6, float:0.0; 7, default_parameter; 7, 8; 7, 9; 8, identifier:y_sigma; 9, float:0.0; 10, block; 10, 11; 10, 137; 10, 145; 10, 153; 10, 160;...
def GaussianFilterCore(x_sigma=0.0, y_sigma=0.0): def filter_1D(sigma): alpha = 1.0 / (2.0 * (max(sigma, 0.0001) ** 2.0)) coefs = [] coef = 1.0 while coef > 0.0001: coefs.append(coef) coef = math.exp(-(alpha * (float(len(coefs) ** 2)))) fil_dim = len(c...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:either; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, if_statement; 6, 7; 6, 13; 6, 22; 7, not_operator; 7, 8; 8, call; 8, 9; 8, 10; 9, identifier:hasattr; 10, argument_list; 10, 11; 10, 12; 11, identifier:self; 12, string:'childr...
def either(self): if not hasattr(self, 'children'): return Either(Required(self)) else: ret = [] groups = [[self]] while groups: children = groups.pop(0) types = [type(c) for c in children] if Either in types...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:TranslateManagedObject; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:mObj; 5, identifier:xlateOrg; 6, identifier:xlateMap; 7, block; 7, 8; 7, 15; 7, 20; 7, 28; 7, 39; 7, 198; 7, 352; 8, import_from_statement; 8, 9; 8, 11; 8, 13; 9, dotted_nam...
def TranslateManagedObject(mObj, xlateOrg, xlateMap): from UcsBase import UcsUtils, WriteUcsWarning from Mos import OrgOrg xMO = mObj.Clone() xMO.SetHandle(mObj.GetHandle()) if (xlateOrg != None): matchObj = re.match(r'^(org-[\-\.:_a-zA-Z0-9]{1,16}/)*org-[\-\.:_a-zA-Z0-9]{1,16}', xMO.Dn) if matchObj: if Ucs...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:ImportUcsSession; 3, parameters; 3, 4; 3, 5; 4, identifier:filePath; 5, identifier:key; 6, block; 6, 7; 6, 16; 6, 26; 6, 36; 6, 65; 6, 78; 6, 84; 6, 99; 7, import_from_statement; 7, 8; 7, 10; 7, 12; 7, 14; 8, dotted_name; 8, 9; 9, identifier:Uc...
def ImportUcsSession(filePath, key): from UcsBase import UcsUtils, WriteUcsWarning, UcsValidationException if filePath is None: raise UcsValidationException("filePath parameter is not provided.") if key is None: raise UcsValidationException("key parameter is not provided.") if not os.path.isfile(filePath) or no...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:ImportUcsBackup; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:path; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:merge; 10, False; 11, default_parameter; 11, 12; 11, 1...
def ImportUcsBackup(self, path=None, merge=False, dumpXml=False): from UcsBase import WriteUcsWarning, UcsUtils, ManagedObject, WriteObject, UcsUtils, UcsException, \ UcsValidationException from Ucs import ConfigConfig from Mos import MgmtImporter from datetime import datetime if (self._transactionInProgre...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_set_suffix_links; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 8; 5, 14; 6, expression_statement; 6, 7; 7, string:''' Sets all suffix links in all nodes in this trie. '''; 8, expression_statement; 8, 9; 9, assign...
def _set_suffix_links(self): ''' Sets all suffix links in all nodes in this trie. ''' self._suffix_links_set = True for current, parent in self.bfs(): if parent is None: continue current.longest_prefix = parent.longest_prefix if...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_write_mo; 3, parameters; 3, 4; 4, identifier:mo; 5, block; 5, 6; 5, 10; 5, 27; 5, 31; 5, 35; 5, 73; 5, 84; 5, 216; 5, 270; 5, 297; 5, 301; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:classNotFound; 9, False; 10, if_...
def _write_mo(mo): classNotFound = False if (UcsUtils.FindClassIdInMoMetaIgnoreCase(mo.classId) == None): classNotFound = True tabsize = 8 outstr = "\n" if classNotFound: outstr += "Managed Object\t\t\t:\t" + str(UcsUtils.WordU(mo.classId)) + "\n" else: outstr += "Managed Object\t\t\t:\t" + str(mo.propMoMet...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:LoadFromXml; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:node; 6, identifier:handle; 7, block; 7, 8; 7, 15; 7, 183; 8, expression_statement; 8, 9; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self;...
def LoadFromXml(self, node, handle): self.SetHandle(handle) if node.hasAttributes(): attributes = node.attributes attCount = len(attributes) for i in range(attCount): attNode = attributes.item(i) attr = UcsUtils.WordU(attNode.localName) if (UcsUtils.FindClassIdInMoMetaIgnoreCase(self.classId) !...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:GetJavaInstallationPath; 3, parameters; 4, block; 4, 5; 4, 10; 5, import_statement; 5, 6; 5, 8; 6, dotted_name; 6, 7; 7, identifier:os; 8, dotted_name; 8, 9; 9, identifier:platform; 10, if_statement; 10, 11; 10, 18; 10, 85; 11, comparison_opera...
def GetJavaInstallationPath(): import os, platform if platform.system() == "Linux": path = os.environ.get('JAVA_HOME') if not path: raise UcsValidationException( "Please make sure JAVA is installed and variable JAVA_HOME is set properly.") else: path = os.path.join(path, 'bin') path = os.p...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:GetSyncMoConfig; 3, parameters; 3, 4; 4, identifier:ConfigDoc; 5, block; 5, 6; 5, 10; 5, 19; 5, 245; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:moConfigMap; 9, dictionary; 10, expression_statement; 10, 11; 11, assig...
def GetSyncMoConfig(ConfigDoc): moConfigMap = {} configList = ConfigDoc.getElementsByTagName("mo") for moConfigNode in configList: classId = None noun = None version = None actionVersion = None action = None ignoreReason = None status = None excludeList = None if moConfigNode.hasAttribu...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 27; 2, function_name:duration; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:t; 5, default_parameter; 5, 6; 5, 7; 6, identifier:now; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:precision; 10, integer:1; 11, default_parameter; 11...
def duration(t, now=None, precision=1, pad=', ', words=None, justnow=datetime.timedelta(seconds=10)): ''' Time delta compared to ``t``. You can override ``now`` to specify what time to compare to. :param t: timestamp, :class:`datetime.date` or :class:`datetime.datetime` object...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:search; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:query_string; 6, block; 6, 7; 6, 15; 6, 23; 6, 29; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:query; 10, call; 10, 11; 10, 14; 11, attribute; 11,...
def search(self, query_string): query = self.create_query() parser = QueryParser(query_string, query) parser.parse() return self.query(query)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:wrap_error; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:data; 6, identifier:renderer_context; 7, identifier:keys_are_fields; 8, identifier:issue_is_title; 9, block; 9, 10; 9, 20; 9, 31; 9, 35; 9, 127; 9, 135; ...
def wrap_error( self, data, renderer_context, keys_are_fields, issue_is_title): response = renderer_context.get("response", None) status_code = str(response and response.status_code) errors = [] for field, issues in data.items(): if isinstance(issues, six.string_t...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:lunr; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:ref; 5, identifier:fields; 6, identifier:documents; 7, default_parameter; 7, 8; 7, 9; 8, identifier:languages; 9, None; 10, block; 10, 11; 10, 115; 10, 122; 10, 150; 10, 186; 11, if_st...
def lunr(ref, fields, documents, languages=None): if languages is not None and lang.LANGUAGE_SUPPORT: if isinstance(languages, basestring): languages = [languages] unsupported_languages = set(languages) - set(lang.SUPPORTED_LANGUAGES) if unsupported_languages: raise R...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:build_trie; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:pattern_filename; 5, identifier:pattern_format; 6, identifier:encoding; 7, identifier:on_word_boundaries; 8, block; 8, 9; 8, 11; 8, 15; 8, 34; 8, 52; 8, 62; 8, 66; 8, 357; 8, 370;...
def build_trie(pattern_filename, pattern_format, encoding, on_word_boundaries): ''' Constructs a finite state machine for performing string rewriting. Arguments: - `pattern_filename`: - `pattern_format`: - `encoding`: - `on_word_boundaries`: ''' boundaries = on_word_boundaries if...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:make_parser; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:add_help; 6, True; 7, default_parameter; 7, 8; 7, 9; 8, identifier:exclude_args; 9, None; 10, block; 10, 11; 10, 20; 10, 31; 10, 40; 10, 58; 10, 83; 10, 10...
def make_parser(add_help=True, exclude_args=None): if exclude_args is None: exclude_args = [] parser = argparse.ArgumentParser(add_help=add_help) parser.description = ("Filter, transform and export a list of JSON " "objects on stdin to JSON or CSV on stdout") if "--colu...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:parse; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:parser; 6, None; 7, default_parameter; 7, 8; 7, 9; 8, identifier:args; 9, None; 10, block; 10, 11; 10, 21; 10, 45; 10, 70; 10, 115; 10, 165; 11, if_statement; 11...
def parse(parser=None, args=None): if not parser: parser = make_parser() try: parsed_args = parser.parse_args(args) except SystemExit as err: raise CommandLineExit(err.code) try: columns = parsed_args.columns except AttributeError: columns = collections.Ordere...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:read_value; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:ftype; 5, identifier:prompt; 6, default_parameter; 6, 7; 6, 8; 7, identifier:default; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:minval; 11,...
def read_value(ftype, prompt, default=None, minval=None, maxval=None, allowed_single_chars=None, question_mark=True): result = None if question_mark: cquestion_mark = ' ? ' else: cquestion_mark = '' if minval is not None: try: iminval = ftype(minval) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:select_configuration; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:obresult; 6, block; 6, 7; 6, 16; 6, 23; 6, 31; 6, 41; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:logger; 10, call; 10, 11; 10, 14; ...
def select_configuration(self, obresult): logger = logging.getLogger(__name__) logger.debug('calling default configuration selector') ref = obresult.get_sample_frame() extr = self.datamodel.extractor_map['fits'] if ref: result = extr.extract('insconf', ref) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:pause_debugplot; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:debugplot; 5, default_parameter; 5, 6; 5, 7; 6, identifier:optional_prompt; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:pltshow; 10, False; 11, default_parame...
def pause_debugplot(debugplot, optional_prompt=None, pltshow=False, tight_layout=True): if debugplot not in DEBUGPLOT_CODES: raise ValueError('Invalid debugplot value:', debugplot) if debugplot < 0: debugplot_ = -debugplot pltclose = True else: debugplot_ ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:mode_half_sample; 3, parameters; 3, 4; 3, 5; 4, identifier:a; 5, default_parameter; 5, 6; 5, 7; 6, identifier:is_sorted; 7, False; 8, block; 8, 9; 8, 11; 8, 20; 8, 39; 8, 46; 9, expression_statement; 9, 10; 10, string:''' Estimate the mode ...
def mode_half_sample(a, is_sorted=False): ''' Estimate the mode using the Half Sample mode. A method to estimate the mode, as described in D. R. Bickel and R. Frühwirth (contributed equally), "On a fast, robust estimator of the mode: Comparisons to other robust estimators with applications," ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:author_id_normalize_and_schema; 3, parameters; 3, 4; 3, 5; 4, identifier:uid; 5, default_parameter; 5, 6; 5, 7; 6, identifier:schema; 7, None; 8, block; 8, 9; 8, 47; 8, 70; 8, 82; 8, 108; 8, 116; 8, 147; 8, 154; 9, function_definition; 9, 10; 9...
def author_id_normalize_and_schema(uid, schema=None): def _get_uid_normalized_in_schema(_uid, _schema): regex, template = _RE_AUTHORS_UID[_schema] match = regex.match(_uid) if match: return template.format(match.group('uid')) if idutils.is_orcid(uid) and schema in (None, 'ORC...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_schema_path; 3, parameters; 3, 4; 3, 5; 4, identifier:schema; 5, default_parameter; 5, 6; 5, 7; 6, identifier:resolved; 7, False; 8, block; 8, 9; 8, 39; 8, 101; 8, 108; 8, 180; 9, function_definition; 9, 10; 9, 11; 9, 13; 10, function_name:...
def get_schema_path(schema, resolved=False): def _strip_first_path_elem(path): stripped_path = path.split(os.path.sep, 1)[1:] return ''.join(stripped_path) def _schema_to_normalized_path(schema): path = os.path.normpath(os.path.sep + urlsplit(schema).path) if path.startswith(os.p...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_license_from_url; 3, parameters; 3, 4; 4, identifier:url; 5, block; 5, 6; 5, 11; 5, 21; 5, 167; 6, if_statement; 6, 7; 6, 9; 7, not_operator; 7, 8; 8, identifier:url; 9, block; 9, 10; 10, return_statement; 11, expression_statement; 11, 12; ...
def get_license_from_url(url): if not url: return split_url = urlsplit(url, scheme='http') if split_url.netloc.lower() == 'creativecommons.org': if 'publicdomain' in split_url.path: match = _RE_PUBLIC_DOMAIN_URL.match(split_url.path) if match is None: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:convert_old_publication_info_to_new; 3, parameters; 3, 4; 4, identifier:publication_infos; 5, block; 5, 6; 5, 10; 5, 14; 5, 280; 5, 302; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:result; 9, list:[]; 10, expression_...
def convert_old_publication_info_to_new(publication_infos): result = [] hidden_publication_infos = [] for publication_info in publication_infos: _publication_info = copy.deepcopy(publication_info) journal_title = _publication_info.get('journal_title') try: journal_title =...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:construct_reference_system; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:symbols; 5, default_parameter; 5, 6; 5, 7; 6, identifier:candidates; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:options; 10, None; 11, block; 11, 12; 11,...
def construct_reference_system( symbols, candidates=None, options=None, ): if hasattr(options, 'no_hydrogen') and options.no_hydrogen: add_hydrogen = False else: add_hydrogen = True references = {} sorted_candidates = [ 'H2', 'H2O', 'NH3', 'N2'...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:gen_triplets_master; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:wv_master; 5, default_parameter; 5, 6; 5, 7; 6, identifier:geometry; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:debugplot; 10, integer:0; 11, block; 11, 12; 11,...
def gen_triplets_master(wv_master, geometry=None, debugplot=0): nlines_master = wv_master.size wv_previous = wv_master[0] for i in range(1, nlines_master): if wv_previous >= wv_master[i]: raise ValueError('Wavelengths:\n--> ' + str(wv_previous) + '\n--> ' + s...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:match_wv_arrays; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:wv_master; 5, identifier:wv_expected_all_peaks; 6, identifier:delta_wv_max; 7, block; 7, 8; 7, 17; 7, 29; 7, 41; 7, 47; 7, 343; 8, expression_statement; 8, 9; 9, assignment; 9, 10;...
def match_wv_arrays(wv_master, wv_expected_all_peaks, delta_wv_max): wv_verified_all_peaks = np.zeros_like(wv_expected_all_peaks) wv_unused = np.ones_like(wv_expected_all_peaks, dtype=bool) minimum_delta_wv = np.ones_like(wv_expected_all_peaks, dtype=float) minimum_delta_wv *= np.infty for i in rang...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 41; 2, function_name:add_publication_info; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 3, 35; 3, 38; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:year; 7, None; 8, default_parameter; 8, 9; 8, 10; ...
def add_publication_info( self, year=None, cnum=None, artid=None, page_end=None, page_start=None, journal_issue=None, journal_title=None, journal_volume=None, pubinfo_freetext=None, material=None, parent_record=None, ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:compute_operation; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 4, identifier:file1; 5, identifier:file2; 6, identifier:operation; 7, identifier:output; 8, identifier:display; 9, identifier:args_z1z2; 10, identifier:...
def compute_operation(file1, file2, operation, output, display, args_z1z2, args_bbox, args_keystitle, args_geometry): with fits.open(file1) as hdulist: image_header1 = hdulist[0].header image1 = hdulist[0].data.astype(np.float) naxis1 = image_header1['naxis1'] naxis2 = ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:summary; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:x; 5, default_parameter; 5, 6; 5, 7; 6, identifier:rm_nan; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:debug; 10, False; 11, block; 11, 12; 11, 64; 11, 85; 11, 104; 11, 111...
def summary(x, rm_nan=False, debug=False): if type(x) is np.ndarray: xx = np.copy(x) else: if type(x) is list: xx = np.array(x) else: raise ValueError('x=' + str(x) + ' must be a numpy.ndarray') if xx.ndim is not 1: raise ValueError('xx.dim=' + str(xx....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:find_peaks_spectrum; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:sx; 5, identifier:nwinwidth; 6, default_parameter; 6, 7; 6, 8; 7, identifier:threshold; 8, integer:0; 9, default_parameter; 9, 10; 9, 11; 10, identifier:debugplot; 11, i...
def find_peaks_spectrum(sx, nwinwidth, threshold=0, debugplot=0): if type(sx) is not np.ndarray: raise ValueError("sx=" + str(sx) + " must be a numpy.ndarray") elif sx.ndim is not 1: raise ValueError("sx.ndim=" + str(sx.ndim) + " must be 1") sx_shape = sx.shape nmed = nwinwidth//2 if...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:shortlex; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:start; 5, identifier:other; 6, default_parameter; 6, 7; 6, 8; 7, identifier:excludestart; 8, False; 9, block; 9, 10; 9, 17; 9, 29; 10, if_statement; 10, 11; 10, 13; 11, not_operator; 11, ...
def shortlex(start, other, excludestart=False): if not excludestart: yield start queue = collections.deque([(start, other)]) while queue: current, other = queue.popleft() while other: first, other = other[0], other[1:] result = current | first yiel...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:reverse_shortlex; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:end; 5, identifier:other; 6, default_parameter; 6, 7; 6, 8; 7, identifier:excludeend; 8, False; 9, block; 9, 10; 9, 17; 9, 29; 10, if_statement; 10, 11; 10, 13; 11, not_operator; ...
def reverse_shortlex(end, other, excludeend=False): if not excludeend: yield end queue = collections.deque([(end, other)]) while queue: current, other = queue.popleft() while other: first, other = other[0], other[1:] result = current & first yield ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:gnuplot; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:script_name; 5, default_parameter; 5, 6; 5, 7; 6, identifier:args_dict; 7, dictionary; 8, default_parameter; 8, 9; 8, 10; 9, identifier:data; 10, list:[]; 11, default_parameter; 11...
def gnuplot(script_name, args_dict={}, data=[], silent=True): ''' Call a Gnuplot script, passing it arguments and datasets. Args: scipt_name(str): The name of the Gnuplot script. args_dict(dict): A dictionary of parameters to pass to the script. The `key` is the name of the ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:read; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:skip; 7, list:[]; 8, default_parameter; 8, 9; 8, 10; 9, identifier:goto_metal; 10, None; 11, default_parameter; 11, 12; 11, 13; 1...
def read(self, skip=[], goto_metal=None, goto_reaction=None): if len(skip) > 0: for skip_f in skip: self.omit_folders.append(skip_f) if os.path.isfile(self.data_base + '/publication.txt'): self.user_base_level -= 1 self.stdout.write('----------------------...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:location; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:wave_field; 6, default_parameter; 6, 7; 6, 8; 7, identifier:depth; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:index; 11, None; 12, block; 12, 1...
def location(self, wave_field, depth=None, index=None): if not isinstance(wave_field, WaveField): wave_field = WaveField[wave_field] if index is None and depth is not None: for i, layer in enumerate(self[:-1]): if layer.depth <= depth < layer.depth_base: ...