Dataset Viewer
Auto-converted to Parquet Duplicate
sequence
stringlengths
492
15.9k
code
stringlengths
75
8.58k
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:gather_categories; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:imap; 5, identifier:header; 6, default_parameter; 6, 7; 6, 8; 7, identifier:categories; 8, None; 9, block; 9, 10; 9, 31; 9, 52; 9, 58; 9, 65; 9, 124; 9, 147; 9, 208; 9, 214; 9, 2...
def gather_categories(imap, header, categories=None): if categories is None: return {"default": DataCategory(set(imap.keys()), {})} cat_ids = [header.index(cat) for cat in categories if cat in header and "=" not in cat] table = OrderedDict() conditions = defaultdict(set) for i...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:color_mapping; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:sample_map; 5, identifier:header; 6, identifier:group_column; 7, default_parameter; 7, 8; 7, 9; 8, identifier:color_column; 9, None; 10, block; 10, 11; 10, 17; 10, 27; 10, 99;...
def color_mapping(sample_map, header, group_column, color_column=None): group_colors = OrderedDict() group_gather = gather_categories(sample_map, header, [group_column]) if color_column is not None: color_gather = gather_categories(sample_map, header, [color_column]) for group in group_gathe...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 29; 2, function_name:shuffle_genome; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 12; 3, 15; 3, 16; 3, 19; 3, 22; 3, 23; 3, 26; 4, identifier:genome; 5, identifier:cat; 6, default_parameter; 6, 7; 6, 8; 7, identifier:fraction; 8, call; 8, 9; 8, 10; 9, identifier:float; 10,...
def shuffle_genome(genome, cat, fraction = float(100), plot = True, \ alpha = 0.1, beta = 100000, \ min_length = 1000, max_length = 200000): header = '>randomized_%s' % (genome.name) sequence = list(''.join([i[1] for i in parse_fasta(genome)])) length = len(sequence) shuffled = [] wh...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:sam2fastq; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:sam; 5, default_parameter; 5, 6; 5, 7; 6, identifier:singles; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:force; 10, False; 11, block; 11, 12; 11, 20; 12, expression_stat...
def sam2fastq(sam, singles = False, force = False): L, R = None, None for line in sam: if line.startswith('@') is True: continue line = line.strip().split() bit = [True if i == '1' else False \ for i in bin(int(line[1])).split('b')[1][::-1]] while len(...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_sam; 3, parameters; 3, 4; 3, 5; 4, identifier:sam; 5, identifier:sort; 6, block; 6, 7; 6, 29; 6, 141; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:tempdir; 10, binary_operator:%; 10, 11; 10, 12; 11, string:'%s/'...
def sort_sam(sam, sort): tempdir = '%s/' % (os.path.abspath(sam).rsplit('/', 1)[0]) if sort is True: mapping = '%s.sorted.sam' % (sam.rsplit('.', 1)[0]) if sam != '-': if os.path.exists(mapping) is False: os.system("\ sort -k1 --buffer-size=%sG -T ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:crossmap; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 4, identifier:fas; 5, identifier:reads; 6, identifier:options; 7, identifier:no_shrink; 8, identifier:keepDB; 9, identifier:threads; 10, identifier:cluster; 11, identif...
def crossmap(fas, reads, options, no_shrink, keepDB, threads, cluster, nodes): if cluster is True: threads = '48' btc = [] for fa in fas: btd = bowtiedb(fa, keepDB) F, R, U = reads if F is not False: if U is False: u = False for i, f in...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:bit_by_bit; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:in_data; 6, block; 6, 7; 6, 25; 6, 31; 6, 97; 6, 135; 6, 152; 7, if_statement; 7, 8; 7, 13; 8, call; 8, 9; 8, 10; 9, identifier:isinstance; 10, argument_list; 10, 11; 10, ...
def bit_by_bit(self, in_data): if isinstance(in_data, str): in_data = [ord(c) for c in in_data] register = self.NonDirectInit for octet in in_data: if self.ReflectIn: octet = self.reflect(octet, 8) for i in range(8): topbit = re...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:parse_ggKbase_tables; 3, parameters; 3, 4; 3, 5; 4, identifier:tables; 5, identifier:id_type; 6, block; 6, 7; 6, 11; 6, 232; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:g2info; 10, dictionary; 11, for_statement; 11,...
def parse_ggKbase_tables(tables, id_type): g2info = {} for table in tables: for line in open(table): line = line.strip().split('\t') if line[0].startswith('name'): header = line header[4] = 'genome size (bp)' header[12] = ' ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:top_hits; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:hits; 5, identifier:num; 6, identifier:column; 7, identifier:reverse; 8, block; 8, 9; 8, 24; 9, expression_statement; 9, 10; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13;...
def top_hits(hits, num, column, reverse): hits.sort(key = itemgetter(column), reverse = reverse) for hit in hits[0:num]: yield hit
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:numBlast_sort; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:blast; 5, identifier:numHits; 6, identifier:evalueT; 7, identifier:bitT; 8, block; 8, 9; 8, 32; 8, 35; 8, 45; 8, 136; 8, 145; 9, expression_statement; 9, 10; 10, assignment; 10...
def numBlast_sort(blast, numHits, evalueT, bitT): header = [' 'qstart', 'qend', 'tstart', 'tend', 'evalue', 'bitscore'] yield header hmm = {h:[] for h in header} for line in blast: if line.startswith(' continue line = line.strip().split('\t') line[10], l...
0, module; 0, 1; 0, 64; 0, 67; 0, 75; 0, 267; 1, function_definition; 1, 2; 1, 3; 1, 9; 1, 47; 2, function_name:numDomtblout; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:domtblout; 5, identifier:numHits; 6, identifier:evalueT; 7, identifier:bitT; 8, identifier:sort; 9, ERROR; 9, 10; 9, 29; 9, 30; 9, 40; ...
def numDomtblout(domtblout, numHits, evalueT, bitT, sort): if sort is True: for hit in numDomtblout_sort(domtblout, numHits, evalueT, bitT): yield hit return header = [' 'query name', 'query accession', 'qlen', 'full E-value', 'full score', 'full bias', ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:compare_clades; 3, parameters; 3, 4; 4, identifier:pw; 5, block; 5, 6; 5, 20; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:names; 9, call; 9, 10; 9, 11; 10, identifier:sorted; 11, argument_list; 11, 12; 12, call; 12, ...
def compare_clades(pw): names = sorted(set([i for i in pw])) for i in range(0, 4): wi, bt = {}, {} for a in names: for b in pw[a]: if ';' not in a or ';' not in b: continue pident = pw[a][b] cA, cB = a.split(';')[i],...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:searchAccession; 3, parameters; 3, 4; 4, identifier:acc; 5, block; 5, 6; 5, 16; 5, 91; 5, 101; 5, 176; 5, 186; 5, 261; 5, 292; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 11; 8, pattern_list; 8, 9; 8, 10; 9, identifier:out; 10, ident...
def searchAccession(acc): out, error = entrez('genome', acc) for line in out.splitlines(): line = line.decode('ascii').strip() if 'Assembly_Accession' in line or 'BioSample' in line: newAcc = line.split('>')[1].split('<')[0].split('.')[0].split(',')[0] if len(newAcc) > 0:...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:_configure_logger; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, identifier:fmt; 5, identifier:quiet; 6, identifier:level; 7, identifier:fpath; 8, identifier:pre_hooks; 9, identifier:post_hooks; 10, identifier:metric_grouping_in...
def _configure_logger(fmt, quiet, level, fpath, pre_hooks, post_hooks, metric_grouping_interval): level = getattr(logging, level.upper()) global _GLOBAL_LOG_CONFIGURED if _GLOBAL_LOG_CONFIGURED: return def wrap_hook(fn): @wraps(fn) def processor(logger, method_name, event_dic...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:combine_modifiers; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:graphemes; 6, block; 6, 7; 6, 11; 6, 15; 6, 22; 6, 203; 6, 213; 6, 217; 6, 221; 6, 278; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:res...
def combine_modifiers(self, graphemes): result = [] temp = "" count = len(graphemes) for grapheme in reversed(graphemes): count -= 1 if len(grapheme) == 1 and unicodedata.category(grapheme) == "Lm" \ and not ord(grapheme) in [712, 716]: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:check_mismatches; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:read; 5, identifier:pair; 6, identifier:mismatches; 7, identifier:mm_option; 8, identifier:req_map; 9, block; 9, 10; 9, 43; 9, 50; 9, 57; 9, 68; 9, 75; 9, 91; 9, 117; ...
def check_mismatches(read, pair, mismatches, mm_option, req_map): if pair is False: mm = count_mismatches(read) if mm is False: return False if mismatches is False: return True if mm <= mismatches: return True r_mm = count_mismatches(read) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:get_steam; 3, parameters; 4, block; 4, 5; 4, 25; 4, 33; 4, 47; 4, 61; 4, 84; 5, expression_statement; 5, 6; 6, assignment; 6, 7; 6, 8; 7, identifier:helper; 8, lambda; 8, 9; 8, 11; 9, lambda_parameters; 9, 10; 10, identifier:udd; 11, conditiona...
def get_steam(): helper = lambda udd: Steam(udd) if os.path.exists(udd) else None plat = platform.system() if plat == 'Darwin': return helper(paths.default_osx_userdata_path()) if plat == 'Linux': return helper(paths.default_linux_userdata_path()) if plat == 'Windows': possible_dir = winutils.find...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:generate_barcodes; 3, parameters; 3, 4; 3, 5; 4, identifier:nIds; 5, default_parameter; 5, 6; 5, 7; 6, identifier:codeLen; 7, integer:12; 8, block; 8, 9; 8, 39; 8, 54; 8, 75; 8, 87; 8, 112; 8, 116; 8, 192; 9, function_definition; 9, 10; 9, 11; ...
def generate_barcodes(nIds, codeLen=12): def next_code(b, c, i): return c[:i] + b + (c[i+1:] if i < -1 else '') def rand_base(): return random.choice(['A', 'T', 'C', 'G']) def rand_seq(n): return ''.join([rand_base() for _ in range(n)]) hpf = re.compile('aaaa|cccc|gggg|tttt', re....
0, module; 0, 1; 1, ERROR; 1, 2; 2, function_definition; 2, 3; 2, 4; 2, 8; 3, function_name:parse_fasta_annotations; 4, parameters; 4, 5; 4, 6; 4, 7; 5, identifier:fastas; 6, identifier:annot_tables; 7, identifier:trans_table; 8, block; 8, 9; 8, 57; 8, 215; 8, 235; 8, 246; 8, 260; 8, 277; 9, if_statement; 9, 10; 9, 13;...
def parse_fasta_annotations(fastas, annot_tables, trans_table): if annot_tables is not False: annots = {} for table in annot_tables: for cds in open(table): ID, start, end, strand = cds.strip().split() annots[ID] = [start, end, int(strand)] for fasta i...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:find_consensus; 3, parameters; 3, 4; 4, identifier:bases; 5, block; 5, 6; 5, 15; 5, 32; 5, 75; 5, 93; 5, 123; 5, 183; 5, 189; 5, 195; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:nucs; 9, list:['A', 'T', 'G', 'C', 'N'...
def find_consensus(bases): nucs = ['A', 'T', 'G', 'C', 'N'] total = sum([bases[nuc] for nuc in nucs if nuc in bases]) try: top = max([bases[nuc] for nuc in nucs if nuc in bases]) except: bases['consensus'] = ('N', 'n/a') bases['consensus frequency'] = 'n/a' bases['referen...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:print_consensus; 3, parameters; 3, 4; 4, identifier:genomes; 5, block; 5, 6; 5, 10; 5, 128; 5, 204; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:cons; 9, dictionary; 10, for_statement; 10, 11; 10, 14; 10, 22; 11, patt...
def print_consensus(genomes): cons = {} for genome, contigs in list(genomes.items()): cons[genome] = {} for contig, samples in list(contigs.items()): for sample, stats in list(samples.items()): if sample not in cons[genome]: cons[genome][sample] = ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:parse_cov; 3, parameters; 3, 4; 3, 5; 4, identifier:cov_table; 5, identifier:scaffold2genome; 6, block; 6, 7; 6, 11; 6, 15; 6, 179; 6, 195; 6, 255; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:size; 10, dictionary; 1...
def parse_cov(cov_table, scaffold2genome): size = {} mapped = {} for line in open(cov_table): line = line.strip().split('\t') if line[0].startswith(' samples = line[1:] samples = [i.rsplit('/', 1)[-1].split('.', 1)[0] for i in samples] continue s...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:print_genome_matrix; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:hits; 5, identifier:fastas; 6, identifier:id2desc; 7, identifier:file_name; 8, block; 8, 9; 8, 17; 8, 24; 8, 35; 8, 85; 8, 98; 8, 106; 8, 117; 8, 189; 9, expression_state...
def print_genome_matrix(hits, fastas, id2desc, file_name): out = open(file_name, 'w') fastas = sorted(fastas) print(' print(' for fasta in fastas: line = [fasta] for other in fastas: if other == fasta: average = '-' else: averag...
0, module; 0, 1; 1, ERROR; 1, 2; 1, 298; 1, 304; 2, function_definition; 2, 3; 2, 4; 2, 17; 3, function_name:calc_thresholds; 4, parameters; 4, 5; 4, 6; 4, 7; 4, 14; 5, identifier:rbh; 6, identifier:file_name; 7, default_parameter; 7, 8; 7, 9; 8, identifier:thresholds; 9, list:[False, False, False, False]; 9, 10; 9, 11...
def calc_thresholds(rbh, file_name, thresholds = [False, False, False, False], stdevs = 2): calc_threshold = thresholds[-1] norm_threshold = {} for pair in itertools.permutations([i for i in rbh], 2): if pair[0] not in norm_threshold: norm_threshold[pair[0]] = {} norm_threshold[p...
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
7