nodes
stringlengths
501
22.4k
edges
stringlengths
138
5.07k
code
stringlengths
108
19.3k
0, module; 1, function_definition; 2, function_name:gather_categories; 3, parameters; 4, block; 5, identifier:imap; 6, identifier:header; 7, default_parameter; 8, expression_statement; 9, comment:# If no categories provided, return all SampleIDs; 10, if_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, for_statement; 15, comment:# If invalid categories or conditions identified, return all SampleIDs; 16, if_statement; 17, comment:#If only category column given, return column-wise SampleIDs; 18, if_statement; 19, comment:# Collect all condition names; 20, expression_statement; 21, for_statement; 22, expression_statement; 23, comment:# If column name and condition given, return overlapping SampleIDs of column and; 24, comment:# condition combinations; 25, for_statement; 26, try_statement; 27, identifier:categories; 28, None; 29, comment:""" Find the user specified categories in the map and create a dictionary to contain the relevant data for each type within the categories. Multiple categories will have their types combined such that each possible combination will have its own entry in the dictionary. :type imap: dict :param imap: The input mapping file data keyed by SampleID :type header: list :param header: The header line from the input mapping file. This will be searched for the user-specified categories :type categories: list :param categories: The list of user-specified category column name from mapping file :rtype: dict :return: A sorted dictionary keyed on the combinations of all the types found within the user-specified categories. Each entry will contain an empty DataCategory namedtuple. If no categories are specified, a single entry with the key 'default' will be returned """; 30, comparison_operator:categories is None; 31, block; 32, assignment; 33, assignment; 34, assignment; 35, pattern_list; 36, call; 37, block; 38, boolean_operator; 39, block; 40, boolean_operator; 41, block; 42, assignment; 43, identifier:k; 44, identifier:conditions; 45, block; 46, assignment; 47, pattern_list; 48, call; 49, block; 50, block; 51, except_clause; 52, else_clause; 53, identifier:categories; 54, None; 55, return_statement; 56, identifier:cat_ids; 57, list_comprehension; 58, identifier:table; 59, call; 60, identifier:conditions; 61, call; 62, identifier:i; 63, identifier:cat; 64, identifier:enumerate; 65, argument_list; 66, if_statement; 67, not_operator; 68, not_operator; 69, return_statement; 70, identifier:cat_ids; 71, not_operator; 72, for_statement; 73, return_statement; 74, identifier:cond_ids; 75, call; 76, try_statement; 77, identifier:idx_to_test; 78, call; 79, identifier:sid; 80, identifier:row; 81, attribute; 82, argument_list; 83, if_statement; 84, assert_statement; 85, identifier:AssertionError; 86, block; 87, block; 88, dictionary; 89, call; 90, for_in_clause; 91, if_clause; 92, identifier:OrderedDict; 93, argument_list; 94, identifier:defaultdict; 95, argument_list; 96, identifier:categories; 97, boolean_operator; 98, block; 99, identifier:cat_ids; 100, identifier:conditions; 101, dictionary; 102, identifier:conditions; 103, pattern_list; 104, call; 105, block; 106, identifier:table; 107, identifier:set; 108, argument_list; 109, block; 110, except_clause; 111, attribute; 112, argument_list; 113, identifier:imap; 114, identifier:items; 115, call; 116, block; 117, comparison_operator:len(table) > 0; 118, return_statement; 119, return_statement; 120, pair; 121, attribute; 122, argument_list; 123, identifier:cat; 124, identifier:categories; 125, boolean_operator; 126, identifier:set; 127, comparison_operator:"=" in cat; 128, comparison_operator:cat.split("=")[0] in header; 129, expression_statement; 130, expression_statement; 131, pair; 132, identifier:sid; 133, identifier:row; 134, attribute; 135, argument_list; 136, expression_statement; 137, if_statement; 138, expression_statement; 139, expression_statement; 140, identifier:ValueError; 141, block; 142, call; 143, identifier:union; 144, identifier:cond_ids; 145, identifier:all; 146, argument_list; 147, expression_statement; 148, try_statement; 149, expression_statement; 150, call; 151, integer:0; 152, dictionary; 153, identifier:table; 154, string:"default"; 155, call; 156, identifier:header; 157, identifier:index; 158, identifier:cat; 159, comparison_operator:cat in header; 160, comparison_operator:"=" not in cat; 161, string:"="; 162, identifier:cat; 163, subscript; 164, identifier:header; 165, assignment; 166, call; 167, string:"default"; 168, call; 169, identifier:imap; 170, identifier:items; 171, assignment; 172, comparison_operator:cat_name not in table; 173, block; 174, call; 175, call; 176, continue_statement; 177, identifier:set; 178, argument_list; 179, list_comprehension; 180, assignment; 181, block; 182, except_clause; 183, call; 184, identifier:len; 185, argument_list; 186, pair; 187, identifier:DataCategory; 188, argument_list; 189, identifier:cat; 190, identifier:header; 191, string:"="; 192, identifier:cat; 193, call; 194, integer:0; 195, identifier:cat_name; 196, subscript; 197, attribute; 198, argument_list; 199, identifier:DataCategory; 200, argument_list; 201, identifier:cat_name; 202, call; 203, identifier:cat_name; 204, identifier:table; 205, expression_statement; 206, attribute; 207, argument_list; 208, attribute; 209, argument_list; 210, identifier:cat_ids; 211, comparison_operator:row[header.index(c)] in conditions[c]; 212, for_in_clause; 213, identifier:key; 214, call; 215, assert_statement; 216, identifier:AssertionError; 217, block; 218, attribute; 219, argument_list; 220, identifier:table; 221, string:"default"; 222, call; 223, call; 224, dictionary; 225, attribute; 226, argument_list; 227, identifier:header; 228, call; 229, subscript; 230, identifier:add; 231, subscript; 232, call; 233, dictionary; 234, attribute; 235, argument_list; 236, assignment; 237, attribute; 238, identifier:add; 239, identifier:sid; 240, identifier:cond_ids; 241, identifier:add; 242, call; 243, subscript; 244, subscript; 245, identifier:c; 246, identifier:conditions; 247, attribute; 248, argument_list; 249, comparison_operator:key in table.keys(); 250, expression_statement; 251, attribute; 252, identifier:add; 253, identifier:sid; 254, identifier:DataCategory; 255, argument_list; 256, identifier:set; 257, argument_list; 258, identifier:cat; 259, identifier:split; 260, string:"="; 261, attribute; 262, argument_list; 263, identifier:conditions; 264, identifier:cat_name; 265, call; 266, integer:1; 267, identifier:set; 268, argument_list; 269, string:"_"; 270, identifier:join; 271, list_comprehension; 272, subscript; 273, call; 274, subscript; 275, identifier:sids; 276, attribute; 277, argument_list; 278, identifier:row; 279, call; 280, identifier:conditions; 281, identifier:c; 282, string:"_"; 283, identifier:join; 284, list_comprehension; 285, identifier:key; 286, call; 287, assignment; 288, subscript; 289, identifier:sids; 290, call; 291, dictionary; 292, call; 293, identifier:header; 294, identifier:index; 295, subscript; 296, attribute; 297, argument_list; 298, call; 299, subscript; 300, for_in_clause; 301, identifier:table; 302, identifier:cat_name; 303, identifier:DataCategory; 304, argument_list; 305, identifier:table; 306, identifier:cat_name; 307, identifier:header; 308, identifier:index; 309, identifier:k; 310, attribute; 311, argument_list; 312, subscript; 313, for_in_clause; 314, attribute; 315, argument_list; 316, subscript; 317, call; 318, identifier:table; 319, identifier:key; 320, identifier:set; 321, argument_list; 322, attribute; 323, argument_list; 324, call; 325, integer:0; 326, identifier:cat; 327, identifier:split; 328, string:"="; 329, attribute; 330, argument_list; 331, identifier:row; 332, identifier:cid; 333, identifier:cid; 334, identifier:cat_ids; 335, call; 336, dictionary; 337, identifier:header; 338, identifier:index; 339, identifier:c; 340, identifier:row; 341, identifier:idx; 342, identifier:idx; 343, identifier:idx_to_test; 344, identifier:table; 345, identifier:keys; 346, identifier:table; 347, identifier:key; 348, identifier:DataCategory; 349, argument_list; 350, call; 351, identifier:imap; 352, identifier:keys; 353, attribute; 354, argument_list; 355, identifier:imap; 356, identifier:keys; 357, identifier:set; 358, argument_list; 359, call; 360, dictionary; 361, attribute; 362, argument_list; 363, identifier:cat; 364, identifier:split; 365, string:"="; 366, identifier:set; 367, argument_list; 368, identifier:imap; 369, identifier:keys
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 4, 23; 4, 24; 4, 25; 4, 26; 7, 27; 7, 28; 8, 29; 10, 30; 10, 31; 11, 32; 12, 33; 13, 34; 14, 35; 14, 36; 14, 37; 16, 38; 16, 39; 18, 40; 18, 41; 20, 42; 21, 43; 21, 44; 21, 45; 22, 46; 25, 47; 25, 48; 25, 49; 26, 50; 26, 51; 26, 52; 30, 53; 30, 54; 31, 55; 32, 56; 32, 57; 33, 58; 33, 59; 34, 60; 34, 61; 35, 62; 35, 63; 36, 64; 36, 65; 37, 66; 38, 67; 38, 68; 39, 69; 40, 70; 40, 71; 41, 72; 41, 73; 42, 74; 42, 75; 45, 76; 46, 77; 46, 78; 47, 79; 47, 80; 48, 81; 48, 82; 49, 83; 50, 84; 51, 85; 51, 86; 52, 87; 55, 88; 57, 89; 57, 90; 57, 91; 59, 92; 59, 93; 61, 94; 61, 95; 65, 96; 66, 97; 66, 98; 67, 99; 68, 100; 69, 101; 71, 102; 72, 103; 72, 104; 72, 105; 73, 106; 75, 107; 75, 108; 76, 109; 76, 110; 78, 111; 78, 112; 81, 113; 81, 114; 83, 115; 83, 116; 84, 117; 86, 118; 87, 119; 88, 120; 89, 121; 89, 122; 90, 123; 90, 124; 91, 125; 95, 126; 97, 127; 97, 128; 98, 129; 98, 130; 101, 131; 103, 132; 103, 133; 104, 134; 104, 135; 105, 136; 105, 137; 105, 138; 109, 139; 110, 140; 110, 141; 111, 142; 111, 143; 112, 144; 115, 145; 115, 146; 116, 147; 116, 148; 116, 149; 117, 150; 117, 151; 118, 152; 119, 153; 120, 154; 120, 155; 121, 156; 121, 157; 122, 158; 125, 159; 125, 160; 127, 161; 127, 162; 128, 163; 128, 164; 129, 165; 130, 166; 131, 167; 131, 168; 134, 169; 134, 170; 136, 171; 137, 172; 137, 173; 138, 174; 139, 175; 141, 176; 142, 177; 142, 178; 146, 179; 147, 180; 148, 181; 148, 182; 149, 183; 150, 184; 150, 185; 152, 186; 155, 187; 155, 188; 159, 189; 159, 190; 160, 191; 160, 192; 163, 193; 163, 194; 165, 195; 165, 196; 166, 197; 166, 198; 168, 199; 168, 200; 171, 201; 171, 202; 172, 203; 172, 204; 173, 205; 174, 206; 174, 207; 175, 208; 175, 209; 178, 210; 179, 211; 179, 212; 180, 213; 180, 214; 181, 215; 182, 216; 182, 217; 183, 218; 183, 219; 185, 220; 186, 221; 186, 222; 188, 223; 188, 224; 193, 225; 193, 226; 196, 227; 196, 228; 197, 229; 197, 230; 198, 231; 200, 232; 200, 233; 202, 234; 202, 235; 205, 236; 206, 237; 206, 238; 207, 239; 208, 240; 208, 241; 209, 242; 211, 243; 211, 244; 212, 245; 212, 246; 214, 247; 214, 248; 215, 249; 217, 250; 218, 251; 218, 252; 219, 253; 222, 254; 222, 255; 223, 256; 223, 257; 225, 258; 225, 259; 226, 260; 228, 261; 228, 262; 229, 263; 229, 264; 231, 265; 231, 266; 232, 267; 232, 268; 234, 269; 234, 270; 235, 271; 236, 272; 236, 273; 237, 274; 237, 275; 242, 276; 242, 277; 243, 278; 243, 279; 244, 280; 244, 281; 247, 282; 247, 283; 248, 284; 249, 285; 249, 286; 250, 287; 251, 288; 251, 289; 255, 290; 255, 291; 257, 292; 261, 293; 261, 294; 262, 295; 265, 296; 265, 297; 268, 298; 271, 299; 271, 300; 272, 301; 272, 302; 273, 303; 273, 304; 274, 305; 274, 306; 276, 307; 276, 308; 277, 309; 279, 310; 279, 311; 284, 312; 284, 313; 286, 314; 286, 315; 287, 316; 287, 317; 288, 318; 288, 319; 290, 320; 290, 321; 292, 322; 292, 323; 295, 324; 295, 325; 296, 326; 296, 327; 297, 328; 298, 329; 298, 330; 299, 331; 299, 332; 300, 333; 300, 334; 304, 335; 304, 336; 310, 337; 310, 338; 311, 339; 312, 340; 312, 341; 313, 342; 313, 343; 314, 344; 314, 345; 316, 346; 316, 347; 317, 348; 317, 349; 321, 350; 322, 351; 322, 352; 324, 353; 324, 354; 329, 355; 329, 356; 335, 357; 335, 358; 349, 359; 349, 360; 350, 361; 350, 362; 353, 363; 353, 364; 354, 365; 359, 366; 359, 367; 361, 368; 361, 369
def gather_categories(imap, header, categories=None): """ Find the user specified categories in the map and create a dictionary to contain the relevant data for each type within the categories. Multiple categories will have their types combined such that each possible combination will have its own entry in the dictionary. :type imap: dict :param imap: The input mapping file data keyed by SampleID :type header: list :param header: The header line from the input mapping file. This will be searched for the user-specified categories :type categories: list :param categories: The list of user-specified category column name from mapping file :rtype: dict :return: A sorted dictionary keyed on the combinations of all the types found within the user-specified categories. Each entry will contain an empty DataCategory namedtuple. If no categories are specified, a single entry with the key 'default' will be returned """ # If no categories provided, return all SampleIDs 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 invalid categories or conditions identified, return all SampleIDs if not cat_ids and not conditions: return {"default": DataCategory(set(imap.keys()), {})} #If only category column given, return column-wise SampleIDs 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 # Collect all condition names 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) # If column name and condition given, return overlapping SampleIDs of column and # condition combinations 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; 1, function_definition; 2, function_name:sort_sam; 3, parameters; 4, block; 5, identifier:sam; 6, identifier:sort; 7, expression_statement; 8, expression_statement; 9, if_statement; 10, return_statement; 11, comment:""" sort sam file """; 12, assignment; 13, comparison_operator:sort is True; 14, block; 15, else_clause; 16, identifier:mapping; 17, identifier:tempdir; 18, binary_operator:'%s/' % (os.path.abspath(sam).rsplit('/', 1)[0]); 19, identifier:sort; 20, True; 21, expression_statement; 22, if_statement; 23, expression_statement; 24, block; 25, string; 26, parenthesized_expression; 27, assignment; 28, comparison_operator:sam != '-'; 29, block; 30, else_clause; 31, assignment; 32, if_statement; 33, string_content:%s/; 34, subscript; 35, identifier:mapping; 36, binary_operator:'%s.sorted.sam' % (sam.rsplit('.', 1)[0]); 37, identifier:sam; 38, string; 39, if_statement; 40, block; 41, identifier:mapping; 42, call; 43, comparison_operator:sam == '-'; 44, block; 45, else_clause; 46, call; 47, integer:0; 48, string; 49, parenthesized_expression; 50, string_content:-; 51, comparison_operator:os.path.exists(mapping) is False; 52, block; 53, expression_statement; 54, expression_statement; 55, expression_statement; 56, identifier:open; 57, argument_list; 58, identifier:sam; 59, string; 60, expression_statement; 61, block; 62, attribute; 63, argument_list; 64, string_content:%s.sorted.sam; 65, subscript; 66, call; 67, False; 68, expression_statement; 69, assignment; 70, assignment; 71, call; 72, identifier:mapping; 73, string_content:-; 74, assignment; 75, expression_statement; 76, call; 77, identifier:rsplit; 78, string; 79, integer:1; 80, call; 81, integer:0; 82, attribute; 83, argument_list; 84, call; 85, identifier:mapping; 86, string; 87, identifier:p; 88, call; 89, attribute; 90, argument_list; 91, identifier:mapping; 92, attribute; 93, assignment; 94, attribute; 95, argument_list; 96, string_content:/; 97, attribute; 98, argument_list; 99, attribute; 100, identifier:exists; 101, identifier:mapping; 102, attribute; 103, argument_list; 104, string_content:stdin-sam.sorted.sam; 105, identifier:Popen; 106, argument_list; 107, identifier:p; 108, identifier:communicate; 109, identifier:sys; 110, identifier:stdin; 111, identifier:mapping; 112, call; 113, attribute; 114, identifier:abspath; 115, identifier:sam; 116, identifier:sam; 117, identifier:rsplit; 118, string; 119, integer:1; 120, identifier:os; 121, identifier:path; 122, identifier:os; 123, identifier:system; 124, binary_operator:"\ sort -k1 --buffer-size=%sG -T %s -o %s %s\ " % (sbuffer, tempdir, mapping, sam); 125, binary_operator:"sort -k1 --buffer-size=%sG -T %s -o %s" \ % (sbuffer, tempdir, mapping); 126, keyword_argument; 127, keyword_argument; 128, identifier:open; 129, argument_list; 130, identifier:os; 131, identifier:path; 132, string_content:.; 133, string:"\ sort -k1 --buffer-size=%sG -T %s -o %s %s\ "; 134, tuple; 135, string:"sort -k1 --buffer-size=%sG -T %s -o %s"; 136, line_continuation:\; 137, tuple; 138, identifier:stdin; 139, attribute; 140, identifier:shell; 141, True; 142, identifier:sam; 143, identifier:sbuffer; 144, identifier:tempdir; 145, identifier:mapping; 146, identifier:sam; 147, identifier:sbuffer; 148, identifier:tempdir; 149, identifier:mapping; 150, identifier:sys; 151, identifier:stdin
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 7, 11; 8, 12; 9, 13; 9, 14; 9, 15; 10, 16; 12, 17; 12, 18; 13, 19; 13, 20; 14, 21; 14, 22; 14, 23; 15, 24; 18, 25; 18, 26; 21, 27; 22, 28; 22, 29; 22, 30; 23, 31; 24, 32; 25, 33; 26, 34; 27, 35; 27, 36; 28, 37; 28, 38; 29, 39; 30, 40; 31, 41; 31, 42; 32, 43; 32, 44; 32, 45; 34, 46; 34, 47; 36, 48; 36, 49; 38, 50; 39, 51; 39, 52; 40, 53; 40, 54; 40, 55; 42, 56; 42, 57; 43, 58; 43, 59; 44, 60; 45, 61; 46, 62; 46, 63; 48, 64; 49, 65; 51, 66; 51, 67; 52, 68; 53, 69; 54, 70; 55, 71; 57, 72; 59, 73; 60, 74; 61, 75; 62, 76; 62, 77; 63, 78; 63, 79; 65, 80; 65, 81; 66, 82; 66, 83; 68, 84; 69, 85; 69, 86; 70, 87; 70, 88; 71, 89; 71, 90; 74, 91; 74, 92; 75, 93; 76, 94; 76, 95; 78, 96; 80, 97; 80, 98; 82, 99; 82, 100; 83, 101; 84, 102; 84, 103; 86, 104; 88, 105; 88, 106; 89, 107; 89, 108; 92, 109; 92, 110; 93, 111; 93, 112; 94, 113; 94, 114; 95, 115; 97, 116; 97, 117; 98, 118; 98, 119; 99, 120; 99, 121; 102, 122; 102, 123; 103, 124; 106, 125; 106, 126; 106, 127; 112, 128; 112, 129; 113, 130; 113, 131; 118, 132; 124, 133; 124, 134; 125, 135; 125, 136; 125, 137; 126, 138; 126, 139; 127, 140; 127, 141; 129, 142; 134, 143; 134, 144; 134, 145; 134, 146; 137, 147; 137, 148; 137, 149; 139, 150; 139, 151
def sort_sam(sam, sort): """ sort sam file """ 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; 1, function_definition; 2, function_name:top_hits; 3, parameters; 4, block; 5, identifier:hits; 6, identifier:num; 7, identifier:column; 8, identifier:reverse; 9, expression_statement; 10, expression_statement; 11, for_statement; 12, comment:""" get top hits after sorting by column number """; 13, call; 14, identifier:hit; 15, subscript; 16, block; 17, attribute; 18, argument_list; 19, identifier:hits; 20, slice; 21, expression_statement; 22, identifier:hits; 23, identifier:sort; 24, keyword_argument; 25, keyword_argument; 26, integer:0; 27, identifier:num; 28, yield; 29, identifier:key; 30, call; 31, identifier:reverse; 32, identifier:reverse; 33, identifier:hit; 34, identifier:itemgetter; 35, argument_list; 36, identifier:column
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 9, 12; 10, 13; 11, 14; 11, 15; 11, 16; 13, 17; 13, 18; 15, 19; 15, 20; 16, 21; 17, 22; 17, 23; 18, 24; 18, 25; 20, 26; 20, 27; 21, 28; 24, 29; 24, 30; 25, 31; 25, 32; 28, 33; 30, 34; 30, 35; 35, 36
def top_hits(hits, num, column, reverse): """ get top hits after sorting by column number """ hits.sort(key = itemgetter(column), reverse = reverse) for hit in hits[0:num]: yield hit
0, module; 1, function_definition; 2, function_name:numBlast_sort; 3, parameters; 4, block; 5, identifier:blast; 6, identifier:numHits; 7, identifier:evalueT; 8, identifier:bitT; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, for_statement; 14, expression_statement; 15, for_statement; 16, comment:""" parse b6 output with sorting """; 17, assignment; 18, yield; 19, assignment; 20, identifier:line; 21, identifier:blast; 22, block; 23, assignment; 24, pattern_list; 25, call; 26, block; 27, identifier:header; 28, list; 29, identifier:header; 30, identifier:hmm; 31, dictionary_comprehension; 32, if_statement; 33, expression_statement; 34, comment:# Evalue and Bitscore thresholds; 35, expression_statement; 36, expression_statement; 37, if_statement; 38, if_statement; 39, for_statement; 40, identifier:hmm; 41, call; 42, identifier:query; 43, identifier:df; 44, attribute; 45, argument_list; 46, expression_statement; 47, for_statement; 48, string; 49, string; 50, string; 51, string; 52, string; 53, string; 54, string; 55, string; 56, string; 57, string; 58, string; 59, string; 60, pair; 61, for_in_clause; 62, call; 63, block; 64, assignment; 65, assignment; 66, assignment; 67, boolean_operator; 68, block; 69, boolean_operator; 70, block; 71, pattern_list; 72, call; 73, block; 74, attribute; 75, argument_list; 76, identifier:hmm; 77, identifier:groupby; 78, keyword_argument; 79, assignment; 80, identifier:hit; 81, subscript; 82, block; 83, string_content:#query; 84, string_content:target; 85, string_content:pident; 86, string_content:alen; 87, string_content:mismatch; 88, string_content:gapopen; 89, string_content:qstart; 90, string_content:qend; 91, string_content:tstart; 92, string_content:tend; 93, string_content:evalue; 94, string_content:bitscore; 95, identifier:h; 96, list; 97, identifier:h; 98, identifier:header; 99, attribute; 100, argument_list; 101, continue_statement; 102, identifier:line; 103, call; 104, pattern_list; 105, expression_list; 106, pattern_list; 107, expression_list; 108, comparison_operator:evalueT is not False; 109, comparison_operator:evalue > evalueT; 110, continue_statement; 111, comparison_operator:bitT is not False; 112, comparison_operator:bit < bitT; 113, continue_statement; 114, identifier:i; 115, identifier:h; 116, identifier:zip; 117, argument_list; 118, expression_statement; 119, identifier:pd; 120, identifier:DataFrame; 121, identifier:hmm; 122, identifier:by; 123, list; 124, identifier:df; 125, call; 126, attribute; 127, slice; 128, expression_statement; 129, identifier:line; 130, identifier:startswith; 131, string; 132, attribute; 133, argument_list; 134, subscript; 135, subscript; 136, call; 137, call; 138, identifier:evalue; 139, identifier:bit; 140, subscript; 141, subscript; 142, identifier:evalueT; 143, False; 144, identifier:evalue; 145, identifier:evalueT; 146, identifier:bitT; 147, False; 148, identifier:bit; 149, identifier:bitT; 150, identifier:line; 151, identifier:header; 152, call; 153, string; 154, attribute; 155, argument_list; 156, subscript; 157, identifier:values; 158, integer:0; 159, identifier:numHits; 160, yield; 161, string_content:#; 162, call; 163, identifier:split; 164, string; 165, identifier:line; 166, integer:10; 167, identifier:line; 168, integer:11; 169, identifier:float; 170, argument_list; 171, identifier:float; 172, argument_list; 173, identifier:line; 174, integer:10; 175, identifier:line; 176, integer:11; 177, attribute; 178, argument_list; 179, string_content:#query; 180, identifier:df; 181, identifier:sort_values; 182, keyword_argument; 183, keyword_argument; 184, identifier:df; 185, identifier:header; 186, identifier:hit; 187, attribute; 188, argument_list; 189, string_content; 190, subscript; 191, subscript; 192, subscript; 193, identifier:append; 194, identifier:i; 195, identifier:by; 196, list; 197, identifier:ascending; 198, False; 199, identifier:line; 200, identifier:strip; 201, escape_sequence:\t; 202, identifier:line; 203, integer:10; 204, identifier:line; 205, integer:11; 206, identifier:hmm; 207, identifier:h; 208, string; 209, string_content:bitscore
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 9, 16; 10, 17; 11, 18; 12, 19; 13, 20; 13, 21; 13, 22; 14, 23; 15, 24; 15, 25; 15, 26; 17, 27; 17, 28; 18, 29; 19, 30; 19, 31; 22, 32; 22, 33; 22, 34; 22, 35; 22, 36; 22, 37; 22, 38; 22, 39; 23, 40; 23, 41; 24, 42; 24, 43; 25, 44; 25, 45; 26, 46; 26, 47; 28, 48; 28, 49; 28, 50; 28, 51; 28, 52; 28, 53; 28, 54; 28, 55; 28, 56; 28, 57; 28, 58; 28, 59; 31, 60; 31, 61; 32, 62; 32, 63; 33, 64; 35, 65; 36, 66; 37, 67; 37, 68; 38, 69; 38, 70; 39, 71; 39, 72; 39, 73; 41, 74; 41, 75; 44, 76; 44, 77; 45, 78; 46, 79; 47, 80; 47, 81; 47, 82; 48, 83; 49, 84; 50, 85; 51, 86; 52, 87; 53, 88; 54, 89; 55, 90; 56, 91; 57, 92; 58, 93; 59, 94; 60, 95; 60, 96; 61, 97; 61, 98; 62, 99; 62, 100; 63, 101; 64, 102; 64, 103; 65, 104; 65, 105; 66, 106; 66, 107; 67, 108; 67, 109; 68, 110; 69, 111; 69, 112; 70, 113; 71, 114; 71, 115; 72, 116; 72, 117; 73, 118; 74, 119; 74, 120; 75, 121; 78, 122; 78, 123; 79, 124; 79, 125; 81, 126; 81, 127; 82, 128; 99, 129; 99, 130; 100, 131; 103, 132; 103, 133; 104, 134; 104, 135; 105, 136; 105, 137; 106, 138; 106, 139; 107, 140; 107, 141; 108, 142; 108, 143; 109, 144; 109, 145; 111, 146; 111, 147; 112, 148; 112, 149; 117, 150; 117, 151; 118, 152; 123, 153; 125, 154; 125, 155; 126, 156; 126, 157; 127, 158; 127, 159; 128, 160; 131, 161; 132, 162; 132, 163; 133, 164; 134, 165; 134, 166; 135, 167; 135, 168; 136, 169; 136, 170; 137, 171; 137, 172; 140, 173; 140, 174; 141, 175; 141, 176; 152, 177; 152, 178; 153, 179; 154, 180; 154, 181; 155, 182; 155, 183; 156, 184; 156, 185; 160, 186; 162, 187; 162, 188; 164, 189; 170, 190; 172, 191; 177, 192; 177, 193; 178, 194; 182, 195; 182, 196; 183, 197; 183, 198; 187, 199; 187, 200; 189, 201; 190, 202; 190, 203; 191, 204; 191, 205; 192, 206; 192, 207; 196, 208; 208, 209
def numBlast_sort(blast, numHits, evalueT, bitT): """ parse b6 output with sorting """ header = ['#query', 'target', 'pident', 'alen', 'mismatch', 'gapopen', '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') # Evalue and Bitscore thresholds 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 = ['#query']): df = df.sort_values(by = ['bitscore'], ascending = False) for hit in df[header].values[0:numHits]: yield hit
0, module; 1, function_definition; 2, function_name:numDomtblout; 3, parameters; 4, block; 5, identifier:domtblout; 6, identifier:numHits; 7, identifier:evalueT; 8, identifier:bitT; 9, identifier:sort; 10, expression_statement; 11, if_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, for_statement; 16, for_statement; 17, comment:""" parse hmm domain table output this version is faster but does not work unless the table is sorted """; 18, comparison_operator:sort is True; 19, block; 20, assignment; 21, yield; 22, assignment; 23, identifier:line; 24, identifier:domtblout; 25, block; 26, identifier:hit; 27, call; 28, block; 29, identifier:sort; 30, True; 31, for_statement; 32, return_statement; 33, identifier:header; 34, list; 35, identifier:header; 36, pattern_list; 37, expression_list; 38, if_statement; 39, comment:# parse line and get description; 40, expression_statement; 41, expression_statement; 42, expression_statement; 43, expression_statement; 44, comment:# create ID based on query name and domain number; 45, expression_statement; 46, comment:# domain c-Evalue and domain score thresholds; 47, expression_statement; 48, expression_statement; 49, expression_statement; 50, if_statement; 51, if_statement; 52, expression_statement; 53, identifier:top_hits; 54, argument_list; 55, expression_statement; 56, identifier:hit; 57, call; 58, block; 59, string; 60, string; 61, string; 62, string; 63, string; 64, string; 65, string; 66, string; 67, string; 68, string; 69, string; 70, string; 71, string; 72, string; 73, string; 74, string; 75, string; 76, string; 77, string; 78, string; 79, string; 80, string; 81, string; 82, identifier:prev; 83, identifier:hits; 84, None; 85, list; 86, call; 87, block; 88, assignment; 89, assignment; 90, assignment; 91, call; 92, assignment; 93, assignment; 94, assignment; 95, assignment; 96, comparison_operator:ID != prev; 97, block; 98, boolean_operator; 99, block; 100, elif_clause; 101, elif_clause; 102, elif_clause; 103, assignment; 104, identifier:hits; 105, identifier:numHits; 106, integer:13; 107, True; 108, yield; 109, identifier:numDomtblout_sort; 110, argument_list; 111, expression_statement; 112, string_content:#target name; 113, string_content:target accession; 114, string_content:tlen; 115, string_content:query name; 116, string_content:query accession; 117, string_content:qlen; 118, string_content:full E-value; 119, string_content:full score; 120, string_content:full bias; 121, string_content:domain #; 122, string_content:# domains; 123, string_content:domain c-Evalue; 124, string_content:domain i-Evalue; 125, string_content:domain score; 126, string_content:domain bias; 127, string_content:hmm from; 128, string_content:hmm to; 129, string_content:seq from; 130, string_content:seq to; 131, string_content:env from; 132, string_content:env to; 133, string_content:acc; 134, string_content:target description; 135, attribute; 136, argument_list; 137, continue_statement; 138, identifier:line; 139, call; 140, identifier:desc; 141, call; 142, identifier:line; 143, subscript; 144, attribute; 145, argument_list; 146, identifier:ID; 147, binary_operator:line[0] + line[9]; 148, pattern_list; 149, expression_list; 150, pattern_list; 151, expression_list; 152, pattern_list; 153, expression_list; 154, identifier:ID; 155, identifier:prev; 156, if_statement; 157, expression_statement; 158, comparison_operator:evalueT == False; 159, comparison_operator:bitT == False; 160, expression_statement; 161, boolean_operator; 162, block; 163, boolean_operator; 164, block; 165, boolean_operator; 166, block; 167, identifier:prev; 168, identifier:ID; 169, identifier:hit; 170, identifier:domtblout; 171, identifier:numHits; 172, identifier:evalueT; 173, identifier:bitT; 174, yield; 175, identifier:line; 176, identifier:startswith; 177, string; 178, attribute; 179, argument_list; 180, attribute; 181, argument_list; 182, identifier:line; 183, slice; 184, identifier:line; 185, identifier:append; 186, identifier:desc; 187, subscript; 188, subscript; 189, subscript; 190, subscript; 191, call; 192, call; 193, identifier:evalue; 194, identifier:bitscore; 195, subscript; 196, subscript; 197, subscript; 198, subscript; 199, identifier:evalue; 200, identifier:bitscore; 201, comparison_operator:len(hits) > 0; 202, block; 203, assignment; 204, identifier:evalueT; 205, False; 206, identifier:bitT; 207, False; 208, call; 209, comparison_operator:evalue <= evalueT; 210, comparison_operator:bitT == False; 211, expression_statement; 212, comparison_operator:evalue <= evalueT; 213, comparison_operator:bit >= bitT; 214, expression_statement; 215, comparison_operator:evalueT == False; 216, comparison_operator:bit >= bitT; 217, expression_statement; 218, identifier:hit; 219, string_content:#; 220, call; 221, identifier:split; 222, string; 223, identifier:join; 224, subscript; 225, integer:0; 226, integer:18; 227, identifier:line; 228, integer:0; 229, identifier:line; 230, integer:9; 231, identifier:line; 232, integer:11; 233, identifier:line; 234, integer:13; 235, identifier:float; 236, argument_list; 237, identifier:float; 238, argument_list; 239, identifier:line; 240, integer:11; 241, identifier:line; 242, integer:13; 243, identifier:line; 244, integer:11; 245, identifier:line; 246, integer:13; 247, call; 248, integer:0; 249, for_statement; 250, identifier:hits; 251, list; 252, attribute; 253, argument_list; 254, identifier:evalue; 255, identifier:evalueT; 256, identifier:bitT; 257, False; 258, call; 259, identifier:evalue; 260, identifier:evalueT; 261, identifier:bit; 262, identifier:bitT; 263, call; 264, identifier:evalueT; 265, False; 266, identifier:bit; 267, identifier:bitT; 268, call; 269, attribute; 270, argument_list; 271, string_content:; 272, identifier:line; 273, slice; 274, subscript; 275, subscript; 276, identifier:len; 277, argument_list; 278, identifier:hit; 279, call; 280, block; 281, identifier:hits; 282, identifier:append; 283, identifier:line; 284, attribute; 285, argument_list; 286, attribute; 287, argument_list; 288, attribute; 289, argument_list; 290, identifier:line; 291, identifier:strip; 292, integer:18; 293, identifier:line; 294, integer:11; 295, identifier:line; 296, integer:13; 297, identifier:hits; 298, identifier:top_hits; 299, argument_list; 300, expression_statement; 301, identifier:hits; 302, identifier:append; 303, identifier:line; 304, identifier:hits; 305, identifier:append; 306, identifier:line; 307, identifier:hits; 308, identifier:append; 309, identifier:line; 310, identifier:hits; 311, identifier:numHits; 312, integer:13; 313, True; 314, yield; 315, identifier:hit
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 10, 17; 11, 18; 11, 19; 12, 20; 13, 21; 14, 22; 15, 23; 15, 24; 15, 25; 16, 26; 16, 27; 16, 28; 18, 29; 18, 30; 19, 31; 19, 32; 20, 33; 20, 34; 21, 35; 22, 36; 22, 37; 25, 38; 25, 39; 25, 40; 25, 41; 25, 42; 25, 43; 25, 44; 25, 45; 25, 46; 25, 47; 25, 48; 25, 49; 25, 50; 25, 51; 25, 52; 27, 53; 27, 54; 28, 55; 31, 56; 31, 57; 31, 58; 34, 59; 34, 60; 34, 61; 34, 62; 34, 63; 34, 64; 34, 65; 34, 66; 34, 67; 34, 68; 34, 69; 34, 70; 34, 71; 34, 72; 34, 73; 34, 74; 34, 75; 34, 76; 34, 77; 34, 78; 34, 79; 34, 80; 34, 81; 36, 82; 36, 83; 37, 84; 37, 85; 38, 86; 38, 87; 40, 88; 41, 89; 42, 90; 43, 91; 45, 92; 47, 93; 48, 94; 49, 95; 50, 96; 50, 97; 51, 98; 51, 99; 51, 100; 51, 101; 51, 102; 52, 103; 54, 104; 54, 105; 54, 106; 54, 107; 55, 108; 57, 109; 57, 110; 58, 111; 59, 112; 60, 113; 61, 114; 62, 115; 63, 116; 64, 117; 65, 118; 66, 119; 67, 120; 68, 121; 69, 122; 70, 123; 71, 124; 72, 125; 73, 126; 74, 127; 75, 128; 76, 129; 77, 130; 78, 131; 79, 132; 80, 133; 81, 134; 86, 135; 86, 136; 87, 137; 88, 138; 88, 139; 89, 140; 89, 141; 90, 142; 90, 143; 91, 144; 91, 145; 92, 146; 92, 147; 93, 148; 93, 149; 94, 150; 94, 151; 95, 152; 95, 153; 96, 154; 96, 155; 97, 156; 97, 157; 98, 158; 98, 159; 99, 160; 100, 161; 100, 162; 101, 163; 101, 164; 102, 165; 102, 166; 103, 167; 103, 168; 108, 169; 110, 170; 110, 171; 110, 172; 110, 173; 111, 174; 135, 175; 135, 176; 136, 177; 139, 178; 139, 179; 141, 180; 141, 181; 143, 182; 143, 183; 144, 184; 144, 185; 145, 186; 147, 187; 147, 188; 148, 189; 148, 190; 149, 191; 149, 192; 150, 193; 150, 194; 151, 195; 151, 196; 152, 197; 152, 198; 153, 199; 153, 200; 156, 201; 156, 202; 157, 203; 158, 204; 158, 205; 159, 206; 159, 207; 160, 208; 161, 209; 161, 210; 162, 211; 163, 212; 163, 213; 164, 214; 165, 215; 165, 216; 166, 217; 174, 218; 177, 219; 178, 220; 178, 221; 180, 222; 180, 223; 181, 224; 183, 225; 183, 226; 187, 227; 187, 228; 188, 229; 188, 230; 189, 231; 189, 232; 190, 233; 190, 234; 191, 235; 191, 236; 192, 237; 192, 238; 195, 239; 195, 240; 196, 241; 196, 242; 197, 243; 197, 244; 198, 245; 198, 246; 201, 247; 201, 248; 202, 249; 203, 250; 203, 251; 208, 252; 208, 253; 209, 254; 209, 255; 210, 256; 210, 257; 211, 258; 212, 259; 212, 260; 213, 261; 213, 262; 214, 263; 215, 264; 215, 265; 216, 266; 216, 267; 217, 268; 220, 269; 220, 270; 222, 271; 224, 272; 224, 273; 236, 274; 238, 275; 247, 276; 247, 277; 249, 278; 249, 279; 249, 280; 252, 281; 252, 282; 253, 283; 258, 284; 258, 285; 263, 286; 263, 287; 268, 288; 268, 289; 269, 290; 269, 291; 273, 292; 274, 293; 274, 294; 275, 295; 275, 296; 277, 297; 279, 298; 279, 299; 280, 300; 284, 301; 284, 302; 285, 303; 286, 304; 286, 305; 287, 306; 288, 307; 288, 308; 289, 309; 299, 310; 299, 311; 299, 312; 299, 313; 300, 314; 314, 315
def numDomtblout(domtblout, numHits, evalueT, bitT, sort): """ parse hmm domain table output this version is faster but does not work unless the table is sorted """ if sort is True: for hit in numDomtblout_sort(domtblout, numHits, evalueT, bitT): yield hit return header = ['#target name', 'target accession', 'tlen', 'query name', 'query accession', 'qlen', 'full E-value', 'full score', 'full bias', 'domain #', '# domains', '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 # parse line and get description line = line.strip().split() desc = ' '.join(line[18:]) line = line[0:18] line.append(desc) # create ID based on query name and domain number ID = line[0] + line[9] # domain c-Evalue and domain score thresholds 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; 1, function_definition; 2, function_name:S; 3, parameters; 4, block; 5, identifier:Document; 6, list_splat_pattern; 7, expression_statement; 8, expression_statement; 9, for_statement; 10, return_statement; 11, identifier:fields; 12, comment:"""Generate a MongoDB sort order list using the Django ORM style."""; 13, assignment; 14, identifier:field; 15, identifier:fields; 16, block; 17, identifier:result; 18, identifier:result; 19, list; 20, if_statement; 21, expression_statement; 22, if_statement; 23, if_statement; 24, if_statement; 25, expression_statement; 26, expression_statement; 27, call; 28, comment:# Unpack existing tuple.; 29, block; 30, assignment; 31, not_operator; 32, block; 33, comparison_operator:field[0] == '-'; 34, block; 35, comparison_operator:field[0] in ('+', '-'); 36, block; 37, assignment; 38, call; 39, identifier:isinstance; 40, argument_list; 41, expression_statement; 42, expression_statement; 43, continue_statement; 44, identifier:direction; 45, identifier:ASCENDING; 46, call; 47, expression_statement; 48, subscript; 49, string; 50, expression_statement; 51, subscript; 52, tuple; 53, expression_statement; 54, identifier:_field; 55, call; 56, attribute; 57, argument_list; 58, identifier:field; 59, identifier:tuple; 60, assignment; 61, call; 62, attribute; 63, argument_list; 64, assignment; 65, identifier:field; 66, integer:0; 67, string_content:-; 68, assignment; 69, identifier:field; 70, integer:0; 71, string; 72, string; 73, assignment; 74, identifier:traverse; 75, argument_list; 76, identifier:result; 77, identifier:append; 78, tuple; 79, pattern_list; 80, identifier:field; 81, attribute; 82, argument_list; 83, identifier:field; 84, identifier:startswith; 85, string; 86, identifier:field; 87, call; 88, identifier:direction; 89, identifier:DESCENDING; 90, string_content:+; 91, string_content:-; 92, identifier:field; 93, subscript; 94, identifier:Document; 95, identifier:field; 96, keyword_argument; 97, conditional_expression:(~_field) if _field else field; 98, identifier:direction; 99, identifier:field; 100, identifier:direction; 101, identifier:result; 102, identifier:append; 103, tuple; 104, string_content:__; 105, attribute; 106, argument_list; 107, identifier:field; 108, slice; 109, identifier:default; 110, None; 111, parenthesized_expression; 112, identifier:_field; 113, identifier:field; 114, identifier:field; 115, identifier:direction; 116, identifier:field; 117, identifier:replace; 118, string; 119, string; 120, integer:1; 121, unary_operator; 122, string_content:__; 123, string_content:.; 124, identifier:_field
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 6, 11; 7, 12; 8, 13; 9, 14; 9, 15; 9, 16; 10, 17; 13, 18; 13, 19; 16, 20; 16, 21; 16, 22; 16, 23; 16, 24; 16, 25; 16, 26; 20, 27; 20, 28; 20, 29; 21, 30; 22, 31; 22, 32; 23, 33; 23, 34; 24, 35; 24, 36; 25, 37; 26, 38; 27, 39; 27, 40; 29, 41; 29, 42; 29, 43; 30, 44; 30, 45; 31, 46; 32, 47; 33, 48; 33, 49; 34, 50; 35, 51; 35, 52; 36, 53; 37, 54; 37, 55; 38, 56; 38, 57; 40, 58; 40, 59; 41, 60; 42, 61; 46, 62; 46, 63; 47, 64; 48, 65; 48, 66; 49, 67; 50, 68; 51, 69; 51, 70; 52, 71; 52, 72; 53, 73; 55, 74; 55, 75; 56, 76; 56, 77; 57, 78; 60, 79; 60, 80; 61, 81; 61, 82; 62, 83; 62, 84; 63, 85; 64, 86; 64, 87; 68, 88; 68, 89; 71, 90; 72, 91; 73, 92; 73, 93; 75, 94; 75, 95; 75, 96; 78, 97; 78, 98; 79, 99; 79, 100; 81, 101; 81, 102; 82, 103; 85, 104; 87, 105; 87, 106; 93, 107; 93, 108; 96, 109; 96, 110; 97, 111; 97, 112; 97, 113; 103, 114; 103, 115; 105, 116; 105, 117; 106, 118; 106, 119; 108, 120; 111, 121; 118, 122; 119, 123; 121, 124
def S(Document, *fields): """Generate a MongoDB sort order list using the Django ORM style.""" result = [] for field in fields: if isinstance(field, tuple): # Unpack existing tuple. field, direction = field result.append((field, direction)) continue direction = ASCENDING if not field.startswith('__'): field = field.replace('__', '.') if field[0] == '-': direction = DESCENDING if field[0] in ('+', '-'): field = field[1:] _field = traverse(Document, field, default=None) result.append(((~_field) if _field else field, direction)) return result
0, module; 1, function_definition; 2, function_name:arrayuniqify; 3, parameters; 4, block; 5, identifier:X; 6, default_parameter; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, if_statement; 12, identifier:retainorder; 13, False; 14, comment:""" Very fast uniqify routine for numpy arrays. **Parameters** **X** : numpy array Determine the unique elements of this numpy array. **retainorder** : Boolean, optional Whether or not to return indices corresponding to unique values of `X` that also sort the values. Default value is `False`, in which case `[D,s]` is returned. This can be used to produce a uniqified version of `X` by simply taking:: X[s][D] or:: X[s[D.nonzero()[0]]] **Returns** **D** : numpy array List of "first differences" in the sorted verion of `X`. Returned when `retainorder` is `False` (default). **s** : numpy array Permutation that will sort `X`. Returned when `retainorder` is `False` (default). **ind** : numpy array List of indices that correspond to unique values of `X`, without sorting those values. Returned when `retainorder` is `True`. **See Also:** :func:`tabular.fast.recarrayuniqify` """; 15, assignment; 16, assignment; 17, assignment; 18, identifier:retainorder; 19, block; 20, else_clause; 21, identifier:s; 22, call; 23, identifier:X; 24, subscript; 25, identifier:D; 26, call; 27, expression_statement; 28, expression_statement; 29, expression_statement; 30, return_statement; 31, block; 32, attribute; 33, argument_list; 34, identifier:X; 35, identifier:s; 36, attribute; 37, argument_list; 38, assignment; 39, assignment; 40, call; 41, identifier:ind; 42, return_statement; 43, identifier:X; 44, identifier:argsort; 45, identifier:np; 46, identifier:append; 47, list; 48, comparison_operator:X[1:] != X[:-1]; 49, identifier:DD; 50, call; 51, identifier:ind; 52, list_comprehension; 53, attribute; 54, argument_list; 55, list; 56, True; 57, subscript; 58, subscript; 59, attribute; 60, argument_list; 61, call; 62, for_in_clause; 63, identifier:ind; 64, identifier:sort; 65, identifier:D; 66, identifier:s; 67, identifier:X; 68, slice; 69, identifier:X; 70, slice; 71, identifier:np; 72, identifier:append; 73, subscript; 74, call; 75, identifier:min; 76, argument_list; 77, tuple_pattern; 78, call; 79, integer:1; 80, unary_operator; 81, call; 82, integer:0; 83, identifier:len; 84, argument_list; 85, subscript; 86, identifier:i; 87, identifier:x; 88, identifier:enumerate; 89, argument_list; 90, integer:1; 91, attribute; 92, argument_list; 93, identifier:X; 94, identifier:s; 95, slice; 96, subscript; 97, identifier:D; 98, identifier:nonzero; 99, identifier:x; 100, subscript; 101, identifier:DD; 102, slice; 103, identifier:DD; 104, binary_operator:i+1; 105, unary_operator; 106, identifier:i; 107, integer:1; 108, integer:1
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 6, 12; 6, 13; 7, 14; 8, 15; 9, 16; 10, 17; 11, 18; 11, 19; 11, 20; 15, 21; 15, 22; 16, 23; 16, 24; 17, 25; 17, 26; 19, 27; 19, 28; 19, 29; 19, 30; 20, 31; 22, 32; 22, 33; 24, 34; 24, 35; 26, 36; 26, 37; 27, 38; 28, 39; 29, 40; 30, 41; 31, 42; 32, 43; 32, 44; 36, 45; 36, 46; 37, 47; 37, 48; 38, 49; 38, 50; 39, 51; 39, 52; 40, 53; 40, 54; 42, 55; 47, 56; 48, 57; 48, 58; 50, 59; 50, 60; 52, 61; 52, 62; 53, 63; 53, 64; 55, 65; 55, 66; 57, 67; 57, 68; 58, 69; 58, 70; 59, 71; 59, 72; 60, 73; 60, 74; 61, 75; 61, 76; 62, 77; 62, 78; 68, 79; 70, 80; 73, 81; 73, 82; 74, 83; 74, 84; 76, 85; 77, 86; 77, 87; 78, 88; 78, 89; 80, 90; 81, 91; 81, 92; 84, 93; 85, 94; 85, 95; 89, 96; 91, 97; 91, 98; 95, 99; 95, 100; 96, 101; 96, 102; 100, 103; 100, 104; 102, 105; 104, 106; 104, 107; 105, 108
def arrayuniqify(X, retainorder=False): """ Very fast uniqify routine for numpy arrays. **Parameters** **X** : numpy array Determine the unique elements of this numpy array. **retainorder** : Boolean, optional Whether or not to return indices corresponding to unique values of `X` that also sort the values. Default value is `False`, in which case `[D,s]` is returned. This can be used to produce a uniqified version of `X` by simply taking:: X[s][D] or:: X[s[D.nonzero()[0]]] **Returns** **D** : numpy array List of "first differences" in the sorted verion of `X`. Returned when `retainorder` is `False` (default). **s** : numpy array Permutation that will sort `X`. Returned when `retainorder` is `False` (default). **ind** : numpy array List of indices that correspond to unique values of `X`, without sorting those values. Returned when `retainorder` is `True`. **See Also:** :func:`tabular.fast.recarrayuniqify` """ s = X.argsort() X = X[s] D = np.append([True],X[1:] != X[:-1]) if retainorder: DD = np.append(D.nonzero()[0],len(X)) ind = [min(s[x:DD[i+1]]) for (i,x) in enumerate(DD[:-1])] ind.sort() return ind else: return [D,s]
0, module; 1, function_definition; 2, function_name:equalspairs; 3, parameters; 4, block; 5, identifier:X; 6, identifier:Y; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, expression_statement; 16, expression_statement; 17, return_statement; 18, comment:""" Indices of elements in a sorted numpy array equal to those in another. Given numpy array `X` and sorted numpy array `Y`, determine the indices in Y equal to indices in X. Returns `[A,B]` where `A` and `B` are numpy arrays of indices in `X` such that:: Y[A[i]:B[i]] = Y[Y == X[i]]` `A[i] = B[i] = 0` if `X[i]` is not in `Y`. **Parameters** **X** : numpy array Numpy array to compare to the sorted numpy array `Y`. **Y** : numpy array Sorted numpy array. Determine the indices of elements of `Y` equal to those in numpy array `X`. **Returns** **A** : numpy array List of indices in `Y`, `len(A) = len(Y)`. **B** : numpy array List of indices in `Y`, `len(B) = len(Y)`. **See Also:** :func:`tabular.fast.recarrayequalspairs` """; 19, assignment; 20, assignment; 21, assignment; 22, assignment; 23, assignment; 24, assignment; 25, assignment; 26, assignment; 27, assignment; 28, list; 29, identifier:T; 30, call; 31, identifier:R; 32, subscript; 33, identifier:R; 34, call; 35, identifier:M; 36, subscript; 37, identifier:D; 38, call; 39, identifier:T; 40, call; 41, identifier:M; 42, call; 43, identifier:A; 44, binary_operator:(T[D] == X) * D; 45, identifier:B; 46, binary_operator:(T[D] == X) * (M[D] + 1); 47, identifier:A; 48, identifier:B; 49, attribute; 50, argument_list; 51, call; 52, integer:0; 53, attribute; 54, argument_list; 55, identifier:R; 56, call; 57, attribute; 58, argument_list; 59, attribute; 60, argument_list; 61, attribute; 62, argument_list; 63, parenthesized_expression; 64, identifier:D; 65, parenthesized_expression; 66, parenthesized_expression; 67, identifier:Y; 68, identifier:copy; 69, attribute; 70, argument_list; 71, identifier:np; 72, identifier:append; 73, identifier:R; 74, call; 75, attribute; 76, argument_list; 77, identifier:T; 78, identifier:searchsorted; 79, identifier:X; 80, identifier:np; 81, identifier:append; 82, identifier:T; 83, call; 84, identifier:np; 85, identifier:append; 86, identifier:M; 87, call; 88, comparison_operator:T[D] == X; 89, comparison_operator:T[D] == X; 90, binary_operator:M[D] + 1; 91, parenthesized_expression; 92, identifier:nonzero; 93, attribute; 94, argument_list; 95, identifier:R; 96, identifier:searchsorted; 97, call; 98, attribute; 99, argument_list; 100, attribute; 101, argument_list; 102, subscript; 103, identifier:X; 104, subscript; 105, identifier:X; 106, subscript; 107, integer:1; 108, comparison_operator:T[1:] != T[:-1]; 109, identifier:np; 110, identifier:array; 111, list; 112, identifier:range; 113, argument_list; 114, identifier:np; 115, identifier:array; 116, list; 117, identifier:np; 118, identifier:array; 119, list; 120, identifier:T; 121, identifier:D; 122, identifier:T; 123, identifier:D; 124, identifier:M; 125, identifier:D; 126, subscript; 127, subscript; 128, binary_operator:len(T)-1; 129, call; 130, integer:0; 131, integer:0; 132, identifier:T; 133, slice; 134, identifier:T; 135, slice; 136, call; 137, integer:1; 138, identifier:len; 139, argument_list; 140, integer:1; 141, unary_operator; 142, identifier:len; 143, argument_list; 144, identifier:T; 145, integer:1; 146, identifier:T
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 7, 18; 8, 19; 9, 20; 10, 21; 11, 22; 12, 23; 13, 24; 14, 25; 15, 26; 16, 27; 17, 28; 19, 29; 19, 30; 20, 31; 20, 32; 21, 33; 21, 34; 22, 35; 22, 36; 23, 37; 23, 38; 24, 39; 24, 40; 25, 41; 25, 42; 26, 43; 26, 44; 27, 45; 27, 46; 28, 47; 28, 48; 30, 49; 30, 50; 32, 51; 32, 52; 34, 53; 34, 54; 36, 55; 36, 56; 38, 57; 38, 58; 40, 59; 40, 60; 42, 61; 42, 62; 44, 63; 44, 64; 46, 65; 46, 66; 49, 67; 49, 68; 51, 69; 51, 70; 53, 71; 53, 72; 54, 73; 54, 74; 56, 75; 56, 76; 57, 77; 57, 78; 58, 79; 59, 80; 59, 81; 60, 82; 60, 83; 61, 84; 61, 85; 62, 86; 62, 87; 63, 88; 65, 89; 66, 90; 69, 91; 69, 92; 74, 93; 74, 94; 75, 95; 75, 96; 76, 97; 83, 98; 83, 99; 87, 100; 87, 101; 88, 102; 88, 103; 89, 104; 89, 105; 90, 106; 90, 107; 91, 108; 93, 109; 93, 110; 94, 111; 97, 112; 97, 113; 98, 114; 98, 115; 99, 116; 100, 117; 100, 118; 101, 119; 102, 120; 102, 121; 104, 122; 104, 123; 106, 124; 106, 125; 108, 126; 108, 127; 111, 128; 113, 129; 116, 130; 119, 131; 126, 132; 126, 133; 127, 134; 127, 135; 128, 136; 128, 137; 129, 138; 129, 139; 133, 140; 135, 141; 136, 142; 136, 143; 139, 144; 141, 145; 143, 146
def equalspairs(X, Y): """ Indices of elements in a sorted numpy array equal to those in another. Given numpy array `X` and sorted numpy array `Y`, determine the indices in Y equal to indices in X. Returns `[A,B]` where `A` and `B` are numpy arrays of indices in `X` such that:: Y[A[i]:B[i]] = Y[Y == X[i]]` `A[i] = B[i] = 0` if `X[i]` is not in `Y`. **Parameters** **X** : numpy array Numpy array to compare to the sorted numpy array `Y`. **Y** : numpy array Sorted numpy array. Determine the indices of elements of `Y` equal to those in numpy array `X`. **Returns** **A** : numpy array List of indices in `Y`, `len(A) = len(Y)`. **B** : numpy array List of indices in `Y`, `len(B) = len(Y)`. **See Also:** :func:`tabular.fast.recarrayequalspairs` """ T = Y.copy() R = (T[1:] != T[:-1]).nonzero()[0] R = np.append(R,np.array([len(T)-1])) M = R[R.searchsorted(range(len(T)))] D = T.searchsorted(X) T = np.append(T,np.array([0])) M = np.append(M,np.array([0])) A = (T[D] == X) * D B = (T[D] == X) * (M[D] + 1) return [A,B]
0, module; 1, function_definition; 2, function_name:_inplace_sort_by_id; 3, parameters; 4, block; 5, identifier:unsorted_list; 6, expression_statement; 7, if_statement; 8, expression_statement; 9, expression_statement; 10, delete_statement; 11, expression_statement; 12, comment:"""Takes a list of dicts each of which has an '@id' key, sorts the elements in the list by the value of the @id key. Assumes that @id is unique or the dicts have a meaningul < operator """; 13, not_operator; 14, block; 15, assignment; 16, call; 17, subscript; 18, call; 19, call; 20, return_statement; 21, identifier:sorted_list; 22, list_comprehension; 23, attribute; 24, argument_list; 25, identifier:unsorted_list; 26, slice; 27, attribute; 28, argument_list; 29, identifier:isinstance; 30, argument_list; 31, tuple; 32, for_in_clause; 33, identifier:sorted_list; 34, identifier:sort; 35, identifier:unsorted_list; 36, identifier:extend; 37, list_comprehension; 38, identifier:unsorted_list; 39, identifier:list; 40, call; 41, identifier:i; 42, identifier:i; 43, identifier:unsorted_list; 44, subscript; 45, for_in_clause; 46, attribute; 47, argument_list; 48, identifier:i; 49, integer:1; 50, identifier:i; 51, identifier:sorted_list; 52, identifier:i; 53, identifier:get; 54, string; 55, string_content:@id
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 6, 12; 7, 13; 7, 14; 8, 15; 9, 16; 10, 17; 11, 18; 13, 19; 14, 20; 15, 21; 15, 22; 16, 23; 16, 24; 17, 25; 17, 26; 18, 27; 18, 28; 19, 29; 19, 30; 22, 31; 22, 32; 23, 33; 23, 34; 27, 35; 27, 36; 28, 37; 30, 38; 30, 39; 31, 40; 31, 41; 32, 42; 32, 43; 37, 44; 37, 45; 40, 46; 40, 47; 44, 48; 44, 49; 45, 50; 45, 51; 46, 52; 46, 53; 47, 54; 54, 55
def _inplace_sort_by_id(unsorted_list): """Takes a list of dicts each of which has an '@id' key, sorts the elements in the list by the value of the @id key. Assumes that @id is unique or the dicts have a meaningul < operator """ if not isinstance(unsorted_list, list): return sorted_list = [(i.get('@id'), i) for i in unsorted_list] sorted_list.sort() del unsorted_list[:] unsorted_list.extend([i[1] for i in sorted_list])
0, module; 1, function_definition; 2, function_name:get_schemaloc_string; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, if_statement; 11, if_statement; 12, expression_statement; 13, for_statement; 14, if_statement; 15, return_statement; 16, identifier:ns_uris; 17, None; 18, identifier:sort; 19, False; 20, identifier:delim; 21, string:"\n"; 22, comment:"""Constructs and returns a schemalocation attribute. If no namespaces in this set have any schema locations defined, returns an empty string. Args: ns_uris (iterable): The namespaces to include in the constructed attribute value. If None, all are included. sort (bool): Whether the sort the namespace URIs. delim (str): The delimiter to use between namespace/schemaloc *pairs*. Returns: str: A schemalocation attribute in the format: ``xsi:schemaLocation="nsuri schemaloc<delim>nsuri2 schemaloc2<delim>..."`` """; 23, not_operator; 24, block; 25, identifier:sort; 26, block; 27, assignment; 28, identifier:ns_uri; 29, identifier:ns_uris; 30, block; 31, not_operator; 32, block; 33, call; 34, identifier:ns_uris; 35, expression_statement; 36, expression_statement; 37, identifier:schemalocs; 38, list; 39, expression_statement; 40, if_statement; 41, identifier:schemalocs; 42, return_statement; 43, attribute; 44, argument_list; 45, assignment; 46, assignment; 47, assignment; 48, attribute; 49, block; 50, string:""; 51, string:'xsi:schemaLocation="{0}"'; 52, identifier:format; 53, call; 54, identifier:ns_uris; 55, call; 56, identifier:ns_uris; 57, call; 58, identifier:ni; 59, call; 60, identifier:ni; 61, identifier:schema_location; 62, expression_statement; 63, attribute; 64, argument_list; 65, attribute; 66, argument_list; 67, identifier:sorted; 68, argument_list; 69, attribute; 70, argument_list; 71, call; 72, identifier:delim; 73, identifier:join; 74, identifier:schemalocs; 75, identifier:six; 76, identifier:iterkeys; 77, attribute; 78, identifier:ns_uris; 79, identifier:self; 80, identifier:__lookup_uri; 81, identifier:ns_uri; 82, attribute; 83, argument_list; 84, identifier:self; 85, identifier:__ns_uri_map; 86, identifier:schemalocs; 87, identifier:append; 88, call; 89, attribute; 90, argument_list; 91, string:"{0.uri} {0.schema_location}"; 92, identifier:format; 93, identifier:ni
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 6, 16; 6, 17; 7, 18; 7, 19; 8, 20; 8, 21; 9, 22; 10, 23; 10, 24; 11, 25; 11, 26; 12, 27; 13, 28; 13, 29; 13, 30; 14, 31; 14, 32; 15, 33; 23, 34; 24, 35; 26, 36; 27, 37; 27, 38; 30, 39; 30, 40; 31, 41; 32, 42; 33, 43; 33, 44; 35, 45; 36, 46; 39, 47; 40, 48; 40, 49; 42, 50; 43, 51; 43, 52; 44, 53; 45, 54; 45, 55; 46, 56; 46, 57; 47, 58; 47, 59; 48, 60; 48, 61; 49, 62; 53, 63; 53, 64; 55, 65; 55, 66; 57, 67; 57, 68; 59, 69; 59, 70; 62, 71; 63, 72; 63, 73; 64, 74; 65, 75; 65, 76; 66, 77; 68, 78; 69, 79; 69, 80; 70, 81; 71, 82; 71, 83; 77, 84; 77, 85; 82, 86; 82, 87; 83, 88; 88, 89; 88, 90; 89, 91; 89, 92; 90, 93
def get_schemaloc_string(self, ns_uris=None, sort=False, delim="\n"): """Constructs and returns a schemalocation attribute. If no namespaces in this set have any schema locations defined, returns an empty string. Args: ns_uris (iterable): The namespaces to include in the constructed attribute value. If None, all are included. sort (bool): Whether the sort the namespace URIs. delim (str): The delimiter to use between namespace/schemaloc *pairs*. Returns: str: A schemalocation attribute in the format: ``xsi:schemaLocation="nsuri schemaloc<delim>nsuri2 schemaloc2<delim>..."`` """ if not ns_uris: ns_uris = six.iterkeys(self.__ns_uri_map) if sort: ns_uris = sorted(ns_uris) schemalocs = [] for ns_uri in ns_uris: ni = self.__lookup_uri(ns_uri) if ni.schema_location: schemalocs.append("{0.uri} {0.schema_location}".format(ni)) if not schemalocs: return "" return 'xsi:schemaLocation="{0}"'.format(delim.join(schemalocs))
0, module; 1, function_definition; 2, function_name:aggregate; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13, expression_statement; 14, if_statement; 15, expression_statement; 16, expression_statement; 17, if_statement; 18, identifier:On; 19, None; 20, identifier:AggFuncDict; 21, None; 22, identifier:AggFunc; 23, None; 24, identifier:AggList; 25, None; 26, identifier:returnsort; 27, False; 28, identifier:KeepOthers; 29, True; 30, identifier:keyfuncdict; 31, None; 32, comment:""" Aggregate a tabarray on columns for given functions. Method wraps:: tabular.spreadsheet.aggregate(self, On, AggFuncDict, AggFunc, returnsort) """; 33, identifier:returnsort; 34, block; 35, else_clause; 36, assignment; 37, assignment; 38, identifier:returnsort; 39, block; 40, else_clause; 41, expression_statement; 42, block; 43, identifier:data; 44, call; 45, attribute; 46, attribute; 47, return_statement; 48, block; 49, assignment; 50, expression_statement; 51, attribute; 52, argument_list; 53, identifier:data; 54, identifier:coloring; 55, identifier:self; 56, identifier:coloring; 57, list; 58, return_statement; 59, list_pattern; 60, call; 61, assignment; 62, identifier:data; 63, identifier:view; 64, identifier:tabarray; 65, identifier:data; 66, identifier:s; 67, identifier:data; 68, identifier:data; 69, identifier:s; 70, attribute; 71, argument_list; 72, identifier:data; 73, call; 74, identifier:spreadsheet; 75, identifier:aggregate; 76, keyword_argument; 77, keyword_argument; 78, keyword_argument; 79, keyword_argument; 80, keyword_argument; 81, keyword_argument; 82, keyword_argument; 83, attribute; 84, argument_list; 85, identifier:X; 86, identifier:self; 87, identifier:On; 88, identifier:On; 89, identifier:AggFuncDict; 90, identifier:AggFuncDict; 91, identifier:AggFunc; 92, identifier:AggFunc; 93, identifier:AggList; 94, identifier:AggList; 95, identifier:returnsort; 96, identifier:returnsort; 97, identifier:keyfuncdict; 98, identifier:keyfuncdict; 99, identifier:spreadsheet; 100, identifier:aggregate; 101, keyword_argument; 102, keyword_argument; 103, keyword_argument; 104, keyword_argument; 105, keyword_argument; 106, keyword_argument; 107, keyword_argument; 108, keyword_argument; 109, identifier:X; 110, identifier:self; 111, identifier:On; 112, identifier:On; 113, identifier:AggFuncDict; 114, identifier:AggFuncDict; 115, identifier:AggFunc; 116, identifier:AggFunc; 117, identifier:AggList; 118, identifier:AggList; 119, identifier:returnsort; 120, identifier:returnsort; 121, identifier:KeepOthers; 122, identifier:KeepOthers; 123, identifier:keyfuncdict; 124, identifier:keyfuncdict
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 6, 18; 6, 19; 7, 20; 7, 21; 8, 22; 8, 23; 9, 24; 9, 25; 10, 26; 10, 27; 11, 28; 11, 29; 12, 30; 12, 31; 13, 32; 14, 33; 14, 34; 14, 35; 15, 36; 16, 37; 17, 38; 17, 39; 17, 40; 34, 41; 35, 42; 36, 43; 36, 44; 37, 45; 37, 46; 39, 47; 40, 48; 41, 49; 42, 50; 44, 51; 44, 52; 45, 53; 45, 54; 46, 55; 46, 56; 47, 57; 48, 58; 49, 59; 49, 60; 50, 61; 51, 62; 51, 63; 52, 64; 57, 65; 57, 66; 58, 67; 59, 68; 59, 69; 60, 70; 60, 71; 61, 72; 61, 73; 70, 74; 70, 75; 71, 76; 71, 77; 71, 78; 71, 79; 71, 80; 71, 81; 71, 82; 73, 83; 73, 84; 76, 85; 76, 86; 77, 87; 77, 88; 78, 89; 78, 90; 79, 91; 79, 92; 80, 93; 80, 94; 81, 95; 81, 96; 82, 97; 82, 98; 83, 99; 83, 100; 84, 101; 84, 102; 84, 103; 84, 104; 84, 105; 84, 106; 84, 107; 84, 108; 101, 109; 101, 110; 102, 111; 102, 112; 103, 113; 103, 114; 104, 115; 104, 116; 105, 117; 105, 118; 106, 119; 106, 120; 107, 121; 107, 122; 108, 123; 108, 124
def aggregate(self, On=None, AggFuncDict=None, AggFunc=None, AggList = None, returnsort=False,KeepOthers=True, keyfuncdict=None): """ Aggregate a tabarray on columns for given functions. Method wraps:: tabular.spreadsheet.aggregate(self, On, AggFuncDict, AggFunc, returnsort) """ if returnsort: [data, s] = spreadsheet.aggregate(X=self, On=On, AggFuncDict=AggFuncDict, AggFunc=AggFunc, AggList=AggList, returnsort=returnsort, keyfuncdict=keyfuncdict) else: data = spreadsheet.aggregate(X=self, On=On, AggFuncDict=AggFuncDict, AggFunc=AggFunc, AggList = AggList, returnsort=returnsort, KeepOthers=KeepOthers, keyfuncdict=keyfuncdict) data = data.view(tabarray) data.coloring = self.coloring if returnsort: return [data, s] else: return data
0, module; 1, function_definition; 2, function_name:argsort; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, return_statement; 13, identifier:axis; 14, unary_operator; 15, identifier:kind; 16, string; 17, identifier:order; 18, None; 19, comment:""" Returns the indices that would sort an array. .. note:: This method wraps `numpy.argsort`. This documentation is modified from that of `numpy.argsort`. Perform an indirect sort along the given axis using the algorithm specified by the `kind` keyword. It returns an array of indices of the same shape as the original array that index data along the given axis in sorted order. **Parameters** **axis** : int or None, optional Axis along which to sort. The default is -1 (the last axis). If `None`, the flattened array is used. **kind** : {'quicksort', 'mergesort', 'heapsort'}, optional Sorting algorithm. **order** : list, optional This argument specifies which fields to compare first, second, etc. Not all fields need be specified. **Returns** **index_array** : ndarray, int Array of indices that sort the tabarray along the specified axis. In other words, ``a[index_array]`` yields a sorted `a`. **See Also** sort : Describes sorting algorithms used. lexsort : Indirect stable sort with multiple keys. ndarray.sort : Inplace sort. **Notes** See `numpy.sort` for notes on the different sorting algorithms. **Examples** Sorting with keys: >>> x = tabarray([(1, 0), (0, 1)], dtype=[('x', '<i4'), ('y', '<i4')]) >>> x tabarray([(1, 0), (0, 1)], dtype=[('x', '<i4'), ('y', '<i4')]) >>> x.argsort(order=('x','y')) array([1, 0]) >>> x.argsort(order=('y','x')) array([0, 1]) """; 20, assignment; 21, assignment; 22, identifier:index_array; 23, integer:1; 24, string_content:quicksort; 25, identifier:index_array; 26, call; 27, identifier:index_array; 28, call; 29, attribute; 30, argument_list; 31, attribute; 32, argument_list; 33, attribute; 34, identifier:_wrapit; 35, identifier:self; 36, string; 37, identifier:axis; 38, identifier:kind; 39, identifier:order; 40, identifier:index_array; 41, identifier:view; 42, attribute; 43, attribute; 44, identifier:fromnumeric; 45, string_content:argsort; 46, identifier:np; 47, identifier:ndarray; 48, identifier:np; 49, identifier:core
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 6, 13; 6, 14; 7, 15; 7, 16; 8, 17; 8, 18; 9, 19; 10, 20; 11, 21; 12, 22; 14, 23; 16, 24; 20, 25; 20, 26; 21, 27; 21, 28; 26, 29; 26, 30; 28, 31; 28, 32; 29, 33; 29, 34; 30, 35; 30, 36; 30, 37; 30, 38; 30, 39; 31, 40; 31, 41; 32, 42; 33, 43; 33, 44; 36, 45; 42, 46; 42, 47; 43, 48; 43, 49
def argsort(self, axis=-1, kind='quicksort', order=None): """ Returns the indices that would sort an array. .. note:: This method wraps `numpy.argsort`. This documentation is modified from that of `numpy.argsort`. Perform an indirect sort along the given axis using the algorithm specified by the `kind` keyword. It returns an array of indices of the same shape as the original array that index data along the given axis in sorted order. **Parameters** **axis** : int or None, optional Axis along which to sort. The default is -1 (the last axis). If `None`, the flattened array is used. **kind** : {'quicksort', 'mergesort', 'heapsort'}, optional Sorting algorithm. **order** : list, optional This argument specifies which fields to compare first, second, etc. Not all fields need be specified. **Returns** **index_array** : ndarray, int Array of indices that sort the tabarray along the specified axis. In other words, ``a[index_array]`` yields a sorted `a`. **See Also** sort : Describes sorting algorithms used. lexsort : Indirect stable sort with multiple keys. ndarray.sort : Inplace sort. **Notes** See `numpy.sort` for notes on the different sorting algorithms. **Examples** Sorting with keys: >>> x = tabarray([(1, 0), (0, 1)], dtype=[('x', '<i4'), ('y', '<i4')]) >>> x tabarray([(1, 0), (0, 1)], dtype=[('x', '<i4'), ('y', '<i4')]) >>> x.argsort(order=('x','y')) array([1, 0]) >>> x.argsort(order=('y','x')) array([0, 1]) """ index_array = np.core.fromnumeric._wrapit(self, 'argsort', axis, kind, order) index_array = index_array.view(np.ndarray) return index_array
0, module; 1, function_definition; 2, function_name:blt; 3, parameters; 4, type; 5, block; 6, typed_parameter; 7, typed_parameter; 8, generic_type; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, return_statement; 13, identifier:f; 14, type; 15, identifier:x; 16, type; 17, identifier:Dict; 18, type_parameter; 19, comment:""" Sort equations by dependence """; 20, assignment; 21, assignment; 22, dictionary; 23, generic_type; 24, generic_type; 25, type; 26, type; 27, identifier:J; 28, call; 29, pattern_list; 30, call; 31, pair; 32, pair; 33, pair; 34, pair; 35, pair; 36, pair; 37, pair; 38, pair; 39, identifier:List; 40, type_parameter; 41, identifier:List; 42, type_parameter; 43, identifier:str; 44, identifier:Any; 45, attribute; 46, argument_list; 47, identifier:nblock; 48, identifier:rowperm; 49, identifier:colperm; 50, identifier:rowblock; 51, identifier:colblock; 52, identifier:coarserow; 53, identifier:coarsecol; 54, attribute; 55, argument_list; 56, string; 57, identifier:J; 58, string; 59, identifier:nblock; 60, string; 61, identifier:rowperm; 62, string; 63, identifier:colperm; 64, string; 65, identifier:rowblock; 66, string; 67, identifier:colblock; 68, string; 69, identifier:coarserow; 70, string; 71, identifier:coarsecol; 72, type; 73, type; 74, identifier:ca; 75, identifier:jacobian; 76, identifier:f; 77, identifier:x; 78, call; 79, identifier:btf; 80, string_content:J; 81, string_content:nblock; 82, string_content:rowperm; 83, string_content:colperm; 84, string_content:rowblock; 85, string_content:colblock; 86, string_content:coarserow; 87, string_content:coarsecol; 88, identifier:SYM; 89, identifier:SYM; 90, attribute; 91, argument_list; 92, identifier:J; 93, identifier:sparsity
0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 3, 6; 3, 7; 4, 8; 5, 9; 5, 10; 5, 11; 5, 12; 6, 13; 6, 14; 7, 15; 7, 16; 8, 17; 8, 18; 9, 19; 10, 20; 11, 21; 12, 22; 14, 23; 16, 24; 18, 25; 18, 26; 20, 27; 20, 28; 21, 29; 21, 30; 22, 31; 22, 32; 22, 33; 22, 34; 22, 35; 22, 36; 22, 37; 22, 38; 23, 39; 23, 40; 24, 41; 24, 42; 25, 43; 26, 44; 28, 45; 28, 46; 29, 47; 29, 48; 29, 49; 29, 50; 29, 51; 29, 52; 29, 53; 30, 54; 30, 55; 31, 56; 31, 57; 32, 58; 32, 59; 33, 60; 33, 61; 34, 62; 34, 63; 35, 64; 35, 65; 36, 66; 36, 67; 37, 68; 37, 69; 38, 70; 38, 71; 40, 72; 42, 73; 45, 74; 45, 75; 46, 76; 46, 77; 54, 78; 54, 79; 56, 80; 58, 81; 60, 82; 62, 83; 64, 84; 66, 85; 68, 86; 70, 87; 72, 88; 73, 89; 78, 90; 78, 91; 90, 92; 90, 93
def blt(f: List[SYM], x: List[SYM]) -> Dict[str, Any]: """ Sort equations by dependence """ J = ca.jacobian(f, x) nblock, rowperm, colperm, rowblock, colblock, coarserow, coarsecol = J.sparsity().btf() return { 'J': J, 'nblock': nblock, 'rowperm': rowperm, 'colperm': colperm, 'rowblock': rowblock, 'colblock': colblock, 'coarserow': coarserow, 'coarsecol': coarsecol }
0, module; 1, function_definition; 2, function_name:sort_generators; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, comment:""" Reorders the list of generators according to bus index. """; 9, call; 10, attribute; 11, argument_list; 12, attribute; 13, identifier:sort; 14, keyword_argument; 15, identifier:self; 16, identifier:generators; 17, identifier:key; 18, lambda; 19, lambda_parameters; 20, attribute; 21, identifier:gn; 22, attribute; 23, identifier:_i; 24, identifier:gn; 25, identifier:bus
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 6, 8; 7, 9; 9, 10; 9, 11; 10, 12; 10, 13; 11, 14; 12, 15; 12, 16; 14, 17; 14, 18; 18, 19; 18, 20; 19, 21; 20, 22; 20, 23; 22, 24; 22, 25
def sort_generators(self): """ Reorders the list of generators according to bus index. """ self.generators.sort(key=lambda gn: gn.bus._i)
0, module; 1, function_definition; 2, function_name:list; 3, parameters; 4, comment:# pylint: disable=redefined-builtin; 5, block; 6, identifier:self; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, expression_statement; 16, return_statement; 17, identifier:filter; 18, None; 19, identifier:type; 20, None; 21, identifier:sort; 22, None; 23, identifier:limit; 24, None; 25, identifier:page; 26, None; 27, comment:"""Get a list of configs. :param filter: (optional) Filters to apply as a string list. :param type: (optional) `union` or `inter` as string. :param sort: (optional) Sort fields to apply as string list. :param limit: (optional) Limit returned list length. :param page: (optional) Page to return. :return: :class:`configs.Page <configs.Page>` object """; 28, assignment; 29, assignment; 30, assignment; 31, call; 32, identifier:schema; 33, attribute; 34, identifier:resp; 35, call; 36, pattern_list; 37, call; 38, identifier:Page; 39, argument_list; 40, identifier:self; 41, identifier:LIST_SCHEMA; 42, attribute; 43, argument_list; 44, identifier:cs; 45, identifier:l; 46, attribute; 47, argument_list; 48, identifier:cs; 49, identifier:l; 50, attribute; 51, identifier:list; 52, attribute; 53, identifier:filter; 54, identifier:type; 55, identifier:sort; 56, identifier:limit; 57, identifier:page; 58, attribute; 59, identifier:decode; 60, identifier:schema; 61, identifier:resp; 62, keyword_argument; 63, keyword_argument; 64, identifier:self; 65, identifier:service; 66, identifier:self; 67, identifier:base; 68, identifier:self; 69, identifier:service; 70, identifier:many; 71, True; 72, identifier:links; 73, True
0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 5, 12; 5, 13; 5, 14; 5, 15; 5, 16; 7, 17; 7, 18; 8, 19; 8, 20; 9, 21; 9, 22; 10, 23; 10, 24; 11, 25; 11, 26; 12, 27; 13, 28; 14, 29; 15, 30; 16, 31; 28, 32; 28, 33; 29, 34; 29, 35; 30, 36; 30, 37; 31, 38; 31, 39; 33, 40; 33, 41; 35, 42; 35, 43; 36, 44; 36, 45; 37, 46; 37, 47; 39, 48; 39, 49; 42, 50; 42, 51; 43, 52; 43, 53; 43, 54; 43, 55; 43, 56; 43, 57; 46, 58; 46, 59; 47, 60; 47, 61; 47, 62; 47, 63; 50, 64; 50, 65; 52, 66; 52, 67; 58, 68; 58, 69; 62, 70; 62, 71; 63, 72; 63, 73
def list(self, filter=None, type=None, sort=None, limit=None, page=None): # pylint: disable=redefined-builtin """Get a list of configs. :param filter: (optional) Filters to apply as a string list. :param type: (optional) `union` or `inter` as string. :param sort: (optional) Sort fields to apply as string list. :param limit: (optional) Limit returned list length. :param page: (optional) Page to return. :return: :class:`configs.Page <configs.Page>` object """ schema = self.LIST_SCHEMA resp = self.service.list(self.base, filter, type, sort, limit, page) cs, l = self.service.decode(schema, resp, many=True, links=True) return Page(cs, l)
0, module; 1, function_definition; 2, function_name:list_csv; 3, parameters; 4, comment:# pylint: disable=redefined-builtin; 5, block; 6, identifier:self; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, expression_statement; 13, return_statement; 14, identifier:filter; 15, None; 16, identifier:type; 17, None; 18, identifier:sort; 19, None; 20, identifier:limit; 21, None; 22, identifier:page; 23, None; 24, comment:"""Get a list of results as CSV. :param filter: (optional) Filters to apply as a string list. :param type: (optional) `union` or `inter` as string. :param sort: (optional) Sort fields to apply as string list. :param limit: (optional) Limit returned list length. :param page: (optional) Page to return. :rtype: string """; 25, attribute; 26, call; 27, identifier:text; 28, attribute; 29, argument_list; 30, attribute; 31, identifier:list; 32, attribute; 33, identifier:filter; 34, identifier:type; 35, identifier:sort; 36, identifier:limit; 37, identifier:page; 38, keyword_argument; 39, identifier:self; 40, identifier:service; 41, identifier:self; 42, identifier:base; 43, identifier:format; 44, string; 45, string_content:csv
0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 5, 12; 5, 13; 7, 14; 7, 15; 8, 16; 8, 17; 9, 18; 9, 19; 10, 20; 10, 21; 11, 22; 11, 23; 12, 24; 13, 25; 25, 26; 25, 27; 26, 28; 26, 29; 28, 30; 28, 31; 29, 32; 29, 33; 29, 34; 29, 35; 29, 36; 29, 37; 29, 38; 30, 39; 30, 40; 32, 41; 32, 42; 38, 43; 38, 44; 44, 45
def list_csv(self, filter=None, type=None, sort=None, limit=None, page=None): # pylint: disable=redefined-builtin """Get a list of results as CSV. :param filter: (optional) Filters to apply as a string list. :param type: (optional) `union` or `inter` as string. :param sort: (optional) Sort fields to apply as string list. :param limit: (optional) Limit returned list length. :param page: (optional) Page to return. :rtype: string """ return self.service.list(self.base, filter, type, sort, limit, page, format='csv').text
0, module; 1, function_definition; 2, function_name:list_logdir; 3, parameters; 4, comment:# pylint: disable=invalid-name,redefined-builtin; 5, block; 6, identifier:self; 7, identifier:id; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, return_statement; 14, identifier:filter; 15, None; 16, identifier:sort; 17, None; 18, comment:"""Get a list of logdir files. :param id: Result ID as an int. :param filter: Filter to apply as string. :param sort: Sort field to apply as string. :return: :class:`results.LogDirFile <results.LogDirFile>` list """; 19, assignment; 20, assignment; 21, call; 22, identifier:schema; 23, call; 24, identifier:resp; 25, call; 26, attribute; 27, argument_list; 28, identifier:LogDirFileSchema; 29, argument_list; 30, attribute; 31, argument_list; 32, attribute; 33, identifier:decode; 34, identifier:schema; 35, identifier:resp; 36, keyword_argument; 37, attribute; 38, identifier:list; 39, binary_operator:self.base+str(id)+'/logdir/'; 40, identifier:filter; 41, identifier:sort; 42, identifier:self; 43, identifier:service; 44, identifier:many; 45, True; 46, identifier:self; 47, identifier:service; 48, binary_operator:self.base+str(id); 49, string; 50, attribute; 51, call; 52, string_content:/logdir/; 53, identifier:self; 54, identifier:base; 55, identifier:str; 56, argument_list; 57, identifier:id
0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 3, 6; 3, 7; 3, 8; 3, 9; 5, 10; 5, 11; 5, 12; 5, 13; 8, 14; 8, 15; 9, 16; 9, 17; 10, 18; 11, 19; 12, 20; 13, 21; 19, 22; 19, 23; 20, 24; 20, 25; 21, 26; 21, 27; 23, 28; 23, 29; 25, 30; 25, 31; 26, 32; 26, 33; 27, 34; 27, 35; 27, 36; 30, 37; 30, 38; 31, 39; 31, 40; 31, 41; 32, 42; 32, 43; 36, 44; 36, 45; 37, 46; 37, 47; 39, 48; 39, 49; 48, 50; 48, 51; 49, 52; 50, 53; 50, 54; 51, 55; 51, 56; 56, 57
def list_logdir(self, id, filter=None, sort=None): # pylint: disable=invalid-name,redefined-builtin """Get a list of logdir files. :param id: Result ID as an int. :param filter: Filter to apply as string. :param sort: Sort field to apply as string. :return: :class:`results.LogDirFile <results.LogDirFile>` list """ schema = LogDirFileSchema() resp = self.service.list(self.base+str(id)+'/logdir/', filter, sort) return self.service.decode(schema, resp, many=True)
0, module; 1, function_definition; 2, function_name:list; 3, parameters; 4, comment:# pylint: disable=redefined-builtin; 5, block; 6, identifier:self; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, expression_statement; 16, return_statement; 17, identifier:filter; 18, None; 19, identifier:type; 20, None; 21, identifier:sort; 22, None; 23, identifier:limit; 24, None; 25, identifier:page; 26, None; 27, comment:"""Get a list of packages. :param filter: (optional) Filters to apply as a string list. :param type: (optional) `union` or `inter` as string. :param sort: (optional) Sort fields to apply as string list. :param limit: (optional) Limit returned list length. :param page: (optional) Page to return. :return: :class:`packages.Page <packages.Page>` object """; 28, assignment; 29, assignment; 30, assignment; 31, call; 32, identifier:schema; 33, call; 34, identifier:resp; 35, call; 36, pattern_list; 37, call; 38, identifier:Page; 39, argument_list; 40, identifier:PackageSchema; 41, argument_list; 42, attribute; 43, argument_list; 44, identifier:ps; 45, identifier:l; 46, attribute; 47, argument_list; 48, identifier:ps; 49, identifier:l; 50, keyword_argument; 51, attribute; 52, identifier:list; 53, attribute; 54, identifier:filter; 55, identifier:type; 56, identifier:sort; 57, identifier:limit; 58, identifier:page; 59, attribute; 60, identifier:decode; 61, identifier:schema; 62, identifier:resp; 63, keyword_argument; 64, keyword_argument; 65, identifier:exclude; 66, tuple; 67, identifier:self; 68, identifier:service; 69, identifier:self; 70, identifier:base; 71, identifier:self; 72, identifier:service; 73, identifier:many; 74, True; 75, identifier:links; 76, True; 77, string; 78, string; 79, string; 80, string; 81, string; 82, string_content:testlist; 83, string_content:extra_cli_args; 84, string_content:agent_id; 85, string_content:options; 86, string_content:note
0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 5, 12; 5, 13; 5, 14; 5, 15; 5, 16; 7, 17; 7, 18; 8, 19; 8, 20; 9, 21; 9, 22; 10, 23; 10, 24; 11, 25; 11, 26; 12, 27; 13, 28; 14, 29; 15, 30; 16, 31; 28, 32; 28, 33; 29, 34; 29, 35; 30, 36; 30, 37; 31, 38; 31, 39; 33, 40; 33, 41; 35, 42; 35, 43; 36, 44; 36, 45; 37, 46; 37, 47; 39, 48; 39, 49; 41, 50; 42, 51; 42, 52; 43, 53; 43, 54; 43, 55; 43, 56; 43, 57; 43, 58; 46, 59; 46, 60; 47, 61; 47, 62; 47, 63; 47, 64; 50, 65; 50, 66; 51, 67; 51, 68; 53, 69; 53, 70; 59, 71; 59, 72; 63, 73; 63, 74; 64, 75; 64, 76; 66, 77; 66, 78; 66, 79; 66, 80; 66, 81; 77, 82; 78, 83; 79, 84; 80, 85; 81, 86
def list(self, filter=None, type=None, sort=None, limit=None, page=None): # pylint: disable=redefined-builtin """Get a list of packages. :param filter: (optional) Filters to apply as a string list. :param type: (optional) `union` or `inter` as string. :param sort: (optional) Sort fields to apply as string list. :param limit: (optional) Limit returned list length. :param page: (optional) Page to return. :return: :class:`packages.Page <packages.Page>` object """ schema = PackageSchema(exclude=('testlist', 'extra_cli_args', 'agent_id', 'options', 'note')) resp = self.service.list(self.base, filter, type, sort, limit, page) ps, l = self.service.decode(schema, resp, many=True, links=True) return Page(ps, l)
0, module; 1, function_definition; 2, function_name:list; 3, parameters; 4, comment:# pylint: disable=invalid-name,redefined-builtin; 5, block; 6, identifier:self; 7, identifier:id; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, default_parameter; 13, expression_statement; 14, expression_statement; 15, expression_statement; 16, expression_statement; 17, return_statement; 18, identifier:filter; 19, None; 20, identifier:type; 21, None; 22, identifier:sort; 23, None; 24, identifier:limit; 25, None; 26, identifier:page; 27, None; 28, comment:"""Get a list of a device's attachments. :param id: Device ID as an int. :param filter: (optional) Filters to apply as a string list. :param type: (optional) `union` or `inter` as string. :param sort: (optional) Sort fields to apply as string list. :param limit: (optional) Limit returned list length. :param page: (optional) Page to return. :return: :class:`attachments.Page <attachments.Page>` object """; 29, assignment; 30, assignment; 31, assignment; 32, call; 33, identifier:schema; 34, call; 35, identifier:resp; 36, call; 37, pattern_list; 38, call; 39, identifier:Page; 40, argument_list; 41, identifier:AttachmentSchema; 42, argument_list; 43, attribute; 44, argument_list; 45, identifier:at; 46, identifier:l; 47, attribute; 48, argument_list; 49, identifier:at; 50, identifier:l; 51, keyword_argument; 52, attribute; 53, identifier:list; 54, call; 55, identifier:filter; 56, identifier:type; 57, identifier:sort; 58, identifier:limit; 59, identifier:page; 60, attribute; 61, identifier:decode; 62, identifier:schema; 63, identifier:resp; 64, keyword_argument; 65, keyword_argument; 66, identifier:exclude; 67, parenthesized_expression; 68, identifier:self; 69, identifier:service; 70, attribute; 71, argument_list; 72, identifier:self; 73, identifier:service; 74, identifier:many; 75, True; 76, identifier:links; 77, True; 78, string; 79, identifier:self; 80, identifier:_base; 81, identifier:id; 82, string_content:path
0, 1; 1, 2; 1, 3; 1, 4; 1, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 5, 13; 5, 14; 5, 15; 5, 16; 5, 17; 8, 18; 8, 19; 9, 20; 9, 21; 10, 22; 10, 23; 11, 24; 11, 25; 12, 26; 12, 27; 13, 28; 14, 29; 15, 30; 16, 31; 17, 32; 29, 33; 29, 34; 30, 35; 30, 36; 31, 37; 31, 38; 32, 39; 32, 40; 34, 41; 34, 42; 36, 43; 36, 44; 37, 45; 37, 46; 38, 47; 38, 48; 40, 49; 40, 50; 42, 51; 43, 52; 43, 53; 44, 54; 44, 55; 44, 56; 44, 57; 44, 58; 44, 59; 47, 60; 47, 61; 48, 62; 48, 63; 48, 64; 48, 65; 51, 66; 51, 67; 52, 68; 52, 69; 54, 70; 54, 71; 60, 72; 60, 73; 64, 74; 64, 75; 65, 76; 65, 77; 67, 78; 70, 79; 70, 80; 71, 81; 78, 82
def list(self, id, filter=None, type=None, sort=None, limit=None, page=None): # pylint: disable=invalid-name,redefined-builtin """Get a list of a device's attachments. :param id: Device ID as an int. :param filter: (optional) Filters to apply as a string list. :param type: (optional) `union` or `inter` as string. :param sort: (optional) Sort fields to apply as string list. :param limit: (optional) Limit returned list length. :param page: (optional) Page to return. :return: :class:`attachments.Page <attachments.Page>` object """ schema = AttachmentSchema(exclude=('path')) resp = self.service.list(self._base(id), filter, type, sort, limit, page) at, l = self.service.decode(schema, resp, many=True, links=True) return Page(at, l)
0, module; 1, function_definition; 2, function_name:_process_value; 3, parameters; 4, block; 5, identifier:self; 6, identifier:value; 7, identifier:type; 8, expression_statement; 9, if_statement; 10, return_statement; 11, comment:""" Process a value that will be sent to backend :param value: the value to return :param type: hint for what sort of value this is :type type: str """; 12, not_operator; 13, block; 14, identifier:value; 15, call; 16, expression_statement; 17, identifier:isinstance; 18, argument_list; 19, assignment; 20, identifier:value; 21, binary_operator:six.string_types + (list,); 22, identifier:value; 23, call; 24, attribute; 25, tuple; 26, attribute; 27, argument_list; 28, identifier:six; 29, identifier:string_types; 30, identifier:list; 31, identifier:json; 32, identifier:dumps; 33, identifier:value
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 8, 11; 9, 12; 9, 13; 10, 14; 12, 15; 13, 16; 15, 17; 15, 18; 16, 19; 18, 20; 18, 21; 19, 22; 19, 23; 21, 24; 21, 25; 23, 26; 23, 27; 24, 28; 24, 29; 25, 30; 26, 31; 26, 32; 27, 33
def _process_value(self, value, type): """ Process a value that will be sent to backend :param value: the value to return :param type: hint for what sort of value this is :type type: str """ if not isinstance(value, six.string_types + (list,)): value = json.dumps(value) return value
0, module; 1, function_definition; 2, function_name:representatives; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, if_statement; 11, if_statement; 12, expression_statement; 13, expression_statement; 14, for_statement; 15, return_statement; 16, identifier:count; 17, None; 18, identifier:sorting; 19, False; 20, comment:""" Returns a list of pairs of representative and its voting weight :param count: Max amount of representatives to return :type count: int :param sorting: If true, sorts by weight :type sorting: bool :raises: :py:exc:`nano.rpc.RPCException` >>> rpc.representatives() { "xrb_1111111111111111111111111111111111111111111111111117353trpda": 3822372327060170000000000000000000000, "xrb_1111111111111111111111111111111111111111111111111awsq94gtecn": 30999999999999999999999999000000, "xrb_114nk4rwjctu6n6tr6g6ps61g1w3hdpjxfas4xj1tq6i8jyomc5d858xr1xi": 0 } """; 21, assignment; 22, comparison_operator:count is not None; 23, block; 24, identifier:sorting; 25, block; 26, assignment; 27, assignment; 28, pattern_list; 29, call; 30, block; 31, identifier:representatives; 32, identifier:payload; 33, dictionary; 34, identifier:count; 35, None; 36, expression_statement; 37, expression_statement; 38, identifier:resp; 39, call; 40, identifier:representatives; 41, boolean_operator; 42, identifier:k; 43, identifier:v; 44, attribute; 45, argument_list; 46, expression_statement; 47, assignment; 48, assignment; 49, attribute; 50, argument_list; 51, call; 52, dictionary; 53, identifier:representatives; 54, identifier:items; 55, assignment; 56, subscript; 57, call; 58, subscript; 59, call; 60, identifier:self; 61, identifier:call; 62, string; 63, identifier:payload; 64, attribute; 65, argument_list; 66, subscript; 67, call; 68, identifier:payload; 69, string; 70, attribute; 71, argument_list; 72, identifier:payload; 73, string; 74, attribute; 75, argument_list; 76, string_content:representatives; 77, identifier:resp; 78, identifier:get; 79, string; 80, identifier:representatives; 81, identifier:k; 82, identifier:int; 83, argument_list; 84, string_content:count; 85, identifier:self; 86, identifier:_process_value; 87, identifier:count; 88, string; 89, string_content:sorting; 90, identifier:self; 91, identifier:_process_value; 92, identifier:sorting; 93, string; 94, string_content:representatives; 95, identifier:v; 96, string_content:int; 97, string_content:strbool
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 6, 16; 6, 17; 7, 18; 7, 19; 8, 20; 9, 21; 10, 22; 10, 23; 11, 24; 11, 25; 12, 26; 13, 27; 14, 28; 14, 29; 14, 30; 15, 31; 21, 32; 21, 33; 22, 34; 22, 35; 23, 36; 25, 37; 26, 38; 26, 39; 27, 40; 27, 41; 28, 42; 28, 43; 29, 44; 29, 45; 30, 46; 36, 47; 37, 48; 39, 49; 39, 50; 41, 51; 41, 52; 44, 53; 44, 54; 46, 55; 47, 56; 47, 57; 48, 58; 48, 59; 49, 60; 49, 61; 50, 62; 50, 63; 51, 64; 51, 65; 55, 66; 55, 67; 56, 68; 56, 69; 57, 70; 57, 71; 58, 72; 58, 73; 59, 74; 59, 75; 62, 76; 64, 77; 64, 78; 65, 79; 66, 80; 66, 81; 67, 82; 67, 83; 69, 84; 70, 85; 70, 86; 71, 87; 71, 88; 73, 89; 74, 90; 74, 91; 75, 92; 75, 93; 79, 94; 83, 95; 88, 96; 93, 97
def representatives(self, count=None, sorting=False): """ Returns a list of pairs of representative and its voting weight :param count: Max amount of representatives to return :type count: int :param sorting: If true, sorts by weight :type sorting: bool :raises: :py:exc:`nano.rpc.RPCException` >>> rpc.representatives() { "xrb_1111111111111111111111111111111111111111111111111117353trpda": 3822372327060170000000000000000000000, "xrb_1111111111111111111111111111111111111111111111111awsq94gtecn": 30999999999999999999999999000000, "xrb_114nk4rwjctu6n6tr6g6ps61g1w3hdpjxfas4xj1tq6i8jyomc5d858xr1xi": 0 } """ payload = {} if count is not None: payload['count'] = self._process_value(count, 'int') if sorting: payload['sorting'] = self._process_value(sorting, 'strbool') resp = self.call('representatives', payload) representatives = resp.get('representatives') or {} for k, v in representatives.items(): representatives[k] = int(v) return representatives
0, module; 1, function_definition; 2, function_name:iterative_overlap_assembly; 3, parameters; 4, block; 5, identifier:variant_sequences; 6, default_parameter; 7, expression_statement; 8, if_statement; 9, comment:# reduce the number of inputs to the merge algorithm by first collapsing; 10, comment:# shorter sequences onto the longer sequences which contain them; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, expression_statement; 16, return_statement; 17, identifier:min_overlap_size; 18, identifier:MIN_VARIANT_SEQUENCE_ASSEMBLY_OVERLAP_SIZE; 19, comment:""" Assembles longer sequences from reads centered on a variant by between merging all pairs of overlapping sequences and collapsing shorter sequences onto every longer sequence which contains them. Returns a list of variant sequences, sorted by decreasing read support. """; 20, comparison_operator:len(variant_sequences) <= 1; 21, comment:# if we don't have at least two sequences to start with then; 22, comment:# skip the whole mess below; 23, block; 24, assignment; 25, assignment; 26, assignment; 27, call; 28, assignment; 29, call; 30, call; 31, integer:1; 32, return_statement; 33, identifier:n_before_collapse; 34, call; 35, identifier:variant_sequences; 36, call; 37, identifier:n_after_collapse; 38, call; 39, attribute; 40, argument_list; 41, identifier:merged_variant_sequences; 42, call; 43, identifier:list; 44, argument_list; 45, identifier:len; 46, argument_list; 47, identifier:variant_sequences; 48, identifier:len; 49, argument_list; 50, identifier:collapse_substrings; 51, argument_list; 52, identifier:len; 53, argument_list; 54, identifier:logger; 55, identifier:info; 56, string:"Collapsed %d -> %d sequences"; 57, identifier:n_before_collapse; 58, identifier:n_after_collapse; 59, identifier:greedy_merge; 60, argument_list; 61, call; 62, identifier:variant_sequences; 63, identifier:variant_sequences; 64, identifier:variant_sequences; 65, identifier:variant_sequences; 66, identifier:variant_sequences; 67, identifier:min_overlap_size; 68, identifier:sorted; 69, argument_list; 70, identifier:merged_variant_sequences; 71, keyword_argument; 72, identifier:key; 73, lambda; 74, lambda_parameters; 75, unary_operator; 76, identifier:seq; 77, call; 78, identifier:len; 79, argument_list; 80, attribute; 81, identifier:seq; 82, identifier:reads
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 6, 17; 6, 18; 7, 19; 8, 20; 8, 21; 8, 22; 8, 23; 11, 24; 12, 25; 13, 26; 14, 27; 15, 28; 16, 29; 20, 30; 20, 31; 23, 32; 24, 33; 24, 34; 25, 35; 25, 36; 26, 37; 26, 38; 27, 39; 27, 40; 28, 41; 28, 42; 29, 43; 29, 44; 30, 45; 30, 46; 32, 47; 34, 48; 34, 49; 36, 50; 36, 51; 38, 52; 38, 53; 39, 54; 39, 55; 40, 56; 40, 57; 40, 58; 42, 59; 42, 60; 44, 61; 46, 62; 49, 63; 51, 64; 53, 65; 60, 66; 60, 67; 61, 68; 61, 69; 69, 70; 69, 71; 71, 72; 71, 73; 73, 74; 73, 75; 74, 76; 75, 77; 77, 78; 77, 79; 79, 80; 80, 81; 80, 82
def iterative_overlap_assembly( variant_sequences, min_overlap_size=MIN_VARIANT_SEQUENCE_ASSEMBLY_OVERLAP_SIZE): """ Assembles longer sequences from reads centered on a variant by between merging all pairs of overlapping sequences and collapsing shorter sequences onto every longer sequence which contains them. Returns a list of variant sequences, sorted by decreasing read support. """ if len(variant_sequences) <= 1: # if we don't have at least two sequences to start with then # skip the whole mess below return variant_sequences # reduce the number of inputs to the merge algorithm by first collapsing # shorter sequences onto the longer sequences which contain them n_before_collapse = len(variant_sequences) variant_sequences = collapse_substrings(variant_sequences) n_after_collapse = len(variant_sequences) logger.info( "Collapsed %d -> %d sequences", n_before_collapse, n_after_collapse) merged_variant_sequences = greedy_merge(variant_sequences, min_overlap_size) return list(sorted( merged_variant_sequences, key=lambda seq: -len(seq.reads)))
0, module; 1, function_definition; 2, function_name:rot_consts; 3, parameters; 4, block; 5, identifier:geom; 6, identifier:masses; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, comment:# Imports; 11, import_statement; 12, import_from_statement; 13, comment:# Ensure units are valid; 14, if_statement; 15, comment:## end if; 16, comment:# Retrieve the moments, axes and top type. Geom and masses are proofed; 17, comment:# internally in this call.; 18, expression_statement; 19, comment:# Check for special cases; 20, if_statement; 21, comment:## end if; 22, comment:# Calculate the values in the indicated units; 23, if_statement; 24, comment:## end if; 25, comment:# Return the result; 26, return_statement; 27, identifier:units; 28, attribute; 29, identifier:on_tol; 30, attribute; 31, comment:"""Rotational constants for a given molecular system. Calculates the rotational constants for the provided system with numerical value given in the units provided in `units`. The orthnormality tolerance `on_tol` is required in order to be passed through to the :func:`principals` function. If the system is linear or a single atom, the effectively-zero principal moments of inertia will be assigned values of :data:`opan.const.PRM.ZERO_MOMENT_TOL` before transformation into the appropriate rotational constant units. The moments of inertia are always sorted in increasing order as :math:`0 \\leq I_A \\leq I_B \\leq I_C`; the rotational constants calculated from these will thus always be in **decreasing** order as :math:`B_A \\geq B_B \\geq B_C`, retaining the ordering and association with the three principal ``axes[:,i]`` generated by :func:`principals`. Parameters ---------- geom length-3N |npfloat_| -- Coordinates of the atoms masses length-N OR length-3N |npfloat_| -- Atomic masses of the atoms. Length-3N option is to allow calculation of a per-coordinate perturbed value. units :class:`~opan.const.EnumUnitsRotConst`, optional -- Enum value indicating the desired units of the output rotational constants. Default is :data:`~opan.const.EnumUnitsRotConst.INV_INERTIA` :math:`\\left(1\\over \\mathrm{uB^2}\\right)` on_tol |npfloat_|, optional -- Tolerance for deviation from unity/zero for principal axis dot products, within which axes are considered orthonormal. Default is :data:`opan.const.DEF.ORTHONORM_TOL` Returns ------- rc length-3 |npfloat_| -- Vector of rotational constants in the indicated units """; 32, aliased_import; 33, relative_import; 34, aliased_import; 35, aliased_import; 36, dotted_name; 37, dotted_name; 38, not_operator; 39, block; 40, assignment; 41, comparison_operator:top == ETT.ATOM; 42, comment:# All moments are zero; set to zero-moment threshold; 43, block; 44, elif_clause; 45, comparison_operator:units == EURC.INV_INERTIA; 46, comment:# 1/(amu*B^2); 47, block; 48, elif_clause; 49, elif_clause; 50, elif_clause; 51, elif_clause; 52, elif_clause; 53, elif_clause; 54, elif_clause; 55, else_clause; 56, identifier:rc; 57, identifier:_EURC; 58, identifier:INV_INERTIA; 59, identifier:_DEF; 60, identifier:ORTHONORM_TOL; 61, dotted_name; 62, identifier:np; 63, import_prefix; 64, dotted_name; 65, dotted_name; 66, identifier:ETT; 67, dotted_name; 68, identifier:EURC; 69, identifier:PRM; 70, identifier:PHYS; 71, comparison_operator:units in EURC; 72, raise_statement; 73, pattern_list; 74, call; 75, identifier:top; 76, attribute; 77, expression_statement; 78, comparison_operator:top == ETT.LINEAR; 79, comment:# First moment is zero; set to zero-moment threshold; 80, block; 81, identifier:units; 82, attribute; 83, expression_statement; 84, comparison_operator:units == EURC.ANGFREQ_ATOMIC; 85, comment:# 1/Ta; 86, block; 87, comparison_operator:units == EURC.ANGFREQ_SECS; 88, comment:# 1/s; 89, block; 90, comparison_operator:units == EURC.CYCFREQ_ATOMIC; 91, comment:# cyc/Ta; 92, block; 93, comparison_operator:units == EURC.CYCFREQ_HZ; 94, comment:# cyc/s; 95, block; 96, comparison_operator:units == EURC.CYCFREQ_MHZ; 97, comment:# Mcyc/s; 98, block; 99, comparison_operator:units == EURC.WAVENUM_ATOMIC; 100, comment:# cyc/B; 101, block; 102, comparison_operator:units == EURC.WAVENUM_CM; 103, comment:# cyc/cm; 104, block; 105, comment:# pragma: no cover -- Valid units; not implemented; 106, block; 107, identifier:numpy; 108, identifier:const; 109, identifier:EnumTopType; 110, identifier:EnumUnitsRotConst; 111, identifier:units; 112, identifier:EURC; 113, call; 114, identifier:mom; 115, identifier:ax; 116, identifier:top; 117, identifier:principals; 118, argument_list; 119, identifier:ETT; 120, identifier:ATOM; 121, assignment; 122, identifier:top; 123, attribute; 124, expression_statement; 125, identifier:EURC; 126, identifier:INV_INERTIA; 127, assignment; 128, identifier:units; 129, attribute; 130, expression_statement; 131, identifier:units; 132, attribute; 133, expression_statement; 134, identifier:units; 135, attribute; 136, expression_statement; 137, identifier:units; 138, attribute; 139, expression_statement; 140, identifier:units; 141, attribute; 142, expression_statement; 143, identifier:units; 144, attribute; 145, expression_statement; 146, identifier:units; 147, attribute; 148, expression_statement; 149, raise_statement; 150, identifier:ValueError; 151, argument_list; 152, identifier:geom; 153, identifier:masses; 154, identifier:on_tol; 155, identifier:mom; 156, call; 157, identifier:ETT; 158, identifier:LINEAR; 159, assignment; 160, identifier:rc; 161, binary_operator:1.0 / (2.0 * mom); 162, identifier:EURC; 163, identifier:ANGFREQ_ATOMIC; 164, assignment; 165, identifier:EURC; 166, identifier:ANGFREQ_SECS; 167, assignment; 168, identifier:EURC; 169, identifier:CYCFREQ_ATOMIC; 170, assignment; 171, identifier:EURC; 172, identifier:CYCFREQ_HZ; 173, assignment; 174, identifier:EURC; 175, identifier:CYCFREQ_MHZ; 176, assignment; 177, identifier:EURC; 178, identifier:WAVENUM_ATOMIC; 179, assignment; 180, identifier:EURC; 181, identifier:WAVENUM_CM; 182, assignment; 183, call; 184, call; 185, attribute; 186, argument_list; 187, subscript; 188, attribute; 189, float:1.0; 190, parenthesized_expression; 191, identifier:rc; 192, binary_operator:PHYS.PLANCK_BAR / (2.0 * mom * PHYS.ME_PER_AMU); 193, identifier:rc; 194, binary_operator:PHYS.PLANCK_BAR / (2.0 * mom * PHYS.ME_PER_AMU) / PHYS.SEC_PER_TA; 195, identifier:rc; 196, binary_operator:PHYS.PLANCK_BAR / (4.0 * np.pi * mom * PHYS.ME_PER_AMU); 197, identifier:rc; 198, binary_operator:PHYS.PLANCK_BAR / (4.0 * np.pi * mom * PHYS.ME_PER_AMU) / \ PHYS.SEC_PER_TA; 199, identifier:rc; 200, binary_operator:PHYS.PLANCK_BAR / (4.0 * np.pi * mom * PHYS.ME_PER_AMU) / \ PHYS.SEC_PER_TA / 1.0e6; 201, identifier:rc; 202, binary_operator:PHYS.PLANCK / (mom * PHYS.ME_PER_AMU) / \ (8.0 * np.pi**2.0 * PHYS.LIGHT_SPEED); 203, identifier:rc; 204, binary_operator:PHYS.PLANCK / (mom * PHYS.ME_PER_AMU) / \ (8.0 * np.pi**2.0 * PHYS.LIGHT_SPEED * PHYS.ANG_PER_BOHR) * 1.0e8; 205, identifier:NotImplementedError; 206, argument_list; 207, attribute; 208, argument_list; 209, identifier:np; 210, identifier:repeat; 211, attribute; 212, integer:3; 213, identifier:mom; 214, integer:0; 215, identifier:PRM; 216, identifier:ZERO_MOMENT_TOL; 217, binary_operator:2.0 * mom; 218, attribute; 219, parenthesized_expression; 220, binary_operator:PHYS.PLANCK_BAR / (2.0 * mom * PHYS.ME_PER_AMU); 221, attribute; 222, attribute; 223, parenthesized_expression; 224, binary_operator:PHYS.PLANCK_BAR / (4.0 * np.pi * mom * PHYS.ME_PER_AMU); 225, line_continuation:\; 226, attribute; 227, binary_operator:PHYS.PLANCK_BAR / (4.0 * np.pi * mom * PHYS.ME_PER_AMU) / \ PHYS.SEC_PER_TA; 228, float:1.0e6; 229, binary_operator:PHYS.PLANCK / (mom * PHYS.ME_PER_AMU); 230, line_continuation:\; 231, parenthesized_expression; 232, binary_operator:PHYS.PLANCK / (mom * PHYS.ME_PER_AMU) / \ (8.0 * np.pi**2.0 * PHYS.LIGHT_SPEED * PHYS.ANG_PER_BOHR); 233, float:1.0e8; 234, string:"Units conversion not yet implemented."; 235, string:"'{0}' is not a valid units value"; 236, identifier:format; 237, identifier:units; 238, identifier:PRM; 239, identifier:ZERO_MOMENT_TOL; 240, float:2.0; 241, identifier:mom; 242, identifier:PHYS; 243, identifier:PLANCK_BAR; 244, binary_operator:2.0 * mom * PHYS.ME_PER_AMU; 245, attribute; 246, parenthesized_expression; 247, identifier:PHYS; 248, identifier:SEC_PER_TA; 249, identifier:PHYS; 250, identifier:PLANCK_BAR; 251, binary_operator:4.0 * np.pi * mom * PHYS.ME_PER_AMU; 252, attribute; 253, parenthesized_expression; 254, identifier:PHYS; 255, identifier:SEC_PER_TA; 256, binary_operator:PHYS.PLANCK_BAR / (4.0 * np.pi * mom * PHYS.ME_PER_AMU); 257, line_continuation:\; 258, attribute; 259, attribute; 260, parenthesized_expression; 261, binary_operator:8.0 * np.pi**2.0 * PHYS.LIGHT_SPEED; 262, binary_operator:PHYS.PLANCK / (mom * PHYS.ME_PER_AMU); 263, line_continuation:\; 264, parenthesized_expression; 265, binary_operator:2.0 * mom; 266, attribute; 267, identifier:PHYS; 268, identifier:PLANCK_BAR; 269, binary_operator:2.0 * mom * PHYS.ME_PER_AMU; 270, binary_operator:4.0 * np.pi * mom; 271, attribute; 272, identifier:PHYS; 273, identifier:PLANCK_BAR; 274, binary_operator:4.0 * np.pi * mom * PHYS.ME_PER_AMU; 275, attribute; 276, parenthesized_expression; 277, identifier:PHYS; 278, identifier:SEC_PER_TA; 279, identifier:PHYS; 280, identifier:PLANCK; 281, binary_operator:mom * PHYS.ME_PER_AMU; 282, binary_operator:8.0 * np.pi**2.0; 283, attribute; 284, attribute; 285, parenthesized_expression; 286, binary_operator:8.0 * np.pi**2.0 * PHYS.LIGHT_SPEED * PHYS.ANG_PER_BOHR; 287, float:2.0; 288, identifier:mom; 289, identifier:PHYS; 290, identifier:ME_PER_AMU; 291, binary_operator:2.0 * mom; 292, attribute; 293, binary_operator:4.0 * np.pi; 294, identifier:mom; 295, identifier:PHYS; 296, identifier:ME_PER_AMU; 297, binary_operator:4.0 * np.pi * mom; 298, attribute; 299, identifier:PHYS; 300, identifier:PLANCK_BAR; 301, binary_operator:4.0 * np.pi * mom * PHYS.ME_PER_AMU; 302, identifier:mom; 303, attribute; 304, float:8.0; 305, binary_operator:np.pi**2.0; 306, identifier:PHYS; 307, identifier:LIGHT_SPEED; 308, identifier:PHYS; 309, identifier:PLANCK; 310, binary_operator:mom * PHYS.ME_PER_AMU; 311, binary_operator:8.0 * np.pi**2.0 * PHYS.LIGHT_SPEED; 312, attribute; 313, float:2.0; 314, identifier:mom; 315, identifier:PHYS; 316, identifier:ME_PER_AMU; 317, float:4.0; 318, attribute; 319, binary_operator:4.0 * np.pi; 320, identifier:mom; 321, identifier:PHYS; 322, identifier:ME_PER_AMU; 323, binary_operator:4.0 * np.pi * mom; 324, attribute; 325, identifier:PHYS; 326, identifier:ME_PER_AMU; 327, attribute; 328, float:2.0; 329, identifier:mom; 330, attribute; 331, binary_operator:8.0 * np.pi**2.0; 332, attribute; 333, identifier:PHYS; 334, identifier:ANG_PER_BOHR; 335, identifier:np; 336, identifier:pi; 337, float:4.0; 338, attribute; 339, binary_operator:4.0 * np.pi; 340, identifier:mom; 341, identifier:PHYS; 342, identifier:ME_PER_AMU; 343, identifier:np; 344, identifier:pi; 345, identifier:PHYS; 346, identifier:ME_PER_AMU; 347, float:8.0; 348, binary_operator:np.pi**2.0; 349, identifier:PHYS; 350, identifier:LIGHT_SPEED; 351, identifier:np; 352, identifier:pi; 353, float:4.0; 354, attribute; 355, attribute; 356, float:2.0; 357, identifier:np; 358, identifier:pi; 359, identifier:np; 360, identifier:pi
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 4, 23; 4, 24; 4, 25; 4, 26; 7, 27; 7, 28; 8, 29; 8, 30; 9, 31; 11, 32; 12, 33; 12, 34; 12, 35; 12, 36; 12, 37; 14, 38; 14, 39; 18, 40; 20, 41; 20, 42; 20, 43; 20, 44; 23, 45; 23, 46; 23, 47; 23, 48; 23, 49; 23, 50; 23, 51; 23, 52; 23, 53; 23, 54; 23, 55; 26, 56; 28, 57; 28, 58; 30, 59; 30, 60; 32, 61; 32, 62; 33, 63; 33, 64; 34, 65; 34, 66; 35, 67; 35, 68; 36, 69; 37, 70; 38, 71; 39, 72; 40, 73; 40, 74; 41, 75; 41, 76; 43, 77; 44, 78; 44, 79; 44, 80; 45, 81; 45, 82; 47, 83; 48, 84; 48, 85; 48, 86; 49, 87; 49, 88; 49, 89; 50, 90; 50, 91; 50, 92; 51, 93; 51, 94; 51, 95; 52, 96; 52, 97; 52, 98; 53, 99; 53, 100; 53, 101; 54, 102; 54, 103; 54, 104; 55, 105; 55, 106; 61, 107; 64, 108; 65, 109; 67, 110; 71, 111; 71, 112; 72, 113; 73, 114; 73, 115; 73, 116; 74, 117; 74, 118; 76, 119; 76, 120; 77, 121; 78, 122; 78, 123; 80, 124; 82, 125; 82, 126; 83, 127; 84, 128; 84, 129; 86, 130; 87, 131; 87, 132; 89, 133; 90, 134; 90, 135; 92, 136; 93, 137; 93, 138; 95, 139; 96, 140; 96, 141; 98, 142; 99, 143; 99, 144; 101, 145; 102, 146; 102, 147; 104, 148; 106, 149; 113, 150; 113, 151; 118, 152; 118, 153; 118, 154; 121, 155; 121, 156; 123, 157; 123, 158; 124, 159; 127, 160; 127, 161; 129, 162; 129, 163; 130, 164; 132, 165; 132, 166; 133, 167; 135, 168; 135, 169; 136, 170; 138, 171; 138, 172; 139, 173; 141, 174; 141, 175; 142, 176; 144, 177; 144, 178; 145, 179; 147, 180; 147, 181; 148, 182; 149, 183; 151, 184; 156, 185; 156, 186; 159, 187; 159, 188; 161, 189; 161, 190; 164, 191; 164, 192; 167, 193; 167, 194; 170, 195; 170, 196; 173, 197; 173, 198; 176, 199; 176, 200; 179, 201; 179, 202; 182, 203; 182, 204; 183, 205; 183, 206; 184, 207; 184, 208; 185, 209; 185, 210; 186, 211; 186, 212; 187, 213; 187, 214; 188, 215; 188, 216; 190, 217; 192, 218; 192, 219; 194, 220; 194, 221; 196, 222; 196, 223; 198, 224; 198, 225; 198, 226; 200, 227; 200, 228; 202, 229; 202, 230; 202, 231; 204, 232; 204, 233; 206, 234; 207, 235; 207, 236; 208, 237; 211, 238; 211, 239; 217, 240; 217, 241; 218, 242; 218, 243; 219, 244; 220, 245; 220, 246; 221, 247; 221, 248; 222, 249; 222, 250; 223, 251; 224, 252; 224, 253; 226, 254; 226, 255; 227, 256; 227, 257; 227, 258; 229, 259; 229, 260; 231, 261; 232, 262; 232, 263; 232, 264; 244, 265; 244, 266; 245, 267; 245, 268; 246, 269; 251, 270; 251, 271; 252, 272; 252, 273; 253, 274; 256, 275; 256, 276; 258, 277; 258, 278; 259, 279; 259, 280; 260, 281; 261, 282; 261, 283; 262, 284; 262, 285; 264, 286; 265, 287; 265, 288; 266, 289; 266, 290; 269, 291; 269, 292; 270, 293; 270, 294; 271, 295; 271, 296; 274, 297; 274, 298; 275, 299; 275, 300; 276, 301; 281, 302; 281, 303; 282, 304; 282, 305; 283, 306; 283, 307; 284, 308; 284, 309; 285, 310; 286, 311; 286, 312; 291, 313; 291, 314; 292, 315; 292, 316; 293, 317; 293, 318; 297, 319; 297, 320; 298, 321; 298, 322; 301, 323; 301, 324; 303, 325; 303, 326; 305, 327; 305, 328; 310, 329; 310, 330; 311, 331; 311, 332; 312, 333; 312, 334; 318, 335; 318, 336; 319, 337; 319, 338; 323, 339; 323, 340; 324, 341; 324, 342; 327, 343; 327, 344; 330, 345; 330, 346; 331, 347; 331, 348; 332, 349; 332, 350; 338, 351; 338, 352; 339, 353; 339, 354; 348, 355; 348, 356; 354, 357; 354, 358; 355, 359; 355, 360
def rot_consts(geom, masses, units=_EURC.INV_INERTIA, on_tol=_DEF.ORTHONORM_TOL): """Rotational constants for a given molecular system. Calculates the rotational constants for the provided system with numerical value given in the units provided in `units`. The orthnormality tolerance `on_tol` is required in order to be passed through to the :func:`principals` function. If the system is linear or a single atom, the effectively-zero principal moments of inertia will be assigned values of :data:`opan.const.PRM.ZERO_MOMENT_TOL` before transformation into the appropriate rotational constant units. The moments of inertia are always sorted in increasing order as :math:`0 \\leq I_A \\leq I_B \\leq I_C`; the rotational constants calculated from these will thus always be in **decreasing** order as :math:`B_A \\geq B_B \\geq B_C`, retaining the ordering and association with the three principal ``axes[:,i]`` generated by :func:`principals`. Parameters ---------- geom length-3N |npfloat_| -- Coordinates of the atoms masses length-N OR length-3N |npfloat_| -- Atomic masses of the atoms. Length-3N option is to allow calculation of a per-coordinate perturbed value. units :class:`~opan.const.EnumUnitsRotConst`, optional -- Enum value indicating the desired units of the output rotational constants. Default is :data:`~opan.const.EnumUnitsRotConst.INV_INERTIA` :math:`\\left(1\\over \\mathrm{uB^2}\\right)` on_tol |npfloat_|, optional -- Tolerance for deviation from unity/zero for principal axis dot products, within which axes are considered orthonormal. Default is :data:`opan.const.DEF.ORTHONORM_TOL` Returns ------- rc length-3 |npfloat_| -- Vector of rotational constants in the indicated units """ # Imports import numpy as np from ..const import EnumTopType as ETT, EnumUnitsRotConst as EURC, PRM, PHYS # Ensure units are valid if not units in EURC: raise ValueError("'{0}' is not a valid units value".format(units)) ## end if # Retrieve the moments, axes and top type. Geom and masses are proofed # internally in this call. mom, ax, top = principals(geom, masses, on_tol) # Check for special cases if top == ETT.ATOM: # All moments are zero; set to zero-moment threshold mom = np.repeat(PRM.ZERO_MOMENT_TOL, 3) elif top == ETT.LINEAR: # First moment is zero; set to zero-moment threshold mom[0] = PRM.ZERO_MOMENT_TOL ## end if # Calculate the values in the indicated units if units == EURC.INV_INERTIA: # 1/(amu*B^2) rc = 1.0 / (2.0 * mom) elif units == EURC.ANGFREQ_ATOMIC: # 1/Ta rc = PHYS.PLANCK_BAR / (2.0 * mom * PHYS.ME_PER_AMU) elif units == EURC.ANGFREQ_SECS: # 1/s rc = PHYS.PLANCK_BAR / (2.0 * mom * PHYS.ME_PER_AMU) / PHYS.SEC_PER_TA elif units == EURC.CYCFREQ_ATOMIC: # cyc/Ta rc = PHYS.PLANCK_BAR / (4.0 * np.pi * mom * PHYS.ME_PER_AMU) elif units == EURC.CYCFREQ_HZ: # cyc/s rc = PHYS.PLANCK_BAR / (4.0 * np.pi * mom * PHYS.ME_PER_AMU) / \ PHYS.SEC_PER_TA elif units == EURC.CYCFREQ_MHZ: # Mcyc/s rc = PHYS.PLANCK_BAR / (4.0 * np.pi * mom * PHYS.ME_PER_AMU) / \ PHYS.SEC_PER_TA / 1.0e6 elif units == EURC.WAVENUM_ATOMIC: # cyc/B rc = PHYS.PLANCK / (mom * PHYS.ME_PER_AMU) / \ (8.0 * np.pi**2.0 * PHYS.LIGHT_SPEED) elif units == EURC.WAVENUM_CM: # cyc/cm rc = PHYS.PLANCK / (mom * PHYS.ME_PER_AMU) / \ (8.0 * np.pi**2.0 * PHYS.LIGHT_SPEED * PHYS.ANG_PER_BOHR) * 1.0e8 else: # pragma: no cover -- Valid units; not implemented raise NotImplementedError("Units conversion not yet implemented.") ## end if # Return the result return rc
0, module; 1, function_definition; 2, function_name:reference_contexts_for_variants; 3, parameters; 4, block; 5, identifier:variants; 6, identifier:context_size; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, return_statement; 12, identifier:transcript_id_whitelist; 13, None; 14, comment:""" Extract a set of reference contexts for each variant in the collection. Parameters ---------- variants : varcode.VariantCollection context_size : int Max of nucleotides to include to the left and right of the variant in the context sequence. transcript_id_whitelist : set, optional If given, then only consider transcripts whose IDs are in this set. Returns a dictionary from variants to lists of ReferenceContext objects, sorted by max coding sequence length of any transcript. """; 15, assignment; 16, identifier:variant; 17, identifier:variants; 18, block; 19, identifier:result; 20, identifier:result; 21, call; 22, expression_statement; 23, identifier:OrderedDict; 24, argument_list; 25, assignment; 26, subscript; 27, call; 28, identifier:result; 29, identifier:variant; 30, identifier:reference_contexts_for_variant; 31, argument_list; 32, keyword_argument; 33, keyword_argument; 34, keyword_argument; 35, identifier:variant; 36, identifier:variant; 37, identifier:context_size; 38, identifier:context_size; 39, identifier:transcript_id_whitelist; 40, identifier:transcript_id_whitelist
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 7, 12; 7, 13; 8, 14; 9, 15; 10, 16; 10, 17; 10, 18; 11, 19; 15, 20; 15, 21; 18, 22; 21, 23; 21, 24; 22, 25; 25, 26; 25, 27; 26, 28; 26, 29; 27, 30; 27, 31; 31, 32; 31, 33; 31, 34; 32, 35; 32, 36; 33, 37; 33, 38; 34, 39; 34, 40
def reference_contexts_for_variants( variants, context_size, transcript_id_whitelist=None): """ Extract a set of reference contexts for each variant in the collection. Parameters ---------- variants : varcode.VariantCollection context_size : int Max of nucleotides to include to the left and right of the variant in the context sequence. transcript_id_whitelist : set, optional If given, then only consider transcripts whose IDs are in this set. Returns a dictionary from variants to lists of ReferenceContext objects, sorted by max coding sequence length of any transcript. """ result = OrderedDict() for variant in variants: result[variant] = reference_contexts_for_variant( variant=variant, context_size=context_size, transcript_id_whitelist=transcript_id_whitelist) return result
0, module; 1, function_definition; 2, function_name:ffd; 3, parameters; 4, block; 5, identifier:items; 6, identifier:targets; 7, dictionary_splat_pattern; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, return_statement; 13, identifier:kwargs; 14, comment:"""First-Fit Decreasing This is perhaps the simplest packing heuristic; it simply packs items in the next available bin. This algorithm differs only from Next-Fit Decreasing in having a 'sort'; that is, the items are pre-sorted (largest to smallest). Complexity O(n^2) """; 15, assignment; 16, assignment; 17, assignment; 18, call; 19, identifier:sizes; 20, call; 21, identifier:sizes; 22, call; 23, identifier:items; 24, call; 25, identifier:ff; 26, argument_list; 27, identifier:zip; 28, argument_list; 29, identifier:sorted; 30, argument_list; 31, identifier:map; 32, argument_list; 33, identifier:items; 34, identifier:targets; 35, identifier:items; 36, call; 37, identifier:sizes; 38, keyword_argument; 39, keyword_argument; 40, call; 41, identifier:sizes; 42, identifier:weight; 43, argument_list; 44, identifier:key; 45, call; 46, identifier:reverse; 47, True; 48, attribute; 49, argument_list; 50, identifier:items; 51, dictionary_splat; 52, attribute; 53, argument_list; 54, identifier:operator; 55, identifier:itemgetter; 56, integer:0; 57, identifier:kwargs; 58, identifier:operator; 59, identifier:itemgetter; 60, integer:1
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 7, 13; 8, 14; 9, 15; 10, 16; 11, 17; 12, 18; 15, 19; 15, 20; 16, 21; 16, 22; 17, 23; 17, 24; 18, 25; 18, 26; 20, 27; 20, 28; 22, 29; 22, 30; 24, 31; 24, 32; 26, 33; 26, 34; 28, 35; 28, 36; 30, 37; 30, 38; 30, 39; 32, 40; 32, 41; 36, 42; 36, 43; 38, 44; 38, 45; 39, 46; 39, 47; 40, 48; 40, 49; 43, 50; 43, 51; 45, 52; 45, 53; 48, 54; 48, 55; 49, 56; 51, 57; 52, 58; 52, 59; 53, 60
def ffd(items, targets, **kwargs): """First-Fit Decreasing This is perhaps the simplest packing heuristic; it simply packs items in the next available bin. This algorithm differs only from Next-Fit Decreasing in having a 'sort'; that is, the items are pre-sorted (largest to smallest). Complexity O(n^2) """ sizes = zip(items, weight(items, **kwargs)) sizes = sorted(sizes, key=operator.itemgetter(1), reverse=True) items = map(operator.itemgetter(0), sizes) return ff(items, targets)
0, module; 1, function_definition; 2, function_name:sort_protein_sequences; 3, parameters; 4, block; 5, identifier:protein_sequences; 6, expression_statement; 7, return_statement; 8, comment:""" Sort protein sequences in decreasing order of priority """; 9, call; 10, identifier:list; 11, argument_list; 12, call; 13, identifier:sorted; 14, argument_list; 15, identifier:protein_sequences; 16, keyword_argument; 17, keyword_argument; 18, identifier:key; 19, attribute; 20, identifier:reverse; 21, True; 22, identifier:ProteinSequence; 23, identifier:ascending_sort_key
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 6, 8; 7, 9; 9, 10; 9, 11; 11, 12; 12, 13; 12, 14; 14, 15; 14, 16; 14, 17; 16, 18; 16, 19; 17, 20; 17, 21; 19, 22; 19, 23
def sort_protein_sequences(protein_sequences): """ Sort protein sequences in decreasing order of priority """ return list( sorted( protein_sequences, key=ProteinSequence.ascending_sort_key, reverse=True))
0, module; 1, function_definition; 2, function_name:dump; 3, parameters; 4, block; 5, identifier:obj; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, dictionary_splat_pattern; 10, expression_statement; 11, if_statement; 12, identifier:fp; 13, None; 14, identifier:indent; 15, None; 16, identifier:sort_keys; 17, False; 18, identifier:kw; 19, comment:""" Dump object to a file like object or string. :param obj: :param fp: Open file like object :param int indent: Indent size, default 2 :param bool sort_keys: Optionally sort dictionary keys. :return: Yaml serialized data. """; 20, identifier:fp; 21, block; 22, else_clause; 23, expression_statement; 24, for_statement; 25, block; 26, assignment; 27, identifier:chunk; 28, identifier:iterable; 29, block; 30, return_statement; 31, identifier:iterable; 32, call; 33, expression_statement; 34, call; 35, attribute; 36, argument_list; 37, call; 38, identifier:dumps; 39, argument_list; 40, call; 41, identifier:iterencode; 42, identifier:obj; 43, attribute; 44, argument_list; 45, identifier:obj; 46, keyword_argument; 47, keyword_argument; 48, dictionary_splat; 49, identifier:YAMLEncoder; 50, argument_list; 51, identifier:fp; 52, identifier:write; 53, identifier:chunk; 54, identifier:indent; 55, identifier:indent; 56, identifier:sort_keys; 57, identifier:sort_keys; 58, identifier:kw; 59, keyword_argument; 60, keyword_argument; 61, dictionary_splat; 62, identifier:indent; 63, identifier:indent; 64, identifier:sort_keys; 65, identifier:sort_keys; 66, identifier:kw
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, 10; 4, 11; 6, 12; 6, 13; 7, 14; 7, 15; 8, 16; 8, 17; 9, 18; 10, 19; 11, 20; 11, 21; 11, 22; 21, 23; 21, 24; 22, 25; 23, 26; 24, 27; 24, 28; 24, 29; 25, 30; 26, 31; 26, 32; 29, 33; 30, 34; 32, 35; 32, 36; 33, 37; 34, 38; 34, 39; 35, 40; 35, 41; 36, 42; 37, 43; 37, 44; 39, 45; 39, 46; 39, 47; 39, 48; 40, 49; 40, 50; 43, 51; 43, 52; 44, 53; 46, 54; 46, 55; 47, 56; 47, 57; 48, 58; 50, 59; 50, 60; 50, 61; 59, 62; 59, 63; 60, 64; 60, 65; 61, 66
def dump(obj, fp=None, indent=None, sort_keys=False, **kw): """ Dump object to a file like object or string. :param obj: :param fp: Open file like object :param int indent: Indent size, default 2 :param bool sort_keys: Optionally sort dictionary keys. :return: Yaml serialized data. """ if fp: iterable = YAMLEncoder(indent=indent, sort_keys=sort_keys, **kw).iterencode(obj) for chunk in iterable: fp.write(chunk) else: return dumps(obj, indent=indent, sort_keys=sort_keys, **kw)
0, module; 1, function_definition; 2, function_name:sorted_options; 3, parameters; 4, block; 5, identifier:sort_options; 6, expression_statement; 7, return_statement; 8, comment:"""Sort sort options for display. :param sort_options: A dictionary containing the field name as key and asc/desc as value. :returns: A dictionary with sorting options for Invenio-Search-JS. """; 9, list_comprehension; 10, dictionary; 11, for_in_clause; 12, pair; 13, pair; 14, pattern_list; 15, call; 16, string; 17, subscript; 18, string; 19, parenthesized_expression; 20, identifier:k; 21, identifier:v; 22, identifier:sorted; 23, argument_list; 24, string_content:title; 25, identifier:v; 26, string; 27, string_content:value; 28, conditional_expression:'-{0}'.format(k) if v.get('default_order', 'asc') == 'desc' else k; 29, call; 30, keyword_argument; 31, string_content:title; 32, call; 33, comparison_operator:v.get('default_order', 'asc') == 'desc'; 34, identifier:k; 35, attribute; 36, argument_list; 37, identifier:key; 38, lambda; 39, attribute; 40, argument_list; 41, call; 42, string; 43, identifier:sort_options; 44, identifier:items; 45, lambda_parameters; 46, call; 47, string; 48, identifier:format; 49, identifier:k; 50, attribute; 51, argument_list; 52, string_content:desc; 53, identifier:x; 54, attribute; 55, argument_list; 56, string_content:-{0}; 57, identifier:v; 58, identifier:get; 59, string; 60, string; 61, subscript; 62, identifier:get; 63, string; 64, integer:0; 65, string_content:default_order; 66, string_content:asc; 67, identifier:x; 68, integer:1; 69, string_content:order
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 6, 8; 7, 9; 9, 10; 9, 11; 10, 12; 10, 13; 11, 14; 11, 15; 12, 16; 12, 17; 13, 18; 13, 19; 14, 20; 14, 21; 15, 22; 15, 23; 16, 24; 17, 25; 17, 26; 18, 27; 19, 28; 23, 29; 23, 30; 26, 31; 28, 32; 28, 33; 28, 34; 29, 35; 29, 36; 30, 37; 30, 38; 32, 39; 32, 40; 33, 41; 33, 42; 35, 43; 35, 44; 38, 45; 38, 46; 39, 47; 39, 48; 40, 49; 41, 50; 41, 51; 42, 52; 45, 53; 46, 54; 46, 55; 47, 56; 50, 57; 50, 58; 51, 59; 51, 60; 54, 61; 54, 62; 55, 63; 55, 64; 59, 65; 60, 66; 61, 67; 61, 68; 63, 69
def sorted_options(sort_options): """Sort sort options for display. :param sort_options: A dictionary containing the field name as key and asc/desc as value. :returns: A dictionary with sorting options for Invenio-Search-JS. """ return [ { 'title': v['title'], 'value': ('-{0}'.format(k) if v.get('default_order', 'asc') == 'desc' else k), } for k, v in sorted(sort_options.items(), key=lambda x: x[1].get('order', 0)) ]
0, module; 1, function_definition; 2, function_name:info; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, return_statement; 8, string; 9, call; 10, string_content:Returns information on all the registered checkers. Sorted by namespace and then name :returns a list of CheckerInfo; 11, identifier:sorted; 12, argument_list; 13, call; 14, keyword_argument; 15, attribute; 16, argument_list; 17, identifier:key; 18, lambda; 19, attribute; 20, identifier:values; 21, lambda_parameters; 22, tuple; 23, identifier:self; 24, identifier:_checkers; 25, identifier:x; 26, attribute; 27, attribute; 28, identifier:x; 29, identifier:ns; 30, identifier:x; 31, identifier:name
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 6, 8; 7, 9; 8, 10; 9, 11; 9, 12; 12, 13; 12, 14; 13, 15; 13, 16; 14, 17; 14, 18; 15, 19; 15, 20; 18, 21; 18, 22; 19, 23; 19, 24; 21, 25; 22, 26; 22, 27; 26, 28; 26, 29; 27, 30; 27, 31
def info(self): ''' Returns information on all the registered checkers. Sorted by namespace and then name :returns a list of CheckerInfo ''' return sorted(self._checkers.values(), key=lambda x: (x.ns, x.name))
0, module; 1, function_definition; 2, function_name:extract_from_text; 3, parameters; 4, block; 5, identifier:text; 6, expression_statement; 7, return_statement; 8, comment:""" Extract HAL ids from a text. :param text: The text to extract HAL ids from. :returns: A list of matching HAL ids. >>> sorted(extract_from_text("hal-01258754 hal-01258754v2 foobar")) ['hal-01258754', 'hal-01258754v2'] """; 9, call; 10, attribute; 11, argument_list; 12, identifier:tools; 13, identifier:remove_duplicates; 14, list_comprehension; 15, subscript; 16, for_in_clause; 17, if_clause; 18, identifier:i; 19, integer:0; 20, identifier:i; 21, call; 22, comparison_operator:i != ''; 23, attribute; 24, argument_list; 25, identifier:i; 26, string; 27, identifier:REGEX; 28, identifier:findall; 29, identifier:text
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 6, 8; 7, 9; 9, 10; 9, 11; 10, 12; 10, 13; 11, 14; 14, 15; 14, 16; 14, 17; 15, 18; 15, 19; 16, 20; 16, 21; 17, 22; 21, 23; 21, 24; 22, 25; 22, 26; 23, 27; 23, 28; 24, 29
def extract_from_text(text): """ Extract HAL ids from a text. :param text: The text to extract HAL ids from. :returns: A list of matching HAL ids. >>> sorted(extract_from_text("hal-01258754 hal-01258754v2 foobar")) ['hal-01258754', 'hal-01258754v2'] """ return tools.remove_duplicates([i[0] for i in REGEX.findall(text) if i != ''])
0, module; 1, function_definition; 2, function_name:_show_documentation; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, expression_statement; 8, for_statement; 9, expression_statement; 10, expression_statement; 11, if_statement; 12, expression_statement; 13, expression_statement; 14, while_statement; 15, comment:""" Shows all documents of the current groundwork app in the console. Documents are sorted bei its names, except "main", which gets set to the beginning. """; 16, assignment; 17, pattern_list; 18, call; 19, block; 20, assignment; 21, assignment; 22, comparison_operator:main is not None; 23, block; 24, assignment; 25, assignment; 26, comparison_operator:user_answer != "X"; 27, block; 28, identifier:documents; 29, list; 30, identifier:key; 31, identifier:document; 32, attribute; 33, argument_list; 34, if_statement; 35, identifier:documents; 36, call; 37, identifier:main; 38, call; 39, identifier:main; 40, None; 41, expression_statement; 42, identifier:user_answer; 43, string:""; 44, identifier:index; 45, integer:0; 46, identifier:user_answer; 47, string:"X"; 48, if_statement; 49, if_statement; 50, expression_statement; 51, expression_statement; 52, expression_statement; 53, expression_statement; 54, expression_statement; 55, expression_statement; 56, expression_statement; 57, expression_statement; 58, if_statement; 59, if_statement; 60, expression_statement; 61, expression_statement; 62, if_statement; 63, expression_statement; 64, if_statement; 65, call; 66, identifier:items; 67, comparison_operator:key != "main"; 68, block; 69, identifier:sorted; 70, argument_list; 71, attribute; 72, argument_list; 73, call; 74, comparison_operator:index < 0; 75, block; 76, comparison_operator:index > len(documents) - 1; 77, block; 78, assignment; 79, call; 80, call; 81, assignment; 82, call; 83, call; 84, call; 85, assignment; 86, comparison_operator:index < len(documents) - 1; 87, block; 88, comparison_operator:index > 0; 89, block; 90, augmented_assignment; 91, call; 92, comparison_operator:index < len(documents) - 1; 93, block; 94, elif_clause; 95, else_clause; 96, assignment; 97, comparison_operator:user_answer == "N"; 98, block; 99, elif_clause; 100, attribute; 101, argument_list; 102, identifier:key; 103, string:"main"; 104, expression_statement; 105, identifier:documents; 106, keyword_argument; 107, attribute; 108, identifier:get; 109, string:"main"; 110, attribute; 111, argument_list; 112, identifier:index; 113, integer:0; 114, expression_statement; 115, identifier:index; 116, binary_operator:len(documents) - 1; 117, expression_statement; 118, identifier:document; 119, subscript; 120, attribute; 121, argument_list; 122, identifier:echo; 123, argument_list; 124, identifier:source; 125, binary_operator:"This document is registered by '%s' under the name '%s'" % (document.plugin.name, document.name); 126, identifier:echo; 127, argument_list; 128, identifier:echo; 129, argument_list; 130, identifier:echo; 131, argument_list; 132, identifier:commands; 133, string:"Actions: "; 134, identifier:index; 135, binary_operator:len(documents) - 1; 136, expression_statement; 137, identifier:index; 138, integer:0; 139, expression_statement; 140, identifier:commands; 141, string:"E[x]it"; 142, identifier:echo; 143, argument_list; 144, identifier:index; 145, binary_operator:len(documents) - 1; 146, expression_statement; 147, comparison_operator:index > 0; 148, block; 149, block; 150, identifier:user_answer; 151, call; 152, identifier:user_answer; 153, string:"N"; 154, expression_statement; 155, comparison_operator:user_answer == "P"; 156, block; 157, attribute; 158, identifier:get; 159, call; 160, identifier:key; 161, lambda; 162, attribute; 163, identifier:documents; 164, identifier:documents; 165, identifier:insert; 166, integer:0; 167, tuple; 168, assignment; 169, call; 170, integer:1; 171, assignment; 172, subscript; 173, integer:1; 174, identifier:os; 175, identifier:system; 176, conditional_expression:'cls' if os.name == 'nt' else 'clear'; 177, call; 178, string:"This document is registered by '%s' under the name '%s'"; 179, tuple; 180, binary_operator:"-" * len(source); 181, identifier:source; 182, binary_operator:"-" * len(source); 183, call; 184, integer:1; 185, augmented_assignment; 186, augmented_assignment; 187, identifier:commands; 188, call; 189, integer:1; 190, assignment; 191, identifier:index; 192, integer:0; 193, expression_statement; 194, expression_statement; 195, attribute; 196, argument_list; 197, augmented_assignment; 198, identifier:user_answer; 199, string:"P"; 200, expression_statement; 201, attribute; 202, identifier:documents; 203, attribute; 204, argument_list; 205, lambda_parameters; 206, subscript; 207, identifier:self; 208, identifier:app; 209, attribute; 210, identifier:main; 211, identifier:index; 212, integer:0; 213, identifier:len; 214, argument_list; 215, identifier:index; 216, binary_operator:len(documents) - 1; 217, identifier:documents; 218, identifier:index; 219, string; 220, comparison_operator:os.name == 'nt'; 221, string; 222, attribute; 223, argument_list; 224, attribute; 225, attribute; 226, string:"-"; 227, call; 228, string:"-"; 229, call; 230, identifier:len; 231, argument_list; 232, identifier:commands; 233, string:"[N]ext, "; 234, identifier:commands; 235, string:"[P]revious, "; 236, identifier:len; 237, argument_list; 238, identifier:default; 239, string:"N"; 240, assignment; 241, assignment; 242, call; 243, identifier:upper; 244, identifier:index; 245, integer:1; 246, augmented_assignment; 247, identifier:self; 248, identifier:app; 249, identifier:documents; 250, identifier:append; 251, tuple; 252, identifier:x; 253, identifier:x; 254, integer:0; 255, identifier:main; 256, identifier:name; 257, identifier:documents; 258, call; 259, integer:1; 260, string_content:cls; 261, attribute; 262, string; 263, string_content:clear; 264, call; 265, identifier:render; 266, keyword_argument; 267, keyword_argument; 268, attribute; 269, identifier:name; 270, identifier:document; 271, identifier:name; 272, identifier:len; 273, argument_list; 274, identifier:len; 275, argument_list; 276, identifier:documents; 277, identifier:documents; 278, identifier:default; 279, string:"P"; 280, identifier:default; 281, string:"X"; 282, identifier:prompt; 283, argument_list; 284, identifier:index; 285, integer:1; 286, identifier:key; 287, identifier:document; 288, identifier:len; 289, argument_list; 290, identifier:os; 291, identifier:name; 292, string_content:nt; 293, attribute; 294, argument_list; 295, identifier:app; 296, attribute; 297, identifier:plugin; 298, attribute; 299, identifier:document; 300, identifier:plugin; 301, identifier:source; 302, identifier:source; 303, string:"Select your action"; 304, keyword_argument; 305, identifier:documents; 306, call; 307, identifier:from_string; 308, attribute; 309, identifier:self; 310, identifier:app; 311, identifier:document; 312, identifier:plugin; 313, identifier:default; 314, identifier:default; 315, identifier:Environment; 316, argument_list; 317, identifier:document; 318, identifier:content
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 6, 15; 7, 16; 8, 17; 8, 18; 8, 19; 9, 20; 10, 21; 11, 22; 11, 23; 12, 24; 13, 25; 14, 26; 14, 27; 16, 28; 16, 29; 17, 30; 17, 31; 18, 32; 18, 33; 19, 34; 20, 35; 20, 36; 21, 37; 21, 38; 22, 39; 22, 40; 23, 41; 24, 42; 24, 43; 25, 44; 25, 45; 26, 46; 26, 47; 27, 48; 27, 49; 27, 50; 27, 51; 27, 52; 27, 53; 27, 54; 27, 55; 27, 56; 27, 57; 27, 58; 27, 59; 27, 60; 27, 61; 27, 62; 27, 63; 27, 64; 32, 65; 32, 66; 34, 67; 34, 68; 36, 69; 36, 70; 38, 71; 38, 72; 41, 73; 48, 74; 48, 75; 49, 76; 49, 77; 50, 78; 51, 79; 52, 80; 53, 81; 54, 82; 55, 83; 56, 84; 57, 85; 58, 86; 58, 87; 59, 88; 59, 89; 60, 90; 61, 91; 62, 92; 62, 93; 62, 94; 62, 95; 63, 96; 64, 97; 64, 98; 64, 99; 65, 100; 65, 101; 67, 102; 67, 103; 68, 104; 70, 105; 70, 106; 71, 107; 71, 108; 72, 109; 73, 110; 73, 111; 74, 112; 74, 113; 75, 114; 76, 115; 76, 116; 77, 117; 78, 118; 78, 119; 79, 120; 79, 121; 80, 122; 80, 123; 81, 124; 81, 125; 82, 126; 82, 127; 83, 128; 83, 129; 84, 130; 84, 131; 85, 132; 85, 133; 86, 134; 86, 135; 87, 136; 88, 137; 88, 138; 89, 139; 90, 140; 90, 141; 91, 142; 91, 143; 92, 144; 92, 145; 93, 146; 94, 147; 94, 148; 95, 149; 96, 150; 96, 151; 97, 152; 97, 153; 98, 154; 99, 155; 99, 156; 100, 157; 100, 158; 104, 159; 106, 160; 106, 161; 107, 162; 107, 163; 110, 164; 110, 165; 111, 166; 111, 167; 114, 168; 116, 169; 116, 170; 117, 171; 119, 172; 119, 173; 120, 174; 120, 175; 121, 176; 123, 177; 125, 178; 125, 179; 127, 180; 129, 181; 131, 182; 135, 183; 135, 184; 136, 185; 139, 186; 143, 187; 145, 188; 145, 189; 146, 190; 147, 191; 147, 192; 148, 193; 149, 194; 151, 195; 151, 196; 154, 197; 155, 198; 155, 199; 156, 200; 157, 201; 157, 202; 159, 203; 159, 204; 161, 205; 161, 206; 162, 207; 162, 208; 167, 209; 167, 210; 168, 211; 168, 212; 169, 213; 169, 214; 171, 215; 171, 216; 172, 217; 172, 218; 176, 219; 176, 220; 176, 221; 177, 222; 177, 223; 179, 224; 179, 225; 180, 226; 180, 227; 182, 228; 182, 229; 183, 230; 183, 231; 185, 232; 185, 233; 186, 234; 186, 235; 188, 236; 188, 237; 190, 238; 190, 239; 193, 240; 194, 241; 195, 242; 195, 243; 197, 244; 197, 245; 200, 246; 201, 247; 201, 248; 203, 249; 203, 250; 204, 251; 205, 252; 206, 253; 206, 254; 209, 255; 209, 256; 214, 257; 216, 258; 216, 259; 219, 260; 220, 261; 220, 262; 221, 263; 222, 264; 222, 265; 223, 266; 223, 267; 224, 268; 224, 269; 225, 270; 225, 271; 227, 272; 227, 273; 229, 274; 229, 275; 231, 276; 237, 277; 240, 278; 240, 279; 241, 280; 241, 281; 242, 282; 242, 283; 246, 284; 246, 285; 251, 286; 251, 287; 258, 288; 258, 289; 261, 290; 261, 291; 262, 292; 264, 293; 264, 294; 266, 295; 266, 296; 267, 297; 267, 298; 268, 299; 268, 300; 273, 301; 275, 302; 283, 303; 283, 304; 289, 305; 293, 306; 293, 307; 294, 308; 296, 309; 296, 310; 298, 311; 298, 312; 304, 313; 304, 314; 306, 315; 306, 316; 308, 317; 308, 318
def _show_documentation(self): """ Shows all documents of the current groundwork app in the console. Documents are sorted bei its names, except "main", which gets set to the beginning. """ documents = [] for key, document in self.app.documents.get().items(): if key != "main": documents.append((key, document)) documents = sorted(documents, key=lambda x: x[0]) main = self.app.documents.get("main") if main is not None: documents.insert(0, (main.name, main)) user_answer = "" index = 0 while user_answer != "X": if index < 0: index = 0 if index > len(documents) - 1: index = len(documents) - 1 document = documents[index][1] os.system('cls' if os.name == 'nt' else 'clear') echo(Environment().from_string(document.content).render(app=self.app, plugin=document.plugin)) source = "This document is registered by '%s' under the name '%s'" % (document.plugin.name, document.name) echo("-" * len(source)) echo(source) echo("-" * len(source)) commands = "Actions: " if index < len(documents) - 1: commands += "[N]ext, " if index > 0: commands += "[P]revious, " commands += "E[x]it" echo(commands) if index < len(documents) - 1: default = "N" elif index > 0: default = "P" else: default = "X" user_answer = prompt("Select your action", default=default).upper() if user_answer == "N": index += 1 elif user_answer == "P": index -= 1
0, module; 1, function_definition; 2, function_name:dispersion_ranking_NN; 3, parameters; 4, block; 5, identifier:self; 6, identifier:nnm; 7, default_parameter; 8, expression_statement; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, expression_statement; 16, expression_statement; 17, expression_statement; 18, expression_statement; 19, return_statement; 20, identifier:num_norm_avg; 21, integer:50; 22, comment:"""Computes the spatial dispersion factors for each gene. Parameters ---------- nnm - scipy.sparse, float Square cell-to-cell nearest-neighbor matrix. num_norm_avg - int, optional, default 50 The top 'num_norm_avg' dispersions are averaged to determine the normalization factor when calculating the weights. This ensures that outlier genes do not significantly skew the weight distribution. Returns: ------- indices - ndarray, int The indices corresponding to the gene weights sorted in decreasing order. weights - ndarray, float The vector of gene weights. """; 23, call; 24, assignment; 25, assignment; 26, assignment; 27, assignment; 28, assignment; 29, assignment; 30, assignment; 31, assignment; 32, assignment; 33, identifier:weights; 34, attribute; 35, argument_list; 36, identifier:D_avg; 37, subscript; 38, pattern_list; 39, call; 40, identifier:dispersions; 41, call; 42, subscript; 43, binary_operator:var[mu > 0] / mu[mu > 0]; 44, subscript; 45, call; 46, identifier:ma; 47, call; 48, subscript; 49, identifier:ma; 50, identifier:weights; 51, call; 52, subscript; 53, identifier:weights; 54, identifier:self; 55, identifier:knn_avg; 56, identifier:nnm; 57, attribute; 58, string; 59, identifier:mu; 60, identifier:var; 61, attribute; 62, argument_list; 63, attribute; 64, argument_list; 65, identifier:dispersions; 66, comparison_operator:mu > 0; 67, subscript; 68, subscript; 69, attribute; 70, string; 71, attribute; 72, argument_list; 73, attribute; 74, argument_list; 75, identifier:dispersions; 76, comparison_operator:dispersions >= ma; 77, attribute; 78, argument_list; 79, attribute; 80, string; 81, attribute; 82, identifier:layers; 83, string_content:X_knn_avg; 84, identifier:sf; 85, identifier:mean_variance_axis; 86, identifier:D_avg; 87, keyword_argument; 88, identifier:np; 89, identifier:zeros; 90, attribute; 91, identifier:mu; 92, integer:0; 93, identifier:var; 94, comparison_operator:mu > 0; 95, identifier:mu; 96, comparison_operator:mu > 0; 97, attribute; 98, identifier:var; 99, string_content:spatial_dispersions; 100, identifier:dispersions; 101, identifier:copy; 102, subscript; 103, identifier:mean; 104, identifier:dispersions; 105, identifier:ma; 106, parenthesized_expression; 107, identifier:flatten; 108, attribute; 109, identifier:var; 110, string_content:weights; 111, identifier:self; 112, identifier:adata; 113, identifier:axis; 114, integer:0; 115, identifier:var; 116, identifier:size; 117, identifier:mu; 118, integer:0; 119, identifier:mu; 120, integer:0; 121, identifier:self; 122, identifier:adata; 123, call; 124, slice; 125, binary_operator:(dispersions / dispersions.max())**0.5; 126, identifier:self; 127, identifier:adata; 128, attribute; 129, argument_list; 130, unary_operator; 131, parenthesized_expression; 132, float:0.5; 133, identifier:np; 134, identifier:sort; 135, identifier:dispersions; 136, identifier:num_norm_avg; 137, binary_operator:dispersions / dispersions.max(); 138, identifier:dispersions; 139, call; 140, attribute; 141, argument_list; 142, identifier:dispersions; 143, identifier:max
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 4, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 7, 20; 7, 21; 8, 22; 9, 23; 10, 24; 11, 25; 12, 26; 13, 27; 14, 28; 15, 29; 16, 30; 17, 31; 18, 32; 19, 33; 23, 34; 23, 35; 24, 36; 24, 37; 25, 38; 25, 39; 26, 40; 26, 41; 27, 42; 27, 43; 28, 44; 28, 45; 29, 46; 29, 47; 30, 48; 30, 49; 31, 50; 31, 51; 32, 52; 32, 53; 34, 54; 34, 55; 35, 56; 37, 57; 37, 58; 38, 59; 38, 60; 39, 61; 39, 62; 41, 63; 41, 64; 42, 65; 42, 66; 43, 67; 43, 68; 44, 69; 44, 70; 45, 71; 45, 72; 47, 73; 47, 74; 48, 75; 48, 76; 51, 77; 51, 78; 52, 79; 52, 80; 57, 81; 57, 82; 58, 83; 61, 84; 61, 85; 62, 86; 62, 87; 63, 88; 63, 89; 64, 90; 66, 91; 66, 92; 67, 93; 67, 94; 68, 95; 68, 96; 69, 97; 69, 98; 70, 99; 71, 100; 71, 101; 73, 102; 73, 103; 76, 104; 76, 105; 77, 106; 77, 107; 79, 108; 79, 109; 80, 110; 81, 111; 81, 112; 87, 113; 87, 114; 90, 115; 90, 116; 94, 117; 94, 118; 96, 119; 96, 120; 97, 121; 97, 122; 102, 123; 102, 124; 106, 125; 108, 126; 108, 127; 123, 128; 123, 129; 124, 130; 125, 131; 125, 132; 128, 133; 128, 134; 129, 135; 130, 136; 131, 137; 137, 138; 137, 139; 139, 140; 139, 141; 140, 142; 140, 143
def dispersion_ranking_NN(self, nnm, num_norm_avg=50): """Computes the spatial dispersion factors for each gene. Parameters ---------- nnm - scipy.sparse, float Square cell-to-cell nearest-neighbor matrix. num_norm_avg - int, optional, default 50 The top 'num_norm_avg' dispersions are averaged to determine the normalization factor when calculating the weights. This ensures that outlier genes do not significantly skew the weight distribution. Returns: ------- indices - ndarray, int The indices corresponding to the gene weights sorted in decreasing order. weights - ndarray, float The vector of gene weights. """ self.knn_avg(nnm) D_avg = self.adata.layers['X_knn_avg'] mu, var = sf.mean_variance_axis(D_avg, axis=0) dispersions = np.zeros(var.size) dispersions[mu > 0] = var[mu > 0] / mu[mu > 0] self.adata.var['spatial_dispersions'] = dispersions.copy() ma = np.sort(dispersions)[-num_norm_avg:].mean() dispersions[dispersions >= ma] = ma weights = ((dispersions / dispersions.max())**0.5).flatten() self.adata.var['weights'] = weights return weights
0, module; 1, function_definition; 2, function_name:canonical_ops; 3, parameters; 4, block; 5, identifier:ops; 6, expression_statement; 7, expression_statement; 8, return_statement; 9, string; 10, assignment; 11, identifier:new_ops; 12, string_content:Returns the given operations array sorted with duplicates removed. @param ops checker.Ops @return: checker.Ops; 13, identifier:new_ops; 14, call; 15, identifier:sorted; 16, argument_list; 17, call; 18, keyword_argument; 19, identifier:set; 20, argument_list; 21, identifier:key; 22, lambda; 23, identifier:ops; 24, lambda_parameters; 25, tuple; 26, identifier:x; 27, attribute; 28, attribute; 29, identifier:x; 30, identifier:entity; 31, identifier:x; 32, identifier:action
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 6, 9; 7, 10; 8, 11; 9, 12; 10, 13; 10, 14; 14, 15; 14, 16; 16, 17; 16, 18; 17, 19; 17, 20; 18, 21; 18, 22; 20, 23; 22, 24; 22, 25; 24, 26; 25, 27; 25, 28; 27, 29; 27, 30; 28, 31; 28, 32
def canonical_ops(ops): ''' Returns the given operations array sorted with duplicates removed. @param ops checker.Ops @return: checker.Ops ''' new_ops = sorted(set(ops), key=lambda x: (x.entity, x.action)) return new_ops
0, module; 1, function_definition; 2, function_name:extract_from_text; 3, parameters; 4, block; 5, identifier:text; 6, expression_statement; 7, comment:# Remove the leading "arxiv:".; 8, return_statement; 9, comment:""" Extract arXiv IDs from a text. :param text: The text to extract arXiv IDs from. :returns: A list of matching arXiv IDs, in canonical form. >>> sorted(extract_from_text('1506.06690 1506.06690v1 arXiv:1506.06690 arXiv:1506.06690v1 arxiv:1506.06690 arxiv:1506.06690v1 math.GT/0309136 abcdf bar1506.06690foo mare.GG/0309136')) ['1506.06690', '1506.06690v1', 'math.GT/0309136'] """; 10, call; 11, attribute; 12, argument_list; 13, identifier:tools; 14, identifier:remove_duplicates; 15, list_comprehension; 16, call; 17, for_in_clause; 18, if_clause; 19, attribute; 20, argument_list; 21, identifier:i; 22, call; 23, comparison_operator:i[0] != ''; 24, identifier:re; 25, identifier:sub; 26, string:"arxiv:"; 27, string:""; 28, subscript; 29, keyword_argument; 30, attribute; 31, argument_list; 32, subscript; 33, string; 34, identifier:i; 35, integer:0; 36, identifier:flags; 37, attribute; 38, identifier:REGEX; 39, identifier:findall; 40, identifier:text; 41, identifier:i; 42, integer:0; 43, identifier:re; 44, identifier:IGNORECASE
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 6, 9; 8, 10; 10, 11; 10, 12; 11, 13; 11, 14; 12, 15; 15, 16; 15, 17; 15, 18; 16, 19; 16, 20; 17, 21; 17, 22; 18, 23; 19, 24; 19, 25; 20, 26; 20, 27; 20, 28; 20, 29; 22, 30; 22, 31; 23, 32; 23, 33; 28, 34; 28, 35; 29, 36; 29, 37; 30, 38; 30, 39; 31, 40; 32, 41; 32, 42; 37, 43; 37, 44
def extract_from_text(text): """ Extract arXiv IDs from a text. :param text: The text to extract arXiv IDs from. :returns: A list of matching arXiv IDs, in canonical form. >>> sorted(extract_from_text('1506.06690 1506.06690v1 arXiv:1506.06690 arXiv:1506.06690v1 arxiv:1506.06690 arxiv:1506.06690v1 math.GT/0309136 abcdf bar1506.06690foo mare.GG/0309136')) ['1506.06690', '1506.06690v1', 'math.GT/0309136'] """ # Remove the leading "arxiv:". return tools.remove_duplicates([re.sub("arxiv:", "", i[0], flags=re.IGNORECASE) for i in REGEX.findall(text) if i[0] != ''])
0, module; 1, function_definition; 2, function_name:serialize_text; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, if_statement; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, return_statement; 12, string; 13, boolean_operator; 14, block; 15, assignment; 16, assignment; 17, identifier:uri; 18, identifier:od; 19, block; 20, call; 21, string_content:Returns a serialized form of the Namepace. All the elements in the namespace are sorted by URI, joined to the associated prefix with a colon and separated with spaces. :return: bytes; 22, comparison_operator:self._uri_to_prefix is None; 23, comparison_operator:len(self._uri_to_prefix) == 0; 24, return_statement; 25, identifier:od; 26, call; 27, identifier:data; 28, list; 29, expression_statement; 30, attribute; 31, argument_list; 32, attribute; 33, None; 34, call; 35, integer:0; 36, string; 37, attribute; 38, argument_list; 39, call; 40, call; 41, identifier:encode; 42, string; 43, identifier:self; 44, identifier:_uri_to_prefix; 45, identifier:len; 46, argument_list; 47, identifier:collections; 48, identifier:OrderedDict; 49, call; 50, attribute; 51, argument_list; 52, attribute; 53, argument_list; 54, string_content:utf-8; 55, attribute; 56, identifier:sorted; 57, argument_list; 58, identifier:data; 59, identifier:append; 60, binary_operator:uri + ':' + od[uri]; 61, string; 62, identifier:join; 63, identifier:data; 64, identifier:self; 65, identifier:_uri_to_prefix; 66, call; 67, binary_operator:uri + ':'; 68, subscript; 69, string_content:; 70, attribute; 71, argument_list; 72, identifier:uri; 73, string; 74, identifier:od; 75, identifier:uri; 76, attribute; 77, identifier:items; 78, string_content::; 79, identifier:self; 80, identifier:_uri_to_prefix
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 4, 6; 4, 7; 4, 8; 4, 9; 4, 10; 4, 11; 6, 12; 7, 13; 7, 14; 8, 15; 9, 16; 10, 17; 10, 18; 10, 19; 11, 20; 12, 21; 13, 22; 13, 23; 14, 24; 15, 25; 15, 26; 16, 27; 16, 28; 19, 29; 20, 30; 20, 31; 22, 32; 22, 33; 23, 34; 23, 35; 24, 36; 26, 37; 26, 38; 29, 39; 30, 40; 30, 41; 31, 42; 32, 43; 32, 44; 34, 45; 34, 46; 37, 47; 37, 48; 38, 49; 39, 50; 39, 51; 40, 52; 40, 53; 42, 54; 46, 55; 49, 56; 49, 57; 50, 58; 50, 59; 51, 60; 52, 61; 52, 62; 53, 63; 55, 64; 55, 65; 57, 66; 60, 67; 60, 68; 61, 69; 66, 70; 66, 71; 67, 72; 67, 73; 68, 74; 68, 75; 70, 76; 70, 77; 73, 78; 76, 79; 76, 80
def serialize_text(self): '''Returns a serialized form of the Namepace. All the elements in the namespace are sorted by URI, joined to the associated prefix with a colon and separated with spaces. :return: bytes ''' if self._uri_to_prefix is None or len(self._uri_to_prefix) == 0: return b'' od = collections.OrderedDict(sorted(self._uri_to_prefix.items())) data = [] for uri in od: data.append(uri + ':' + od[uri]) return ' '.join(data).encode('utf-8')
0, module; 1, function_definition; 2, function_name:process; 3, parameters; 4, block; 5, identifier:self; 6, identifier:versions; 7, expression_statement; 8, for_statement; 9, comment:"""Logging version sorted ascending by tool name."""; 10, identifier:tool_name; 11, call; 12, block; 13, identifier:sorted; 14, argument_list; 15, expression_statement; 16, expression_statement; 17, call; 18, assignment; 19, call; 20, attribute; 21, argument_list; 22, identifier:version; 23, subscript; 24, attribute; 25, argument_list; 26, identifier:versions; 27, identifier:keys; 28, identifier:versions; 29, identifier:tool_name; 30, identifier:self; 31, identifier:_log; 32, binary_operator:"Using tool '%s', %s" % (tool_name, version); 33, string:"Using tool '%s', %s"; 34, tuple; 35, identifier:tool_name; 36, identifier:version
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 4, 7; 4, 8; 7, 9; 8, 10; 8, 11; 8, 12; 11, 13; 11, 14; 12, 15; 12, 16; 14, 17; 15, 18; 16, 19; 17, 20; 17, 21; 18, 22; 18, 23; 19, 24; 19, 25; 20, 26; 20, 27; 23, 28; 23, 29; 24, 30; 24, 31; 25, 32; 32, 33; 32, 34; 34, 35; 34, 36
def process(self, versions): """Logging version sorted ascending by tool name.""" for tool_name in sorted(versions.keys()): version = versions[tool_name] self._log("Using tool '%s', %s" % (tool_name, version))
0, module; 1, function_definition; 2, function_name:most_similar_catchments; 3, parameters; 4, block; 5, identifier:self; 6, identifier:subject_catchment; 7, identifier:similarity_dist_function; 8, default_parameter; 9, default_parameter; 10, expression_statement; 11, if_statement; 12, expression_statement; 13, comment:# At least 10 AMAX records; 14, expression_statement; 15, comment:# Add subject catchment if required (may not exist in database, so add after querying db; 16, if_statement; 17, comment:# Store the similarity distance as an additional attribute for each catchment; 18, for_statement; 19, comment:# Then simply sort by this attribute; 20, expression_statement; 21, comment:# Limit catchments until total amax_records counts is at least `records_limit`, default 500; 22, expression_statement; 23, expression_statement; 24, for_statement; 25, return_statement; 26, identifier:records_limit; 27, integer:500; 28, identifier:include_subject_catchment; 29, string; 30, comment:""" Return a list of catchments sorted by hydrological similarity defined by `similarity_distance_function` :param subject_catchment: subject catchment to find similar catchments for :type subject_catchment: :class:`floodestimation.entities.Catchment` :param similarity_dist_function: a method returning a similarity distance measure with 2 arguments, both :class:`floodestimation.entities.Catchment` objects :param include_subject_catchment: - `auto`: include subject catchment if suitable for pooling and if urbext < 0.03 - `force`: always include subject catchment having at least 10 years of data - `exclude`: do not include the subject catchment :type include_subject_catchment: str :return: list of catchments sorted by similarity :type: list of :class:`floodestimation.entities.Catchment` """; 31, comparison_operator:include_subject_catchment not in ['auto', 'force', 'exclude']; 32, block; 33, assignment; 34, assignment; 35, comparison_operator:include_subject_catchment == 'force'; 36, block; 37, elif_clause; 38, identifier:catchment; 39, identifier:catchments; 40, block; 41, call; 42, assignment; 43, assignment; 44, identifier:catchment; 45, identifier:catchments; 46, block; 47, identifier:catchments_limited; 48, string_content:auto; 49, identifier:include_subject_catchment; 50, list; 51, raise_statement; 52, identifier:query; 53, parenthesized_expression; 54, identifier:catchments; 55, call; 56, identifier:include_subject_catchment; 57, string; 58, if_statement; 59, comparison_operator:include_subject_catchment == 'auto'; 60, block; 61, expression_statement; 62, attribute; 63, argument_list; 64, identifier:amax_records_count; 65, integer:0; 66, identifier:catchments_limited; 67, list; 68, expression_statement; 69, expression_statement; 70, if_statement; 71, string; 72, string; 73, string; 74, call; 75, call; 76, attribute; 77, argument_list; 78, string_content:force; 79, comparison_operator:len(subject_catchment.amax_records) >= 10; 80, comment:# Never include short-record catchments; 81, block; 82, identifier:include_subject_catchment; 83, string; 84, if_statement; 85, assignment; 86, identifier:catchments; 87, identifier:sort; 88, keyword_argument; 89, call; 90, augmented_assignment; 91, comparison_operator:amax_records_count >= records_limit; 92, block; 93, string_content:auto; 94, string_content:force; 95, string_content:exclude; 96, identifier:ValueError; 97, argument_list; 98, attribute; 99, argument_list; 100, identifier:query; 101, identifier:all; 102, call; 103, integer:10; 104, expression_statement; 105, string_content:auto; 106, boolean_operator; 107, block; 108, attribute; 109, call; 110, identifier:key; 111, call; 112, attribute; 113, argument_list; 114, identifier:amax_records_count; 115, attribute; 116, identifier:amax_records_count; 117, identifier:records_limit; 118, break_statement; 119, binary_operator:"Parameter `include_subject_catchment={}` invalid.".format(include_subject_catchment) + "Must be one of `auto`, `force` or `exclude`."; 120, call; 121, identifier:having; 122, comparison_operator:func.count(AmaxRecord.catchment_id) >= 10; 123, identifier:len; 124, argument_list; 125, call; 126, boolean_operator; 127, line_continuation:\; 128, parenthesized_expression; 129, expression_statement; 130, identifier:catchment; 131, identifier:similarity_dist; 132, identifier:similarity_dist_function; 133, argument_list; 134, identifier:attrgetter; 135, argument_list; 136, identifier:catchments_limited; 137, identifier:append; 138, identifier:catchment; 139, identifier:catchment; 140, identifier:record_length; 141, call; 142, string:"Must be one of `auto`, `force` or `exclude`."; 143, attribute; 144, argument_list; 145, call; 146, integer:10; 147, attribute; 148, attribute; 149, argument_list; 150, comparison_operator:len(subject_catchment.amax_records) >= 10; 151, attribute; 152, boolean_operator; 153, call; 154, identifier:subject_catchment; 155, identifier:catchment; 156, string; 157, attribute; 158, argument_list; 159, call; 160, identifier:group_by; 161, identifier:Catchment; 162, attribute; 163, argument_list; 164, identifier:subject_catchment; 165, identifier:amax_records; 166, identifier:catchments; 167, identifier:append; 168, identifier:subject_catchment; 169, call; 170, integer:10; 171, identifier:subject_catchment; 172, identifier:is_suitable_for_pooling; 173, comparison_operator:subject_catchment.descriptors.urbext2000 < 0.03; 174, comparison_operator:subject_catchment.descriptors.urbext2000 is None; 175, attribute; 176, argument_list; 177, string_content:similarity_dist; 178, string:"Parameter `include_subject_catchment={}` invalid."; 179, identifier:format; 180, identifier:include_subject_catchment; 181, attribute; 182, argument_list; 183, identifier:func; 184, identifier:count; 185, attribute; 186, identifier:len; 187, argument_list; 188, attribute; 189, float:0.03; 190, attribute; 191, None; 192, identifier:catchments; 193, identifier:append; 194, identifier:subject_catchment; 195, call; 196, identifier:filter; 197, comparison_operator:Catchment.id != subject_catchment.id; 198, attribute; 199, call; 200, comparison_operator:AmaxRecord.flag == 0; 201, identifier:AmaxRecord; 202, identifier:catchment_id; 203, attribute; 204, attribute; 205, identifier:urbext2000; 206, attribute; 207, identifier:urbext2000; 208, attribute; 209, argument_list; 210, attribute; 211, attribute; 212, identifier:Catchment; 213, identifier:is_suitable_for_pooling; 214, identifier:or_; 215, argument_list; 216, attribute; 217, integer:0; 218, identifier:subject_catchment; 219, identifier:amax_records; 220, identifier:subject_catchment; 221, identifier:descriptors; 222, identifier:subject_catchment; 223, identifier:descriptors; 224, call; 225, identifier:join; 226, attribute; 227, identifier:Catchment; 228, identifier:id; 229, identifier:subject_catchment; 230, identifier:id; 231, comparison_operator:Descriptors.urbext2000 < 0.03; 232, comparison_operator:Descriptors.urbext2000 == None; 233, identifier:AmaxRecord; 234, identifier:flag; 235, attribute; 236, argument_list; 237, identifier:Catchment; 238, identifier:amax_records; 239, attribute; 240, float:0.03; 241, attribute; 242, None; 243, call; 244, identifier:join; 245, attribute; 246, identifier:Descriptors; 247, identifier:urbext2000; 248, identifier:Descriptors; 249, identifier:urbext2000; 250, attribute; 251, argument_list; 252, identifier:Catchment; 253, identifier:descriptors; 254, attribute; 255, identifier:query; 256, identifier:Catchment; 257, identifier:self; 258, identifier:db_session
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 4, 16; 4, 17; 4, 18; 4, 19; 4, 20; 4, 21; 4, 22; 4, 23; 4, 24; 4, 25; 8, 26; 8, 27; 9, 28; 9, 29; 10, 30; 11, 31; 11, 32; 12, 33; 14, 34; 16, 35; 16, 36; 16, 37; 18, 38; 18, 39; 18, 40; 20, 41; 22, 42; 23, 43; 24, 44; 24, 45; 24, 46; 25, 47; 29, 48; 31, 49; 31, 50; 32, 51; 33, 52; 33, 53; 34, 54; 34, 55; 35, 56; 35, 57; 36, 58; 37, 59; 37, 60; 40, 61; 41, 62; 41, 63; 42, 64; 42, 65; 43, 66; 43, 67; 46, 68; 46, 69; 46, 70; 50, 71; 50, 72; 50, 73; 51, 74; 53, 75; 55, 76; 55, 77; 57, 78; 58, 79; 58, 80; 58, 81; 59, 82; 59, 83; 60, 84; 61, 85; 62, 86; 62, 87; 63, 88; 68, 89; 69, 90; 70, 91; 70, 92; 71, 93; 72, 94; 73, 95; 74, 96; 74, 97; 75, 98; 75, 99; 76, 100; 76, 101; 79, 102; 79, 103; 81, 104; 83, 105; 84, 106; 84, 107; 85, 108; 85, 109; 88, 110; 88, 111; 89, 112; 89, 113; 90, 114; 90, 115; 91, 116; 91, 117; 92, 118; 97, 119; 98, 120; 98, 121; 99, 122; 102, 123; 102, 124; 104, 125; 106, 126; 106, 127; 106, 128; 107, 129; 108, 130; 108, 131; 109, 132; 109, 133; 111, 134; 111, 135; 112, 136; 112, 137; 113, 138; 115, 139; 115, 140; 119, 141; 119, 142; 120, 143; 120, 144; 122, 145; 122, 146; 124, 147; 125, 148; 125, 149; 126, 150; 126, 151; 128, 152; 129, 153; 133, 154; 133, 155; 135, 156; 141, 157; 141, 158; 143, 159; 143, 160; 144, 161; 145, 162; 145, 163; 147, 164; 147, 165; 148, 166; 148, 167; 149, 168; 150, 169; 150, 170; 151, 171; 151, 172; 152, 173; 152, 174; 153, 175; 153, 176; 156, 177; 157, 178; 157, 179; 158, 180; 159, 181; 159, 182; 162, 183; 162, 184; 163, 185; 169, 186; 169, 187; 173, 188; 173, 189; 174, 190; 174, 191; 175, 192; 175, 193; 176, 194; 181, 195; 181, 196; 182, 197; 182, 198; 182, 199; 182, 200; 185, 201; 185, 202; 187, 203; 188, 204; 188, 205; 190, 206; 190, 207; 195, 208; 195, 209; 197, 210; 197, 211; 198, 212; 198, 213; 199, 214; 199, 215; 200, 216; 200, 217; 203, 218; 203, 219; 204, 220; 204, 221; 206, 222; 206, 223; 208, 224; 208, 225; 209, 226; 210, 227; 210, 228; 211, 229; 211, 230; 215, 231; 215, 232; 216, 233; 216, 234; 224, 235; 224, 236; 226, 237; 226, 238; 231, 239; 231, 240; 232, 241; 232, 242; 235, 243; 235, 244; 236, 245; 239, 246; 239, 247; 241, 248; 241, 249; 243, 250; 243, 251; 245, 252; 245, 253; 250, 254; 250, 255; 251, 256; 254, 257; 254, 258
def most_similar_catchments(self, subject_catchment, similarity_dist_function, records_limit=500, include_subject_catchment='auto'): """ Return a list of catchments sorted by hydrological similarity defined by `similarity_distance_function` :param subject_catchment: subject catchment to find similar catchments for :type subject_catchment: :class:`floodestimation.entities.Catchment` :param similarity_dist_function: a method returning a similarity distance measure with 2 arguments, both :class:`floodestimation.entities.Catchment` objects :param include_subject_catchment: - `auto`: include subject catchment if suitable for pooling and if urbext < 0.03 - `force`: always include subject catchment having at least 10 years of data - `exclude`: do not include the subject catchment :type include_subject_catchment: str :return: list of catchments sorted by similarity :type: list of :class:`floodestimation.entities.Catchment` """ if include_subject_catchment not in ['auto', 'force', 'exclude']: raise ValueError("Parameter `include_subject_catchment={}` invalid.".format(include_subject_catchment) + "Must be one of `auto`, `force` or `exclude`.") query = (self.db_session.query(Catchment). join(Catchment.descriptors). join(Catchment.amax_records). filter(Catchment.id != subject_catchment.id, Catchment.is_suitable_for_pooling, or_(Descriptors.urbext2000 < 0.03, Descriptors.urbext2000 == None), AmaxRecord.flag == 0). group_by(Catchment). having(func.count(AmaxRecord.catchment_id) >= 10)) # At least 10 AMAX records catchments = query.all() # Add subject catchment if required (may not exist in database, so add after querying db if include_subject_catchment == 'force': if len(subject_catchment.amax_records) >= 10: # Never include short-record catchments catchments.append(subject_catchment) elif include_subject_catchment == 'auto': if len(subject_catchment.amax_records) >= 10 and subject_catchment.is_suitable_for_pooling and \ (subject_catchment.descriptors.urbext2000 < 0.03 or subject_catchment.descriptors.urbext2000 is None): catchments.append(subject_catchment) # Store the similarity distance as an additional attribute for each catchment for catchment in catchments: catchment.similarity_dist = similarity_dist_function(subject_catchment, catchment) # Then simply sort by this attribute catchments.sort(key=attrgetter('similarity_dist')) # Limit catchments until total amax_records counts is at least `records_limit`, default 500 amax_records_count = 0 catchments_limited = [] for catchment in catchments: catchments_limited.append(catchment) amax_records_count += catchment.record_length if amax_records_count >= records_limit: break return catchments_limited
0, module; 1, function_definition; 2, function_name:sort_and_index_star; 3, parameters; 4, block; 5, identifier:job; 6, identifier:star_bams; 7, identifier:univ_options; 8, identifier:star_options; 9, expression_statement; 10, expression_statement; 11, expression_statement; 12, expression_statement; 13, expression_statement; 14, expression_statement; 15, return_statement; 16, comment:""" A wrapper for sorting and indexing the genomic star bam generated by run_star. It is required since run_star returns a dict of 2 bams :param dict star_bams: The bams from run_star :param dict univ_options: Dict of universal options used by almost all tools :param dict star_options: Options specific to star :return: Dict containing input bam and the generated index (.bam.bai) output_files: |- 'rna_transcriptome.bam': fsID +- 'rna_genome': |- 'rna_sorted.bam': fsID +- 'rna_sorted.bam.bai': fsID +- 'rnaChimeric.out.junction': fsID :rtype: dict """; 17, assignment; 18, assignment; 19, assignment; 20, call; 21, call; 22, dictionary; 23, subscript; 24, subscript; 25, identifier:sort; 26, call; 27, identifier:index; 28, call; 29, attribute; 30, argument_list; 31, attribute; 32, argument_list; 33, pair; 34, pair; 35, pair; 36, subscript; 37, string; 38, identifier:star_options; 39, string; 40, attribute; 41, argument_list; 42, attribute; 43, argument_list; 44, identifier:job; 45, identifier:addChild; 46, identifier:sort; 47, identifier:sort; 48, identifier:addChild; 49, identifier:index; 50, string; 51, call; 52, string; 53, subscript; 54, string; 55, subscript; 56, identifier:star_options; 57, string; 58, string_content:n; 59, string_content:n; 60, identifier:job; 61, identifier:wrapJobFn; 62, identifier:sort_bamfile; 63, subscript; 64, string; 65, identifier:univ_options; 66, keyword_argument; 67, keyword_argument; 68, identifier:job; 69, identifier:wrapJobFn; 70, identifier:index_bamfile; 71, call; 72, string; 73, identifier:univ_options; 74, keyword_argument; 75, keyword_argument; 76, keyword_argument; 77, string_content:rna_genome; 78, attribute; 79, argument_list; 80, string_content:rna_transcriptome.bam; 81, identifier:star_bams; 82, string; 83, string_content:rnaChimeric.out.junction; 84, identifier:star_bams; 85, string; 86, string_content:samtools; 87, identifier:star_bams; 88, string; 89, string_content:rna; 90, identifier:samtools_options; 91, subscript; 92, identifier:disk; 93, call; 94, attribute; 95, argument_list; 96, string_content:rna; 97, identifier:samtools_options; 98, subscript; 99, identifier:sample_info; 100, string; 101, identifier:disk; 102, call; 103, identifier:index; 104, identifier:rv; 105, string_content:rnaAligned.toTranscriptome.out.bam; 106, string_content:rnaChimeric.out.junction; 107, string_content:rnaAligned.out.bam; 108, identifier:star_options; 109, string; 110, identifier:PromisedRequirement; 111, argument_list; 112, identifier:sort; 113, identifier:rv; 114, identifier:star_options; 115, string; 116, string_content:genome_sorted; 117, identifier:PromisedRequirement; 118, argument_list; 119, string_content:samtools; 120, identifier:sort_disk; 121, subscript; 122, string_content:samtools; 123, identifier:index_disk; 124, call; 125, identifier:star_bams; 126, string; 127, attribute; 128, argument_list; 129, string_content:rnaAligned.out.bam; 130, identifier:sort; 131, identifier:rv
0, 1; 1, 2; 1, 3; 1, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, 9; 4, 10; 4, 11; 4, 12; 4, 13; 4, 14; 4, 15; 9, 16; 10, 17; 11, 18; 12, 19; 13, 20; 14, 21; 15, 22; 17, 23; 17, 24; 18, 25; 18, 26; 19, 27; 19, 28; 20, 29; 20, 30; 21, 31; 21, 32; 22, 33; 22, 34; 22, 35; 23, 36; 23, 37; 24, 38; 24, 39; 26, 40; 26, 41; 28, 42; 28, 43; 29, 44; 29, 45; 30, 46; 31, 47; 31, 48; 32, 49; 33, 50; 33, 51; 34, 52; 34, 53; 35, 54; 35, 55; 36, 56; 36, 57; 37, 58; 39, 59; 40, 60; 40, 61; 41, 62; 41, 63; 41, 64; 41, 65; 41, 66; 41, 67; 42, 68; 42, 69; 43, 70; 43, 71; 43, 72; 43, 73; 43, 74; 43, 75; 43, 76; 50, 77; 51, 78; 51, 79; 52, 80; 53, 81; 53, 82; 54, 83; 55, 84; 55, 85; 57, 86; 63, 87; 63, 88; 64, 89; 66, 90; 66, 91; 67, 92; 67, 93; 71, 94; 71, 95; 72, 96; 74, 97; 74, 98; 75, 99; 75, 100; 76, 101; 76, 102; 78, 103; 78, 104; 82, 105; 85, 106; 88, 107; 91, 108; 91, 109; 93, 110; 93, 111; 94, 112; 94, 113; 98, 114; 98, 115; 100, 116; 102, 117; 102, 118; 109, 119; 111, 120; 111, 121; 115, 122; 118, 123; 118, 124; 121, 125; 121, 126; 124, 127; 124, 128; 126, 129; 127, 130; 127, 131
def sort_and_index_star(job, star_bams, univ_options, star_options): """ A wrapper for sorting and indexing the genomic star bam generated by run_star. It is required since run_star returns a dict of 2 bams :param dict star_bams: The bams from run_star :param dict univ_options: Dict of universal options used by almost all tools :param dict star_options: Options specific to star :return: Dict containing input bam and the generated index (.bam.bai) output_files: |- 'rna_transcriptome.bam': fsID +- 'rna_genome': |- 'rna_sorted.bam': fsID +- 'rna_sorted.bam.bai': fsID +- 'rnaChimeric.out.junction': fsID :rtype: dict """ star_options['samtools']['n'] = star_options['n'] sort = job.wrapJobFn(sort_bamfile, star_bams['rnaAligned.out.bam'], 'rna', univ_options, samtools_options=star_options['samtools'], disk=PromisedRequirement(sort_disk, star_bams['rnaAligned.out.bam'])) index = job.wrapJobFn(index_bamfile, sort.rv(), 'rna', univ_options, samtools_options=star_options['samtools'], sample_info='genome_sorted', disk=PromisedRequirement(index_disk, sort.rv())) job.addChild(sort) sort.addChild(index) return {'rna_genome': index.rv(), 'rna_transcriptome.bam': star_bams['rnaAligned.toTranscriptome.out.bam'], 'rnaChimeric.out.junction': star_bams['rnaChimeric.out.junction']}

No dataset card yet

Downloads last month
3