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, 236; 9, 248; 9, 330; 10, if_statement; 10, 11; 10, 14; 11, comparison_operator:is; 11, 12; 11, 13; 12, identifier:categories; 13, None; 14, block; 14, 15; 15, return_statement; 15, 16; 16, dictionary; 16, 17; 17, pair; 17, 18; 17, 19; 18, string:"default"; 19, call; 19, 20; 19, 21; 20, identifier:DataCategory; 21, argument_list; 21, 22; 21, 30; 22, call; 22, 23; 22, 24; 23, identifier:set; 24, argument_list; 24, 25; 25, call; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:imap; 28, identifier:keys; 29, argument_list; 30, dictionary; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:cat_ids; 34, list_comprehension; 34, 35; 34, 41; 34, 44; 35, call; 35, 36; 35, 39; 36, attribute; 36, 37; 36, 38; 37, identifier:header; 38, identifier:index; 39, argument_list; 39, 40; 40, identifier:cat; 41, for_in_clause; 41, 42; 41, 43; 42, identifier:cat; 43, identifier:categories; 44, if_clause; 44, 45; 45, boolean_operator:and; 45, 46; 45, 49; 46, comparison_operator:in; 46, 47; 46, 48; 47, identifier:cat; 48, identifier:header; 49, comparison_operator:not; 49, 50; 49, 51; 50, string:"="; 51, identifier:cat; 52, expression_statement; 52, 53; 53, assignment; 53, 54; 53, 55; 54, identifier:table; 55, call; 55, 56; 55, 57; 56, identifier:OrderedDict; 57, argument_list; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 61; 60, identifier:conditions; 61, call; 61, 62; 61, 63; 62, identifier:defaultdict; 63, argument_list; 63, 64; 64, identifier:set; 65, for_statement; 65, 66; 65, 69; 65, 73; 66, pattern_list; 66, 67; 66, 68; 67, identifier:i; 68, identifier:cat; 69, call; 69, 70; 69, 71; 70, identifier:enumerate; 71, argument_list; 71, 72; 72, identifier:categories; 73, block; 73, 74; 74, if_statement; 74, 75; 74, 89; 75, boolean_operator:and; 75, 76; 75, 79; 76, comparison_operator:in; 76, 77; 76, 78; 77, string:"="; 78, identifier:cat; 79, comparison_operator:in; 79, 80; 79, 88; 80, subscript; 80, 81; 80, 87; 81, call; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:cat; 84, identifier:split; 85, argument_list; 85, 86; 86, string:"="; 87, integer:0; 88, identifier:header; 89, block; 89, 90; 89, 108; 90, expression_statement; 90, 91; 91, assignment; 91, 92; 91, 93; 92, identifier:cat_name; 93, subscript; 93, 94; 93, 95; 94, identifier:header; 95, call; 95, 96; 95, 99; 96, attribute; 96, 97; 96, 98; 97, identifier:header; 98, identifier:index; 99, argument_list; 99, 100; 100, subscript; 100, 101; 100, 107; 101, call; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, identifier:cat; 104, identifier:split; 105, argument_list; 105, 106; 106, string:"="; 107, integer:0; 108, expression_statement; 108, 109; 109, call; 109, 110; 109, 115; 110, attribute; 110, 111; 110, 114; 111, subscript; 111, 112; 111, 113; 112, identifier:conditions; 113, identifier:cat_name; 114, identifier:add; 115, argument_list; 115, 116; 116, subscript; 116, 117; 116, 123; 117, call; 117, 118; 117, 121; 118, attribute; 118, 119; 118, 120; 119, identifier:cat; 120, identifier:split; 121, argument_list; 121, 122; 122, string:"="; 123, integer:1; 124, if_statement; 124, 125; 124, 130; 125, boolean_operator:and; 125, 126; 125, 128; 126, not_operator; 126, 127; 127, identifier:cat_ids; 128, not_operator; 128, 129; 129, identifier:conditions; 130, block; 130, 131; 131, return_statement; 131, 132; 132, dictionary; 132, 133; 133, pair; 133, 134; 133, 135; 134, string:"default"; 135, call; 135, 136; 135, 137; 136, identifier:DataCategory; 137, argument_list; 137, 138; 137, 146; 138, call; 138, 139; 138, 140; 139, identifier:set; 140, argument_list; 140, 141; 141, call; 141, 142; 141, 145; 142, attribute; 142, 143; 142, 144; 143, identifier:imap; 144, identifier:keys; 145, argument_list; 146, dictionary; 147, if_statement; 147, 148; 147, 152; 148, boolean_operator:and; 148, 149; 148, 150; 149, identifier:cat_ids; 150, not_operator; 150, 151; 151, identifier:conditions; 152, block; 152, 153; 152, 206; 153, for_statement; 153, 154; 153, 157; 153, 162; 154, pattern_list; 154, 155; 154, 156; 155, identifier:sid; 156, identifier:row; 157, call; 157, 158; 157, 161; 158, attribute; 158, 159; 158, 160; 159, identifier:imap; 160, identifier:items; 161, argument_list; 162, block; 162, 163; 162, 178; 162, 195; 163, expression_statement; 163, 164; 164, assignment; 164, 165; 164, 166; 165, identifier:cat_name; 166, call; 166, 167; 166, 170; 167, attribute; 167, 168; 167, 169; 168, string:"_"; 169, identifier:join; 170, argument_list; 170, 171; 171, list_comprehension; 171, 172; 171, 175; 172, subscript; 172, 173; 172, 174; 173, identifier:row; 174, identifier:cid; 175, for_in_clause; 175, 176; 175, 177; 176, identifier:cid; 177, identifier:cat_ids; 178, if_statement; 178, 179; 178, 182; 179, comparison_operator:not; 179, 180; 179, 181; 180, identifier:cat_name; 181, identifier:table; 182, block; 182, 183; 183, expression_statement; 183, 184; 184, assignment; 184, 185; 184, 188; 185, subscript; 185, 186; 185, 187; 186, identifier:table; 187, identifier:cat_name; 188, call; 188, 189; 188, 190; 189, identifier:DataCategory; 190, argument_list; 190, 191; 190, 194; 191, call; 191, 192; 191, 193; 192, identifier:set; 193, argument_list; 194, dictionary; 195, expression_statement; 195, 196; 196, call; 196, 197; 196, 204; 197, attribute; 197, 198; 197, 203; 198, attribute; 198, 199; 198, 202; 199, subscript; 199, 200; 199, 201; 200, identifier:table; 201, identifier:cat_name; 202, identifier:sids; 203, identifier:add; 204, argument_list; 204, 205; 205, identifier:sid; 206, return_statement; 206, 207; 207, identifier:table; 208, expression_statement; 208, 209; 209, assignment; 209, 210; 209, 211; 210, identifier:cond_ids; 211, call; 211, 212; 211, 213; 212, identifier:set; 213, argument_list; 214, for_statement; 214, 215; 214, 216; 214, 217; 215, identifier:k; 216, identifier:conditions; 217, block; 217, 218; 218, try_statement; 218, 219; 218, 232; 219, block; 219, 220; 220, expression_statement; 220, 221; 221, call; 221, 222; 221, 225; 222, attribute; 222, 223; 222, 224; 223, identifier:cond_ids; 224, identifier:add; 225, argument_list; 225, 226; 226, call; 226, 227; 226, 230; 227, attribute; 227, 228; 227, 229; 228, identifier:header; 229, identifier:index; 230, argument_list; 230, 231; 231, identifier:k; 232, except_clause; 232, 233; 232, 234; 233, identifier:ValueError; 234, block; 234, 235; 235, continue_statement; 236, expression_statement; 236, 237; 237, assignment; 237, 238; 237, 239; 238, identifier:idx_to_test; 239, call; 239, 240; 239, 246; 240, attribute; 240, 241; 240, 245; 241, call; 241, 242; 241, 243; 242, identifier:set; 243, argument_list; 243, 244; 244, identifier:cat_ids; 245, identifier:union; 246, argument_list; 246, 247; 247, identifier:cond_ids; 248, for_statement; 248, 249; 248, 252; 248, 257; 249, pattern_list; 249, 250; 249, 251; 250, identifier:sid; 251, identifier:row; 252, call; 252, 253; 252, 256; 253, attribute; 253, 254; 253, 255; 254, identifier:imap; 255, identifier:items; 256, argument_list; 257, block; 257, 258; 258, if_statement; 258, 259; 258, 278; 259, call; 259, 260; 259, 261; 260, identifier:all; 261, argument_list; 261, 262; 262, list_comprehension; 262, 263; 262, 275; 263, comparison_operator:in; 263, 264; 263, 272; 264, subscript; 264, 265; 264, 266; 265, identifier:row; 266, call; 266, 267; 266, 270; 267, attribute; 267, 268; 267, 269; 268, identifier:header; 269, identifier:index; 270, argument_list; 270, 271; 271, identifier:c; 272, subscript; 272, 273; 272, 274; 273, identifier:conditions; 274, identifier:c; 275, for_in_clause; 275, 276; 275, 277; 276, identifier:c; 277, identifier:conditions; 278, block; 278, 279; 278, 294; 278, 319; 279, expression_statement; 279, 280; 280, assignment; 280, 281; 280, 282; 281, identifier:key; 282, call; 282, 283; 282, 286; 283, attribute; 283, 284; 283, 285; 284, string:"_"; 285, identifier:join; 286, argument_list; 286, 287; 287, list_comprehension; 287, 288; 287, 291; 288, subscript; 288, 289; 288, 290; 289, identifier:row; 290, identifier:idx; 291, for_in_clause; 291, 292; 291, 293; 292, identifier:idx; 293, identifier:idx_to_test; 294, try_statement; 294, 295; 294, 304; 295, block; 295, 296; 296, assert_statement; 296, 297; 297, comparison_operator:in; 297, 298; 297, 299; 298, identifier:key; 299, call; 299, 300; 299, 303; 300, attribute; 300, 301; 300, 302; 301, identifier:table; 302, identifier:keys; 303, argument_list; 304, except_clause; 304, 305; 304, 306; 305, identifier:AssertionError; 306, block; 306, 307; 307, expression_statement; 307, 308; 308, assignment; 308, 309; 308, 312; 309, subscript; 309, 310; 309, 311; 310, identifier:table; 311, identifier:key; 312, call; 312, 313; 312, 314; 313, identifier:DataCategory; 314, argument_list; 314, 315; 314, 318; 315, call; 315, 316; 315, 317; 316, identifier:set; 317, argument_list; 318, dictionary; 319, expression_statement; 319, 320; 320, call; 320, 321; 320, 328; 321, attribute; 321, 322; 321, 327; 322, attribute; 322, 323; 322, 326; 323, subscript; 323, 324; 323, 325; 324, identifier:table; 325, identifier:key; 326, identifier:sids; 327, identifier:add; 328, argument_list; 328, 329; 329, identifier:sid; 330, try_statement; 330, 331; 330, 339; 330, 358; 331, block; 331, 332; 332, assert_statement; 332, 333; 333, comparison_operator:>; 333, 334; 333, 338; 334, call; 334, 335; 334, 336; 335, identifier:len; 336, argument_list; 336, 337; 337, identifier:table; 338, integer:0; 339, except_clause; 339, 340; 339, 341; 340, identifier:AssertionError; 341, block; 341, 342; 342, return_statement; 342, 343; 343, dictionary; 343, 344; 344, pair; 344, 345; 344, 346; 345, string:"default"; 346, call; 346, 347; 346, 348; 347, identifier:DataCategory; 348, argument_list; 348, 349; 348, 357; 349, call; 349, 350; 349, 351; 350, identifier:set; 351, argument_list; 351, 352; 352, call; 352, 353; 352, 356; 353, attribute; 353, 354; 353, 355; 354, identifier:imap; 355, identifier:keys; 356, argument_list; 357, dictionary; 358, else_clause; 358, 359; 359, block; 359, 360; 360, return_statement; 360, 361; 361, identifier:table | 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, cat in enumerate(categories):
if "=" in cat and cat.split("=")[0] in header:
cat_name = header[header.index(cat.split("=")[0])]
conditions[cat_name].add(cat.split("=")[1])
if not cat_ids and not conditions:
return {"default": DataCategory(set(imap.keys()), {})}
if cat_ids and not conditions:
for sid, row in imap.items():
cat_name = "_".join([row[cid] for cid in cat_ids])
if cat_name not in table:
table[cat_name] = DataCategory(set(), {})
table[cat_name].sids.add(sid)
return table
cond_ids = set()
for k in conditions:
try:
cond_ids.add(header.index(k))
except ValueError:
continue
idx_to_test = set(cat_ids).union(cond_ids)
for sid, row in imap.items():
if all([row[header.index(c)] in conditions[c] for c in conditions]):
key = "_".join([row[idx] for idx in idx_to_test])
try:
assert key in table.keys()
except AssertionError:
table[key] = DataCategory(set(), {})
table[key].sids.add(sid)
try:
assert len(table) > 0
except AssertionError:
return {"default": DataCategory(set(imap.keys()), {})}
else:
return table |
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; 11, expression_statement; 11, 12; 12, assignment; 12, 13; 12, 14; 13, identifier:group_colors; 14, call; 14, 15; 14, 16; 15, identifier:OrderedDict; 16, argument_list; 17, expression_statement; 17, 18; 18, assignment; 18, 19; 18, 20; 19, identifier:group_gather; 20, call; 20, 21; 20, 22; 21, identifier:gather_categories; 22, argument_list; 22, 23; 22, 24; 22, 25; 23, identifier:sample_map; 24, identifier:header; 25, list:[group_column]; 25, 26; 26, identifier:group_column; 27, if_statement; 27, 28; 27, 31; 27, 72; 28, comparison_operator:is; 28, 29; 28, 30; 29, identifier:color_column; 30, None; 31, block; 31, 32; 31, 42; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 35; 34, identifier:color_gather; 35, call; 35, 36; 35, 37; 36, identifier:gather_categories; 37, argument_list; 37, 38; 37, 39; 37, 40; 38, identifier:sample_map; 39, identifier:header; 40, list:[color_column]; 40, 41; 41, identifier:color_column; 42, for_statement; 42, 43; 42, 44; 42, 45; 43, identifier:group; 44, identifier:group_gather; 45, block; 45, 46; 46, for_statement; 46, 47; 46, 48; 46, 49; 47, identifier:color; 48, identifier:color_gather; 49, block; 49, 50; 50, if_statement; 50, 51; 50, 65; 51, call; 51, 52; 51, 59; 52, attribute; 52, 53; 52, 58; 53, attribute; 53, 54; 53, 57; 54, subscript; 54, 55; 54, 56; 55, identifier:group_gather; 56, identifier:group; 57, identifier:sids; 58, identifier:intersection; 59, argument_list; 59, 60; 60, attribute; 60, 61; 60, 64; 61, subscript; 61, 62; 61, 63; 62, identifier:color_gather; 63, identifier:color; 64, identifier:sids; 65, block; 65, 66; 66, expression_statement; 66, 67; 67, assignment; 67, 68; 67, 71; 68, subscript; 68, 69; 68, 70; 69, identifier:group_colors; 70, identifier:group; 71, identifier:color; 72, else_clause; 72, 73; 73, block; 73, 74; 73, 85; 74, expression_statement; 74, 75; 75, assignment; 75, 76; 75, 77; 76, identifier:bcolors; 77, call; 77, 78; 77, 81; 78, attribute; 78, 79; 78, 80; 79, identifier:itertools; 80, identifier:cycle; 81, argument_list; 81, 82; 82, attribute; 82, 83; 82, 84; 83, identifier:Set3_12; 84, identifier:hex_colors; 85, for_statement; 85, 86; 85, 87; 85, 88; 86, identifier:group; 87, identifier:group_gather; 88, block; 88, 89; 89, expression_statement; 89, 90; 90, assignment; 90, 91; 90, 94; 91, subscript; 91, 92; 91, 93; 92, identifier:group_colors; 93, identifier:group; 94, call; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:bcolors; 97, identifier:next; 98, argument_list; 99, return_statement; 99, 100; 100, identifier:group_colors | 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_gather:
for color in color_gather:
if group_gather[group].sids.intersection(color_gather[color].sids):
group_colors[group] = color
else:
bcolors = itertools.cycle(Set3_12.hex_colors)
for group in group_gather:
group_colors[group] = bcolors.next()
return group_colors |
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, argument_list; 10, 11; 11, integer:100; 12, default_parameter; 12, 13; 12, 14; 13, identifier:plot; 14, True; 15, line_continuation:\; 16, default_parameter; 16, 17; 16, 18; 17, identifier:alpha; 18, float:0.1; 19, default_parameter; 19, 20; 19, 21; 20, identifier:beta; 21, integer:100000; 22, line_continuation:\; 23, default_parameter; 23, 24; 23, 25; 24, identifier:min_length; 25, integer:1000; 26, default_parameter; 26, 27; 26, 28; 27, identifier:max_length; 28, integer:200000; 29, block; 29, 30; 29, 39; 29, 60; 29, 67; 29, 71; 29, 152; 29, 159; 29, 242; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 33; 32, identifier:header; 33, binary_operator:%; 33, 34; 33, 35; 34, string:'>randomized_%s'; 35, parenthesized_expression; 35, 36; 36, attribute; 36, 37; 36, 38; 37, identifier:genome; 38, identifier:name; 39, expression_statement; 39, 40; 40, assignment; 40, 41; 40, 42; 41, identifier:sequence; 42, call; 42, 43; 42, 44; 43, identifier:list; 44, argument_list; 44, 45; 45, call; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, string:''; 48, identifier:join; 49, argument_list; 49, 50; 50, list_comprehension; 50, 51; 50, 54; 51, subscript; 51, 52; 51, 53; 52, identifier:i; 53, integer:1; 54, for_in_clause; 54, 55; 54, 56; 55, identifier:i; 56, call; 56, 57; 56, 58; 57, identifier:parse_fasta; 58, argument_list; 58, 59; 59, identifier:genome; 60, expression_statement; 60, 61; 61, assignment; 61, 62; 61, 63; 62, identifier:length; 63, call; 63, 64; 63, 65; 64, identifier:len; 65, argument_list; 65, 66; 66, identifier:sequence; 67, expression_statement; 67, 68; 68, assignment; 68, 69; 68, 70; 69, identifier:shuffled; 70, list:[]; 71, while_statement; 71, 72; 71, 75; 72, comparison_operator:is; 72, 73; 72, 74; 73, identifier:sequence; 74, False; 75, block; 75, 76; 75, 89; 75, 99; 75, 126; 75, 134; 75, 146; 76, expression_statement; 76, 77; 77, assignment; 77, 78; 77, 79; 78, identifier:s; 79, call; 79, 80; 79, 81; 80, identifier:int; 81, argument_list; 81, 82; 82, call; 82, 83; 82, 86; 83, attribute; 83, 84; 83, 85; 84, identifier:random; 85, identifier:gammavariate; 86, argument_list; 86, 87; 86, 88; 87, identifier:alpha; 88, identifier:beta; 89, if_statement; 89, 90; 89, 97; 90, boolean_operator:or; 90, 91; 90, 94; 91, comparison_operator:<=; 91, 92; 91, 93; 92, identifier:s; 93, identifier:min_length; 94, comparison_operator:>=; 94, 95; 94, 96; 95, identifier:s; 96, identifier:max_length; 97, block; 97, 98; 98, continue_statement; 99, if_statement; 99, 100; 99, 106; 99, 115; 100, comparison_operator:<; 100, 101; 100, 105; 101, call; 101, 102; 101, 103; 102, identifier:len; 103, argument_list; 103, 104; 104, identifier:sequence; 105, identifier:s; 106, block; 106, 107; 107, expression_statement; 107, 108; 108, assignment; 108, 109; 108, 110; 109, identifier:seq; 110, subscript; 110, 111; 110, 112; 111, identifier:sequence; 112, slice; 112, 113; 112, 114; 113, integer:0; 114, colon; 115, else_clause; 115, 116; 116, block; 116, 117; 117, expression_statement; 117, 118; 118, assignment; 118, 119; 118, 120; 119, identifier:seq; 120, subscript; 120, 121; 120, 122; 121, identifier:sequence; 122, slice; 122, 123; 122, 124; 122, 125; 123, integer:0; 124, colon; 125, identifier:s; 126, expression_statement; 126, 127; 127, assignment; 127, 128; 127, 129; 128, identifier:sequence; 129, subscript; 129, 130; 129, 131; 130, identifier:sequence; 131, slice; 131, 132; 131, 133; 132, identifier:s; 133, colon; 134, expression_statement; 134, 135; 135, call; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:shuffled; 138, identifier:append; 139, argument_list; 139, 140; 140, call; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, string:''; 143, identifier:join; 144, argument_list; 144, 145; 145, identifier:seq; 146, if_statement; 146, 147; 146, 150; 147, comparison_operator:==; 147, 148; 147, 149; 148, identifier:sequence; 149, list:[]; 150, block; 150, 151; 151, break_statement; 152, expression_statement; 152, 153; 153, call; 153, 154; 153, 157; 154, attribute; 154, 155; 154, 156; 155, identifier:random; 156, identifier:shuffle; 157, argument_list; 157, 158; 158, identifier:shuffled; 159, if_statement; 159, 160; 159, 166; 159, 171; 160, comparison_operator:==; 160, 161; 160, 162; 161, identifier:fraction; 162, call; 162, 163; 162, 164; 163, identifier:float; 164, argument_list; 164, 165; 165, integer:100; 166, block; 166, 167; 167, expression_statement; 167, 168; 168, assignment; 168, 169; 168, 170; 169, identifier:subset; 170, identifier:shuffled; 171, else_clause; 171, 172; 172, block; 172, 173; 172, 184; 172, 192; 173, expression_statement; 173, 174; 174, assignment; 174, 175; 174, 176; 175, identifier:max_pieces; 176, call; 176, 177; 176, 178; 177, identifier:int; 178, argument_list; 178, 179; 179, binary_operator:/; 179, 180; 179, 183; 180, binary_operator:*; 180, 181; 180, 182; 181, identifier:length; 182, identifier:fraction; 183, integer:100; 184, expression_statement; 184, 185; 185, assignment; 185, 186; 185, 189; 186, pattern_list; 186, 187; 186, 188; 187, identifier:subset; 188, identifier:total; 189, expression_list; 189, 190; 189, 191; 190, list:[]; 191, integer:0; 192, for_statement; 192, 193; 192, 194; 192, 195; 193, identifier:fragment; 194, identifier:shuffled; 195, block; 195, 196; 195, 203; 196, expression_statement; 196, 197; 197, assignment; 197, 198; 197, 199; 198, identifier:length; 199, call; 199, 200; 199, 201; 200, identifier:len; 201, argument_list; 201, 202; 202, identifier:fragment; 203, if_statement; 203, 204; 203, 209; 203, 221; 204, comparison_operator:<=; 204, 205; 204, 208; 205, binary_operator:+; 205, 206; 205, 207; 206, identifier:total; 207, identifier:length; 208, identifier:max_pieces; 209, block; 209, 210; 209, 217; 210, expression_statement; 210, 211; 211, call; 211, 212; 211, 215; 212, attribute; 212, 213; 212, 214; 213, identifier:subset; 214, identifier:append; 215, argument_list; 215, 216; 216, identifier:fragment; 217, expression_statement; 217, 218; 218, augmented_assignment:+=; 218, 219; 218, 220; 219, identifier:total; 220, identifier:length; 221, else_clause; 221, 222; 222, block; 222, 223; 222, 229; 222, 241; 223, expression_statement; 223, 224; 224, assignment; 224, 225; 224, 226; 225, identifier:diff; 226, binary_operator:-; 226, 227; 226, 228; 227, identifier:max_pieces; 228, identifier:total; 229, expression_statement; 229, 230; 230, call; 230, 231; 230, 234; 231, attribute; 231, 232; 231, 233; 232, identifier:subset; 233, identifier:append; 234, argument_list; 234, 235; 235, subscript; 235, 236; 235, 237; 236, identifier:fragment; 237, slice; 237, 238; 237, 239; 237, 240; 238, integer:0; 239, colon; 240, identifier:diff; 241, break_statement; 242, if_statement; 242, 243; 242, 246; 242, 257; 243, comparison_operator:is; 243, 244; 243, 245; 244, identifier:cat; 245, True; 246, block; 246, 247; 247, expression_statement; 247, 248; 248, yield; 248, 249; 249, list:[header, ''.join(subset)]; 249, 250; 249, 251; 250, identifier:header; 251, call; 251, 252; 251, 255; 252, attribute; 252, 253; 252, 254; 253, string:''; 254, identifier:join; 255, argument_list; 255, 256; 256, identifier:subset; 257, else_clause; 257, 258; 258, block; 258, 259; 259, for_statement; 259, 260; 259, 263; 259, 267; 260, pattern_list; 260, 261; 260, 262; 261, identifier:i; 262, identifier:seq; 263, call; 263, 264; 263, 265; 264, identifier:enumerate; 265, argument_list; 265, 266; 266, identifier:subset; 267, block; 267, 268; 268, expression_statement; 268, 269; 269, yield; 269, 270; 270, list:['%s fragment:%s' % (header, i), seq]; 270, 271; 270, 276; 271, binary_operator:%; 271, 272; 271, 273; 272, string:'%s fragment:%s'; 273, tuple; 273, 274; 273, 275; 274, identifier:header; 275, identifier:i; 276, identifier:seq | 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 = []
while sequence is not False:
s = int(random.gammavariate(alpha, beta))
if s <= min_length or s >= max_length:
continue
if len(sequence) < s:
seq = sequence[0:]
else:
seq = sequence[0:s]
sequence = sequence[s:]
shuffled.append(''.join(seq))
if sequence == []:
break
random.shuffle(shuffled)
if fraction == float(100):
subset = shuffled
else:
max_pieces = int(length * fraction/100)
subset, total = [], 0
for fragment in shuffled:
length = len(fragment)
if total + length <= max_pieces:
subset.append(fragment)
total += length
else:
diff = max_pieces - total
subset.append(fragment[0:diff])
break
if cat is True:
yield [header, ''.join(subset)]
else:
for i, seq in enumerate(subset):
yield ['%s fragment:%s' % (header, i), seq] |
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_statement; 12, 13; 13, assignment; 13, 14; 13, 17; 14, pattern_list; 14, 15; 14, 16; 15, identifier:L; 16, identifier:R; 17, expression_list; 17, 18; 17, 19; 18, None; 19, None; 20, for_statement; 20, 21; 20, 22; 20, 23; 21, identifier:line; 22, identifier:sam; 23, block; 23, 24; 23, 35; 23, 47; 23, 82; 23, 97; 23, 109; 23, 126; 23, 170; 23, 258; 24, if_statement; 24, 25; 24, 33; 25, comparison_operator:is; 25, 26; 25, 32; 26, call; 26, 27; 26, 30; 27, attribute; 27, 28; 27, 29; 28, identifier:line; 29, identifier:startswith; 30, argument_list; 30, 31; 31, string:'@'; 32, True; 33, block; 33, 34; 34, continue_statement; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 38; 37, identifier:line; 38, call; 38, 39; 38, 46; 39, attribute; 39, 40; 39, 45; 40, call; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:line; 43, identifier:strip; 44, argument_list; 45, identifier:split; 46, argument_list; 47, expression_statement; 47, 48; 48, assignment; 48, 49; 48, 50; 49, identifier:bit; 50, list_comprehension; 50, 51; 50, 57; 50, 58; 51, conditional_expression:if; 51, 52; 51, 53; 51, 56; 52, True; 53, comparison_operator:==; 53, 54; 53, 55; 54, identifier:i; 55, string:'1'; 56, False; 57, line_continuation:\; 58, for_in_clause; 58, 59; 58, 60; 59, identifier:i; 60, subscript; 60, 61; 60, 77; 61, subscript; 61, 62; 61, 76; 62, call; 62, 63; 62, 74; 63, attribute; 63, 64; 63, 73; 64, call; 64, 65; 64, 66; 65, identifier:bin; 66, argument_list; 66, 67; 67, call; 67, 68; 67, 69; 68, identifier:int; 69, argument_list; 69, 70; 70, subscript; 70, 71; 70, 72; 71, identifier:line; 72, integer:1; 73, identifier:split; 74, argument_list; 74, 75; 75, string:'b'; 76, integer:1; 77, slice; 77, 78; 77, 79; 77, 80; 78, colon; 79, colon; 80, unary_operator:-; 80, 81; 81, integer:1; 82, while_statement; 82, 83; 82, 89; 83, comparison_operator:<; 83, 84; 83, 88; 84, call; 84, 85; 84, 86; 85, identifier:len; 86, argument_list; 86, 87; 87, identifier:bit; 88, integer:8; 89, block; 89, 90; 90, expression_statement; 90, 91; 91, call; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:bit; 94, identifier:append; 95, argument_list; 95, 96; 96, False; 97, expression_statement; 97, 98; 98, assignment; 98, 99; 98, 108; 99, pattern_list; 99, 100; 99, 101; 99, 102; 99, 103; 99, 104; 99, 105; 99, 106; 99, 107; 100, identifier:pair; 101, identifier:proper; 102, identifier:na; 103, identifier:nap; 104, identifier:rev; 105, identifier:mrev; 106, identifier:left; 107, identifier:right; 108, identifier:bit; 109, if_statement; 109, 110; 109, 113; 110, comparison_operator:is; 110, 111; 110, 112; 111, identifier:pair; 112, False; 113, block; 113, 114; 113, 125; 114, if_statement; 114, 115; 114, 118; 115, comparison_operator:is; 115, 116; 115, 117; 116, identifier:singles; 117, True; 118, block; 118, 119; 119, expression_statement; 119, 120; 120, call; 120, 121; 120, 122; 121, identifier:print_single; 122, argument_list; 122, 123; 122, 124; 123, identifier:line; 124, identifier:rev; 125, continue_statement; 126, if_statement; 126, 127; 126, 130; 126, 156; 127, comparison_operator:is; 127, 128; 127, 129; 128, identifier:rev; 129, True; 130, block; 130, 131; 130, 144; 131, expression_statement; 131, 132; 132, assignment; 132, 133; 132, 134; 133, identifier:seq; 134, subscript; 134, 135; 134, 143; 135, call; 135, 136; 135, 137; 136, identifier:rc; 137, argument_list; 137, 138; 138, list:['', line[9]]; 138, 139; 138, 140; 139, string:''; 140, subscript; 140, 141; 140, 142; 141, identifier:line; 142, integer:9; 143, integer:1; 144, expression_statement; 144, 145; 145, assignment; 145, 146; 145, 147; 146, identifier:qual; 147, subscript; 147, 148; 147, 151; 148, subscript; 148, 149; 148, 150; 149, identifier:line; 150, integer:10; 151, slice; 151, 152; 151, 153; 151, 154; 152, colon; 153, colon; 154, unary_operator:-; 154, 155; 155, integer:1; 156, else_clause; 156, 157; 157, block; 157, 158; 157, 164; 158, expression_statement; 158, 159; 159, assignment; 159, 160; 159, 161; 160, identifier:seq; 161, subscript; 161, 162; 161, 163; 162, identifier:line; 163, integer:9; 164, expression_statement; 164, 165; 165, assignment; 165, 166; 165, 167; 166, identifier:qual; 167, subscript; 167, 168; 167, 169; 168, identifier:line; 169, integer:10; 170, if_statement; 170, 171; 170, 174; 171, comparison_operator:is; 171, 172; 171, 173; 172, identifier:left; 173, True; 174, block; 174, 175; 174, 213; 174, 223; 174, 239; 175, if_statement; 175, 176; 175, 183; 176, boolean_operator:and; 176, 177; 176, 180; 177, comparison_operator:is; 177, 178; 177, 179; 178, identifier:L; 179, None; 180, comparison_operator:is; 180, 181; 180, 182; 181, identifier:force; 182, False; 183, block; 183, 184; 183, 194; 183, 209; 184, expression_statement; 184, 185; 185, call; 185, 186; 185, 187; 186, identifier:print; 187, argument_list; 187, 188; 187, 189; 188, string:'sam file is not sorted'; 189, keyword_argument; 189, 190; 189, 191; 190, identifier:file; 191, attribute; 191, 192; 191, 193; 192, identifier:sys; 193, identifier:stderr; 194, expression_statement; 194, 195; 195, call; 195, 196; 195, 197; 196, identifier:print; 197, argument_list; 197, 198; 197, 204; 198, binary_operator:%; 198, 199; 198, 200; 199, string:'\te.g.: %s'; 200, parenthesized_expression; 200, 201; 201, subscript; 201, 202; 201, 203; 202, identifier:line; 203, integer:0; 204, keyword_argument; 204, 205; 204, 206; 205, identifier:file; 206, attribute; 206, 207; 206, 208; 207, identifier:sys; 208, identifier:stderr; 209, expression_statement; 209, 210; 210, call; 210, 211; 210, 212; 211, identifier:exit; 212, argument_list; 213, if_statement; 213, 214; 213, 217; 214, comparison_operator:is; 214, 215; 214, 216; 215, identifier:L; 216, None; 217, block; 217, 218; 217, 222; 218, expression_statement; 218, 219; 219, assignment; 219, 220; 219, 221; 220, identifier:L; 221, None; 222, continue_statement; 223, expression_statement; 223, 224; 224, assignment; 224, 225; 224, 226; 225, identifier:L; 226, list:['@%s' % line[0], seq, '+%s' % line[0], qual]; 226, 227; 226, 232; 226, 233; 226, 238; 227, binary_operator:%; 227, 228; 227, 229; 228, string:'@%s'; 229, subscript; 229, 230; 229, 231; 230, identifier:line; 231, integer:0; 232, identifier:seq; 233, binary_operator:%; 233, 234; 233, 235; 234, string:'+%s'; 235, subscript; 235, 236; 235, 237; 236, identifier:line; 237, integer:0; 238, identifier:qual; 239, if_statement; 239, 240; 239, 243; 240, comparison_operator:is; 240, 241; 240, 242; 241, identifier:R; 242, None; 243, block; 243, 244; 243, 247; 243, 250; 244, expression_statement; 244, 245; 245, yield; 245, 246; 246, identifier:L; 247, expression_statement; 247, 248; 248, yield; 248, 249; 249, identifier:R; 250, expression_statement; 250, 251; 251, assignment; 251, 252; 251, 255; 252, pattern_list; 252, 253; 252, 254; 253, identifier:L; 254, identifier:R; 255, expression_list; 255, 256; 255, 257; 256, None; 257, None; 258, if_statement; 258, 259; 258, 262; 259, comparison_operator:is; 259, 260; 259, 261; 260, identifier:right; 261, True; 262, block; 262, 263; 262, 301; 262, 311; 262, 327; 263, if_statement; 263, 264; 263, 271; 264, boolean_operator:and; 264, 265; 264, 268; 265, comparison_operator:is; 265, 266; 265, 267; 266, identifier:R; 267, None; 268, comparison_operator:is; 268, 269; 268, 270; 269, identifier:force; 270, False; 271, block; 271, 272; 271, 282; 271, 297; 272, expression_statement; 272, 273; 273, call; 273, 274; 273, 275; 274, identifier:print; 275, argument_list; 275, 276; 275, 277; 276, string:'sam file is not sorted'; 277, keyword_argument; 277, 278; 277, 279; 278, identifier:file; 279, attribute; 279, 280; 279, 281; 280, identifier:sys; 281, identifier:stderr; 282, expression_statement; 282, 283; 283, call; 283, 284; 283, 285; 284, identifier:print; 285, argument_list; 285, 286; 285, 292; 286, binary_operator:%; 286, 287; 286, 288; 287, string:'\te.g.: %s'; 288, parenthesized_expression; 288, 289; 289, subscript; 289, 290; 289, 291; 290, identifier:line; 291, integer:0; 292, keyword_argument; 292, 293; 292, 294; 293, identifier:file; 294, attribute; 294, 295; 294, 296; 295, identifier:sys; 296, identifier:stderr; 297, expression_statement; 297, 298; 298, call; 298, 299; 298, 300; 299, identifier:exit; 300, argument_list; 301, if_statement; 301, 302; 301, 305; 302, comparison_operator:is; 302, 303; 302, 304; 303, identifier:R; 304, None; 305, block; 305, 306; 305, 310; 306, expression_statement; 306, 307; 307, assignment; 307, 308; 307, 309; 308, identifier:R; 309, None; 310, continue_statement; 311, expression_statement; 311, 312; 312, assignment; 312, 313; 312, 314; 313, identifier:R; 314, list:['@%s' % line[0], seq, '+%s' % line[0], qual]; 314, 315; 314, 320; 314, 321; 314, 326; 315, binary_operator:%; 315, 316; 315, 317; 316, string:'@%s'; 317, subscript; 317, 318; 317, 319; 318, identifier:line; 319, integer:0; 320, identifier:seq; 321, binary_operator:%; 321, 322; 321, 323; 322, string:'+%s'; 323, subscript; 323, 324; 323, 325; 324, identifier:line; 325, integer:0; 326, identifier:qual; 327, if_statement; 327, 328; 327, 331; 328, comparison_operator:is; 328, 329; 328, 330; 329, identifier:L; 330, None; 331, block; 331, 332; 331, 335; 331, 338; 332, expression_statement; 332, 333; 333, yield; 333, 334; 334, identifier:L; 335, expression_statement; 335, 336; 336, yield; 336, 337; 337, identifier:R; 338, expression_statement; 338, 339; 339, assignment; 339, 340; 339, 343; 340, pattern_list; 340, 341; 340, 342; 341, identifier:L; 342, identifier:R; 343, expression_list; 343, 344; 343, 345; 344, None; 345, None | 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(bit) < 8:
bit.append(False)
pair, proper, na, nap, rev, mrev, left, right = bit
if pair is False:
if singles is True:
print_single(line, rev)
continue
if rev is True:
seq = rc(['', line[9]])[1]
qual = line[10][::-1]
else:
seq = line[9]
qual = line[10]
if left is True:
if L is not None and force is False:
print('sam file is not sorted', file = sys.stderr)
print('\te.g.: %s' % (line[0]), file = sys.stderr)
exit()
if L is not None:
L = None
continue
L = ['@%s' % line[0], seq, '+%s' % line[0], qual]
if R is not None:
yield L
yield R
L, R = None, None
if right is True:
if R is not None and force is False:
print('sam file is not sorted', file = sys.stderr)
print('\te.g.: %s' % (line[0]), file = sys.stderr)
exit()
if R is not None:
R = None
continue
R = ['@%s' % line[0], seq, '+%s' % line[0], qual]
if L is not None:
yield L
yield R
L, R = None, None |
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/'; 12, parenthesized_expression; 12, 13; 13, subscript; 13, 14; 13, 28; 14, call; 14, 15; 14, 25; 15, attribute; 15, 16; 15, 24; 16, call; 16, 17; 16, 22; 17, attribute; 17, 18; 17, 21; 18, attribute; 18, 19; 18, 20; 19, identifier:os; 20, identifier:path; 21, identifier:abspath; 22, argument_list; 22, 23; 23, identifier:sam; 24, identifier:rsplit; 25, argument_list; 25, 26; 25, 27; 26, string:'/'; 27, integer:1; 28, integer:0; 29, if_statement; 29, 30; 29, 33; 29, 119; 30, comparison_operator:is; 30, 31; 30, 32; 31, identifier:sort; 32, True; 33, block; 33, 34; 33, 49; 33, 112; 34, expression_statement; 34, 35; 35, assignment; 35, 36; 35, 37; 36, identifier:mapping; 37, binary_operator:%; 37, 38; 37, 39; 38, string:'%s.sorted.sam'; 39, parenthesized_expression; 39, 40; 40, subscript; 40, 41; 40, 48; 41, call; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:sam; 44, identifier:rsplit; 45, argument_list; 45, 46; 45, 47; 46, string:'.'; 47, integer:1; 48, integer:0; 49, if_statement; 49, 50; 49, 53; 49, 79; 50, comparison_operator:!=; 50, 51; 50, 52; 51, identifier:sam; 52, string:'-'; 53, block; 53, 54; 54, if_statement; 54, 55; 54, 65; 55, comparison_operator:is; 55, 56; 55, 64; 56, call; 56, 57; 56, 62; 57, attribute; 57, 58; 57, 61; 58, attribute; 58, 59; 58, 60; 59, identifier:os; 60, identifier:path; 61, identifier:exists; 62, argument_list; 62, 63; 63, identifier:mapping; 64, False; 65, block; 65, 66; 66, expression_statement; 66, 67; 67, call; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, identifier:os; 70, identifier:system; 71, argument_list; 71, 72; 72, binary_operator:%; 72, 73; 72, 74; 73, string:"\
sort -k1 --buffer-size=%sG -T %s -o %s %s\
"; 74, tuple; 74, 75; 74, 76; 74, 77; 74, 78; 75, identifier:sbuffer; 76, identifier:tempdir; 77, identifier:mapping; 78, identifier:sam; 79, else_clause; 79, 80; 80, block; 80, 81; 80, 85; 80, 106; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 84; 83, identifier:mapping; 84, string:'stdin-sam.sorted.sam'; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 88; 87, identifier:p; 88, call; 88, 89; 88, 90; 89, identifier:Popen; 90, argument_list; 90, 91; 90, 98; 90, 103; 91, binary_operator:%; 91, 92; 91, 93; 91, 94; 92, string:"sort -k1 --buffer-size=%sG -T %s -o %s"; 93, line_continuation:\; 94, tuple; 94, 95; 94, 96; 94, 97; 95, identifier:sbuffer; 96, identifier:tempdir; 97, identifier:mapping; 98, keyword_argument; 98, 99; 98, 100; 99, identifier:stdin; 100, attribute; 100, 101; 100, 102; 101, identifier:sys; 102, identifier:stdin; 103, keyword_argument; 103, 104; 103, 105; 104, identifier:shell; 105, True; 106, expression_statement; 106, 107; 107, call; 107, 108; 107, 111; 108, attribute; 108, 109; 108, 110; 109, identifier:p; 110, identifier:communicate; 111, argument_list; 112, expression_statement; 112, 113; 113, assignment; 113, 114; 113, 115; 114, identifier:mapping; 115, call; 115, 116; 115, 117; 116, identifier:open; 117, argument_list; 117, 118; 118, identifier:mapping; 119, else_clause; 119, 120; 120, block; 120, 121; 121, if_statement; 121, 122; 121, 125; 121, 132; 122, comparison_operator:==; 122, 123; 122, 124; 123, identifier:sam; 124, string:'-'; 125, block; 125, 126; 126, expression_statement; 126, 127; 127, assignment; 127, 128; 127, 129; 128, identifier:mapping; 129, attribute; 129, 130; 129, 131; 130, identifier:sys; 131, identifier:stdin; 132, else_clause; 132, 133; 133, block; 133, 134; 134, expression_statement; 134, 135; 135, assignment; 135, 136; 135, 137; 136, identifier:mapping; 137, call; 137, 138; 137, 139; 138, identifier:open; 139, argument_list; 139, 140; 140, identifier:sam; 141, return_statement; 141, 142; 142, identifier:mapping | 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 %s -o %s %s\
" % (sbuffer, tempdir, mapping, sam))
else:
mapping = 'stdin-sam.sorted.sam'
p = Popen("sort -k1 --buffer-size=%sG -T %s -o %s" \
% (sbuffer, tempdir, mapping), stdin = sys.stdin, shell = True)
p.communicate()
mapping = open(mapping)
else:
if sam == '-':
mapping = sys.stdin
else:
mapping = open(sam)
return mapping |
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, identifier:nodes; 12, block; 12, 13; 12, 22; 12, 26; 12, 213; 13, if_statement; 13, 14; 13, 17; 14, comparison_operator:is; 14, 15; 14, 16; 15, identifier:cluster; 16, True; 17, block; 17, 18; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:threads; 21, string:'48'; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 25; 24, identifier:btc; 25, list:[]; 26, for_statement; 26, 27; 26, 28; 26, 29; 27, identifier:fa; 28, identifier:fas; 29, block; 29, 30; 29, 38; 29, 45; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 33; 32, identifier:btd; 33, call; 33, 34; 33, 35; 34, identifier:bowtiedb; 35, argument_list; 35, 36; 35, 37; 36, identifier:fa; 37, identifier:keepDB; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 44; 40, pattern_list; 40, 41; 40, 42; 40, 43; 41, identifier:F; 42, identifier:R; 43, identifier:U; 44, identifier:reads; 45, if_statement; 45, 46; 45, 49; 45, 142; 46, comparison_operator:is; 46, 47; 46, 48; 47, identifier:F; 48, False; 49, block; 49, 50; 49, 59; 50, if_statement; 50, 51; 50, 54; 51, comparison_operator:is; 51, 52; 51, 53; 52, identifier:U; 53, False; 54, block; 54, 55; 55, expression_statement; 55, 56; 56, assignment; 56, 57; 56, 58; 57, identifier:u; 58, False; 59, for_statement; 59, 60; 59, 63; 59, 67; 60, pattern_list; 60, 61; 60, 62; 61, identifier:i; 62, identifier:f; 63, call; 63, 64; 63, 65; 64, identifier:enumerate; 65, argument_list; 65, 66; 66, identifier:F; 67, block; 67, 68; 67, 74; 67, 85; 67, 125; 68, expression_statement; 68, 69; 69, assignment; 69, 70; 69, 71; 70, identifier:r; 71, subscript; 71, 72; 71, 73; 72, identifier:R; 73, identifier:i; 74, if_statement; 74, 75; 74, 78; 75, comparison_operator:is; 75, 76; 75, 77; 76, identifier:U; 77, False; 78, block; 78, 79; 79, expression_statement; 79, 80; 80, assignment; 80, 81; 80, 82; 81, identifier:u; 82, subscript; 82, 83; 82, 84; 83, identifier:U; 84, identifier:i; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 88; 87, identifier:sam; 88, binary_operator:%; 88, 89; 88, 90; 89, string:'%s/%s-vs-%s'; 90, tuple; 90, 91; 90, 96; 90, 97; 90, 107; 91, call; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:os; 94, identifier:getcwd; 95, argument_list; 96, line_continuation:\; 97, subscript; 97, 98; 97, 105; 98, call; 98, 99; 98, 102; 99, attribute; 99, 100; 99, 101; 100, identifier:fa; 101, identifier:rsplit; 102, argument_list; 102, 103; 102, 104; 103, string:'/'; 104, integer:1; 105, unary_operator:-; 105, 106; 106, integer:1; 107, subscript; 107, 108; 107, 124; 108, call; 108, 109; 108, 121; 109, attribute; 109, 110; 109, 120; 110, subscript; 110, 111; 110, 118; 111, call; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, identifier:f; 114, identifier:rsplit; 115, argument_list; 115, 116; 115, 117; 116, string:'/'; 117, integer:1; 118, unary_operator:-; 118, 119; 119, integer:1; 120, identifier:rsplit; 121, argument_list; 121, 122; 121, 123; 122, string:'.'; 123, integer:3; 124, integer:0; 125, expression_statement; 125, 126; 126, call; 126, 127; 126, 130; 127, attribute; 127, 128; 127, 129; 128, identifier:btc; 129, identifier:append; 130, argument_list; 130, 131; 131, call; 131, 132; 131, 133; 132, identifier:bowtie; 133, argument_list; 133, 134; 133, 135; 133, 136; 133, 137; 133, 138; 133, 139; 133, 140; 133, 141; 134, identifier:sam; 135, identifier:btd; 136, identifier:f; 137, identifier:r; 138, identifier:u; 139, identifier:options; 140, identifier:no_shrink; 141, identifier:threads; 142, else_clause; 142, 143; 143, block; 143, 144; 143, 148; 143, 152; 144, expression_statement; 144, 145; 145, assignment; 145, 146; 145, 147; 146, identifier:f; 147, False; 148, expression_statement; 148, 149; 149, assignment; 149, 150; 149, 151; 150, identifier:r; 151, False; 152, for_statement; 152, 153; 152, 154; 152, 155; 153, identifier:u; 154, identifier:U; 155, block; 155, 156; 155, 196; 156, expression_statement; 156, 157; 157, assignment; 157, 158; 157, 159; 158, identifier:sam; 159, binary_operator:%; 159, 160; 159, 161; 160, string:'%s/%s-vs-%s'; 161, tuple; 161, 162; 161, 167; 161, 168; 161, 178; 162, call; 162, 163; 162, 166; 163, attribute; 163, 164; 163, 165; 164, identifier:os; 165, identifier:getcwd; 166, argument_list; 167, line_continuation:\; 168, subscript; 168, 169; 168, 176; 169, call; 169, 170; 169, 173; 170, attribute; 170, 171; 170, 172; 171, identifier:fa; 172, identifier:rsplit; 173, argument_list; 173, 174; 173, 175; 174, string:'/'; 175, integer:1; 176, unary_operator:-; 176, 177; 177, integer:1; 178, subscript; 178, 179; 178, 195; 179, call; 179, 180; 179, 192; 180, attribute; 180, 181; 180, 191; 181, subscript; 181, 182; 181, 189; 182, call; 182, 183; 182, 186; 183, attribute; 183, 184; 183, 185; 184, identifier:u; 185, identifier:rsplit; 186, argument_list; 186, 187; 186, 188; 187, string:'/'; 188, integer:1; 189, unary_operator:-; 189, 190; 190, integer:1; 191, identifier:rsplit; 192, argument_list; 192, 193; 192, 194; 193, string:'.'; 194, integer:3; 195, integer:0; 196, expression_statement; 196, 197; 197, call; 197, 198; 197, 201; 198, attribute; 198, 199; 198, 200; 199, identifier:btc; 200, identifier:append; 201, argument_list; 201, 202; 202, call; 202, 203; 202, 204; 203, identifier:bowtie; 204, argument_list; 204, 205; 204, 206; 204, 207; 204, 208; 204, 209; 204, 210; 204, 211; 204, 212; 205, identifier:sam; 206, identifier:btd; 207, identifier:f; 208, identifier:r; 209, identifier:u; 210, identifier:options; 211, identifier:no_shrink; 212, identifier:threads; 213, if_statement; 213, 214; 213, 217; 213, 240; 214, comparison_operator:is; 214, 215; 214, 216; 215, identifier:cluster; 216, False; 217, block; 217, 218; 218, for_statement; 218, 219; 218, 220; 218, 221; 219, identifier:i; 220, identifier:btc; 221, block; 221, 222; 221, 234; 222, expression_statement; 222, 223; 223, assignment; 223, 224; 223, 225; 224, identifier:p; 225, call; 225, 226; 225, 229; 226, attribute; 226, 227; 226, 228; 227, identifier:subprocess; 228, identifier:Popen; 229, argument_list; 229, 230; 229, 231; 230, identifier:i; 231, keyword_argument; 231, 232; 231, 233; 232, identifier:shell; 233, True; 234, expression_statement; 234, 235; 235, call; 235, 236; 235, 239; 236, attribute; 236, 237; 236, 238; 237, identifier:p; 238, identifier:communicate; 239, argument_list; 240, else_clause; 240, 241; 241, block; 241, 242; 241, 273; 242, expression_statement; 242, 243; 243, assignment; 243, 244; 243, 245; 244, identifier:ID; 245, call; 245, 246; 245, 249; 246, attribute; 246, 247; 246, 248; 247, string:''; 248, identifier:join; 249, generator_expression; 249, 250; 249, 267; 250, call; 250, 251; 250, 254; 251, attribute; 251, 252; 251, 253; 252, identifier:random; 253, identifier:choice; 254, argument_list; 254, 255; 255, list_comprehension; 255, 256; 255, 260; 256, call; 256, 257; 256, 258; 257, identifier:str; 258, argument_list; 258, 259; 259, identifier:i; 260, for_in_clause; 260, 261; 260, 262; 261, identifier:i; 262, call; 262, 263; 262, 264; 263, identifier:range; 264, argument_list; 264, 265; 264, 266; 265, integer:0; 266, integer:9; 267, for_in_clause; 267, 268; 267, 269; 268, identifier:_; 269, call; 269, 270; 269, 271; 270, identifier:range; 271, argument_list; 271, 272; 272, integer:5; 273, for_statement; 273, 274; 273, 277; 273, 286; 274, pattern_list; 274, 275; 274, 276; 275, identifier:node; 276, identifier:commands; 277, call; 277, 278; 277, 279; 278, identifier:enumerate; 279, argument_list; 279, 280; 279, 285; 280, call; 280, 281; 280, 282; 281, identifier:chunks; 282, argument_list; 282, 283; 282, 284; 283, identifier:btc; 284, identifier:nodes; 285, integer:1; 286, block; 286, 287; 286, 304; 286, 317; 286, 323; 286, 342; 287, expression_statement; 287, 288; 288, assignment; 288, 289; 288, 290; 289, identifier:bs; 290, call; 290, 291; 290, 292; 291, identifier:open; 292, argument_list; 292, 293; 292, 303; 293, binary_operator:%; 293, 294; 293, 295; 294, string:'%s/crossmap-qsub.%s.%s.sh'; 295, tuple; 295, 296; 295, 301; 295, 302; 296, call; 296, 297; 296, 300; 297, attribute; 297, 298; 297, 299; 298, identifier:os; 299, identifier:getcwd; 300, argument_list; 301, identifier:ID; 302, identifier:node; 303, string:'w'; 304, expression_statement; 304, 305; 305, call; 305, 306; 305, 307; 306, identifier:print; 307, argument_list; 307, 308; 307, 314; 308, call; 308, 309; 308, 312; 309, attribute; 309, 310; 309, 311; 310, string:'\n'; 311, identifier:join; 312, argument_list; 312, 313; 313, identifier:commands; 314, keyword_argument; 314, 315; 314, 316; 315, identifier:file; 316, identifier:bs; 317, expression_statement; 317, 318; 318, call; 318, 319; 318, 322; 319, attribute; 319, 320; 319, 321; 320, identifier:bs; 321, identifier:close; 322, argument_list; 323, expression_statement; 323, 324; 324, assignment; 324, 325; 324, 326; 325, identifier:p; 326, call; 326, 327; 326, 330; 327, attribute; 327, 328; 327, 329; 328, identifier:subprocess; 329, identifier:Popen; 330, argument_list; 330, 331; 330, 338; 330, 339; 331, binary_operator:%; 331, 332; 331, 333; 331, 334; 332, string:'qsub -V -N crossmap %s'; 333, line_continuation:\; 334, parenthesized_expression; 334, 335; 335, attribute; 335, 336; 335, 337; 336, identifier:bs; 337, identifier:name; 338, line_continuation:\; 339, keyword_argument; 339, 340; 339, 341; 340, identifier:shell; 341, True; 342, expression_statement; 342, 343; 343, call; 343, 344; 343, 347; 344, attribute; 344, 345; 344, 346; 345, identifier:p; 346, identifier:communicate; 347, argument_list | 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 enumerate(F):
r = R[i]
if U is not False:
u = U[i]
sam = '%s/%s-vs-%s' % (os.getcwd(), \
fa.rsplit('/', 1)[-1], f.rsplit('/', 1)[-1].rsplit('.', 3)[0])
btc.append(bowtie(sam, btd, f, r, u, options, no_shrink, threads))
else:
f = False
r = False
for u in U:
sam = '%s/%s-vs-%s' % (os.getcwd(), \
fa.rsplit('/', 1)[-1], u.rsplit('/', 1)[-1].rsplit('.', 3)[0])
btc.append(bowtie(sam, btd, f, r, u, options, no_shrink, threads))
if cluster is False:
for i in btc:
p = subprocess.Popen(i, shell = True)
p.communicate()
else:
ID = ''.join(random.choice([str(i) for i in range(0, 9)]) for _ in range(5))
for node, commands in enumerate(chunks(btc, nodes), 1):
bs = open('%s/crossmap-qsub.%s.%s.sh' % (os.getcwd(), ID, node), 'w')
print('\n'.join(commands), file=bs)
bs.close()
p = subprocess.Popen(\
'qsub -V -N crossmap %s' \
% (bs.name), \
shell = True)
p.communicate() |
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, 12; 11, identifier:in_data; 12, identifier:str; 13, block; 13, 14; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 17; 16, identifier:in_data; 17, list_comprehension; 17, 18; 17, 22; 18, call; 18, 19; 18, 20; 19, identifier:ord; 20, argument_list; 20, 21; 21, identifier:c; 22, for_in_clause; 22, 23; 22, 24; 23, identifier:c; 24, identifier:in_data; 25, expression_statement; 25, 26; 26, assignment; 26, 27; 26, 28; 27, identifier:register; 28, attribute; 28, 29; 28, 30; 29, identifier:self; 30, identifier:NonDirectInit; 31, for_statement; 31, 32; 31, 33; 31, 34; 32, identifier:octet; 33, identifier:in_data; 34, block; 34, 35; 34, 50; 35, if_statement; 35, 36; 35, 39; 36, attribute; 36, 37; 36, 38; 37, identifier:self; 38, identifier:ReflectIn; 39, block; 39, 40; 40, expression_statement; 40, 41; 41, assignment; 41, 42; 41, 43; 42, identifier:octet; 43, call; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:self; 46, identifier:reflect; 47, argument_list; 47, 48; 47, 49; 48, identifier:octet; 49, integer:8; 50, for_statement; 50, 51; 50, 52; 50, 56; 51, identifier:i; 52, call; 52, 53; 52, 54; 53, identifier:range; 54, argument_list; 54, 55; 55, integer:8; 56, block; 56, 57; 56, 65; 56, 88; 57, expression_statement; 57, 58; 58, assignment; 58, 59; 58, 60; 59, identifier:topbit; 60, binary_operator:&; 60, 61; 60, 62; 61, identifier:register; 62, attribute; 62, 63; 62, 64; 63, identifier:self; 64, identifier:MSB_Mask; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:register; 68, binary_operator:|; 68, 69; 68, 78; 69, parenthesized_expression; 69, 70; 70, binary_operator:&; 70, 71; 70, 75; 71, parenthesized_expression; 71, 72; 72, binary_operator:<<; 72, 73; 72, 74; 73, identifier:register; 74, integer:1; 75, attribute; 75, 76; 75, 77; 76, identifier:self; 77, identifier:Mask; 78, parenthesized_expression; 78, 79; 79, binary_operator:&; 79, 80; 79, 87; 80, parenthesized_expression; 80, 81; 81, binary_operator:>>; 81, 82; 81, 83; 82, identifier:octet; 83, parenthesized_expression; 83, 84; 84, binary_operator:-; 84, 85; 84, 86; 85, integer:7; 86, identifier:i; 87, integer:0x01; 88, if_statement; 88, 89; 88, 90; 89, identifier:topbit; 90, block; 90, 91; 91, expression_statement; 91, 92; 92, augmented_assignment:^=; 92, 93; 92, 94; 93, identifier:register; 94, attribute; 94, 95; 94, 96; 95, identifier:self; 96, identifier:Poly; 97, for_statement; 97, 98; 97, 99; 97, 105; 98, identifier:i; 99, call; 99, 100; 99, 101; 100, identifier:range; 101, argument_list; 101, 102; 102, attribute; 102, 103; 102, 104; 103, identifier:self; 104, identifier:Width; 105, block; 105, 106; 105, 114; 105, 126; 106, expression_statement; 106, 107; 107, assignment; 107, 108; 107, 109; 108, identifier:topbit; 109, binary_operator:&; 109, 110; 109, 111; 110, identifier:register; 111, attribute; 111, 112; 111, 113; 112, identifier:self; 113, identifier:MSB_Mask; 114, expression_statement; 114, 115; 115, assignment; 115, 116; 115, 117; 116, identifier:register; 117, parenthesized_expression; 117, 118; 118, binary_operator:&; 118, 119; 118, 123; 119, parenthesized_expression; 119, 120; 120, binary_operator:<<; 120, 121; 120, 122; 121, identifier:register; 122, integer:1; 123, attribute; 123, 124; 123, 125; 124, identifier:self; 125, identifier:Mask; 126, if_statement; 126, 127; 126, 128; 127, identifier:topbit; 128, block; 128, 129; 129, expression_statement; 129, 130; 130, augmented_assignment:^=; 130, 131; 130, 132; 131, identifier:register; 132, attribute; 132, 133; 132, 134; 133, identifier:self; 134, identifier:Poly; 135, if_statement; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:self; 138, identifier:ReflectOut; 139, block; 139, 140; 140, expression_statement; 140, 141; 141, assignment; 141, 142; 141, 143; 142, identifier:register; 143, call; 143, 144; 143, 147; 144, attribute; 144, 145; 144, 146; 145, identifier:self; 146, identifier:reflect; 147, argument_list; 147, 148; 147, 149; 148, identifier:register; 149, attribute; 149, 150; 149, 151; 150, identifier:self; 151, identifier:Width; 152, return_statement; 152, 153; 153, binary_operator:^; 153, 154; 153, 155; 154, identifier:register; 155, attribute; 155, 156; 155, 157; 156, identifier:self; 157, identifier:XorOut | 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 = register & self.MSB_Mask
register = ((register << 1) & self.Mask) | ((octet >> (7 - i)) & 0x01)
if topbit:
register ^= self.Poly
for i in range(self.Width):
topbit = register & self.MSB_Mask
register = ((register << 1) & self.Mask)
if topbit:
register ^= self.Poly
if self.ReflectOut:
register = self.reflect(register, self.Width)
return register ^ self.XorOut |
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, 12; 11, 13; 11, 14; 12, identifier:table; 13, identifier:tables; 14, block; 14, 15; 15, for_statement; 15, 16; 15, 17; 15, 21; 16, identifier:line; 17, call; 17, 18; 17, 19; 18, identifier:open; 19, argument_list; 19, 20; 20, identifier:table; 21, block; 21, 22; 21, 35; 21, 62; 21, 76; 21, 87; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 25; 24, identifier:line; 25, call; 25, 26; 25, 33; 26, attribute; 26, 27; 26, 32; 27, call; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:line; 30, identifier:strip; 31, argument_list; 32, identifier:split; 33, argument_list; 33, 34; 34, string:'\t'; 35, if_statement; 35, 36; 35, 44; 36, call; 36, 37; 36, 42; 37, attribute; 37, 38; 37, 41; 38, subscript; 38, 39; 38, 40; 39, identifier:line; 40, integer:0; 41, identifier:startswith; 42, argument_list; 42, 43; 43, string:'name'; 44, block; 44, 45; 44, 49; 44, 55; 44, 61; 45, expression_statement; 45, 46; 46, assignment; 46, 47; 46, 48; 47, identifier:header; 48, identifier:line; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 54; 51, subscript; 51, 52; 51, 53; 52, identifier:header; 53, integer:4; 54, string:'genome size (bp)'; 55, expression_statement; 55, 56; 56, assignment; 56, 57; 56, 60; 57, subscript; 57, 58; 57, 59; 58, identifier:header; 59, integer:12; 60, string:'
header[13] = '; 61, continue_statement; 62, expression_statement; 62, 63; 63, assignment; 63, 64; 63, 68; 64, pattern_list; 64, 65; 64, 66; 64, 67; 65, identifier:name; 66, identifier:code; 67, identifier:info; 68, expression_list; 68, 69; 68, 72; 68, 75; 69, subscript; 69, 70; 69, 71; 70, identifier:line; 71, integer:0; 72, subscript; 72, 73; 72, 74; 73, identifier:line; 74, integer:1; 75, identifier:line; 76, expression_statement; 76, 77; 77, assignment; 77, 78; 77, 79; 78, identifier:info; 79, list_comprehension; 79, 80; 79, 84; 80, call; 80, 81; 80, 82; 81, identifier:to_int; 82, argument_list; 82, 83; 83, identifier:i; 84, for_in_clause; 84, 85; 84, 86; 85, identifier:i; 86, identifier:info; 87, if_statement; 87, 88; 87, 91; 87, 167; 88, comparison_operator:is; 88, 89; 88, 90; 89, identifier:id_type; 90, False; 91, block; 91, 92; 91, 105; 91, 144; 92, if_statement; 92, 93; 92, 100; 93, boolean_operator:or; 93, 94; 93, 97; 94, comparison_operator:in; 94, 95; 94, 96; 95, string:'UNK'; 96, identifier:code; 97, comparison_operator:in; 97, 98; 97, 99; 98, string:'unknown'; 99, identifier:code; 100, block; 100, 101; 101, expression_statement; 101, 102; 102, assignment; 102, 103; 102, 104; 103, identifier:code; 104, identifier:name; 105, if_statement; 105, 106; 105, 117; 105, 143; 106, boolean_operator:and; 106, 107; 106, 111; 107, parenthesized_expression; 107, 108; 108, comparison_operator:!=; 108, 109; 108, 110; 109, identifier:name; 110, identifier:code; 111, parenthesized_expression; 111, 112; 112, boolean_operator:and; 112, 113; 112, 114; 113, identifier:name; 114, comparison_operator:in; 114, 115; 114, 116; 115, identifier:code; 116, identifier:g2info; 117, ERROR; 117, 118; 117, 123; 117, 130; 118, call; 118, 119; 118, 120; 118, 122; 119, string:'
print('; 120, ERROR; 120, 121; 121, identifier:exit; 122, argument_list; 123, ERROR; 123, 124; 123, 127; 124, comparison_operator:not; 124, 125; 124, 126; 125, identifier:name; 126, identifier:g2info; 127, subscript; 127, 128; 127, 129; 128, identifier:g2info; 129, identifier:name; 130, dictionary_comprehension; 130, 131; 130, 134; 131, pair; 131, 132; 131, 133; 132, identifier:item; 133, identifier:stat; 134, for_in_clause; 134, 135; 134, 138; 135, pattern_list; 135, 136; 135, 137; 136, identifier:item; 137, identifier:stat; 138, call; 138, 139; 138, 140; 139, identifier:zip; 140, argument_list; 140, 141; 140, 142; 141, identifier:header; 142, identifier:info; 143, block:; 144, if_statement; 144, 145; 144, 148; 145, comparison_operator:not; 145, 146; 145, 147; 146, identifier:code; 147, identifier:g2info; 148, block; 148, 149; 149, expression_statement; 149, 150; 150, assignment; 150, 151; 150, 154; 151, subscript; 151, 152; 151, 153; 152, identifier:g2info; 153, identifier:code; 154, dictionary_comprehension; 154, 155; 154, 158; 155, pair; 155, 156; 155, 157; 156, identifier:item; 157, identifier:stat; 158, for_in_clause; 158, 159; 158, 162; 159, pattern_list; 159, 160; 159, 161; 160, identifier:item; 161, identifier:stat; 162, call; 162, 163; 162, 164; 163, identifier:zip; 164, argument_list; 164, 165; 164, 166; 165, identifier:header; 166, identifier:info; 167, else_clause; 167, 168; 168, block; 168, 169; 169, if_statement; 169, 170; 169, 173; 169, 178; 169, 187; 170, comparison_operator:==; 170, 171; 170, 172; 171, identifier:id_type; 172, string:'name'; 173, block; 173, 174; 174, expression_statement; 174, 175; 175, assignment; 175, 176; 175, 177; 176, identifier:ID; 177, identifier:name; 178, elif_clause; 178, 179; 178, 182; 179, comparison_operator:==; 179, 180; 179, 181; 180, identifier:id_type; 181, string:'code'; 182, block; 182, 183; 183, expression_statement; 183, 184; 184, assignment; 184, 185; 184, 186; 185, identifier:ID; 186, identifier:code; 187, else_clause; 187, 188; 187, 231; 188, ERROR; 188, 189; 188, 204; 188, 217; 188, 230; 189, ERROR; 189, 190; 189, 193; 189, 194; 189, 201; 190, call; 190, 191; 190, 192; 191, identifier:exit; 192, argument_list; 193, identifier:ID; 194, call; 194, 195; 194, 198; 195, attribute; 195, 196; 195, 197; 196, identifier:ID; 197, identifier:replace; 198, argument_list; 198, 199; 198, 200; 199, string:' '; 200, string:''; 201, subscript; 201, 202; 201, 203; 202, identifier:g2info; 203, identifier:ID; 204, dictionary_comprehension; 204, 205; 204, 208; 205, pair; 205, 206; 205, 207; 206, identifier:item; 207, identifier:stat; 208, for_in_clause; 208, 209; 208, 212; 209, pattern_list; 209, 210; 209, 211; 210, identifier:item; 211, identifier:stat; 212, call; 212, 213; 212, 214; 213, identifier:zip; 214, argument_list; 214, 215; 214, 216; 215, identifier:header; 216, identifier:info; 217, ERROR; 217, 218; 217, 225; 218, comparison_operator:==; 218, 219; 218, 224; 219, subscript; 219, 220; 219, 223; 220, subscript; 220, 221; 220, 222; 221, identifier:g2info; 222, identifier:ID; 223, string:'genome size (bp)'; 224, string:''; 225, subscript; 225, 226; 225, 229; 226, subscript; 226, 227; 226, 228; 227, identifier:g2info; 228, identifier:ID; 229, string:'genome size (bp)'; 230, integer:0; 231, block:; 232, return_statement; 232, 233; 233, identifier:g2info | 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] = '
header[13] = '
continue
name, code, info = line[0], line[1], line
info = [to_int(i) for i in info]
if id_type is False:
if 'UNK' in code or 'unknown' in code:
code = name
if (name != code) and (name and code in g2info):
print('
print('
exit()
if name not in g2info:
g2info[name] = {item:stat for item, stat in zip(header, info)}
if code not in g2info:
g2info[code] = {item:stat for item, stat in zip(header, info)}
else:
if id_type == 'name':
ID = name
elif id_type == 'code':
ID = code
else:
print('
exit()
ID = ID.replace(' ', '')
g2info[ID] = {item:stat for item, stat in zip(header, info)}
if g2info[ID]['genome size (bp)'] == '':
g2info[ID]['genome size (bp)'] = 0
return g2info |
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; 12, identifier:hits; 13, identifier:sort; 14, argument_list; 14, 15; 14, 21; 15, keyword_argument; 15, 16; 15, 17; 16, identifier:key; 17, call; 17, 18; 17, 19; 18, identifier:itemgetter; 19, argument_list; 19, 20; 20, identifier:column; 21, keyword_argument; 21, 22; 21, 23; 22, identifier:reverse; 23, identifier:reverse; 24, for_statement; 24, 25; 24, 26; 24, 32; 25, identifier:hit; 26, subscript; 26, 27; 26, 28; 27, identifier:hits; 28, slice; 28, 29; 28, 30; 28, 31; 29, integer:0; 30, colon; 31, identifier:num; 32, block; 32, 33; 33, expression_statement; 33, 34; 34, yield; 34, 35; 35, identifier:hit | 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, 11; 10, 12; 11, identifier:header; 12, list:['
'qstart', 'qend', 'tstart', 'tend', 'evalue', 'bitscore']; 12, 13; 12, 30; 13, concatenated_string; 13, 14; 13, 15; 13, 17; 13, 18; 13, 20; 13, 21; 13, 23; 13, 24; 13, 26; 13, 27; 13, 29; 14, string:'
'; 15, ERROR; 15, 16; 16, identifier:qstart; 17, string:', '; 18, ERROR; 18, 19; 19, identifier:qend; 20, string:', '; 21, ERROR; 21, 22; 22, identifier:tstart; 23, string:', '; 24, ERROR; 24, 25; 25, identifier:tend; 26, string:', '; 27, ERROR; 27, 28; 28, identifier:evalue; 29, string:', '; 30, ERROR; 30, 31; 31, identifier:bitscore; 32, expression_statement; 32, 33; 33, yield; 33, 34; 34, identifier:header; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 38; 37, identifier:hmm; 38, dictionary_comprehension; 38, 39; 38, 42; 39, pair; 39, 40; 39, 41; 40, identifier:h; 41, list:[]; 42, for_in_clause; 42, 43; 42, 44; 43, identifier:h; 44, identifier:header; 45, for_statement; 45, 46; 45, 47; 45, 48; 46, identifier:line; 47, identifier:blast; 48, block; 48, 49; 48, 107; 48, 117; 49, if_statement; 49, 50; 49, 53; 49, 105; 50, attribute; 50, 51; 50, 52; 51, identifier:line; 52, identifier:startswith; 53, ERROR; 53, 54; 53, 56; 53, 72; 53, 76; 53, 82; 53, 88; 53, 90; 53, 95; 53, 98; 54, ERROR; 54, 55; 55, identifier:continue; 56, keyword_argument; 56, 57; 56, 58; 57, identifier:line; 58, subscript; 58, 59; 58, 69; 58, 71; 59, call; 59, 60; 59, 67; 60, attribute; 60, 61; 60, 66; 61, call; 61, 62; 61, 65; 62, attribute; 62, 63; 62, 64; 63, identifier:line; 64, identifier:strip; 65, argument_list; 66, identifier:split; 67, argument_list; 67, 68; 68, string:'\t'; 69, ERROR; 69, 70; 70, identifier:line; 71, integer:10; 72, ERROR; 72, 73; 73, subscript; 73, 74; 73, 75; 74, identifier:line; 75, integer:11; 76, call; 76, 77; 76, 78; 77, identifier:float; 78, argument_list; 78, 79; 79, subscript; 79, 80; 79, 81; 80, identifier:line; 81, integer:10; 82, call; 82, 83; 82, 84; 83, identifier:float; 84, argument_list; 84, 85; 85, subscript; 85, 86; 85, 87; 86, identifier:line; 87, integer:11; 88, ERROR; 88, 89; 89, identifier:evalue; 90, keyword_argument; 90, 91; 90, 92; 91, identifier:bit; 92, subscript; 92, 93; 92, 94; 93, identifier:line; 94, integer:10; 95, subscript; 95, 96; 95, 97; 96, identifier:line; 97, integer:11; 98, boolean_operator:and; 98, 99; 98, 102; 99, comparison_operator:is; 99, 100; 99, 101; 100, identifier:evalueT; 101, False; 102, comparison_operator:>; 102, 103; 102, 104; 103, identifier:evalue; 104, identifier:evalueT; 105, block; 105, 106; 106, continue_statement; 107, if_statement; 107, 108; 107, 115; 108, boolean_operator:and; 108, 109; 108, 112; 109, comparison_operator:is; 109, 110; 109, 111; 110, identifier:bitT; 111, False; 112, comparison_operator:<; 112, 113; 112, 114; 113, identifier:bit; 114, identifier:bitT; 115, block; 115, 116; 116, continue_statement; 117, for_statement; 117, 118; 117, 121; 117, 126; 118, pattern_list; 118, 119; 118, 120; 119, identifier:i; 120, identifier:h; 121, call; 121, 122; 121, 123; 122, identifier:zip; 123, argument_list; 123, 124; 123, 125; 124, identifier:line; 125, identifier:header; 126, block; 126, 127; 127, expression_statement; 127, 128; 128, call; 128, 129; 128, 134; 129, attribute; 129, 130; 129, 133; 130, subscript; 130, 131; 130, 132; 131, identifier:hmm; 132, identifier:h; 133, identifier:append; 134, argument_list; 134, 135; 135, identifier:i; 136, expression_statement; 136, 137; 137, assignment; 137, 138; 137, 139; 138, identifier:hmm; 139, call; 139, 140; 139, 143; 140, attribute; 140, 141; 140, 142; 141, identifier:pd; 142, identifier:DataFrame; 143, argument_list; 143, 144; 144, identifier:hmm; 145, for_statement; 145, 146; 145, 149; 145, 177; 146, pattern_list; 146, 147; 146, 148; 147, identifier:query; 148, identifier:df; 149, comparison_operator:in; 149, 150; 149, 164; 149, 167; 150, call; 150, 151; 150, 154; 151, attribute; 151, 152; 151, 153; 152, identifier:hmm; 153, identifier:groupby; 154, argument_list; 154, 155; 154, 161; 155, keyword_argument; 155, 156; 155, 157; 156, identifier:by; 157, list:['
df = df.sort_values(by = ['bitscore']; 157, 158; 157, 159; 158, string:'
df = df.sort_values(by = ['; 159, ERROR; 159, 160; 160, identifier:bitscore; 161, keyword_argument; 161, 162; 161, 163; 162, identifier:ascending; 163, False; 164, ERROR; 164, 165; 164, 166; 165, identifier:for; 166, identifier:hit; 167, subscript; 167, 168; 167, 173; 168, attribute; 168, 169; 168, 172; 169, subscript; 169, 170; 169, 171; 170, identifier:df; 171, identifier:header; 172, identifier:values; 173, slice; 173, 174; 173, 175; 173, 176; 174, integer:0; 175, colon; 176, identifier:numHits; 177, block; 177, 178; 178, expression_statement; 178, 179; 179, yield; 179, 180; 180, identifier:hit | 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], line[11] = float(line[10]), float(line[11])
evalue, bit = line[10], line[11]
if evalueT is not False and evalue > evalueT:
continue
if bitT is not False and bit < bitT:
continue
for i, h in zip(line, header):
hmm[h].append(i)
hmm = pd.DataFrame(hmm)
for query, df in hmm.groupby(by = ['
df = df.sort_values(by = ['bitscore'], ascending = False)
for hit in df[header].values[0:numHits]:
yield hit |
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; 9, 42; 9, 43; 9, 44; 9, 45; 9, 46; 10, if_statement; 10, 11; 10, 14; 11, comparison_operator:is; 11, 12; 11, 13; 12, identifier:sort; 13, True; 14, block; 14, 15; 14, 28; 15, for_statement; 15, 16; 15, 17; 15, 24; 16, identifier:hit; 17, call; 17, 18; 17, 19; 18, identifier:numDomtblout_sort; 19, argument_list; 19, 20; 19, 21; 19, 22; 19, 23; 20, identifier:domtblout; 21, identifier:numHits; 22, identifier:evalueT; 23, identifier:bitT; 24, block; 24, 25; 25, expression_statement; 25, 26; 26, yield; 26, 27; 27, identifier:hit; 28, return_statement; 29, identifier:header; 30, concatenated_string; 30, 31; 30, 32; 30, 35; 30, 36; 30, 39; 31, string:'
'; 32, ERROR; 32, 33; 32, 34; 33, identifier:query; 34, identifier:name; 35, string:', '; 36, ERROR; 36, 37; 36, 38; 37, identifier:query; 38, identifier:accession; 39, string:', '; 40, ERROR; 40, 41; 41, identifier:qlen; 42, string:'full E-value'; 43, string:'full score'; 44, string:'full bias'; 45, ERROR; 46, identifier:domain; 47, block; 47, 48; 47, 53; 47, 60; 48, expression_statement; 48, 49; 48, 50; 48, 51; 48, 52; 49, string:'domain c-Evalue'; 50, string:'domain i-Evalue'; 51, string:'domain score'; 52, string:'domain bias'; 53, expression_statement; 53, 54; 53, 55; 53, 56; 53, 57; 53, 58; 53, 59; 54, string:'hmm from'; 55, string:'hmm to'; 56, string:'seq from'; 57, string:'seq to'; 58, string:'env from'; 59, string:'env to'; 60, ERROR; 60, 61; 61, expression_statement; 61, 62; 61, 63; 62, string:'acc'; 63, string:'target description'; 64, expression_statement; 64, 65; 65, yield; 65, 66; 66, identifier:header; 67, expression_statement; 67, 68; 68, assignment; 68, 69; 68, 72; 69, pattern_list; 69, 70; 69, 71; 70, identifier:prev; 71, identifier:hits; 72, expression_list; 72, 73; 72, 74; 73, None; 74, list:[]; 75, for_statement; 75, 76; 75, 77; 75, 78; 76, identifier:line; 77, identifier:domtblout; 78, block; 78, 79; 78, 199; 78, 263; 79, if_statement; 79, 80; 79, 83; 79, 173; 80, attribute; 80, 81; 80, 82; 81, identifier:line; 82, identifier:startswith; 83, ERROR; 83, 84; 83, 86; 83, 134; 83, 138; 83, 144; 83, 150; 83, 152; 83, 157; 83, 164; 83, 167; 83, 169; 83, 170; 84, ERROR; 84, 85; 85, identifier:continue; 86, keyword_argument; 86, 87; 86, 88; 86, 123; 87, identifier:line; 88, ERROR; 88, 89; 88, 98; 88, 99; 88, 109; 88, 110; 88, 116; 88, 122; 89, call; 89, 90; 89, 97; 90, attribute; 90, 91; 90, 96; 91, call; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:line; 94, identifier:strip; 95, argument_list; 96, identifier:split; 97, argument_list; 98, identifier:desc; 99, call; 99, 100; 99, 103; 100, attribute; 100, 101; 100, 102; 101, string:' '; 102, identifier:join; 103, argument_list; 103, 104; 104, subscript; 104, 105; 104, 106; 105, identifier:line; 106, slice; 106, 107; 106, 108; 107, integer:18; 108, colon; 109, identifier:line; 110, subscript; 110, 111; 110, 112; 111, identifier:line; 112, slice; 112, 113; 112, 114; 112, 115; 113, integer:0; 114, colon; 115, integer:18; 116, call; 116, 117; 116, 120; 117, attribute; 117, 118; 117, 119; 118, identifier:line; 119, identifier:append; 120, argument_list; 120, 121; 121, identifier:desc; 122, identifier:ID; 123, binary_operator:+; 123, 124; 123, 127; 124, subscript; 124, 125; 124, 126; 125, identifier:line; 126, integer:0; 127, subscript; 127, 128; 127, 131; 127, 133; 128, subscript; 128, 129; 128, 130; 129, identifier:line; 130, integer:9; 131, ERROR; 131, 132; 132, identifier:line; 133, integer:11; 134, ERROR; 134, 135; 135, subscript; 135, 136; 135, 137; 136, identifier:line; 137, integer:13; 138, call; 138, 139; 138, 140; 139, identifier:float; 140, argument_list; 140, 141; 141, subscript; 141, 142; 141, 143; 142, identifier:line; 143, integer:11; 144, call; 144, 145; 144, 146; 145, identifier:float; 146, argument_list; 146, 147; 147, subscript; 147, 148; 147, 149; 148, identifier:line; 149, integer:13; 150, ERROR; 150, 151; 151, identifier:evalue; 152, keyword_argument; 152, 153; 152, 154; 153, identifier:bitscore; 154, subscript; 154, 155; 154, 156; 155, identifier:line; 156, integer:11; 157, subscript; 157, 158; 157, 161; 157, 163; 158, subscript; 158, 159; 158, 160; 159, identifier:line; 160, integer:13; 161, ERROR; 161, 162; 162, identifier:line; 163, integer:11; 164, subscript; 164, 165; 164, 166; 165, identifier:line; 166, integer:13; 167, ERROR; 167, 168; 168, identifier:evalue; 169, identifier:bitscore; 170, comparison_operator:!=; 170, 171; 170, 172; 171, identifier:ID; 172, identifier:prev; 173, block; 173, 174; 173, 195; 174, if_statement; 174, 175; 174, 181; 175, comparison_operator:>; 175, 176; 175, 180; 176, call; 176, 177; 176, 178; 177, identifier:len; 178, argument_list; 178, 179; 179, identifier:hits; 180, integer:0; 181, block; 181, 182; 182, for_statement; 182, 183; 182, 184; 182, 191; 183, identifier:hit; 184, call; 184, 185; 184, 186; 185, identifier:top_hits; 186, argument_list; 186, 187; 186, 188; 186, 189; 186, 190; 187, identifier:hits; 188, identifier:numHits; 189, integer:13; 190, True; 191, block; 191, 192; 192, expression_statement; 192, 193; 193, yield; 193, 194; 194, identifier:hit; 195, expression_statement; 195, 196; 196, assignment; 196, 197; 196, 198; 197, identifier:hits; 198, list:[]; 199, if_statement; 199, 200; 199, 207; 199, 215; 199, 231; 199, 247; 200, boolean_operator:and; 200, 201; 200, 204; 201, comparison_operator:==; 201, 202; 201, 203; 202, identifier:evalueT; 203, False; 204, comparison_operator:==; 204, 205; 204, 206; 205, identifier:bitT; 206, False; 207, block; 207, 208; 208, expression_statement; 208, 209; 209, call; 209, 210; 209, 213; 210, attribute; 210, 211; 210, 212; 211, identifier:hits; 212, identifier:append; 213, argument_list; 213, 214; 214, identifier:line; 215, elif_clause; 215, 216; 215, 223; 216, boolean_operator:and; 216, 217; 216, 220; 217, comparison_operator:<=; 217, 218; 217, 219; 218, identifier:evalue; 219, identifier:evalueT; 220, comparison_operator:==; 220, 221; 220, 222; 221, identifier:bitT; 222, False; 223, block; 223, 224; 224, expression_statement; 224, 225; 225, call; 225, 226; 225, 229; 226, attribute; 226, 227; 226, 228; 227, identifier:hits; 228, identifier:append; 229, argument_list; 229, 230; 230, identifier:line; 231, elif_clause; 231, 232; 231, 239; 232, boolean_operator:and; 232, 233; 232, 236; 233, comparison_operator:<=; 233, 234; 233, 235; 234, identifier:evalue; 235, identifier:evalueT; 236, comparison_operator:>=; 236, 237; 236, 238; 237, identifier:bit; 238, identifier:bitT; 239, block; 239, 240; 240, expression_statement; 240, 241; 241, call; 241, 242; 241, 245; 242, attribute; 242, 243; 242, 244; 243, identifier:hits; 244, identifier:append; 245, argument_list; 245, 246; 246, identifier:line; 247, elif_clause; 247, 248; 247, 255; 248, boolean_operator:and; 248, 249; 248, 252; 249, comparison_operator:==; 249, 250; 249, 251; 250, identifier:evalueT; 251, False; 252, comparison_operator:>=; 252, 253; 252, 254; 253, identifier:bit; 254, identifier:bitT; 255, block; 255, 256; 256, expression_statement; 256, 257; 257, call; 257, 258; 257, 261; 258, attribute; 258, 259; 258, 260; 259, identifier:hits; 260, identifier:append; 261, argument_list; 261, 262; 262, identifier:line; 263, expression_statement; 263, 264; 264, assignment; 264, 265; 264, 266; 265, identifier:prev; 266, identifier:ID; 267, for_statement; 267, 268; 267, 269; 267, 276; 267, 281; 268, identifier:hit; 269, call; 269, 270; 269, 271; 270, identifier:top_hits; 271, argument_list; 271, 272; 271, 273; 271, 274; 271, 275; 272, identifier:hits; 273, identifier:numHits; 274, integer:13; 275, True; 276, ERROR; 276, 277; 277, block; 277, 278; 278, expression_statement; 278, 279; 279, yield; 279, 280; 280, identifier:hit; 281, block: | 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',
'domain
'domain c-Evalue', 'domain i-Evalue', 'domain score', 'domain bias',
'hmm from', 'hmm to', 'seq from', 'seq to', 'env from', 'env to',
'acc', 'target description']
yield header
prev, hits = None, []
for line in domtblout:
if line.startswith('
continue
line = line.strip().split()
desc = ' '.join(line[18:])
line = line[0:18]
line.append(desc)
ID = line[0] + line[9]
line[11], line[13] = float(line[11]), float(line[13])
evalue, bitscore = line[11], line[13]
line[11], line[13] = evalue, bitscore
if ID != prev:
if len(hits) > 0:
for hit in top_hits(hits, numHits, 13, True):
yield hit
hits = []
if evalueT == False and bitT == False:
hits.append(line)
elif evalue <= evalueT and bitT == False:
hits.append(line)
elif evalue <= evalueT and bit >= bitT:
hits.append(line)
elif evalueT == False and bit >= bitT:
hits.append(line)
prev = ID
for hit in top_hits(hits, numHits, 13, True):
yield hit |
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, 13; 12, 14; 13, identifier:set; 14, argument_list; 14, 15; 15, list_comprehension; 15, 16; 15, 17; 16, identifier:i; 17, for_in_clause; 17, 18; 17, 19; 18, identifier:i; 19, identifier:pw; 20, for_statement; 20, 21; 20, 22; 20, 27; 21, identifier:i; 22, call; 22, 23; 22, 24; 23, identifier:range; 24, argument_list; 24, 25; 24, 26; 25, integer:0; 26, integer:4; 27, block; 27, 28; 27, 36; 27, 218; 27, 260; 27, 264; 27, 310; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 33; 30, pattern_list; 30, 31; 30, 32; 31, identifier:wi; 32, identifier:bt; 33, expression_list; 33, 34; 33, 35; 34, dictionary; 35, dictionary; 36, for_statement; 36, 37; 36, 38; 36, 39; 37, identifier:a; 38, identifier:names; 39, block; 39, 40; 40, for_statement; 40, 41; 40, 42; 40, 45; 41, identifier:b; 42, subscript; 42, 43; 42, 44; 43, identifier:pw; 44, identifier:a; 45, block; 45, 46; 45, 56; 45, 64; 45, 86; 45, 154; 46, if_statement; 46, 47; 46, 54; 47, boolean_operator:or; 47, 48; 47, 51; 48, comparison_operator:not; 48, 49; 48, 50; 49, string:';'; 50, identifier:a; 51, comparison_operator:not; 51, 52; 51, 53; 52, string:';'; 53, identifier:b; 54, block; 54, 55; 55, continue_statement; 56, expression_statement; 56, 57; 57, assignment; 57, 58; 57, 59; 58, identifier:pident; 59, subscript; 59, 60; 59, 63; 60, subscript; 60, 61; 60, 62; 61, identifier:pw; 62, identifier:a; 63, identifier:b; 64, expression_statement; 64, 65; 65, assignment; 65, 66; 65, 69; 66, pattern_list; 66, 67; 66, 68; 67, identifier:cA; 68, identifier:cB; 69, expression_list; 69, 70; 69, 78; 70, subscript; 70, 71; 70, 77; 71, call; 71, 72; 71, 75; 72, attribute; 72, 73; 72, 74; 73, identifier:a; 74, identifier:split; 75, argument_list; 75, 76; 76, string:';'; 77, identifier:i; 78, subscript; 78, 79; 78, 85; 79, call; 79, 80; 79, 83; 80, attribute; 80, 81; 80, 82; 81, identifier:b; 82, identifier:split; 83, argument_list; 83, 84; 84, string:';'; 85, identifier:i; 86, if_statement; 86, 87; 86, 98; 86, 123; 87, boolean_operator:and; 87, 88; 87, 95; 88, boolean_operator:and; 88, 89; 88, 92; 89, comparison_operator:==; 89, 90; 89, 91; 90, identifier:i; 91, integer:0; 92, comparison_operator:in; 92, 93; 92, 94; 93, string:'_'; 94, identifier:cA; 95, comparison_operator:in; 95, 96; 95, 97; 96, string:'_'; 97, identifier:cB; 98, block; 98, 99; 98, 111; 99, expression_statement; 99, 100; 100, assignment; 100, 101; 100, 102; 101, identifier:cA; 102, subscript; 102, 103; 102, 110; 103, call; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:cA; 106, identifier:rsplit; 107, argument_list; 107, 108; 107, 109; 108, string:'_'; 109, integer:1; 110, integer:1; 111, expression_statement; 111, 112; 112, assignment; 112, 113; 112, 114; 113, identifier:cB; 114, subscript; 114, 115; 114, 122; 115, call; 115, 116; 115, 119; 116, attribute; 116, 117; 116, 118; 117, identifier:cB; 118, identifier:rsplit; 119, argument_list; 119, 120; 119, 121; 120, string:'_'; 121, integer:1; 122, integer:1; 123, elif_clause; 123, 124; 123, 131; 124, boolean_operator:or; 124, 125; 124, 128; 125, comparison_operator:in; 125, 126; 125, 127; 126, string:'>'; 127, identifier:cA; 128, comparison_operator:in; 128, 129; 128, 130; 129, string:'>'; 130, identifier:cB; 131, block; 131, 132; 131, 143; 132, expression_statement; 132, 133; 133, assignment; 133, 134; 133, 135; 134, identifier:cA; 135, subscript; 135, 136; 135, 142; 136, call; 136, 137; 136, 140; 137, attribute; 137, 138; 137, 139; 138, identifier:cA; 139, identifier:split; 140, argument_list; 140, 141; 141, string:'>'; 142, integer:1; 143, expression_statement; 143, 144; 144, assignment; 144, 145; 144, 146; 145, identifier:cB; 146, subscript; 146, 147; 146, 153; 147, call; 147, 148; 147, 151; 148, attribute; 148, 149; 148, 150; 149, identifier:cB; 150, identifier:split; 151, argument_list; 151, 152; 152, string:'>'; 153, integer:1; 154, if_statement; 154, 155; 154, 158; 154, 179; 155, comparison_operator:==; 155, 156; 155, 157; 156, identifier:cA; 157, identifier:cB; 158, block; 158, 159; 158, 170; 159, if_statement; 159, 160; 159, 163; 160, comparison_operator:not; 160, 161; 160, 162; 161, identifier:cA; 162, identifier:wi; 163, block; 163, 164; 164, expression_statement; 164, 165; 165, assignment; 165, 166; 165, 169; 166, subscript; 166, 167; 166, 168; 167, identifier:wi; 168, identifier:cA; 169, list:[]; 170, expression_statement; 170, 171; 171, call; 171, 172; 171, 177; 172, attribute; 172, 173; 172, 176; 173, subscript; 173, 174; 173, 175; 174, identifier:wi; 175, identifier:cA; 176, identifier:append; 177, argument_list; 177, 178; 178, identifier:pident; 179, else_clause; 179, 180; 180, block; 180, 181; 180, 192; 180, 207; 181, if_statement; 181, 182; 181, 185; 182, comparison_operator:not; 182, 183; 182, 184; 183, identifier:cA; 184, identifier:bt; 185, block; 185, 186; 186, expression_statement; 186, 187; 187, assignment; 187, 188; 187, 191; 188, subscript; 188, 189; 188, 190; 189, identifier:bt; 190, identifier:cA; 191, dictionary; 192, if_statement; 192, 193; 192, 198; 193, comparison_operator:not; 193, 194; 193, 195; 194, identifier:cB; 195, subscript; 195, 196; 195, 197; 196, identifier:bt; 197, identifier:cA; 198, block; 198, 199; 199, expression_statement; 199, 200; 200, assignment; 200, 201; 200, 206; 201, subscript; 201, 202; 201, 205; 202, subscript; 202, 203; 202, 204; 203, identifier:bt; 204, identifier:cA; 205, identifier:cB; 206, list:[]; 207, expression_statement; 207, 208; 208, call; 208, 209; 208, 216; 209, attribute; 209, 210; 209, 215; 210, subscript; 210, 211; 210, 214; 211, subscript; 211, 212; 211, 213; 212, identifier:bt; 213, identifier:cA; 214, identifier:cB; 215, identifier:append; 216, argument_list; 216, 217; 217, identifier:pident; 218, expression_statement; 218, 219; 219, assignment; 219, 220; 219, 221; 219, 236; 220, identifier:print; 221, ERROR; 221, 222; 221, 225; 221, 226; 222, ERROR; 222, 223; 222, 224; 223, escape_sequence:\n; 224, identifier:for; 225, identifier:clade; 226, comparison_operator:in; 226, 227; 226, 228; 227, identifier:pidents; 228, call; 228, 229; 228, 230; 229, identifier:list; 230, argument_list; 230, 231; 231, call; 231, 232; 231, 235; 232, attribute; 232, 233; 232, 234; 233, identifier:wi; 234, identifier:items; 235, argument_list; 236, type; 236, 237; 237, call; 237, 238; 237, 239; 238, identifier:print; 239, argument_list; 239, 240; 240, call; 240, 241; 240, 244; 241, attribute; 241, 242; 241, 243; 242, string:'\t'; 243, identifier:join; 244, argument_list; 244, 245; 245, list:['wi:%s' % str(i), clade, str(min(pidents))]; 245, 246; 245, 252; 245, 253; 246, binary_operator:%; 246, 247; 246, 248; 247, string:'wi:%s'; 248, call; 248, 249; 248, 250; 249, identifier:str; 250, argument_list; 250, 251; 251, identifier:i; 252, identifier:clade; 253, call; 253, 254; 253, 255; 254, identifier:str; 255, argument_list; 255, 256; 256, call; 256, 257; 256, 258; 257, identifier:min; 258, argument_list; 258, 259; 259, identifier:pidents; 260, expression_statement; 260, 261; 261, assignment; 261, 262; 261, 263; 262, identifier:comps; 263, list:[]; 264, expression_statement; 264, 265; 265, assignment; 265, 266; 265, 267; 265, 277; 265, 279; 266, identifier:print; 267, ERROR; 267, 268; 267, 271; 268, ERROR; 268, 269; 268, 270; 269, escape_sequence:\n; 270, identifier:for; 271, comparison_operator:in; 271, 272; 271, 273; 272, identifier:comp; 273, call; 273, 274; 273, 275; 274, identifier:print_pairwise; 275, argument_list; 275, 276; 276, identifier:bt; 277, ERROR; 277, 278; 278, identifier:if; 279, type; 279, 280; 280, constrained_type; 280, 281; 280, 285; 281, type; 281, 282; 282, comparison_operator:is; 282, 283; 282, 284; 283, identifier:comp; 284, None; 285, type; 285, 286; 286, call; 286, 287; 286, 288; 287, identifier:print; 288, argument_list; 288, 289; 289, call; 289, 290; 289, 293; 290, attribute; 290, 291; 290, 292; 291, string:'\t'; 292, identifier:join; 293, argument_list; 293, 294; 294, binary_operator:+; 294, 295; 294, 302; 295, list:['bt:%s' % str(i)]; 295, 296; 296, binary_operator:%; 296, 297; 296, 298; 297, string:'bt:%s'; 298, call; 298, 299; 298, 300; 299, identifier:str; 300, argument_list; 300, 301; 301, identifier:i; 302, list_comprehension; 302, 303; 302, 307; 303, call; 303, 304; 303, 305; 304, identifier:str; 305, argument_list; 305, 306; 306, identifier:j; 307, for_in_clause; 307, 308; 307, 309; 308, identifier:j; 309, identifier:comp; 310, ERROR; 310, 311; 310, 314; 310, 315; 310, 316; 310, 320; 310, 322; 310, 323; 310, 338; 310, 340; 310, 343; 310, 367; 311, subscript; 311, 312; 311, 313; 312, identifier:comp; 313, integer:0; 314, string:'
comps.extend([j for j in comp[1:] if j != '; 315, ERROR; 316, call; 316, 317; 316, 318; 317, identifier:print_comps; 318, argument_list; 318, 319; 319, identifier:comps; 320, ERROR; 320, 321; 321, identifier:comps; 322, ERROR; 323, call; 323, 324; 323, 325; 324, identifier:print; 325, argument_list; 325, 326; 325, 329; 326, ERROR; 326, 327; 326, 328; 327, escape_sequence:\n; 328, identifier:for; 329, comparison_operator:in; 329, 330; 329, 331; 330, identifier:comp; 331, call; 331, 332; 331, 333; 332, identifier:print_pairwise; 333, argument_list; 333, 334; 333, 335; 334, identifier:bt; 335, keyword_argument; 335, 336; 335, 337; 336, identifier:median; 337, True; 338, ERROR; 338, 339; 339, identifier:if; 340, comparison_operator:is; 340, 341; 340, 342; 341, identifier:comp; 342, None; 343, call; 343, 344; 343, 345; 344, identifier:print; 345, argument_list; 345, 346; 346, call; 346, 347; 346, 350; 347, attribute; 347, 348; 347, 349; 348, string:'\t'; 349, identifier:join; 350, argument_list; 350, 351; 351, binary_operator:+; 351, 352; 351, 359; 352, list:['bt:%s' % str(i)]; 352, 353; 353, binary_operator:%; 353, 354; 353, 355; 354, string:'bt:%s'; 355, call; 355, 356; 355, 357; 356, identifier:str; 357, argument_list; 357, 358; 358, identifier:i; 359, list_comprehension; 359, 360; 359, 364; 360, call; 360, 361; 360, 362; 361, identifier:str; 362, argument_list; 362, 363; 363, identifier:j; 364, for_in_clause; 364, 365; 364, 366; 365, identifier:j; 366, identifier:comp; 367, comparison_operator:!=; 367, 368; 367, 371; 368, subscript; 368, 369; 368, 370; 369, identifier:comp; 370, integer:0; 371, binary_operator:-; 371, 372; 371, 373; 371, 374; 372, string:'
comps.extend([j for j in comp[1:] if j != '; 373, ERROR; 374, call; 374, 375; 374, 376; 375, identifier:print_comps; 376, argument_list; 376, 377; 377, identifier:comps | 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], b.split(';')[i]
if i == 0 and '_' in cA and '_' in cB:
cA = cA.rsplit('_', 1)[1]
cB = cB.rsplit('_', 1)[1]
elif '>' in cA or '>' in cB:
cA = cA.split('>')[1]
cB = cB.split('>')[1]
if cA == cB:
if cA not in wi:
wi[cA] = []
wi[cA].append(pident)
else:
if cA not in bt:
bt[cA] = {}
if cB not in bt[cA]:
bt[cA][cB] = []
bt[cA][cB].append(pident)
print('\n
for clade, pidents in list(wi.items()):
print('\t'.join(['wi:%s' % str(i), clade, str(min(pidents))]))
comps = []
print('\n
for comp in print_pairwise(bt):
if comp is not None:
print('\t'.join(['bt:%s' % str(i)] + [str(j) for j in comp]))
if comp[0] != '
comps.extend([j for j in comp[1:] if j != '-'])
print_comps(comps)
comps = []
print('\n
for comp in print_pairwise(bt, median = True):
if comp is not None:
print('\t'.join(['bt:%s' % str(i)] + [str(j) for j in comp]))
if comp[0] != '
comps.extend([j for j in comp[1:] if j != '-'])
print_comps(comps) |
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, identifier:error; 11, call; 11, 12; 11, 13; 12, identifier:entrez; 13, argument_list; 13, 14; 13, 15; 14, string:'genome'; 15, identifier:acc; 16, for_statement; 16, 17; 16, 18; 16, 23; 17, identifier:line; 18, call; 18, 19; 18, 22; 19, attribute; 19, 20; 19, 21; 20, identifier:out; 21, identifier:splitlines; 22, argument_list; 23, block; 23, 24; 23, 37; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 27; 26, identifier:line; 27, call; 27, 28; 27, 36; 28, attribute; 28, 29; 28, 35; 29, call; 29, 30; 29, 33; 30, attribute; 30, 31; 30, 32; 31, identifier:line; 32, identifier:decode; 33, argument_list; 33, 34; 34, string:'ascii'; 35, identifier:strip; 36, argument_list; 37, if_statement; 37, 38; 37, 45; 38, boolean_operator:or; 38, 39; 38, 42; 39, comparison_operator:in; 39, 40; 39, 41; 40, string:'Assembly_Accession'; 41, identifier:line; 42, comparison_operator:in; 42, 43; 42, 44; 43, string:'BioSample'; 44, identifier:line; 45, block; 45, 46; 45, 78; 46, expression_statement; 46, 47; 47, assignment; 47, 48; 47, 49; 48, identifier:newAcc; 49, subscript; 49, 50; 49, 77; 50, call; 50, 51; 50, 75; 51, attribute; 51, 52; 51, 74; 52, subscript; 52, 53; 52, 73; 53, call; 53, 54; 53, 71; 54, attribute; 54, 55; 54, 70; 55, subscript; 55, 56; 55, 69; 56, call; 56, 57; 56, 67; 57, attribute; 57, 58; 57, 66; 58, subscript; 58, 59; 58, 65; 59, call; 59, 60; 59, 63; 60, attribute; 60, 61; 60, 62; 61, identifier:line; 62, identifier:split; 63, argument_list; 63, 64; 64, string:'>'; 65, integer:1; 66, identifier:split; 67, argument_list; 67, 68; 68, string:'<'; 69, integer:0; 70, identifier:split; 71, argument_list; 71, 72; 72, string:'.'; 73, integer:0; 74, identifier:split; 75, argument_list; 75, 76; 76, string:','; 77, integer:0; 78, if_statement; 78, 79; 78, 85; 79, comparison_operator:>; 79, 80; 79, 84; 80, call; 80, 81; 80, 82; 81, identifier:len; 82, argument_list; 82, 83; 83, identifier:newAcc; 84, integer:0; 85, block; 85, 86; 86, return_statement; 86, 87; 87, tuple; 87, 88; 87, 89; 87, 90; 88, True; 89, identifier:acc; 90, identifier:newAcc; 91, expression_statement; 91, 92; 92, assignment; 92, 93; 92, 96; 93, pattern_list; 93, 94; 93, 95; 94, identifier:out; 95, identifier:error; 96, call; 96, 97; 96, 98; 97, identifier:entrez; 98, argument_list; 98, 99; 98, 100; 99, string:'nucleotide'; 100, identifier:acc; 101, for_statement; 101, 102; 101, 103; 101, 108; 102, identifier:line; 103, call; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:out; 106, identifier:splitlines; 107, argument_list; 108, block; 108, 109; 108, 122; 109, expression_statement; 109, 110; 110, assignment; 110, 111; 110, 112; 111, identifier:line; 112, call; 112, 113; 112, 121; 113, attribute; 113, 114; 113, 120; 114, call; 114, 115; 114, 118; 115, attribute; 115, 116; 115, 117; 116, identifier:line; 117, identifier:decode; 118, argument_list; 118, 119; 119, string:'ascii'; 120, identifier:strip; 121, argument_list; 122, if_statement; 122, 123; 122, 130; 123, boolean_operator:or; 123, 124; 123, 127; 124, comparison_operator:in; 124, 125; 124, 126; 125, string:'Assembly_Accession'; 126, identifier:line; 127, comparison_operator:in; 127, 128; 127, 129; 128, string:'BioSample'; 129, identifier:line; 130, block; 130, 131; 130, 163; 131, expression_statement; 131, 132; 132, assignment; 132, 133; 132, 134; 133, identifier:newAcc; 134, subscript; 134, 135; 134, 162; 135, call; 135, 136; 135, 160; 136, attribute; 136, 137; 136, 159; 137, subscript; 137, 138; 137, 158; 138, call; 138, 139; 138, 156; 139, attribute; 139, 140; 139, 155; 140, subscript; 140, 141; 140, 154; 141, call; 141, 142; 141, 152; 142, attribute; 142, 143; 142, 151; 143, subscript; 143, 144; 143, 150; 144, call; 144, 145; 144, 148; 145, attribute; 145, 146; 145, 147; 146, identifier:line; 147, identifier:split; 148, argument_list; 148, 149; 149, string:'>'; 150, integer:1; 151, identifier:split; 152, argument_list; 152, 153; 153, string:'<'; 154, integer:0; 155, identifier:split; 156, argument_list; 156, 157; 157, string:'.'; 158, integer:0; 159, identifier:split; 160, argument_list; 160, 161; 161, string:','; 162, integer:0; 163, if_statement; 163, 164; 163, 170; 164, comparison_operator:>; 164, 165; 164, 169; 165, call; 165, 166; 165, 167; 166, identifier:len; 167, argument_list; 167, 168; 168, identifier:newAcc; 169, integer:0; 170, block; 170, 171; 171, return_statement; 171, 172; 172, tuple; 172, 173; 172, 174; 172, 175; 173, True; 174, identifier:acc; 175, identifier:newAcc; 176, expression_statement; 176, 177; 177, assignment; 177, 178; 177, 181; 178, pattern_list; 178, 179; 178, 180; 179, identifier:out; 180, identifier:error; 181, call; 181, 182; 181, 183; 182, identifier:entrez; 183, argument_list; 183, 184; 183, 185; 184, string:'assembly'; 185, identifier:acc; 186, for_statement; 186, 187; 186, 188; 186, 193; 187, identifier:line; 188, call; 188, 189; 188, 192; 189, attribute; 189, 190; 189, 191; 190, identifier:out; 191, identifier:splitlines; 192, argument_list; 193, block; 193, 194; 193, 207; 194, expression_statement; 194, 195; 195, assignment; 195, 196; 195, 197; 196, identifier:line; 197, call; 197, 198; 197, 206; 198, attribute; 198, 199; 198, 205; 199, call; 199, 200; 199, 203; 200, attribute; 200, 201; 200, 202; 201, identifier:line; 202, identifier:decode; 203, argument_list; 203, 204; 204, string:'ascii'; 205, identifier:strip; 206, argument_list; 207, if_statement; 207, 208; 207, 215; 208, boolean_operator:or; 208, 209; 208, 212; 209, comparison_operator:in; 209, 210; 209, 211; 210, string:'Assembly_Accession'; 211, identifier:line; 212, comparison_operator:in; 212, 213; 212, 214; 213, string:'BioSample'; 214, identifier:line; 215, block; 215, 216; 215, 248; 216, expression_statement; 216, 217; 217, assignment; 217, 218; 217, 219; 218, identifier:newAcc; 219, subscript; 219, 220; 219, 247; 220, call; 220, 221; 220, 245; 221, attribute; 221, 222; 221, 244; 222, subscript; 222, 223; 222, 243; 223, call; 223, 224; 223, 241; 224, attribute; 224, 225; 224, 240; 225, subscript; 225, 226; 225, 239; 226, call; 226, 227; 226, 237; 227, attribute; 227, 228; 227, 236; 228, subscript; 228, 229; 228, 235; 229, call; 229, 230; 229, 233; 230, attribute; 230, 231; 230, 232; 231, identifier:line; 232, identifier:split; 233, argument_list; 233, 234; 234, string:'>'; 235, integer:1; 236, identifier:split; 237, argument_list; 237, 238; 238, string:'<'; 239, integer:0; 240, identifier:split; 241, argument_list; 241, 242; 242, string:'.'; 243, integer:0; 244, identifier:split; 245, argument_list; 245, 246; 246, string:','; 247, integer:0; 248, if_statement; 248, 249; 248, 255; 249, comparison_operator:>; 249, 250; 249, 254; 250, call; 250, 251; 250, 252; 251, identifier:len; 252, argument_list; 252, 253; 253, identifier:newAcc; 254, integer:0; 255, block; 255, 256; 256, return_statement; 256, 257; 257, tuple; 257, 258; 257, 259; 257, 260; 258, True; 259, identifier:acc; 260, identifier:newAcc; 261, for_statement; 261, 262; 261, 263; 261, 268; 262, identifier:error; 263, call; 263, 264; 263, 267; 264, attribute; 264, 265; 264, 266; 265, identifier:error; 266, identifier:splitlines; 267, argument_list; 268, block; 268, 269; 268, 282; 269, expression_statement; 269, 270; 270, assignment; 270, 271; 270, 272; 271, identifier:error; 272, call; 272, 273; 272, 281; 273, attribute; 273, 274; 273, 280; 274, call; 274, 275; 274, 278; 275, attribute; 275, 276; 275, 277; 276, identifier:error; 277, identifier:decode; 278, argument_list; 278, 279; 279, string:'ascii'; 280, identifier:strip; 281, argument_list; 282, if_statement; 282, 283; 282, 286; 283, comparison_operator:in; 283, 284; 283, 285; 284, string:'500 Can'; 285, identifier:error; 286, block; 286, 287; 287, return_statement; 287, 288; 288, tuple; 288, 289; 288, 290; 288, 291; 289, False; 290, identifier:acc; 291, string:'no network'; 292, return_statement; 292, 293; 293, tuple; 293, 294; 293, 295; 293, 296; 294, False; 295, identifier:acc; 296, string:'efetch failed' | 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:
return (True, acc, newAcc)
out, error = entrez('nucleotide', 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:
return (True, acc, newAcc)
out, error = entrez('assembly', 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:
return (True, acc, newAcc)
for error in error.splitlines():
error = error.decode('ascii').strip()
if '500 Can' in error:
return (False, acc, 'no network')
return (False, acc, 'efetch failed') |
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_interval; 11, block; 11, 12; 11, 24; 11, 26; 11, 30; 11, 57; 11, 63; 11, 77; 11, 87; 11, 96; 11, 102; 11, 125; 11, 141; 11, 157; 11, 164; 11, 178; 11, 182; 11, 194; 11, 210; 11, 218; 11, 236; 11, 245; 11, 272; 11, 280; 11, 289; 11, 296; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 14, identifier:level; 15, call; 15, 16; 15, 17; 16, identifier:getattr; 17, argument_list; 17, 18; 17, 19; 18, identifier:logging; 19, call; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:level; 22, identifier:upper; 23, argument_list; 24, global_statement; 24, 25; 25, identifier:_GLOBAL_LOG_CONFIGURED; 26, if_statement; 26, 27; 26, 28; 27, identifier:_GLOBAL_LOG_CONFIGURED; 28, block; 28, 29; 29, return_statement; 30, function_definition; 30, 31; 30, 32; 30, 34; 31, function_name:wrap_hook; 32, parameters; 32, 33; 33, identifier:fn; 34, block; 34, 35; 34, 55; 35, decorated_definition; 35, 36; 35, 41; 36, decorator; 36, 37; 37, call; 37, 38; 37, 39; 38, identifier:wraps; 39, argument_list; 39, 40; 40, identifier:fn; 41, function_definition; 41, 42; 41, 43; 41, 47; 42, function_name:processor; 43, parameters; 43, 44; 43, 45; 43, 46; 44, identifier:logger; 45, identifier:method_name; 46, identifier:event_dict; 47, block; 47, 48; 47, 53; 48, expression_statement; 48, 49; 49, call; 49, 50; 49, 51; 50, identifier:fn; 51, argument_list; 51, 52; 52, identifier:event_dict; 53, return_statement; 53, 54; 54, identifier:event_dict; 55, return_statement; 55, 56; 56, identifier:processor; 57, expression_statement; 57, 58; 58, assignment; 58, 59; 58, 60; 59, identifier:processors; 60, call; 60, 61; 60, 62; 61, identifier:define_log_processors; 62, argument_list; 63, expression_statement; 63, 64; 64, call; 64, 65; 64, 68; 65, attribute; 65, 66; 65, 67; 66, identifier:processors; 67, identifier:extend; 68, argument_list; 68, 69; 69, list_comprehension; 69, 70; 69, 74; 70, call; 70, 71; 70, 72; 71, identifier:wrap_hook; 72, argument_list; 72, 73; 73, identifier:h; 74, for_in_clause; 74, 75; 74, 76; 75, identifier:h; 76, identifier:pre_hooks; 77, if_statement; 77, 78; 77, 79; 78, identifier:metric_grouping_interval; 79, block; 79, 80; 80, expression_statement; 80, 81; 81, call; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:processors; 84, identifier:append; 85, argument_list; 85, 86; 86, identifier:metrics_grouping_processor; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 90; 89, identifier:log_renderer; 90, call; 90, 91; 90, 92; 91, identifier:define_log_renderer; 92, argument_list; 92, 93; 92, 94; 92, 95; 93, identifier:fmt; 94, identifier:fpath; 95, identifier:quiet; 96, expression_statement; 96, 97; 97, assignment; 97, 98; 97, 99; 98, identifier:stderr_required; 99, parenthesized_expression; 99, 100; 100, not_operator; 100, 101; 101, identifier:quiet; 102, expression_statement; 102, 103; 103, assignment; 103, 104; 103, 105; 104, identifier:pretty_to_stderr; 105, parenthesized_expression; 105, 106; 106, boolean_operator:and; 106, 107; 106, 108; 107, identifier:stderr_required; 108, parenthesized_expression; 108, 109; 109, boolean_operator:or; 109, 110; 109, 113; 110, comparison_operator:==; 110, 111; 110, 112; 111, identifier:fmt; 112, string:"pretty"; 113, parenthesized_expression; 113, 114; 114, boolean_operator:and; 114, 115; 114, 118; 115, comparison_operator:is; 115, 116; 115, 117; 116, identifier:fmt; 117, None; 118, call; 118, 119; 118, 124; 119, attribute; 119, 120; 119, 123; 120, attribute; 120, 121; 120, 122; 121, identifier:sys; 122, identifier:stderr; 123, identifier:isatty; 124, argument_list; 125, expression_statement; 125, 126; 126, assignment; 126, 127; 126, 128; 127, identifier:should_inject_pretty_renderer; 128, parenthesized_expression; 128, 129; 129, boolean_operator:and; 129, 130; 129, 131; 130, identifier:pretty_to_stderr; 131, not_operator; 131, 132; 132, call; 132, 133; 132, 134; 133, identifier:isinstance; 134, argument_list; 134, 135; 134, 136; 135, identifier:log_renderer; 136, attribute; 136, 137; 136, 140; 137, attribute; 137, 138; 137, 139; 138, identifier:structlog; 139, identifier:dev; 140, identifier:ConsoleRenderer; 141, if_statement; 141, 142; 141, 143; 142, identifier:should_inject_pretty_renderer; 143, block; 143, 144; 143, 148; 144, expression_statement; 144, 145; 145, assignment; 145, 146; 145, 147; 146, identifier:stderr_required; 147, False; 148, expression_statement; 148, 149; 149, call; 149, 150; 149, 153; 150, attribute; 150, 151; 150, 152; 151, identifier:processors; 152, identifier:append; 153, argument_list; 153, 154; 154, call; 154, 155; 154, 156; 155, identifier:StderrConsoleRenderer; 156, argument_list; 157, expression_statement; 157, 158; 158, call; 158, 159; 158, 162; 159, attribute; 159, 160; 159, 161; 160, identifier:processors; 161, identifier:append; 162, argument_list; 162, 163; 163, identifier:log_renderer; 164, expression_statement; 164, 165; 165, call; 165, 166; 165, 169; 166, attribute; 166, 167; 166, 168; 167, identifier:processors; 168, identifier:extend; 169, argument_list; 169, 170; 170, list_comprehension; 170, 171; 170, 175; 171, call; 171, 172; 171, 173; 172, identifier:wrap_hook; 173, argument_list; 173, 174; 174, identifier:h; 175, for_in_clause; 175, 176; 175, 177; 176, identifier:h; 177, identifier:post_hooks; 178, expression_statement; 178, 179; 179, assignment; 179, 180; 179, 181; 180, identifier:streams; 181, list:[]; 182, if_statement; 182, 183; 182, 184; 183, identifier:stderr_required; 184, block; 184, 185; 185, expression_statement; 185, 186; 186, call; 186, 187; 186, 190; 187, attribute; 187, 188; 187, 189; 188, identifier:streams; 189, identifier:append; 190, argument_list; 190, 191; 191, attribute; 191, 192; 191, 193; 192, identifier:sys; 193, identifier:stderr; 194, if_statement; 194, 195; 194, 198; 195, comparison_operator:is; 195, 196; 195, 197; 196, identifier:fpath; 197, None; 198, block; 198, 199; 199, expression_statement; 199, 200; 200, call; 200, 201; 200, 204; 201, attribute; 201, 202; 201, 203; 202, identifier:streams; 203, identifier:append; 204, argument_list; 204, 205; 205, call; 205, 206; 205, 207; 206, identifier:open; 207, argument_list; 207, 208; 207, 209; 208, identifier:fpath; 209, string:'a'; 210, assert_statement; 210, 211; 210, 217; 211, comparison_operator:!=; 211, 212; 211, 216; 212, call; 212, 213; 212, 214; 213, identifier:len; 214, argument_list; 214, 215; 215, identifier:streams; 216, integer:0; 217, string:"cannot configure logger for 0 streams"; 218, expression_statement; 218, 219; 219, assignment; 219, 220; 219, 221; 220, identifier:stream; 221, conditional_expression:if; 221, 222; 221, 225; 221, 231; 222, subscript; 222, 223; 222, 224; 223, identifier:streams; 224, integer:0; 225, comparison_operator:==; 225, 226; 225, 230; 226, call; 226, 227; 226, 228; 227, identifier:len; 228, argument_list; 228, 229; 229, identifier:streams; 230, integer:1; 231, call; 231, 232; 231, 233; 232, identifier:Stream; 233, argument_list; 233, 234; 234, list_splat; 234, 235; 235, identifier:streams; 236, expression_statement; 236, 237; 237, call; 237, 238; 237, 241; 238, attribute; 238, 239; 238, 240; 239, identifier:atexit; 240, identifier:register; 241, argument_list; 241, 242; 242, attribute; 242, 243; 242, 244; 243, identifier:stream; 244, identifier:close; 245, expression_statement; 245, 246; 246, call; 246, 247; 246, 250; 247, attribute; 247, 248; 247, 249; 248, identifier:structlog; 249, identifier:configure; 250, argument_list; 250, 251; 250, 254; 250, 257; 250, 266; 250, 269; 251, keyword_argument; 251, 252; 251, 253; 252, identifier:processors; 253, identifier:processors; 254, keyword_argument; 254, 255; 254, 256; 255, identifier:context_class; 256, identifier:dict; 257, keyword_argument; 257, 258; 257, 259; 258, identifier:logger_factory; 259, call; 259, 260; 259, 261; 260, identifier:LevelLoggerFactory; 261, argument_list; 261, 262; 261, 263; 262, identifier:stream; 263, keyword_argument; 263, 264; 263, 265; 264, identifier:level; 265, identifier:level; 266, keyword_argument; 266, 267; 266, 268; 267, identifier:wrapper_class; 268, identifier:BoundLevelLogger; 269, keyword_argument; 269, 270; 269, 271; 270, identifier:cache_logger_on_first_use; 271, True; 272, expression_statement; 272, 273; 273, assignment; 273, 274; 273, 275; 274, identifier:stdlib_root_log; 275, call; 275, 276; 275, 279; 276, attribute; 276, 277; 276, 278; 277, identifier:logging; 278, identifier:getLogger; 279, argument_list; 280, expression_statement; 280, 281; 281, call; 281, 282; 281, 285; 282, attribute; 282, 283; 282, 284; 283, identifier:stdlib_root_log; 284, identifier:addHandler; 285, argument_list; 285, 286; 286, call; 286, 287; 286, 288; 287, identifier:StdlibStructlogHandler; 288, argument_list; 289, expression_statement; 289, 290; 290, call; 290, 291; 290, 294; 291, attribute; 291, 292; 291, 293; 292, identifier:stdlib_root_log; 293, identifier:setLevel; 294, argument_list; 294, 295; 295, identifier:level; 296, expression_statement; 296, 297; 297, assignment; 297, 298; 297, 299; 298, identifier:_GLOBAL_LOG_CONFIGURED; 299, True | 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_dict):
fn(event_dict)
return event_dict
return processor
processors = define_log_processors()
processors.extend(
[ wrap_hook(h) for h in pre_hooks ]
)
if metric_grouping_interval:
processors.append(metrics_grouping_processor)
log_renderer = define_log_renderer(fmt, fpath, quiet)
stderr_required = (not quiet)
pretty_to_stderr = (
stderr_required
and (
fmt == "pretty"
or (fmt is None and sys.stderr.isatty())
)
)
should_inject_pretty_renderer = (
pretty_to_stderr
and not isinstance(log_renderer, structlog.dev.ConsoleRenderer)
)
if should_inject_pretty_renderer:
stderr_required = False
processors.append(StderrConsoleRenderer())
processors.append(log_renderer)
processors.extend(
[ wrap_hook(h) for h in post_hooks ]
)
streams = []
if stderr_required:
streams.append(sys.stderr)
if fpath is not None:
streams.append(open(fpath, 'a'))
assert len(streams) != 0, "cannot configure logger for 0 streams"
stream = streams[0] if len(streams) == 1 else Stream(*streams)
atexit.register(stream.close)
structlog.configure(
processors=processors,
context_class=dict,
logger_factory=LevelLoggerFactory(stream, level=level),
wrapper_class=BoundLevelLogger,
cache_logger_on_first_use=True,
)
stdlib_root_log = logging.getLogger()
stdlib_root_log.addHandler(StdlibStructlogHandler())
stdlib_root_log.setLevel(level)
_GLOBAL_LOG_CONFIGURED = True |
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:result; 10, list:[]; 11, expression_statement; 11, 12; 12, assignment; 12, 13; 12, 14; 13, identifier:temp; 14, string:""; 15, expression_statement; 15, 16; 16, assignment; 16, 17; 16, 18; 17, identifier:count; 18, call; 18, 19; 18, 20; 19, identifier:len; 20, argument_list; 20, 21; 21, identifier:graphemes; 22, for_statement; 22, 23; 22, 24; 22, 28; 23, identifier:grapheme; 24, call; 24, 25; 24, 26; 25, identifier:reversed; 26, argument_list; 26, 27; 27, identifier:graphemes; 28, block; 28, 29; 28, 33; 28, 85; 28, 119; 28, 190; 28, 199; 29, expression_statement; 29, 30; 30, augmented_assignment:-=; 30, 31; 30, 32; 31, identifier:count; 32, integer:1; 33, if_statement; 33, 34; 33, 60; 34, boolean_operator:and; 34, 35; 34, 50; 34, 51; 35, boolean_operator:and; 35, 36; 35, 42; 36, comparison_operator:==; 36, 37; 36, 41; 37, call; 37, 38; 37, 39; 38, identifier:len; 39, argument_list; 39, 40; 40, identifier:grapheme; 41, integer:1; 42, comparison_operator:==; 42, 43; 42, 49; 43, call; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:unicodedata; 46, identifier:category; 47, argument_list; 47, 48; 48, identifier:grapheme; 49, string:"Lm"; 50, line_continuation:\; 51, not_operator; 51, 52; 52, comparison_operator:in; 52, 53; 52, 57; 53, call; 53, 54; 53, 55; 54, identifier:ord; 55, argument_list; 55, 56; 56, identifier:grapheme; 57, list:[712, 716]; 57, 58; 57, 59; 58, integer:712; 59, integer:716; 60, block; 60, 61; 60, 67; 60, 84; 61, expression_statement; 61, 62; 62, assignment; 62, 63; 62, 64; 63, identifier:temp; 64, binary_operator:+; 64, 65; 64, 66; 65, identifier:grapheme; 66, identifier:temp; 67, if_statement; 67, 68; 67, 71; 68, comparison_operator:==; 68, 69; 68, 70; 69, identifier:count; 70, integer:0; 71, block; 71, 72; 72, expression_statement; 72, 73; 73, assignment; 73, 74; 73, 78; 74, subscript; 74, 75; 74, 76; 75, identifier:result; 76, unary_operator:-; 76, 77; 77, integer:1; 78, binary_operator:+; 78, 79; 78, 80; 79, identifier:temp; 80, subscript; 80, 81; 80, 82; 81, identifier:result; 82, unary_operator:-; 82, 83; 83, integer:1; 84, continue_statement; 85, if_statement; 85, 86; 85, 101; 86, boolean_operator:and; 86, 87; 86, 93; 87, comparison_operator:==; 87, 88; 87, 92; 88, call; 88, 89; 88, 90; 89, identifier:len; 90, argument_list; 90, 91; 91, identifier:grapheme; 92, integer:1; 93, comparison_operator:in; 93, 94; 93, 98; 94, call; 94, 95; 94, 96; 95, identifier:ord; 96, argument_list; 96, 97; 97, identifier:grapheme; 98, list:[712, 716]; 98, 99; 98, 100; 99, integer:712; 100, integer:716; 101, block; 101, 102; 101, 114; 101, 118; 102, expression_statement; 102, 103; 103, assignment; 103, 104; 103, 108; 104, subscript; 104, 105; 104, 106; 105, identifier:result; 106, unary_operator:-; 106, 107; 107, integer:1; 108, binary_operator:+; 108, 109; 108, 110; 109, identifier:grapheme; 110, subscript; 110, 111; 110, 112; 111, identifier:result; 112, unary_operator:-; 112, 113; 113, integer:1; 114, expression_statement; 114, 115; 115, assignment; 115, 116; 115, 117; 116, identifier:temp; 117, string:""; 118, continue_statement; 119, if_statement; 119, 120; 119, 135; 120, boolean_operator:and; 120, 121; 120, 127; 121, comparison_operator:==; 121, 122; 121, 126; 122, call; 122, 123; 122, 124; 123, identifier:len; 124, argument_list; 124, 125; 125, identifier:grapheme; 126, integer:1; 127, comparison_operator:==; 127, 128; 127, 134; 128, call; 128, 129; 128, 132; 129, attribute; 129, 130; 129, 131; 130, identifier:unicodedata; 131, identifier:category; 132, argument_list; 132, 133; 133, identifier:grapheme; 134, string:"Sk"; 135, block; 135, 136; 136, if_statement; 136, 137; 136, 143; 136, 156; 137, comparison_operator:==; 137, 138; 137, 142; 138, call; 138, 139; 138, 140; 139, identifier:len; 140, argument_list; 140, 141; 141, identifier:result; 142, integer:0; 143, block; 143, 144; 143, 151; 143, 155; 144, expression_statement; 144, 145; 145, call; 145, 146; 145, 149; 146, attribute; 146, 147; 146, 148; 147, identifier:result; 148, identifier:append; 149, argument_list; 149, 150; 150, identifier:grapheme; 151, expression_statement; 151, 152; 152, assignment; 152, 153; 152, 154; 153, identifier:temp; 154, string:""; 155, continue_statement; 156, else_clause; 156, 157; 157, block; 157, 158; 158, if_statement; 158, 159; 158, 172; 159, comparison_operator:==; 159, 160; 159, 171; 160, call; 160, 161; 160, 164; 161, attribute; 161, 162; 161, 163; 162, identifier:unicodedata; 163, identifier:category; 164, argument_list; 164, 165; 165, subscript; 165, 166; 165, 170; 166, subscript; 166, 167; 166, 168; 167, identifier:result; 168, unary_operator:-; 168, 169; 169, integer:1; 170, integer:0; 171, string:"Sk"; 172, block; 172, 173; 172, 185; 172, 189; 173, expression_statement; 173, 174; 174, assignment; 174, 175; 174, 179; 175, subscript; 175, 176; 175, 177; 176, identifier:result; 177, unary_operator:-; 177, 178; 178, integer:1; 179, binary_operator:+; 179, 180; 179, 181; 180, identifier:grapheme; 181, subscript; 181, 182; 181, 183; 182, identifier:result; 183, unary_operator:-; 183, 184; 184, integer:1; 185, expression_statement; 185, 186; 186, assignment; 186, 187; 186, 188; 187, identifier:temp; 188, string:""; 189, continue_statement; 190, expression_statement; 190, 191; 191, call; 191, 192; 191, 195; 192, attribute; 192, 193; 192, 194; 193, identifier:result; 194, identifier:append; 195, argument_list; 195, 196; 196, binary_operator:+; 196, 197; 196, 198; 197, identifier:grapheme; 198, identifier:temp; 199, expression_statement; 199, 200; 200, assignment; 200, 201; 200, 202; 201, identifier:temp; 202, string:""; 203, expression_statement; 203, 204; 204, assignment; 204, 205; 204, 206; 205, identifier:segments; 206, subscript; 206, 207; 206, 208; 207, identifier:result; 208, slice; 208, 209; 208, 210; 208, 211; 209, colon; 210, colon; 211, unary_operator:-; 211, 212; 212, integer:1; 213, expression_statement; 213, 214; 214, assignment; 214, 215; 214, 216; 215, identifier:i; 216, integer:0; 217, expression_statement; 217, 218; 218, assignment; 218, 219; 218, 220; 219, identifier:r; 220, list:[]; 221, while_statement; 221, 222; 221, 228; 222, comparison_operator:<; 222, 223; 222, 224; 223, identifier:i; 224, call; 224, 225; 224, 226; 225, identifier:len; 226, argument_list; 226, 227; 227, identifier:segments; 228, block; 228, 229; 229, if_statement; 229, 230; 229, 243; 229, 263; 230, comparison_operator:in; 230, 231; 230, 240; 231, call; 231, 232; 231, 233; 232, identifier:ord; 233, argument_list; 233, 234; 234, subscript; 234, 235; 234, 238; 235, subscript; 235, 236; 235, 237; 236, identifier:segments; 237, identifier:i; 238, unary_operator:-; 238, 239; 239, integer:1; 240, list:[865, 860]; 240, 241; 240, 242; 241, integer:865; 242, integer:860; 243, block; 243, 244; 243, 259; 244, expression_statement; 244, 245; 245, call; 245, 246; 245, 249; 246, attribute; 246, 247; 246, 248; 247, identifier:r; 248, identifier:append; 249, argument_list; 249, 250; 250, binary_operator:+; 250, 251; 250, 254; 251, subscript; 251, 252; 251, 253; 252, identifier:segments; 253, identifier:i; 254, subscript; 254, 255; 254, 256; 255, identifier:segments; 256, binary_operator:+; 256, 257; 256, 258; 257, identifier:i; 258, integer:1; 259, expression_statement; 259, 260; 260, augmented_assignment:+=; 260, 261; 260, 262; 261, identifier:i; 262, integer:2; 263, else_clause; 263, 264; 264, block; 264, 265; 264, 274; 265, expression_statement; 265, 266; 266, call; 266, 267; 266, 270; 267, attribute; 267, 268; 267, 269; 268, identifier:r; 269, identifier:append; 270, argument_list; 270, 271; 271, subscript; 271, 272; 271, 273; 272, identifier:segments; 273, identifier:i; 274, expression_statement; 274, 275; 275, augmented_assignment:+=; 275, 276; 275, 277; 276, identifier:i; 277, integer:1; 278, return_statement; 278, 279; 279, identifier:r | 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]:
temp = grapheme + temp
if count == 0:
result[-1] = temp + result[-1]
continue
if len(grapheme) == 1 and ord(grapheme) in [712, 716]:
result[-1] = grapheme + result[-1]
temp = ""
continue
if len(grapheme) == 1 and unicodedata.category(grapheme) == "Sk":
if len(result) == 0:
result.append(grapheme)
temp = ""
continue
else:
if unicodedata.category(result[-1][0]) == "Sk":
result[-1] = grapheme + result[-1]
temp = ""
continue
result.append(grapheme + temp)
temp = ""
segments = result[::-1]
i = 0
r = []
while i < len(segments):
if ord(segments[i][-1]) in [865, 860]:
r.append(segments[i] + segments[i + 1])
i += 2
else:
r.append(segments[i])
i += 1
return r |
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; 9, 167; 10, if_statement; 10, 11; 10, 14; 11, comparison_operator:is; 11, 12; 11, 13; 12, identifier:pair; 13, False; 14, block; 14, 15; 14, 22; 14, 29; 14, 36; 15, expression_statement; 15, 16; 16, assignment; 16, 17; 16, 18; 17, identifier:mm; 18, call; 18, 19; 18, 20; 19, identifier:count_mismatches; 20, argument_list; 20, 21; 21, identifier:read; 22, if_statement; 22, 23; 22, 26; 23, comparison_operator:is; 23, 24; 23, 25; 24, identifier:mm; 25, False; 26, block; 26, 27; 27, return_statement; 27, 28; 28, False; 29, if_statement; 29, 30; 29, 33; 30, comparison_operator:is; 30, 31; 30, 32; 31, identifier:mismatches; 32, False; 33, block; 33, 34; 34, return_statement; 34, 35; 35, True; 36, if_statement; 36, 37; 36, 40; 37, comparison_operator:<=; 37, 38; 37, 39; 38, identifier:mm; 39, identifier:mismatches; 40, block; 40, 41; 41, return_statement; 41, 42; 42, True; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 46; 45, identifier:r_mm; 46, call; 46, 47; 46, 48; 47, identifier:count_mismatches; 48, argument_list; 48, 49; 49, identifier:read; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 53; 52, identifier:p_mm; 53, call; 53, 54; 53, 55; 54, identifier:count_mismatches; 55, argument_list; 55, 56; 56, identifier:pair; 57, if_statement; 57, 58; 57, 65; 58, boolean_operator:and; 58, 59; 58, 62; 59, comparison_operator:is; 59, 60; 59, 61; 60, identifier:r_mm; 61, False; 62, comparison_operator:is; 62, 63; 62, 64; 63, identifier:p_mm; 64, False; 65, block; 65, 66; 66, return_statement; 66, 67; 67, False; 68, if_statement; 68, 69; 68, 72; 69, comparison_operator:is; 69, 70; 69, 71; 70, identifier:mismatches; 71, False; 72, block; 72, 73; 73, return_statement; 73, 74; 74, True; 75, if_statement; 75, 76; 75, 79; 76, comparison_operator:is; 76, 77; 76, 78; 77, identifier:req_map; 78, True; 79, block; 79, 80; 80, if_statement; 80, 81; 80, 88; 81, boolean_operator:or; 81, 82; 81, 85; 82, comparison_operator:is; 82, 83; 82, 84; 83, identifier:r_mm; 84, False; 85, comparison_operator:is; 85, 86; 85, 87; 86, identifier:p_mm; 87, False; 88, block; 88, 89; 89, return_statement; 89, 90; 90, False; 91, if_statement; 91, 92; 91, 95; 92, comparison_operator:==; 92, 93; 92, 94; 93, identifier:mm_option; 94, string:'one'; 95, block; 95, 96; 96, if_statement; 96, 97; 96, 114; 97, boolean_operator:or; 97, 98; 97, 106; 98, parenthesized_expression; 98, 99; 99, boolean_operator:and; 99, 100; 99, 103; 100, comparison_operator:is; 100, 101; 100, 102; 101, identifier:r_mm; 102, False; 103, comparison_operator:<=; 103, 104; 103, 105; 104, identifier:r_mm; 105, identifier:mismatches; 106, parenthesized_expression; 106, 107; 107, boolean_operator:and; 107, 108; 107, 111; 108, comparison_operator:is; 108, 109; 108, 110; 109, identifier:p_mm; 110, False; 111, comparison_operator:<=; 111, 112; 111, 113; 112, identifier:p_mm; 113, identifier:mismatches; 114, block; 114, 115; 115, return_statement; 115, 116; 116, True; 117, if_statement; 117, 118; 117, 121; 118, comparison_operator:==; 118, 119; 118, 120; 119, identifier:mm_option; 120, string:'both'; 121, block; 121, 122; 122, if_statement; 122, 123; 122, 126; 122, 134; 122, 146; 123, comparison_operator:is; 123, 124; 123, 125; 124, identifier:r_mm; 125, False; 126, block; 126, 127; 127, if_statement; 127, 128; 127, 131; 128, comparison_operator:<=; 128, 129; 128, 130; 129, identifier:p_mm; 130, identifier:mismatches; 131, block; 131, 132; 132, return_statement; 132, 133; 133, True; 134, elif_clause; 134, 135; 134, 138; 135, comparison_operator:is; 135, 136; 135, 137; 136, identifier:p_mm; 137, False; 138, block; 138, 139; 139, if_statement; 139, 140; 139, 143; 140, comparison_operator:<=; 140, 141; 140, 142; 141, identifier:r_mm; 142, identifier:mismatches; 143, block; 143, 144; 144, return_statement; 144, 145; 145, True; 146, elif_clause; 146, 147; 146, 164; 147, boolean_operator:and; 147, 148; 147, 156; 148, parenthesized_expression; 148, 149; 149, boolean_operator:and; 149, 150; 149, 153; 150, comparison_operator:is; 150, 151; 150, 152; 151, identifier:r_mm; 152, False; 153, comparison_operator:<=; 153, 154; 153, 155; 154, identifier:r_mm; 155, identifier:mismatches; 156, parenthesized_expression; 156, 157; 157, boolean_operator:and; 157, 158; 157, 161; 158, comparison_operator:is; 158, 159; 158, 160; 159, identifier:p_mm; 160, False; 161, comparison_operator:<=; 161, 162; 161, 163; 162, identifier:p_mm; 163, identifier:mismatches; 164, block; 164, 165; 165, return_statement; 165, 166; 166, True; 167, return_statement; 167, 168; 168, False | 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)
p_mm = count_mismatches(pair)
if r_mm is False and p_mm is False:
return False
if mismatches is False:
return True
if req_map is True:
if r_mm is False or p_mm is False:
return False
if mm_option == 'one':
if (r_mm is not False and r_mm <= mismatches) or (p_mm is not False and p_mm <= mismatches):
return True
if mm_option == 'both':
if r_mm is False:
if p_mm <= mismatches:
return True
elif p_mm is False:
if r_mm <= mismatches:
return True
elif (r_mm is not False and r_mm <= mismatches) and (p_mm is not False and p_mm <= mismatches):
return True
return False |
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, conditional_expression:if; 11, 12; 11, 16; 11, 24; 12, call; 12, 13; 12, 14; 13, identifier:Steam; 14, argument_list; 14, 15; 15, identifier:udd; 16, call; 16, 17; 16, 22; 17, attribute; 17, 18; 17, 21; 18, attribute; 18, 19; 18, 20; 19, identifier:os; 20, identifier:path; 21, identifier:exists; 22, argument_list; 22, 23; 23, identifier:udd; 24, None; 25, expression_statement; 25, 26; 26, assignment; 26, 27; 26, 28; 27, identifier:plat; 28, call; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, identifier:platform; 31, identifier:system; 32, argument_list; 33, if_statement; 33, 34; 33, 37; 34, comparison_operator:==; 34, 35; 34, 36; 35, identifier:plat; 36, string:'Darwin'; 37, block; 37, 38; 38, return_statement; 38, 39; 39, call; 39, 40; 39, 41; 40, identifier:helper; 41, argument_list; 41, 42; 42, call; 42, 43; 42, 46; 43, attribute; 43, 44; 43, 45; 44, identifier:paths; 45, identifier:default_osx_userdata_path; 46, argument_list; 47, if_statement; 47, 48; 47, 51; 48, comparison_operator:==; 48, 49; 48, 50; 49, identifier:plat; 50, string:'Linux'; 51, block; 51, 52; 52, return_statement; 52, 53; 53, call; 53, 54; 53, 55; 54, identifier:helper; 55, argument_list; 55, 56; 56, call; 56, 57; 56, 60; 57, attribute; 57, 58; 57, 59; 58, identifier:paths; 59, identifier:default_linux_userdata_path; 60, argument_list; 61, if_statement; 61, 62; 61, 65; 62, comparison_operator:==; 62, 63; 62, 64; 63, identifier:plat; 64, string:'Windows'; 65, block; 65, 66; 65, 74; 66, expression_statement; 66, 67; 67, assignment; 67, 68; 67, 69; 68, identifier:possible_dir; 69, call; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:winutils; 72, identifier:find_userdata_directory; 73, argument_list; 74, return_statement; 74, 75; 75, conditional_expression:if; 75, 76; 75, 80; 75, 83; 76, call; 76, 77; 76, 78; 77, identifier:helper; 78, argument_list; 78, 79; 79, identifier:possible_dir; 80, comparison_operator:is; 80, 81; 80, 82; 81, identifier:possible_dir; 82, None; 83, None; 84, return_statement; 84, 85; 85, None | 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_userdata_directory()
return helper(possible_dir) if possible_dir is not None else None
return None |
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; 9, 15; 10, function_name:next_code; 11, parameters; 11, 12; 11, 13; 11, 14; 12, identifier:b; 13, identifier:c; 14, identifier:i; 15, block; 15, 16; 16, return_statement; 16, 17; 17, binary_operator:+; 17, 18; 17, 25; 18, binary_operator:+; 18, 19; 18, 24; 19, subscript; 19, 20; 19, 21; 20, identifier:c; 21, slice; 21, 22; 21, 23; 22, colon; 23, identifier:i; 24, identifier:b; 25, parenthesized_expression; 25, 26; 26, conditional_expression:if; 26, 27; 26, 34; 26, 38; 27, subscript; 27, 28; 27, 29; 28, identifier:c; 29, slice; 29, 30; 29, 33; 30, binary_operator:+; 30, 31; 30, 32; 31, identifier:i; 32, integer:1; 33, colon; 34, comparison_operator:<; 34, 35; 34, 36; 35, identifier:i; 36, unary_operator:-; 36, 37; 37, integer:1; 38, string:''; 39, function_definition; 39, 40; 39, 41; 39, 42; 40, function_name:rand_base; 41, parameters; 42, block; 42, 43; 43, return_statement; 43, 44; 44, call; 44, 45; 44, 48; 45, attribute; 45, 46; 45, 47; 46, identifier:random; 47, identifier:choice; 48, argument_list; 48, 49; 49, list:['A', 'T', 'C', 'G']; 49, 50; 49, 51; 49, 52; 49, 53; 50, string:'A'; 51, string:'T'; 52, string:'C'; 53, string:'G'; 54, function_definition; 54, 55; 54, 56; 54, 58; 55, function_name:rand_seq; 56, parameters; 56, 57; 57, identifier:n; 58, block; 58, 59; 59, return_statement; 59, 60; 60, call; 60, 61; 60, 64; 61, attribute; 61, 62; 61, 63; 62, string:''; 63, identifier:join; 64, argument_list; 64, 65; 65, list_comprehension; 65, 66; 65, 69; 66, call; 66, 67; 66, 68; 67, identifier:rand_base; 68, argument_list; 69, for_in_clause; 69, 70; 69, 71; 70, identifier:_; 71, call; 71, 72; 71, 73; 72, identifier:range; 73, argument_list; 73, 74; 74, identifier:n; 75, expression_statement; 75, 76; 76, assignment; 76, 77; 76, 78; 77, identifier:hpf; 78, call; 78, 79; 78, 82; 79, attribute; 79, 80; 79, 81; 80, identifier:re; 81, identifier:compile; 82, argument_list; 82, 83; 82, 84; 83, string:'aaaa|cccc|gggg|tttt'; 84, attribute; 84, 85; 84, 86; 85, identifier:re; 86, identifier:IGNORECASE; 87, while_statement; 87, 88; 87, 89; 88, True; 89, block; 89, 90; 89, 98; 90, expression_statement; 90, 91; 91, assignment; 91, 92; 91, 93; 92, identifier:codes; 93, list:[rand_seq(codeLen)]; 93, 94; 94, call; 94, 95; 94, 96; 95, identifier:rand_seq; 96, argument_list; 96, 97; 97, identifier:codeLen; 98, if_statement; 98, 99; 98, 110; 99, parenthesized_expression; 99, 100; 100, comparison_operator:is; 100, 101; 100, 109; 101, call; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, identifier:hpf; 104, identifier:search; 105, argument_list; 105, 106; 106, subscript; 106, 107; 106, 108; 107, identifier:codes; 108, integer:0; 109, None; 110, block; 110, 111; 111, break_statement; 112, expression_statement; 112, 113; 113, assignment; 113, 114; 113, 115; 114, identifier:idx; 115, integer:0; 116, while_statement; 116, 117; 116, 123; 117, comparison_operator:<; 117, 118; 117, 122; 118, call; 118, 119; 118, 120; 119, identifier:len; 120, argument_list; 120, 121; 121, identifier:codes; 122, identifier:nIds; 123, block; 123, 124; 123, 128; 123, 182; 124, expression_statement; 124, 125; 125, augmented_assignment:-=; 125, 126; 125, 127; 126, identifier:idx; 127, integer:1; 128, if_statement; 128, 129; 128, 133; 128, 149; 129, comparison_operator:<; 129, 130; 129, 131; 130, identifier:idx; 131, unary_operator:-; 131, 132; 132, identifier:codeLen; 133, block; 133, 134; 133, 139; 134, expression_statement; 134, 135; 135, assignment; 135, 136; 135, 137; 136, identifier:idx; 137, unary_operator:-; 137, 138; 138, integer:1; 139, expression_statement; 139, 140; 140, call; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, identifier:codes; 143, identifier:append; 144, argument_list; 144, 145; 145, call; 145, 146; 145, 147; 146, identifier:rand_seq; 147, argument_list; 147, 148; 148, identifier:codeLen; 149, else_clause; 149, 150; 150, block; 150, 151; 150, 165; 151, expression_statement; 151, 152; 152, assignment; 152, 153; 152, 154; 153, identifier:nc; 154, call; 154, 155; 154, 156; 155, identifier:next_code; 156, argument_list; 156, 157; 156, 160; 156, 164; 157, call; 157, 158; 157, 159; 158, identifier:rand_base; 159, argument_list; 160, subscript; 160, 161; 160, 162; 161, identifier:codes; 162, unary_operator:-; 162, 163; 163, integer:1; 164, identifier:idx; 165, if_statement; 165, 166; 165, 174; 166, comparison_operator:is; 166, 167; 166, 173; 167, call; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, identifier:hpf; 170, identifier:search; 171, argument_list; 171, 172; 172, identifier:nc; 173, None; 174, block; 174, 175; 175, expression_statement; 175, 176; 176, call; 176, 177; 176, 180; 177, attribute; 177, 178; 177, 179; 178, identifier:codes; 179, identifier:append; 180, argument_list; 180, 181; 181, identifier:nc; 182, expression_statement; 182, 183; 183, assignment; 183, 184; 183, 185; 184, identifier:codes; 185, call; 185, 186; 185, 187; 186, identifier:list; 187, argument_list; 187, 188; 188, call; 188, 189; 188, 190; 189, identifier:set; 190, argument_list; 190, 191; 191, identifier:codes; 192, return_statement; 192, 193; 193, identifier:codes | 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.IGNORECASE)
while True:
codes = [rand_seq(codeLen)]
if (hpf.search(codes[0]) is None):
break
idx = 0
while len(codes) < nIds:
idx -= 1
if idx < -codeLen:
idx = -1
codes.append(rand_seq(codeLen))
else:
nc = next_code(rand_base(), codes[-1], idx)
if hpf.search(nc) is None:
codes.append(nc)
codes = list(set(codes))
return codes |
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; 10, comparison_operator:is; 10, 11; 10, 12; 11, identifier:annot_tables; 12, False; 13, block; 13, 14; 13, 18; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 17; 16, identifier:annots; 17, dictionary; 18, for_statement; 18, 19; 18, 20; 18, 21; 19, identifier:table; 20, identifier:annot_tables; 21, block; 21, 22; 22, for_statement; 22, 23; 22, 24; 22, 28; 23, identifier:cds; 24, call; 24, 25; 24, 26; 25, identifier:open; 26, argument_list; 26, 27; 27, identifier:table; 28, block; 28, 29; 28, 45; 29, expression_statement; 29, 30; 30, assignment; 30, 31; 30, 36; 31, pattern_list; 31, 32; 31, 33; 31, 34; 31, 35; 32, identifier:ID; 33, identifier:start; 34, identifier:end; 35, identifier:strand; 36, call; 36, 37; 36, 44; 37, attribute; 37, 38; 37, 43; 38, call; 38, 39; 38, 42; 39, attribute; 39, 40; 39, 41; 40, identifier:cds; 41, identifier:strip; 42, argument_list; 43, identifier:split; 44, argument_list; 45, expression_statement; 45, 46; 46, assignment; 46, 47; 46, 50; 47, subscript; 47, 48; 47, 49; 48, identifier:annots; 49, identifier:ID; 50, list:[start, end, int(strand)]; 50, 51; 50, 52; 50, 53; 51, identifier:start; 52, identifier:end; 53, call; 53, 54; 53, 55; 54, identifier:int; 55, argument_list; 55, 56; 56, identifier:strand; 57, for_statement; 57, 58; 57, 59; 57, 60; 57, 203; 57, 208; 58, identifier:fasta; 59, identifier:fastas; 60, ERROR; 60, 61; 60, 160; 60, 179; 60, 180; 60, 182; 60, 183; 60, 185; 60, 191; 60, 197; 60, 200; 61, for_statement; 61, 62; 61, 63; 61, 67; 61, 78; 61, 131; 62, identifier:seq; 63, call; 63, 64; 63, 65; 64, identifier:parse_fasta; 65, argument_list; 65, 66; 66, identifier:fasta; 67, ERROR; 67, 68; 67, 73; 68, call; 68, 69; 68, 70; 68, 72; 69, string:'
print('; 70, ERROR; 70, 71; 71, identifier:exit; 72, argument_list; 73, comparison_operator:in; 73, 74; 73, 75; 74, string:'ID='; 75, subscript; 75, 76; 75, 77; 76, identifier:seq; 77, integer:0; 78, block; 78, 79; 78, 101; 79, expression_statement; 79, 80; 80, assignment; 80, 81; 80, 82; 81, identifier:ID; 82, subscript; 82, 83; 82, 100; 83, call; 83, 84; 83, 97; 84, attribute; 84, 85; 84, 96; 85, subscript; 85, 86; 85, 95; 86, call; 86, 87; 86, 92; 87, attribute; 87, 88; 87, 91; 88, subscript; 88, 89; 88, 90; 89, identifier:seq; 90, integer:0; 91, identifier:rsplit; 92, argument_list; 92, 93; 92, 94; 93, string:'ID='; 94, integer:1; 95, integer:1; 96, identifier:split; 97, argument_list; 97, 98; 97, 99; 98, string:';'; 99, integer:1; 100, integer:0; 101, expression_statement; 101, 102; 102, assignment; 102, 103; 102, 104; 103, identifier:contig; 104, subscript; 104, 105; 104, 130; 105, call; 105, 106; 105, 124; 106, attribute; 106, 107; 106, 123; 107, subscript; 107, 108; 107, 122; 108, call; 108, 109; 108, 120; 109, attribute; 109, 110; 109, 119; 110, subscript; 110, 111; 110, 118; 111, call; 111, 112; 111, 117; 112, attribute; 112, 113; 112, 116; 113, subscript; 113, 114; 113, 115; 114, identifier:seq; 115, integer:0; 116, identifier:split; 117, argument_list; 118, integer:0; 119, identifier:split; 120, argument_list; 120, 121; 121, string:'>'; 122, integer:1; 123, identifier:rsplit; 124, argument_list; 124, 125; 124, 129; 125, binary_operator:%; 125, 126; 125, 127; 126, string:'_%s'; 127, parenthesized_expression; 127, 128; 128, identifier:ID; 129, integer:1; 130, integer:0; 131, else_clause; 131, 132; 132, block; 132, 133; 133, expression_statement; 133, 134; 134, assignment; 134, 135; 134, 136; 135, identifier:contig; 136, subscript; 136, 137; 136, 159; 137, call; 137, 138; 137, 156; 138, attribute; 138, 139; 138, 155; 139, subscript; 139, 140; 139, 154; 140, call; 140, 141; 140, 152; 141, attribute; 141, 142; 141, 151; 142, subscript; 142, 143; 142, 150; 143, call; 143, 144; 143, 149; 144, attribute; 144, 145; 144, 148; 145, subscript; 145, 146; 145, 147; 146, identifier:seq; 147, integer:0; 148, identifier:split; 149, argument_list; 150, integer:0; 151, identifier:split; 152, argument_list; 152, 153; 153, string:'>'; 154, integer:1; 155, identifier:rsplit; 156, argument_list; 156, 157; 156, 158; 157, string:'_'; 158, integer:1; 159, integer:0; 160, expression_statement; 160, 161; 161, assignment; 161, 162; 161, 163; 162, identifier:locus; 163, subscript; 163, 164; 163, 178; 164, call; 164, 165; 164, 176; 165, attribute; 165, 166; 165, 175; 166, subscript; 166, 167; 166, 174; 167, call; 167, 168; 167, 173; 168, attribute; 168, 169; 168, 172; 169, subscript; 169, 170; 169, 171; 170, identifier:seq; 171, integer:0; 172, identifier:split; 173, argument_list; 174, integer:0; 175, identifier:split; 176, argument_list; 176, 177; 177, string:'>'; 178, integer:1; 179, string:'
info = seq[0].split('; 180, ERROR; 180, 181; 181, identifier:start; 182, identifier:end; 183, ERROR; 183, 184; 184, identifier:strand; 185, call; 185, 186; 185, 187; 186, identifier:int; 187, argument_list; 187, 188; 188, subscript; 188, 189; 188, 190; 189, identifier:info; 190, integer:1; 191, call; 191, 192; 191, 193; 192, identifier:int; 193, argument_list; 193, 194; 194, subscript; 194, 195; 194, 196; 195, identifier:info; 196, integer:2; 197, subscript; 197, 198; 197, 199; 198, identifier:info; 199, integer:3; 200, comparison_operator:==; 200, 201; 200, 202; 201, identifier:strand; 202, string:'1'; 203, block; 203, 204; 204, expression_statement; 204, 205; 205, assignment; 205, 206; 205, 207; 206, identifier:strand; 207, integer:1; 208, else_clause; 208, 209; 209, block; 209, 210; 210, expression_statement; 210, 211; 211, assignment; 211, 212; 211, 213; 212, identifier:strand; 213, unary_operator:-; 213, 214; 214, integer:1; 215, expression_statement; 215, 216; 216, assignment; 216, 217; 216, 218; 217, identifier:product; 218, list:[''.join(info[4].split()[1:])]; 218, 219; 219, call; 219, 220; 219, 223; 220, attribute; 220, 221; 220, 222; 221, string:''; 222, identifier:join; 223, argument_list; 223, 224; 224, subscript; 224, 225; 224, 232; 225, call; 225, 226; 225, 231; 226, attribute; 226, 227; 226, 230; 227, subscript; 227, 228; 227, 229; 228, identifier:info; 229, integer:4; 230, identifier:split; 231, argument_list; 232, slice; 232, 233; 232, 234; 233, integer:1; 234, colon; 235, expression_statement; 235, 236; 236, assignment; 236, 237; 236, 243; 237, pattern_list; 237, 238; 237, 239; 237, 241; 237, 242; 238, identifier:else; 239, ERROR; 239, 240; 240, identifier:start; 241, identifier:end; 242, identifier:strand; 243, subscript; 243, 244; 243, 245; 244, identifier:annots; 245, identifier:locus; 246, expression_statement; 246, 247; 247, assignment; 247, 248; 247, 249; 248, identifier:product; 249, subscript; 249, 250; 249, 259; 250, call; 250, 251; 250, 256; 251, attribute; 251, 252; 251, 255; 252, subscript; 252, 253; 252, 254; 253, identifier:seq; 254, integer:0; 255, identifier:split; 256, argument_list; 256, 257; 256, 258; 257, string:' '; 258, integer:1; 259, integer:1; 260, expression_statement; 260, 261; 261, assignment; 261, 262; 261, 263; 262, identifier:info; 263, dictionary; 263, 264; 263, 268; 263, 274; 264, pair; 264, 265; 264, 266; 265, string:'transl_table'; 266, list:[trans_table]; 266, 267; 267, identifier:trans_table; 268, pair; 268, 269; 268, 270; 269, string:'translation'; 270, list:[seq[1]]; 270, 271; 271, subscript; 271, 272; 271, 273; 272, identifier:seq; 273, integer:1; 274, pair; 274, 275; 274, 276; 275, string:'product'; 276, identifier:product; 277, expression_statement; 277, 278; 278, yield; 278, 279; 279, expression_list; 279, 280; 279, 281; 280, identifier:contig; 281, list:[locus, [start, end, strand], info]; 281, 282; 281, 283; 281, 287; 282, identifier:locus; 283, list:[start, end, strand]; 283, 284; 283, 285; 283, 286; 284, identifier:start; 285, identifier:end; 286, identifier:strand; 287, identifier:info | 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 in fastas:
for seq in parse_fasta(fasta):
if ('
print('
exit()
if 'ID=' in seq[0]:
ID = seq[0].rsplit('ID=', 1)[1].split(';', 1)[0]
contig = seq[0].split()[0].split('>')[1].rsplit('_%s' % (ID), 1)[0]
else:
contig = seq[0].split()[0].split('>')[1].rsplit('_', 1)[0]
locus = seq[0].split()[0].split('>')[1]
if ('
info = seq[0].split('
start, end, strand = int(info[1]), int(info[2]), info[3]
if strand == '1':
strand = 1
else:
strand = -1
product = [''.join(info[4].split()[1:])]
else:
start, end, strand = annots[locus]
product = seq[0].split(' ', 1)[1]
info = {'transl_table':[trans_table], \
'translation':[seq[1]], \
'product':product}
yield contig, [locus, [start, end, strand], info] |
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']; 9, 10; 9, 11; 9, 12; 9, 13; 9, 14; 10, string:'A'; 11, string:'T'; 12, string:'G'; 13, string:'C'; 14, string:'N'; 15, expression_statement; 15, 16; 16, assignment; 16, 17; 16, 18; 17, identifier:total; 18, call; 18, 19; 18, 20; 19, identifier:sum; 20, argument_list; 20, 21; 21, list_comprehension; 21, 22; 21, 25; 21, 28; 22, subscript; 22, 23; 22, 24; 23, identifier:bases; 24, identifier:nuc; 25, for_in_clause; 25, 26; 25, 27; 26, identifier:nuc; 27, identifier:nucs; 28, if_clause; 28, 29; 29, comparison_operator:in; 29, 30; 29, 31; 30, identifier:nuc; 31, identifier:bases; 32, try_statement; 32, 33; 32, 51; 33, block; 33, 34; 34, expression_statement; 34, 35; 35, assignment; 35, 36; 35, 37; 36, identifier:top; 37, call; 37, 38; 37, 39; 38, identifier:max; 39, argument_list; 39, 40; 40, list_comprehension; 40, 41; 40, 44; 40, 47; 41, subscript; 41, 42; 41, 43; 42, identifier:bases; 43, identifier:nuc; 44, for_in_clause; 44, 45; 44, 46; 45, identifier:nuc; 46, identifier:nucs; 47, if_clause; 47, 48; 48, comparison_operator:in; 48, 49; 48, 50; 49, identifier:nuc; 50, identifier:bases; 51, except_clause; 51, 52; 52, block; 52, 53; 52, 61; 52, 67; 52, 73; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 58; 55, subscript; 55, 56; 55, 57; 56, identifier:bases; 57, string:'consensus'; 58, tuple; 58, 59; 58, 60; 59, string:'N'; 60, string:'n/a'; 61, expression_statement; 61, 62; 62, assignment; 62, 63; 62, 66; 63, subscript; 63, 64; 63, 65; 64, identifier:bases; 65, string:'consensus frequency'; 66, string:'n/a'; 67, expression_statement; 67, 68; 68, assignment; 68, 69; 68, 72; 69, subscript; 69, 70; 69, 71; 70, identifier:bases; 71, string:'reference frequency'; 72, string:'n/a'; 73, return_statement; 73, 74; 74, identifier:bases; 75, expression_statement; 75, 76; 76, assignment; 76, 77; 76, 78; 77, identifier:top; 78, list_comprehension; 78, 79; 78, 84; 78, 87; 79, tuple; 79, 80; 79, 81; 80, identifier:nuc; 81, subscript; 81, 82; 81, 83; 82, identifier:bases; 83, identifier:nuc; 84, for_in_clause; 84, 85; 84, 86; 85, identifier:nuc; 86, identifier:bases; 87, if_clause; 87, 88; 88, comparison_operator:==; 88, 89; 88, 92; 89, subscript; 89, 90; 89, 91; 90, identifier:bases; 91, identifier:nuc; 92, identifier:top; 93, if_statement; 93, 94; 93, 101; 93, 110; 94, comparison_operator:==; 94, 95; 94, 100; 95, subscript; 95, 96; 95, 99; 96, subscript; 96, 97; 96, 98; 97, identifier:top; 98, integer:0; 99, integer:1; 100, integer:0; 101, block; 101, 102; 102, expression_statement; 102, 103; 103, assignment; 103, 104; 103, 107; 104, subscript; 104, 105; 104, 106; 105, identifier:bases; 106, string:'consensus'; 107, tuple; 107, 108; 107, 109; 108, string:'n/a'; 109, integer:0; 110, else_clause; 110, 111; 111, block; 111, 112; 112, expression_statement; 112, 113; 113, assignment; 113, 114; 113, 117; 114, subscript; 114, 115; 114, 116; 115, identifier:bases; 116, string:'consensus'; 117, call; 117, 118; 117, 121; 118, attribute; 118, 119; 118, 120; 119, identifier:random; 120, identifier:choice; 121, argument_list; 121, 122; 122, identifier:top; 123, if_statement; 123, 124; 123, 127; 123, 136; 124, comparison_operator:==; 124, 125; 124, 126; 125, identifier:total; 126, integer:0; 127, block; 127, 128; 127, 132; 128, expression_statement; 128, 129; 129, assignment; 129, 130; 129, 131; 130, identifier:c_freq; 131, string:'n/a'; 132, expression_statement; 132, 133; 133, assignment; 133, 134; 133, 135; 134, identifier:ref_freq; 135, string:'n/a'; 136, else_clause; 136, 137; 137, block; 137, 138; 137, 154; 138, expression_statement; 138, 139; 139, assignment; 139, 140; 139, 141; 140, identifier:c_freq; 141, binary_operator:/; 141, 142; 141, 150; 142, call; 142, 143; 142, 144; 143, identifier:float; 144, argument_list; 144, 145; 145, subscript; 145, 146; 145, 149; 146, subscript; 146, 147; 146, 148; 147, identifier:bases; 148, string:'consensus'; 149, integer:1; 150, call; 150, 151; 150, 152; 151, identifier:float; 152, argument_list; 152, 153; 153, identifier:total; 154, if_statement; 154, 155; 154, 160; 154, 165; 155, comparison_operator:not; 155, 156; 155, 159; 156, subscript; 156, 157; 156, 158; 157, identifier:bases; 158, string:'ref'; 159, identifier:bases; 160, block; 160, 161; 161, expression_statement; 161, 162; 162, assignment; 162, 163; 162, 164; 163, identifier:ref_freq; 164, integer:0; 165, else_clause; 165, 166; 166, block; 166, 167; 167, expression_statement; 167, 168; 168, assignment; 168, 169; 168, 170; 169, identifier:ref_freq; 170, binary_operator:/; 170, 171; 170, 179; 171, call; 171, 172; 171, 173; 172, identifier:float; 173, argument_list; 173, 174; 174, subscript; 174, 175; 174, 176; 175, identifier:bases; 176, subscript; 176, 177; 176, 178; 177, identifier:bases; 178, string:'ref'; 179, call; 179, 180; 179, 181; 180, identifier:float; 181, argument_list; 181, 182; 182, identifier:total; 183, expression_statement; 183, 184; 184, assignment; 184, 185; 184, 188; 185, subscript; 185, 186; 185, 187; 186, identifier:bases; 187, string:'consensus frequency'; 188, identifier:c_freq; 189, expression_statement; 189, 190; 190, assignment; 190, 191; 190, 194; 191, subscript; 191, 192; 191, 193; 192, identifier:bases; 193, string:'reference frequency'; 194, identifier:ref_freq; 195, return_statement; 195, 196; 196, identifier:bases | 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['reference frequency'] = 'n/a'
return bases
top = [(nuc, bases[nuc]) for nuc in bases if bases[nuc] == top]
if top[0][1] == 0:
bases['consensus'] = ('n/a', 0)
else:
bases['consensus'] = random.choice(top)
if total == 0:
c_freq = 'n/a'
ref_freq = 'n/a'
else:
c_freq = float(bases['consensus'][1]) / float(total)
if bases['ref'] not in bases:
ref_freq = 0
else:
ref_freq = float(bases[bases['ref']]) / float(total)
bases['consensus frequency'] = c_freq
bases['reference frequency'] = ref_freq
return bases |
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, pattern_list; 11, 12; 11, 13; 12, identifier:genome; 13, identifier:contigs; 14, call; 14, 15; 14, 16; 15, identifier:list; 16, argument_list; 16, 17; 17, call; 17, 18; 17, 21; 18, attribute; 18, 19; 18, 20; 19, identifier:genomes; 20, identifier:items; 21, argument_list; 22, block; 22, 23; 22, 29; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 28; 25, subscript; 25, 26; 25, 27; 26, identifier:cons; 27, identifier:genome; 28, dictionary; 29, for_statement; 29, 30; 29, 33; 29, 41; 30, pattern_list; 30, 31; 30, 32; 31, identifier:contig; 32, identifier:samples; 33, call; 33, 34; 33, 35; 34, identifier:list; 35, argument_list; 35, 36; 36, call; 36, 37; 36, 40; 37, attribute; 37, 38; 37, 39; 38, identifier:contigs; 39, identifier:items; 40, argument_list; 41, block; 41, 42; 42, for_statement; 42, 43; 42, 46; 42, 54; 43, pattern_list; 43, 44; 43, 45; 44, identifier:sample; 45, identifier:stats; 46, call; 46, 47; 46, 48; 47, identifier:list; 48, argument_list; 48, 49; 49, call; 49, 50; 49, 53; 50, attribute; 50, 51; 50, 52; 51, identifier:samples; 52, identifier:items; 53, argument_list; 54, block; 54, 55; 54, 70; 54, 82; 55, if_statement; 55, 56; 55, 61; 56, comparison_operator:not; 56, 57; 56, 58; 57, identifier:sample; 58, subscript; 58, 59; 58, 60; 59, identifier:cons; 60, identifier:genome; 61, block; 61, 62; 62, expression_statement; 62, 63; 63, assignment; 63, 64; 63, 69; 64, subscript; 64, 65; 64, 68; 65, subscript; 65, 66; 65, 67; 66, identifier:cons; 67, identifier:genome; 68, identifier:sample; 69, dictionary; 70, expression_statement; 70, 71; 71, assignment; 71, 72; 71, 73; 72, identifier:seq; 73, assignment; 73, 74; 73, 81; 74, subscript; 74, 75; 74, 80; 75, subscript; 75, 76; 75, 79; 76, subscript; 76, 77; 76, 78; 77, identifier:cons; 78, identifier:genome; 79, identifier:sample; 80, identifier:contig; 81, list:[]; 82, for_statement; 82, 83; 82, 86; 82, 93; 83, pattern_list; 83, 84; 83, 85; 84, identifier:pos; 85, identifier:ps; 86, call; 86, 87; 86, 88; 87, identifier:enumerate; 88, argument_list; 88, 89; 88, 92; 89, subscript; 89, 90; 89, 91; 90, identifier:stats; 91, string:'bp_stats'; 92, integer:1; 93, block; 93, 94; 93, 108; 93, 121; 94, expression_statement; 94, 95; 95, assignment; 95, 96; 95, 99; 96, pattern_list; 96, 97; 96, 98; 97, identifier:ref; 98, identifier:consensus; 99, expression_list; 99, 100; 99, 103; 100, subscript; 100, 101; 100, 102; 101, identifier:ps; 102, string:'ref'; 103, subscript; 103, 104; 103, 107; 104, subscript; 104, 105; 104, 106; 105, identifier:ps; 106, string:'consensus'; 107, integer:0; 108, if_statement; 108, 109; 108, 112; 109, comparison_operator:==; 109, 110; 109, 111; 110, identifier:consensus; 111, string:'n/a'; 112, block; 112, 113; 113, expression_statement; 113, 114; 114, assignment; 114, 115; 114, 116; 115, identifier:consensus; 116, call; 116, 117; 116, 120; 117, attribute; 117, 118; 117, 119; 118, identifier:ref; 119, identifier:lower; 120, argument_list; 121, expression_statement; 121, 122; 122, call; 122, 123; 122, 126; 123, attribute; 123, 124; 123, 125; 124, identifier:seq; 125, identifier:append; 126, argument_list; 126, 127; 127, identifier:consensus; 128, for_statement; 128, 129; 128, 132; 128, 137; 129, pattern_list; 129, 130; 129, 131; 130, identifier:genome; 131, identifier:samples; 132, call; 132, 133; 132, 136; 133, attribute; 133, 134; 133, 135; 134, identifier:cons; 135, identifier:items; 136, argument_list; 137, block; 137, 138; 138, for_statement; 138, 139; 138, 142; 138, 147; 139, pattern_list; 139, 140; 139, 141; 140, identifier:sample; 141, identifier:contigs; 142, call; 142, 143; 142, 146; 143, attribute; 143, 144; 143, 145; 144, identifier:samples; 145, identifier:items; 146, argument_list; 147, block; 147, 148; 147, 156; 147, 164; 147, 198; 148, expression_statement; 148, 149; 149, assignment; 149, 150; 149, 151; 150, identifier:fn; 151, binary_operator:%; 151, 152; 151, 153; 152, string:'%s.%s.consensus.fa'; 153, tuple; 153, 154; 153, 155; 154, identifier:genome; 155, identifier:sample; 156, expression_statement; 156, 157; 157, assignment; 157, 158; 157, 159; 158, identifier:f; 159, call; 159, 160; 159, 161; 160, identifier:open; 161, argument_list; 161, 162; 161, 163; 162, identifier:fn; 163, string:'w'; 164, for_statement; 164, 165; 164, 168; 164, 173; 165, pattern_list; 165, 166; 165, 167; 166, identifier:contig; 167, identifier:seq; 168, call; 168, 169; 168, 172; 169, attribute; 169, 170; 169, 171; 170, identifier:contigs; 171, identifier:items; 172, argument_list; 173, block; 173, 174; 173, 185; 174, expression_statement; 174, 175; 175, call; 175, 176; 175, 177; 176, identifier:print; 177, argument_list; 177, 178; 177, 182; 178, binary_operator:%; 178, 179; 178, 180; 179, string:'>%s'; 180, parenthesized_expression; 180, 181; 181, identifier:contig; 182, keyword_argument; 182, 183; 182, 184; 183, identifier:file; 184, identifier:f; 185, expression_statement; 185, 186; 186, call; 186, 187; 186, 188; 187, identifier:print; 188, argument_list; 188, 189; 188, 195; 189, call; 189, 190; 189, 193; 190, attribute; 190, 191; 190, 192; 191, string:''; 192, identifier:join; 193, argument_list; 193, 194; 194, identifier:seq; 195, keyword_argument; 195, 196; 195, 197; 196, identifier:file; 197, identifier:f; 198, expression_statement; 198, 199; 199, call; 199, 200; 199, 203; 200, attribute; 200, 201; 200, 202; 201, identifier:f; 202, identifier:close; 203, argument_list; 204, return_statement; 204, 205; 205, identifier:cons | 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] = {}
seq = cons[genome][sample][contig] = []
for pos, ps in enumerate(stats['bp_stats'], 1):
ref, consensus = ps['ref'], ps['consensus'][0]
if consensus == 'n/a':
consensus = ref.lower()
seq.append(consensus)
for genome, samples in cons.items():
for sample, contigs in samples.items():
fn = '%s.%s.consensus.fa' % (genome, sample)
f = open(fn, 'w')
for contig, seq in contigs.items():
print('>%s' % (contig), file = f)
print(''.join(seq), file = f)
f.close()
return cons |
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; 11, expression_statement; 11, 12; 12, assignment; 12, 13; 12, 14; 13, identifier:mapped; 14, dictionary; 15, for_statement; 15, 16; 15, 17; 15, 21; 16, identifier:line; 17, call; 17, 18; 17, 19; 18, identifier:open; 19, argument_list; 19, 20; 20, identifier:cov_table; 21, block; 21, 22; 21, 35; 21, 126; 21, 132; 21, 155; 21, 161; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 25; 24, identifier:line; 25, call; 25, 26; 25, 33; 26, attribute; 26, 27; 26, 32; 27, call; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:line; 30, identifier:strip; 31, argument_list; 32, identifier:split; 33, argument_list; 33, 34; 34, string:'\t'; 35, if_statement; 35, 36; 35, 41; 35, 124; 36, attribute; 36, 37; 36, 40; 37, subscript; 37, 38; 37, 39; 38, identifier:line; 39, integer:0; 40, identifier:startswith; 41, ERROR; 41, 42; 41, 43; 41, 76; 41, 79; 41, 80; 41, 121; 42, ERROR; 43, keyword_argument; 43, 44; 43, 45; 44, identifier:samples; 45, subscript; 45, 46; 45, 51; 45, 53; 46, subscript; 46, 47; 46, 48; 47, identifier:line; 48, slice; 48, 49; 48, 50; 49, integer:1; 50, colon; 51, ERROR; 51, 52; 52, identifier:samples; 53, comparison_operator:in; 53, 54; 53, 72; 53, 75; 54, subscript; 54, 55; 54, 71; 55, call; 55, 56; 55, 68; 56, attribute; 56, 57; 56, 67; 57, subscript; 57, 58; 57, 65; 58, call; 58, 59; 58, 62; 59, attribute; 59, 60; 59, 61; 60, identifier:i; 61, identifier:rsplit; 62, argument_list; 62, 63; 62, 64; 63, string:'/'; 64, integer:1; 65, unary_operator:-; 65, 66; 66, integer:1; 67, identifier:split; 68, argument_list; 68, 69; 68, 70; 69, string:'.'; 70, integer:1; 71, integer:0; 72, ERROR; 72, 73; 72, 74; 73, identifier:for; 74, identifier:i; 75, identifier:samples; 76, ERROR; 76, 77; 76, 78; 77, identifier:continue; 78, identifier:scaffold; 79, identifier:length; 80, subscript; 80, 81; 80, 111; 80, 113; 81, subscript; 81, 82; 81, 96; 81, 98; 82, call; 82, 83; 82, 91; 82, 94; 83, call; 83, 84; 83, 89; 84, attribute; 84, 85; 84, 88; 85, subscript; 85, 86; 85, 87; 86, identifier:line; 87, integer:0; 88, identifier:split; 89, argument_list; 89, 90; 90, string:': '; 91, ERROR; 91, 92; 91, 93; 92, identifier:length; 93, identifier:float; 94, argument_list; 94, 95; 95, identifier:length; 96, ERROR; 96, 97; 97, identifier:covs; 98, comparison_operator:in; 98, 99; 98, 103; 98, 106; 99, call; 99, 100; 99, 101; 100, identifier:float; 101, argument_list; 101, 102; 102, identifier:i; 103, ERROR; 103, 104; 103, 105; 104, identifier:for; 105, identifier:i; 106, subscript; 106, 107; 106, 108; 107, identifier:line; 108, slice; 108, 109; 108, 110; 109, integer:1; 110, colon; 111, ERROR; 111, 112; 112, identifier:bases; 113, comparison_operator:in; 113, 114; 113, 117; 113, 120; 114, binary_operator:*; 114, 115; 114, 116; 115, identifier:c; 116, identifier:length; 117, ERROR; 117, 118; 117, 119; 118, identifier:for; 119, identifier:c; 120, identifier:covs; 121, comparison_operator:not; 121, 122; 121, 123; 122, identifier:scaffold; 123, identifier:scaffold2genome; 124, block; 124, 125; 125, continue_statement; 126, expression_statement; 126, 127; 127, assignment; 127, 128; 127, 129; 128, identifier:genome; 129, subscript; 129, 130; 129, 131; 130, identifier:scaffold2genome; 131, identifier:scaffold; 132, if_statement; 132, 133; 132, 136; 133, comparison_operator:not; 133, 134; 133, 135; 134, identifier:genome; 135, identifier:size; 136, block; 136, 137; 136, 143; 137, expression_statement; 137, 138; 138, assignment; 138, 139; 138, 142; 139, subscript; 139, 140; 139, 141; 140, identifier:size; 141, identifier:genome; 142, integer:0; 143, expression_statement; 143, 144; 144, assignment; 144, 145; 144, 148; 145, subscript; 145, 146; 145, 147; 146, identifier:mapped; 147, identifier:genome; 148, dictionary_comprehension; 148, 149; 148, 152; 149, pair; 149, 150; 149, 151; 150, identifier:sample; 151, integer:0; 152, for_in_clause; 152, 153; 152, 154; 153, identifier:sample; 154, identifier:samples; 155, expression_statement; 155, 156; 156, augmented_assignment:+=; 156, 157; 156, 160; 157, subscript; 157, 158; 157, 159; 158, identifier:size; 159, identifier:genome; 160, identifier:length; 161, for_statement; 161, 162; 161, 165; 161, 170; 162, pattern_list; 162, 163; 162, 164; 163, identifier:sample; 164, identifier:count; 165, call; 165, 166; 165, 167; 166, identifier:zip; 167, argument_list; 167, 168; 167, 169; 168, identifier:samples; 169, identifier:bases; 170, block; 170, 171; 171, expression_statement; 171, 172; 172, augmented_assignment:+=; 172, 173; 172, 178; 173, subscript; 173, 174; 173, 177; 174, subscript; 174, 175; 174, 176; 175, identifier:mapped; 176, identifier:genome; 177, identifier:sample; 178, identifier:count; 179, expression_statement; 179, 180; 180, assignment; 180, 181; 180, 182; 181, identifier:coverage; 182, dictionary; 182, 183; 182, 186; 182, 189; 182, 192; 183, pair; 183, 184; 183, 185; 184, string:'genome'; 185, list:[]; 186, pair; 186, 187; 186, 188; 187, string:'genome size (bp)'; 188, list:[]; 189, pair; 189, 190; 189, 191; 190, string:'sample'; 191, list:[]; 192, pair; 192, 193; 192, 194; 193, string:'coverage'; 194, list:[]; 195, for_statement; 195, 196; 195, 199; 195, 204; 196, pattern_list; 196, 197; 196, 198; 197, identifier:genome; 198, identifier:length; 199, call; 199, 200; 199, 203; 200, attribute; 200, 201; 200, 202; 201, identifier:size; 202, identifier:items; 203, argument_list; 204, block; 204, 205; 205, for_statement; 205, 206; 205, 207; 205, 208; 206, identifier:sample; 207, identifier:samples; 208, block; 208, 209; 208, 219; 208, 228; 208, 237; 208, 246; 209, expression_statement; 209, 210; 210, assignment; 210, 211; 210, 212; 211, identifier:cov; 212, binary_operator:/; 212, 213; 212, 218; 213, subscript; 213, 214; 213, 217; 214, subscript; 214, 215; 214, 216; 215, identifier:mapped; 216, identifier:genome; 217, identifier:sample; 218, identifier:length; 219, expression_statement; 219, 220; 220, call; 220, 221; 220, 226; 221, attribute; 221, 222; 221, 225; 222, subscript; 222, 223; 222, 224; 223, identifier:coverage; 224, string:'genome'; 225, identifier:append; 226, argument_list; 226, 227; 227, identifier:genome; 228, expression_statement; 228, 229; 229, call; 229, 230; 229, 235; 230, attribute; 230, 231; 230, 234; 231, subscript; 231, 232; 231, 233; 232, identifier:coverage; 233, string:'genome size (bp)'; 234, identifier:append; 235, argument_list; 235, 236; 236, identifier:length; 237, expression_statement; 237, 238; 238, call; 238, 239; 238, 244; 239, attribute; 239, 240; 239, 243; 240, subscript; 240, 241; 240, 242; 241, identifier:coverage; 242, string:'sample'; 243, identifier:append; 244, argument_list; 244, 245; 245, identifier:sample; 246, expression_statement; 246, 247; 247, call; 247, 248; 247, 253; 248, attribute; 248, 249; 248, 252; 249, subscript; 249, 250; 249, 251; 250, identifier:coverage; 251, string:'coverage'; 252, identifier:append; 253, argument_list; 253, 254; 254, identifier:cov; 255, return_statement; 255, 256; 256, call; 256, 257; 256, 260; 257, attribute; 257, 258; 257, 259; 258, identifier:pd; 259, identifier:DataFrame; 260, argument_list; 260, 261; 261, identifier:coverage | 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
scaffold, length = line[0].split(': ')
length = float(length)
covs = [float(i) for i in line[1:]]
bases = [c * length for c in covs]
if scaffold not in scaffold2genome:
continue
genome = scaffold2genome[scaffold]
if genome not in size:
size[genome] = 0
mapped[genome] = {sample:0 for sample in samples}
size[genome] += length
for sample, count in zip(samples, bases):
mapped[genome][sample] += count
coverage = {'genome':[], 'genome size (bp)':[], 'sample':[], 'coverage':[]}
for genome, length in size.items():
for sample in samples:
cov = mapped[genome][sample] / length
coverage['genome'].append(genome)
coverage['genome size (bp)'].append(length)
coverage['sample'].append(sample)
coverage['coverage'].append(cov)
return pd.DataFrame(coverage) |
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_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:out; 12, call; 12, 13; 12, 14; 13, identifier:open; 14, argument_list; 14, 15; 14, 16; 15, identifier:file_name; 16, string:'w'; 17, expression_statement; 17, 18; 18, assignment; 18, 19; 18, 20; 19, identifier:fastas; 20, call; 20, 21; 20, 22; 21, identifier:sorted; 22, argument_list; 22, 23; 23, identifier:fastas; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 27; 25, 31; 25, 33; 26, identifier:print; 27, ERROR; 27, 28; 27, 29; 27, 30; 28, string:'
print('; 29, identifier:fasta; 30, identifier:fastas; 31, type; 31, 32; 32, identifier:line; 33, list:[fasta]; 33, 34; 34, identifier:fasta; 35, for_statement; 35, 36; 35, 37; 35, 38; 36, identifier:other; 37, identifier:fastas; 38, block; 38, 39; 38, 75; 39, if_statement; 39, 40; 39, 43; 39, 48; 40, comparison_operator:==; 40, 41; 40, 42; 41, identifier:other; 42, identifier:fasta; 43, block; 43, 44; 44, expression_statement; 44, 45; 45, assignment; 45, 46; 45, 47; 46, identifier:average; 47, string:'-'; 48, else_clause; 48, 49; 49, block; 49, 50; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 53; 52, identifier:average; 53, call; 53, 54; 53, 57; 54, attribute; 54, 55; 54, 56; 55, identifier:numpy; 56, identifier:average; 57, argument_list; 57, 58; 58, list_comprehension; 58, 59; 58, 68; 59, subscript; 59, 60; 59, 67; 60, subscript; 60, 61; 60, 66; 61, subscript; 61, 62; 61, 65; 62, subscript; 62, 63; 62, 64; 63, identifier:hits; 64, identifier:fasta; 65, identifier:other; 66, identifier:i; 67, integer:3; 68, for_in_clause; 68, 69; 68, 70; 69, identifier:i; 70, subscript; 70, 71; 70, 74; 71, subscript; 71, 72; 71, 73; 72, identifier:hits; 73, identifier:fasta; 74, identifier:other; 75, expression_statement; 75, 76; 76, call; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, identifier:line; 79, identifier:append; 80, argument_list; 80, 81; 81, call; 81, 82; 81, 83; 82, identifier:str; 83, argument_list; 83, 84; 84, identifier:average; 85, expression_statement; 85, 86; 86, call; 86, 87; 86, 88; 87, identifier:print; 88, argument_list; 88, 89; 88, 95; 89, call; 89, 90; 89, 93; 90, attribute; 90, 91; 90, 92; 91, string:'\t'; 92, identifier:join; 93, argument_list; 93, 94; 94, identifier:line; 95, keyword_argument; 95, 96; 95, 97; 96, identifier:file; 97, identifier:out; 98, expression_statement; 98, 99; 99, call; 99, 100; 99, 101; 100, identifier:print; 101, argument_list; 101, 102; 101, 103; 102, string:''; 103, keyword_argument; 103, 104; 103, 105; 104, identifier:file; 105, identifier:out; 106, expression_statement; 106, 107; 107, assignment; 107, 108; 107, 109; 107, 113; 107, 115; 108, identifier:print; 109, ERROR; 109, 110; 109, 111; 109, 112; 110, string:'
print('; 111, identifier:fasta; 112, identifier:fastas; 113, type; 113, 114; 114, identifier:line; 115, list:[fasta]; 115, 116; 116, identifier:fasta; 117, for_statement; 117, 118; 117, 119; 117, 120; 118, identifier:other; 119, identifier:fastas; 120, block; 120, 121; 120, 179; 121, if_statement; 121, 122; 121, 125; 121, 130; 122, comparison_operator:==; 122, 123; 122, 124; 123, identifier:other; 124, identifier:fasta; 125, block; 125, 126; 126, expression_statement; 126, 127; 127, assignment; 127, 128; 127, 129; 128, identifier:percent; 129, string:'-'; 130, else_clause; 130, 131; 131, block; 131, 132; 131, 146; 131, 168; 132, expression_statement; 132, 133; 133, assignment; 133, 134; 133, 135; 134, identifier:orthologs; 135, call; 135, 136; 135, 137; 136, identifier:float; 137, argument_list; 137, 138; 138, call; 138, 139; 138, 140; 139, identifier:len; 140, argument_list; 140, 141; 141, subscript; 141, 142; 141, 145; 142, subscript; 142, 143; 142, 144; 143, identifier:hits; 144, identifier:fasta; 145, identifier:other; 146, expression_statement; 146, 147; 147, assignment; 147, 148; 147, 149; 148, identifier:orfs; 149, call; 149, 150; 149, 151; 150, identifier:float; 151, argument_list; 151, 152; 152, call; 152, 153; 152, 154; 153, identifier:len; 154, argument_list; 154, 155; 155, list_comprehension; 155, 156; 155, 157; 155, 160; 156, identifier:i; 157, for_in_clause; 157, 158; 157, 159; 158, identifier:i; 159, identifier:id2desc; 160, if_clause; 160, 161; 161, comparison_operator:==; 161, 162; 161, 167; 162, subscript; 162, 163; 162, 166; 163, subscript; 163, 164; 163, 165; 164, identifier:id2desc; 165, identifier:i; 166, integer:0; 167, identifier:fasta; 168, expression_statement; 168, 169; 169, assignment; 169, 170; 169, 171; 170, identifier:percent; 171, binary_operator:*; 171, 172; 171, 178; 172, call; 172, 173; 172, 174; 173, identifier:float; 174, argument_list; 174, 175; 175, binary_operator:/; 175, 176; 175, 177; 176, identifier:orthologs; 177, identifier:orfs; 178, integer:100; 179, expression_statement; 179, 180; 180, call; 180, 181; 180, 184; 181, attribute; 181, 182; 181, 183; 182, identifier:line; 183, identifier:append; 184, argument_list; 184, 185; 185, call; 185, 186; 185, 187; 186, identifier:str; 187, argument_list; 187, 188; 188, identifier:percent; 189, expression_statement; 189, 190; 190, call; 190, 191; 190, 192; 191, identifier:print; 192, argument_list; 192, 193; 192, 199; 193, call; 193, 194; 193, 197; 194, attribute; 194, 195; 194, 196; 195, string:'\t'; 196, identifier:join; 197, argument_list; 197, 198; 198, identifier:line; 199, keyword_argument; 199, 200; 199, 201; 200, identifier:file; 201, identifier:out | 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:
average = numpy.average([hits[fasta][other][i][3] for i in hits[fasta][other]])
line.append(str(average))
print('\t'.join(line), file=out)
print('', file=out)
print('
print('
for fasta in fastas:
line = [fasta]
for other in fastas:
if other == fasta:
percent = '-'
else:
orthologs = float(len(hits[fasta][other]))
orfs = float(len([i for i in id2desc if id2desc[i][0] == fasta]))
percent = float(orthologs / orfs) * 100
line.append(str(percent))
print('\t'.join(line), file=out) |
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; 9, 12; 9, 13; 10, False; 11, False; 12, False; 13, False; 14, default_parameter; 14, 15; 14, 16; 15, identifier:stdevs; 16, integer:2; 17, block; 17, 18; 17, 25; 17, 29; 17, 70; 17, 78; 17, 84; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:calc_threshold; 21, subscript; 21, 22; 21, 23; 22, identifier:thresholds; 23, unary_operator:-; 23, 24; 24, integer:1; 25, expression_statement; 25, 26; 26, assignment; 26, 27; 26, 28; 27, identifier:norm_threshold; 28, dictionary; 29, for_statement; 29, 30; 29, 31; 29, 42; 30, identifier:pair; 31, call; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:itertools; 34, identifier:permutations; 35, argument_list; 35, 36; 35, 41; 36, list_comprehension; 36, 37; 36, 38; 37, identifier:i; 38, for_in_clause; 38, 39; 38, 40; 39, identifier:i; 40, identifier:rbh; 41, integer:2; 42, block; 42, 43; 42, 58; 43, if_statement; 43, 44; 43, 49; 44, comparison_operator:not; 44, 45; 44, 48; 45, subscript; 45, 46; 45, 47; 46, identifier:pair; 47, integer:0; 48, identifier:norm_threshold; 49, block; 49, 50; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 57; 52, subscript; 52, 53; 52, 54; 53, identifier:norm_threshold; 54, subscript; 54, 55; 54, 56; 55, identifier:pair; 56, integer:0; 57, dictionary; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 69; 60, subscript; 60, 61; 60, 66; 61, subscript; 61, 62; 61, 63; 62, identifier:norm_threshold; 63, subscript; 63, 64; 63, 65; 64, identifier:pair; 65, integer:0; 66, subscript; 66, 67; 66, 68; 67, identifier:pair; 68, integer:1; 69, dictionary; 70, expression_statement; 70, 71; 71, assignment; 71, 72; 71, 73; 72, identifier:out; 73, call; 73, 74; 73, 75; 74, identifier:open; 75, argument_list; 75, 76; 75, 77; 76, identifier:file_name; 77, string:'w'; 78, expression_statement; 78, 79; 79, assignment; 79, 80; 79, 81; 79, 83; 80, identifier:print; 81, ERROR; 81, 82; 82, identifier:comparisons; 83, list:[]; 84, for_statement; 84, 85; 84, 86; 84, 87; 85, identifier:genome; 86, identifier:rbh; 87, block; 87, 88; 88, for_statement; 88, 89; 88, 90; 88, 93; 89, identifier:compare; 90, subscript; 90, 91; 90, 92; 91, identifier:rbh; 92, identifier:genome; 93, block; 93, 94; 93, 108; 93, 114; 93, 121; 93, 140; 93, 170; 93, 179; 93, 188; 93, 197; 93, 206; 93, 215; 94, expression_statement; 94, 95; 95, assignment; 95, 96; 95, 97; 96, identifier:pair; 97, call; 97, 98; 97, 101; 98, attribute; 98, 99; 98, 100; 99, string:''; 100, identifier:join; 101, argument_list; 101, 102; 102, call; 102, 103; 102, 104; 103, identifier:sorted; 104, argument_list; 104, 105; 105, list:[genome, compare]; 105, 106; 105, 107; 106, identifier:genome; 107, identifier:compare; 108, if_statement; 108, 109; 108, 112; 109, comparison_operator:in; 109, 110; 109, 111; 110, identifier:pair; 111, identifier:comparisons; 112, block; 112, 113; 113, continue_statement; 114, expression_statement; 114, 115; 115, call; 115, 116; 115, 119; 116, attribute; 116, 117; 116, 118; 117, identifier:comparisons; 118, identifier:append; 119, argument_list; 119, 120; 120, identifier:pair; 121, expression_statement; 121, 122; 122, assignment; 122, 123; 122, 124; 123, identifier:scores; 124, dictionary; 124, 125; 124, 128; 124, 131; 124, 134; 124, 137; 125, pair; 125, 126; 125, 127; 126, string:'percent identity'; 127, list:[]; 128, pair; 128, 129; 128, 130; 129, string:'e-value'; 130, list:[]; 131, pair; 131, 132; 131, 133; 132, string:'bit score'; 133, list:[]; 134, pair; 134, 135; 134, 136; 135, string:'normalized bit score'; 136, list:[]; 137, pair; 137, 138; 137, 139; 138, string:'alignment length fraction'; 139, list:[]; 140, expression_statement; 140, 141; 141, assignment; 141, 142; 141, 159; 142, pattern_list; 142, 143; 142, 144; 142, 155; 142, 156; 142, 157; 142, 158; 143, identifier:print; 144, ERROR; 144, 145; 144, 147; 144, 154; 145, ERROR; 145, 146; 146, identifier:for; 147, comparison_operator:in; 147, 148; 147, 149; 148, identifier:id; 149, subscript; 149, 150; 149, 153; 150, subscript; 150, 151; 150, 152; 151, identifier:rbh; 152, identifier:genome; 153, identifier:compare; 154, identifier:pident; 155, identifier:length_fraction; 156, identifier:e; 157, identifier:bit; 158, identifier:norm_bit; 159, subscript; 159, 160; 159, 167; 160, subscript; 160, 161; 160, 166; 161, subscript; 161, 162; 161, 165; 162, subscript; 162, 163; 162, 164; 163, identifier:rbh; 164, identifier:genome; 165, identifier:compare; 166, identifier:id; 167, slice; 167, 168; 167, 169; 168, integer:3; 169, colon; 170, expression_statement; 170, 171; 171, call; 171, 172; 171, 177; 172, attribute; 172, 173; 172, 176; 173, subscript; 173, 174; 173, 175; 174, identifier:scores; 175, string:'percent identity'; 176, identifier:append; 177, argument_list; 177, 178; 178, identifier:pident; 179, expression_statement; 179, 180; 180, call; 180, 181; 180, 186; 181, attribute; 181, 182; 181, 185; 182, subscript; 182, 183; 182, 184; 183, identifier:scores; 184, string:'alignment length fraction'; 185, identifier:append; 186, argument_list; 186, 187; 187, identifier:length_fraction; 188, expression_statement; 188, 189; 189, call; 189, 190; 189, 195; 190, attribute; 190, 191; 190, 194; 191, subscript; 191, 192; 191, 193; 192, identifier:scores; 193, string:'e-value'; 194, identifier:append; 195, argument_list; 195, 196; 196, identifier:e; 197, expression_statement; 197, 198; 198, call; 198, 199; 198, 204; 199, attribute; 199, 200; 199, 203; 200, subscript; 200, 201; 200, 202; 201, identifier:scores; 202, string:'bit score'; 203, identifier:append; 204, argument_list; 204, 205; 205, identifier:bit; 206, expression_statement; 206, 207; 207, call; 207, 208; 207, 213; 208, attribute; 208, 209; 208, 212; 209, subscript; 209, 210; 209, 211; 210, identifier:scores; 211, string:'normalized bit score'; 212, identifier:append; 213, argument_list; 213, 214; 214, identifier:norm_bit; 215, if_statement; 215, 216; 215, 219; 215, 287; 216, comparison_operator:is; 216, 217; 216, 218; 217, identifier:calc_threshold; 218, True; 219, ERROR; 219, 220; 219, 226; 219, 235; 219, 244; 219, 253; 219, 254; 219, 256; 219, 257; 219, 262; 219, 267; 219, 269; 219, 276; 219, 277; 219, 279; 220, expression_statement; 220, 221; 221, assignment; 221, 222; 221, 223; 222, identifier:norms; 223, subscript; 223, 224; 223, 225; 224, identifier:scores; 225, string:'normalized bit score'; 226, expression_statement; 226, 227; 227, assignment; 227, 228; 227, 229; 228, identifier:average; 229, call; 229, 230; 229, 233; 230, attribute; 230, 231; 230, 232; 231, identifier:numpy; 232, identifier:average; 233, argument_list; 233, 234; 234, identifier:norms; 235, expression_statement; 235, 236; 236, assignment; 236, 237; 236, 238; 237, identifier:std; 238, call; 238, 239; 238, 242; 239, attribute; 239, 240; 239, 241; 240, identifier:numpy; 241, identifier:std; 242, argument_list; 242, 243; 243, identifier:norms; 244, expression_statement; 244, 245; 245, assignment; 245, 246; 245, 247; 246, identifier:normal_thresh; 247, binary_operator:-; 247, 248; 247, 249; 248, identifier:average; 249, parenthesized_expression; 249, 250; 250, binary_operator:*; 250, 251; 250, 252; 251, identifier:std; 252, identifier:stdevs; 253, string:'
print('; 254, ERROR; 254, 255; 255, identifier:print; 256, ERROR; 257, subscript; 257, 258; 257, 261; 258, subscript; 258, 259; 258, 260; 259, identifier:norm_threshold; 260, identifier:genome; 261, identifier:compare; 262, subscript; 262, 263; 262, 266; 263, subscript; 263, 264; 263, 265; 264, identifier:norm_threshold; 265, identifier:compare; 266, identifier:genome; 267, ERROR; 267, 268; 268, identifier:normal_thresh; 269, ERROR; 269, 270; 270, comparison_operator:in; 270, 271; 270, 272; 270, 275; 271, identifier:normal_thresh; 272, ERROR; 272, 273; 272, 274; 273, identifier:for; 274, identifier:score; 275, identifier:scores; 276, identifier:print; 277, ERROR; 277, 278; 278, identifier:if; 279, comparison_operator:>; 279, 280; 279, 286; 280, call; 280, 281; 280, 282; 281, identifier:len; 282, argument_list; 282, 283; 283, subscript; 283, 284; 283, 285; 284, identifier:scores; 285, identifier:score; 286, integer:0; 287, block; 287, 288; 288, expression_statement; 288, 289; 289, call; 289, 290; 289, 291; 290, identifier:print; 291, argument_list; 291, 292; 291, 295; 292, concatenated_string; 292, 293; 292, 294; 293, string:'
print('; 294, string:'; 295, keyword_argument; 295, 296; 295, 297; 296, identifier:file; 297, identifier:out; 298, expression_statement; 298, 299; 299, call; 299, 300; 299, 303; 300, attribute; 300, 301; 300, 302; 301, identifier:out; 302, identifier:close; 303, argument_list; 304, if_statement; 304, 305; 304, 308; 304, 320; 305, comparison_operator:is; 305, 306; 305, 307; 306, identifier:calc_threshold; 307, True; 308, block; 308, 309; 309, return_statement; 309, 310; 310, binary_operator:+; 310, 311; 310, 318; 311, subscript; 311, 312; 311, 313; 312, identifier:thresholds; 313, slice; 313, 314; 313, 315; 313, 316; 314, integer:0; 315, colon; 316, unary_operator:-; 316, 317; 317, integer:1; 318, list:[norm_threshold]; 318, 319; 319, identifier:norm_threshold; 320, else_clause; 320, 321; 321, block; 321, 322; 322, return_statement; 322, 323; 323, identifier:thresholds | 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[pair[0]][pair[1]] = {}
out = open(file_name, 'w')
print('
comparisons = []
for genome in rbh:
for compare in rbh[genome]:
pair = ''.join(sorted([genome, compare]))
if pair in comparisons:
continue
comparisons.append(pair)
scores = {'percent identity': [], 'e-value': [], 'bit score': [], 'normalized bit score': [], 'alignment length fraction': []}
print('
for id in rbh[genome][compare]:
pident, length_fraction, e, bit, norm_bit = rbh[genome][compare][id][3:]
scores['percent identity'].append(pident)
scores['alignment length fraction'].append(length_fraction)
scores['e-value'].append(e)
scores['bit score'].append(bit)
scores['normalized bit score'].append(norm_bit)
if calc_threshold is True:
norms = scores['normalized bit score']
average = numpy.average(norms)
std = numpy.std(norms)
normal_thresh = average - (std * stdevs)
print('
print('
print('
norm_threshold[genome][compare], norm_threshold[compare][genome] = normal_thresh, normal_thresh
for score in scores:
print('
if len(scores[score]) > 0:
print('
print('', file=out)
out.close()
if calc_threshold is True:
return thresholds[0:-1] + [norm_threshold]
else:
return thresholds |
End of preview. Expand
in Dataset Viewer.
No dataset card yet
- Downloads last month
- 13