sequence
stringlengths
492
15.9k
code
stringlengths
75
8.58k
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:movefastq; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 13; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:logging; 10, identifier:info; 11, argument_list; 11, 12; 12, string:'Moving FASTQ files'; 13, for_statement; 13, 14; 13, 15; 13, 22; 14, identifier:sample; 15, attribute; 15, 16; 15, 21; 16, attribute; 16, 17; 16, 20; 17, attribute; 17, 18; 17, 19; 18, identifier:self; 19, identifier:metadata; 20, identifier:runmetadata; 21, identifier:samples; 22, block; 22, 23; 22, 39; 22, 168; 22, 334; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 26; 25, identifier:outputdir; 26, call; 26, 27; 26, 32; 27, attribute; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:os; 30, identifier:path; 31, identifier:join; 32, argument_list; 32, 33; 32, 36; 33, attribute; 33, 34; 33, 35; 34, identifier:self; 35, identifier:path; 36, attribute; 36, 37; 36, 38; 37, identifier:sample; 38, identifier:name; 39, expression_statement; 39, 40; 40, assignment; 40, 41; 40, 42; 41, identifier:fastqfiles; 42, conditional_expression:if; 42, 43; 42, 67; 42, 68; 42, 92; 42, 93; 43, call; 43, 44; 43, 45; 44, identifier:sorted; 45, argument_list; 45, 46; 46, call; 46, 47; 46, 48; 47, identifier:glob; 48, argument_list; 48, 49; 49, call; 49, 50; 49, 55; 50, attribute; 50, 51; 50, 54; 51, attribute; 51, 52; 51, 53; 52, identifier:os; 53, identifier:path; 54, identifier:join; 55, argument_list; 55, 56; 55, 59; 56, attribute; 56, 57; 56, 58; 57, identifier:self; 58, identifier:path; 59, call; 59, 60; 59, 63; 60, attribute; 60, 61; 60, 62; 61, string:'{}_*.fastq*'; 62, identifier:format; 63, argument_list; 63, 64; 64, attribute; 64, 65; 64, 66; 65, identifier:sample; 66, identifier:name; 67, line_continuation:\; 68, call; 68, 69; 68, 70; 69, identifier:sorted; 70, argument_list; 70, 71; 71, call; 71, 72; 71, 73; 72, identifier:glob; 73, argument_list; 73, 74; 74, call; 74, 75; 74, 80; 75, attribute; 75, 76; 75, 79; 76, attribute; 76, 77; 76, 78; 77, identifier:os; 78, identifier:path; 79, identifier:join; 80, argument_list; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:self; 83, identifier:path; 84, call; 84, 85; 84, 88; 85, attribute; 85, 86; 85, 87; 86, string:'{}_*.fastq*'; 87, identifier:format; 88, argument_list; 88, 89; 89, attribute; 89, 90; 89, 91; 90, identifier:sample; 91, identifier:name; 92, line_continuation:\; 93, conditional_expression:if; 93, 94; 93, 118; 93, 119; 93, 143; 93, 144; 94, call; 94, 95; 94, 96; 95, identifier:sorted; 96, argument_list; 96, 97; 97, call; 97, 98; 97, 99; 98, identifier:glob; 99, argument_list; 99, 100; 100, call; 100, 101; 100, 106; 101, attribute; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, identifier:os; 104, identifier:path; 105, identifier:join; 106, argument_list; 106, 107; 106, 110; 107, attribute; 107, 108; 107, 109; 108, identifier:self; 109, identifier:path; 110, call; 110, 111; 110, 114; 111, attribute; 111, 112; 111, 113; 112, string:'{}.fastq*'; 113, identifier:format; 114, argument_list; 114, 115; 115, attribute; 115, 116; 115, 117; 116, identifier:sample; 117, identifier:name; 118, line_continuation:\; 119, call; 119, 120; 119, 121; 120, identifier:sorted; 121, argument_list; 121, 122; 122, call; 122, 123; 122, 124; 123, identifier:glob; 124, argument_list; 124, 125; 125, call; 125, 126; 125, 131; 126, attribute; 126, 127; 126, 130; 127, attribute; 127, 128; 127, 129; 128, identifier:os; 129, identifier:path; 130, identifier:join; 131, argument_list; 131, 132; 131, 135; 132, attribute; 132, 133; 132, 134; 133, identifier:self; 134, identifier:path; 135, call; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, string:'{}.fastq*'; 138, identifier:format; 139, argument_list; 139, 140; 140, attribute; 140, 141; 140, 142; 141, identifier:sample; 142, identifier:name; 143, line_continuation:\; 144, call; 144, 145; 144, 146; 145, identifier:sorted; 146, argument_list; 146, 147; 147, call; 147, 148; 147, 149; 148, identifier:glob; 149, argument_list; 149, 150; 150, call; 150, 151; 150, 156; 151, attribute; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:os; 154, identifier:path; 155, identifier:join; 156, argument_list; 156, 157; 156, 160; 157, attribute; 157, 158; 157, 159; 158, identifier:self; 159, identifier:path; 160, call; 160, 161; 160, 164; 161, attribute; 161, 162; 161, 163; 162, string:'{}*.fastq*'; 163, identifier:format; 164, argument_list; 164, 165; 165, attribute; 165, 166; 165, 167; 166, identifier:sample; 167, identifier:name; 168, if_statement; 168, 169; 168, 170; 168, 279; 169, identifier:fastqfiles; 170, block; 170, 171; 170, 176; 170, 230; 171, expression_statement; 171, 172; 172, call; 172, 173; 172, 174; 173, identifier:make_path; 174, argument_list; 174, 175; 175, identifier:outputdir; 176, try_statement; 176, 177; 176, 226; 177, block; 177, 178; 178, expression_statement; 178, 179; 179, call; 179, 180; 179, 181; 180, identifier:list; 181, argument_list; 181, 182; 182, call; 182, 183; 182, 184; 183, identifier:map; 184, argument_list; 184, 185; 184, 225; 185, lambda; 185, 186; 185, 188; 186, lambda_parameters; 186, 187; 187, identifier:x; 188, call; 188, 189; 188, 192; 189, attribute; 189, 190; 189, 191; 190, identifier:os; 191, identifier:symlink; 192, argument_list; 192, 193; 192, 209; 193, call; 193, 194; 193, 199; 194, attribute; 194, 195; 194, 198; 195, attribute; 195, 196; 195, 197; 196, identifier:os; 197, identifier:path; 198, identifier:join; 199, argument_list; 199, 200; 199, 201; 200, string:'..'; 201, call; 201, 202; 201, 207; 202, attribute; 202, 203; 202, 206; 203, attribute; 203, 204; 203, 205; 204, identifier:os; 205, identifier:path; 206, identifier:basename; 207, argument_list; 207, 208; 208, identifier:x; 209, call; 209, 210; 209, 215; 210, attribute; 210, 211; 210, 214; 211, attribute; 211, 212; 211, 213; 212, identifier:os; 213, identifier:path; 214, identifier:join; 215, argument_list; 215, 216; 215, 217; 216, identifier:outputdir; 217, call; 217, 218; 217, 223; 218, attribute; 218, 219; 218, 222; 219, attribute; 219, 220; 219, 221; 220, identifier:os; 221, identifier:path; 222, identifier:basename; 223, argument_list; 223, 224; 224, identifier:x; 225, identifier:fastqfiles; 226, except_clause; 226, 227; 226, 228; 227, identifier:OSError; 228, block; 228, 229; 229, pass_statement; 230, expression_statement; 230, 231; 231, assignment; 231, 232; 231, 233; 232, identifier:fastqfiles; 233, list_comprehension; 233, 234; 233, 235; 233, 259; 234, identifier:fastq; 235, for_in_clause; 235, 236; 235, 237; 236, identifier:fastq; 237, call; 237, 238; 237, 239; 238, identifier:sorted; 239, argument_list; 239, 240; 240, call; 240, 241; 240, 242; 241, identifier:glob; 242, argument_list; 242, 243; 243, call; 243, 244; 243, 249; 244, attribute; 244, 245; 244, 248; 245, attribute; 245, 246; 245, 247; 246, identifier:os; 247, identifier:path; 248, identifier:join; 249, argument_list; 249, 250; 249, 251; 250, identifier:outputdir; 251, call; 251, 252; 251, 255; 252, attribute; 252, 253; 252, 254; 253, string:'{}*.fastq*'; 254, identifier:format; 255, argument_list; 255, 256; 256, attribute; 256, 257; 256, 258; 257, identifier:sample; 258, identifier:name; 259, if_clause; 259, 260; 260, boolean_operator:and; 260, 261; 260, 276; 261, boolean_operator:and; 261, 262; 261, 273; 262, boolean_operator:and; 262, 263; 262, 270; 263, boolean_operator:and; 263, 264; 263, 267; 264, comparison_operator:not; 264, 265; 264, 266; 265, string:'trimmed'; 266, identifier:fastq; 267, comparison_operator:not; 267, 268; 267, 269; 268, string:'normalised'; 269, identifier:fastq; 270, comparison_operator:not; 270, 271; 270, 272; 271, string:'corrected'; 272, identifier:fastq; 273, comparison_operator:not; 273, 274; 273, 275; 274, string:'paired'; 275, identifier:fastq; 276, comparison_operator:not; 276, 277; 276, 278; 277, string:'unpaired'; 278, identifier:fastq; 279, else_clause; 279, 280; 280, block; 280, 281; 281, if_statement; 281, 282; 281, 283; 282, identifier:outputdir; 283, block; 283, 284; 284, expression_statement; 284, 285; 285, assignment; 285, 286; 285, 287; 286, identifier:fastqfiles; 287, list_comprehension; 287, 288; 287, 289; 287, 314; 288, identifier:fastq; 289, for_in_clause; 289, 290; 289, 291; 290, identifier:fastq; 291, call; 291, 292; 291, 293; 292, identifier:sorted; 293, argument_list; 293, 294; 294, call; 294, 295; 294, 296; 295, identifier:glob; 296, argument_list; 296, 297; 297, call; 297, 298; 297, 303; 298, attribute; 298, 299; 298, 302; 299, attribute; 299, 300; 299, 301; 300, identifier:os; 301, identifier:path; 302, identifier:join; 303, argument_list; 303, 304; 303, 305; 304, identifier:outputdir; 305, call; 305, 306; 305, 309; 306, attribute; 306, 307; 306, 308; 307, string:'{}*.fastq*'; 308, identifier:format; 309, argument_list; 309, 310; 309, 311; 310, identifier:outputdir; 311, attribute; 311, 312; 311, 313; 312, identifier:sample; 313, identifier:name; 314, if_clause; 314, 315; 315, boolean_operator:and; 315, 316; 315, 331; 316, boolean_operator:and; 316, 317; 316, 328; 317, boolean_operator:and; 317, 318; 317, 325; 318, boolean_operator:and; 318, 319; 318, 322; 319, comparison_operator:not; 319, 320; 319, 321; 320, string:'trimmed'; 321, identifier:fastq; 322, comparison_operator:not; 322, 323; 322, 324; 323, string:'normalised'; 324, identifier:fastq; 325, comparison_operator:not; 325, 326; 325, 327; 326, string:'corrected'; 327, identifier:fastq; 328, comparison_operator:not; 328, 329; 328, 330; 329, string:'paired'; 330, identifier:fastq; 331, comparison_operator:not; 331, 332; 331, 333; 332, string:'unpaired'; 333, identifier:fastq; 334, expression_statement; 334, 335; 335, assignment; 335, 336; 335, 341; 336, attribute; 336, 337; 336, 340; 337, attribute; 337, 338; 337, 339; 338, identifier:sample; 339, identifier:general; 340, identifier:fastqfiles; 341, identifier:fastqfiles
def movefastq(self): logging.info('Moving FASTQ files') for sample in self.metadata.runmetadata.samples: outputdir = os.path.join(self.path, sample.name) fastqfiles = sorted(glob(os.path.join(self.path, '{}_*.fastq*'.format(sample.name)))) \ if sorted(glob(os.path.join(self.path, '{}_*.fastq*'.format(sample.name)))) \ else sorted(glob(os.path.join(self.path, '{}.fastq*'.format(sample.name)))) \ if sorted(glob(os.path.join(self.path, '{}.fastq*'.format(sample.name)))) \ else sorted(glob(os.path.join(self.path, '{}*.fastq*'.format(sample.name)))) if fastqfiles: make_path(outputdir) try: list(map(lambda x: os.symlink(os.path.join('..', os.path.basename(x)), os.path.join(outputdir, os.path.basename(x))), fastqfiles)) except OSError: pass fastqfiles = [fastq for fastq in sorted(glob(os.path.join(outputdir, '{}*.fastq*'.format(sample.name)))) if 'trimmed' not in fastq and 'normalised' not in fastq and 'corrected' not in fastq and 'paired' not in fastq and 'unpaired' not in fastq] else: if outputdir: fastqfiles = [fastq for fastq in sorted(glob(os.path.join( outputdir, '{}*.fastq*'.format(outputdir, sample.name)))) if 'trimmed' not in fastq and 'normalised' not in fastq and 'corrected' not in fastq and 'paired' not in fastq and 'unpaired' not in fastq] sample.general.fastqfiles = fastqfiles
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 1, 11; 2, function_name:add_raw_entity; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:entity; 7, type; 7, 8; 8, identifier:dict; 9, type; 9, 10; 10, identifier:dict; 11, block; 11, 12; 11, 21; 11, 35; 11, 43; 11, 51; 11, 107; 11, 119; 11, 139; 11, 156; 11, 173; 11, 190; 11, 198; 11, 209; 11, 227; 11, 249; 11, 260; 11, 266; 11, 284; 11, 345; 11, 356; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 14, identifier:needed_in_entity; 15, call; 15, 16; 15, 17; 16, identifier:set; 17, argument_list; 17, 18; 18, list:[ 'label', 'type', ]; 18, 19; 18, 20; 19, string:'label'; 20, string:'type'; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 24; 23, identifier:options_in_entity; 24, call; 24, 25; 24, 26; 25, identifier:set; 26, argument_list; 26, 27; 27, list:[ 'label', 'type', 'definition', 'comment', 'superclass', 'synonyms', 'existing_ids' ]; 27, 28; 27, 29; 27, 30; 27, 31; 27, 32; 27, 33; 27, 34; 28, string:'label'; 29, string:'type'; 30, string:'definition'; 31, string:'comment'; 32, string:'superclass'; 33, string:'synonyms'; 34, string:'existing_ids'; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 38; 37, identifier:prime_entity_url; 38, binary_operator:+; 38, 39; 38, 42; 39, attribute; 39, 40; 39, 41; 40, identifier:self; 41, identifier:base_url; 42, string:'ilx/add'; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 46; 45, identifier:add_entity_url; 46, binary_operator:+; 46, 47; 46, 50; 47, attribute; 47, 48; 47, 49; 48, identifier:self; 49, identifier:base_url; 50, string:'term/add'; 51, if_statement; 51, 52; 51, 61; 51, 79; 52, comparison_operator:!=; 52, 53; 52, 60; 53, parenthesized_expression; 53, 54; 54, binary_operator:&; 54, 55; 54, 59; 55, call; 55, 56; 55, 57; 56, identifier:set; 57, argument_list; 57, 58; 58, identifier:entity; 59, identifier:needed_in_entity; 60, identifier:needed_in_entity; 61, block; 61, 62; 62, raise_statement; 62, 63; 63, call; 63, 64; 63, 67; 64, attribute; 64, 65; 64, 66; 65, identifier:self; 66, identifier:MissingKeyError; 67, argument_list; 67, 68; 68, binary_operator:+; 68, 69; 68, 70; 69, string:'You need key(s): '; 70, call; 70, 71; 70, 72; 71, identifier:str; 72, argument_list; 72, 73; 73, binary_operator:-; 73, 74; 73, 75; 74, identifier:needed_in_entity; 75, call; 75, 76; 75, 77; 76, identifier:set; 77, argument_list; 77, 78; 78, identifier:entity; 79, elif_clause; 79, 80; 79, 89; 80, comparison_operator:!=; 80, 81; 80, 88; 81, parenthesized_expression; 81, 82; 82, binary_operator:|; 82, 83; 82, 87; 83, call; 83, 84; 83, 85; 84, identifier:set; 85, argument_list; 85, 86; 86, identifier:entity; 87, identifier:options_in_entity; 88, identifier:options_in_entity; 89, block; 89, 90; 90, raise_statement; 90, 91; 91, call; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:self; 94, identifier:IncorrectKeyError; 95, argument_list; 95, 96; 96, binary_operator:+; 96, 97; 96, 98; 97, string:'Unexpected key(s): '; 98, call; 98, 99; 98, 100; 99, identifier:str; 100, argument_list; 100, 101; 101, binary_operator:-; 101, 102; 101, 106; 102, call; 102, 103; 102, 104; 103, identifier:set; 104, argument_list; 104, 105; 105, identifier:entity; 106, identifier:options_in_entity; 107, expression_statement; 107, 108; 108, assignment; 108, 109; 108, 112; 109, subscript; 109, 110; 109, 111; 110, identifier:entity; 111, string:'type'; 112, call; 112, 113; 112, 118; 113, attribute; 113, 114; 113, 117; 114, subscript; 114, 115; 114, 116; 115, identifier:entity; 116, string:'type'; 117, identifier:lower; 118, argument_list; 119, if_statement; 119, 120; 119, 131; 120, comparison_operator:not; 120, 121; 120, 124; 121, subscript; 121, 122; 121, 123; 122, identifier:entity; 123, string:'type'; 124, list:['term', 'relationship', 'annotation', 'cde', 'fde', 'pde']; 124, 125; 124, 126; 124, 127; 124, 128; 124, 129; 124, 130; 125, string:'term'; 126, string:'relationship'; 127, string:'annotation'; 128, string:'cde'; 129, string:'fde'; 130, string:'pde'; 131, block; 131, 132; 132, raise_statement; 132, 133; 133, call; 133, 134; 133, 135; 134, identifier:TypeError; 135, argument_list; 135, 136; 136, binary_operator:+; 136, 137; 136, 138; 137, string:'Entity should be one of the following: '; 138, string:'term, relationship, annotation, cde, fde, pde'; 139, if_statement; 139, 140; 139, 146; 140, call; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, identifier:entity; 143, identifier:get; 144, argument_list; 144, 145; 145, string:'superclass'; 146, block; 146, 147; 147, expression_statement; 147, 148; 148, assignment; 148, 149; 148, 150; 149, identifier:entity; 150, call; 150, 151; 150, 154; 151, attribute; 151, 152; 151, 153; 152, identifier:self; 153, identifier:process_superclass; 154, argument_list; 154, 155; 155, identifier:entity; 156, if_statement; 156, 157; 156, 163; 157, call; 157, 158; 157, 161; 158, attribute; 158, 159; 158, 160; 159, identifier:entity; 160, identifier:get; 161, argument_list; 161, 162; 162, string:'synonyms'; 163, block; 163, 164; 164, expression_statement; 164, 165; 165, assignment; 165, 166; 165, 167; 166, identifier:entity; 167, call; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, identifier:self; 170, identifier:process_synonyms; 171, argument_list; 171, 172; 172, identifier:entity; 173, if_statement; 173, 174; 173, 180; 174, call; 174, 175; 174, 178; 175, attribute; 175, 176; 175, 177; 176, identifier:entity; 177, identifier:get; 178, argument_list; 178, 179; 179, string:'existing_ids'; 180, block; 180, 181; 181, expression_statement; 181, 182; 182, assignment; 182, 183; 182, 184; 183, identifier:entity; 184, call; 184, 185; 184, 188; 185, attribute; 185, 186; 185, 187; 186, identifier:self; 187, identifier:process_existing_ids; 188, argument_list; 188, 189; 189, identifier:entity; 190, expression_statement; 190, 191; 191, assignment; 191, 192; 191, 195; 192, subscript; 192, 193; 192, 194; 193, identifier:entity; 194, string:'uid'; 195, attribute; 195, 196; 195, 197; 196, identifier:self; 197, identifier:user_id; 198, expression_statement; 198, 199; 199, assignment; 199, 200; 199, 203; 200, subscript; 200, 201; 200, 202; 201, identifier:entity; 202, string:'term'; 203, call; 203, 204; 203, 207; 204, attribute; 204, 205; 204, 206; 205, identifier:entity; 206, identifier:pop; 207, argument_list; 207, 208; 208, string:'label'; 209, expression_statement; 209, 210; 210, assignment; 210, 211; 210, 212; 211, identifier:ilx_data; 212, call; 212, 213; 212, 216; 213, attribute; 213, 214; 213, 215; 214, identifier:self; 215, identifier:post; 216, argument_list; 216, 217; 216, 220; 217, keyword_argument; 217, 218; 217, 219; 218, identifier:url; 219, identifier:prime_entity_url; 220, keyword_argument; 220, 221; 220, 222; 221, identifier:data; 222, call; 222, 223; 222, 226; 223, attribute; 223, 224; 223, 225; 224, identifier:entity; 225, identifier:copy; 226, argument_list; 227, if_statement; 227, 228; 227, 234; 227, 241; 228, call; 228, 229; 228, 232; 229, attribute; 229, 230; 229, 231; 230, identifier:ilx_data; 231, identifier:get; 232, argument_list; 232, 233; 233, string:'ilx'; 234, block; 234, 235; 235, expression_statement; 235, 236; 236, assignment; 236, 237; 236, 238; 237, identifier:ilx_id; 238, subscript; 238, 239; 238, 240; 239, identifier:ilx_data; 240, string:'ilx'; 241, else_clause; 241, 242; 242, block; 242, 243; 243, expression_statement; 243, 244; 244, assignment; 244, 245; 244, 246; 245, identifier:ilx_id; 246, subscript; 246, 247; 246, 248; 247, identifier:ilx_data; 248, string:'fragment'; 249, expression_statement; 249, 250; 250, assignment; 250, 251; 250, 254; 251, subscript; 251, 252; 251, 253; 252, identifier:entity; 253, string:'label'; 254, call; 254, 255; 254, 258; 255, attribute; 255, 256; 255, 257; 256, identifier:entity; 257, identifier:pop; 258, argument_list; 258, 259; 259, string:'term'; 260, expression_statement; 260, 261; 261, assignment; 261, 262; 261, 265; 262, subscript; 262, 263; 262, 264; 263, identifier:entity; 264, string:'ilx'; 265, identifier:ilx_id; 266, expression_statement; 266, 267; 267, assignment; 267, 268; 267, 269; 268, identifier:output; 269, call; 269, 270; 269, 273; 270, attribute; 270, 271; 270, 272; 271, identifier:self; 272, identifier:post; 273, argument_list; 273, 274; 273, 277; 274, keyword_argument; 274, 275; 274, 276; 275, identifier:url; 276, identifier:add_entity_url; 277, keyword_argument; 277, 278; 277, 279; 278, identifier:data; 279, call; 279, 280; 279, 283; 280, attribute; 280, 281; 280, 282; 281, identifier:entity; 282, identifier:copy; 283, argument_list; 284, if_statement; 284, 285; 284, 291; 285, call; 285, 286; 285, 289; 286, attribute; 286, 287; 286, 288; 287, identifier:output; 288, identifier:get; 289, argument_list; 289, 290; 290, string:'errormsg'; 291, block; 291, 292; 291, 338; 292, if_statement; 292, 293; 292, 302; 293, comparison_operator:in; 293, 294; 293, 295; 294, string:'already exists'; 295, call; 295, 296; 295, 301; 296, attribute; 296, 297; 296, 300; 297, subscript; 297, 298; 297, 299; 298, identifier:output; 299, string:'errormsg'; 300, identifier:lower; 301, argument_list; 302, block; 302, 303; 302, 314; 302, 331; 303, expression_statement; 303, 304; 304, assignment; 304, 305; 304, 306; 305, identifier:prexisting_data; 306, call; 306, 307; 306, 310; 307, attribute; 307, 308; 307, 309; 308, identifier:self; 309, identifier:check_scicrunch_for_label; 310, argument_list; 310, 311; 311, subscript; 311, 312; 311, 313; 312, identifier:entity; 313, string:'label'; 314, if_statement; 314, 315; 314, 316; 315, identifier:prexisting_data; 316, block; 316, 317; 316, 329; 317, expression_statement; 317, 318; 318, call; 318, 319; 318, 320; 319, identifier:print; 320, argument_list; 320, 321; 320, 322; 320, 325; 320, 326; 321, string:'You already added entity'; 322, subscript; 322, 323; 322, 324; 323, identifier:entity; 324, string:'label'; 325, string:'with ILX ID:'; 326, subscript; 326, 327; 326, 328; 327, identifier:prexisting_data; 328, string:'ilx'; 329, return_statement; 329, 330; 330, identifier:prexisting_data; 331, expression_statement; 331, 332; 332, call; 332, 333; 332, 336; 333, attribute; 333, 334; 333, 335; 334, identifier:self; 335, identifier:Error; 336, argument_list; 336, 337; 337, identifier:output; 338, expression_statement; 338, 339; 339, call; 339, 340; 339, 343; 340, attribute; 340, 341; 340, 342; 341, identifier:self; 342, identifier:Error; 343, argument_list; 343, 344; 344, identifier:output; 345, expression_statement; 345, 346; 346, assignment; 346, 347; 346, 348; 347, identifier:output; 348, call; 348, 349; 348, 352; 349, attribute; 349, 350; 349, 351; 350, identifier:self; 351, identifier:get_entity; 352, argument_list; 352, 353; 353, subscript; 353, 354; 353, 355; 354, identifier:output; 355, string:'ilx'; 356, return_statement; 356, 357; 357, identifier:output
def add_raw_entity(self, entity: dict) -> dict: needed_in_entity = set([ 'label', 'type', ]) options_in_entity = set([ 'label', 'type', 'definition', 'comment', 'superclass', 'synonyms', 'existing_ids' ]) prime_entity_url = self.base_url + 'ilx/add' add_entity_url = self.base_url + 'term/add' if (set(entity) & needed_in_entity) != needed_in_entity: raise self.MissingKeyError( 'You need key(s): '+ str(needed_in_entity - set(entity))) elif (set(entity) | options_in_entity) != options_in_entity: raise self.IncorrectKeyError( 'Unexpected key(s): ' + str(set(entity) - options_in_entity)) entity['type'] = entity['type'].lower() if entity['type'] not in ['term', 'relationship', 'annotation', 'cde', 'fde', 'pde']: raise TypeError( 'Entity should be one of the following: ' + 'term, relationship, annotation, cde, fde, pde') if entity.get('superclass'): entity = self.process_superclass(entity) if entity.get('synonyms'): entity = self.process_synonyms(entity) if entity.get('existing_ids'): entity = self.process_existing_ids(entity) entity['uid'] = self.user_id entity['term'] = entity.pop('label') ilx_data = self.post( url = prime_entity_url, data = entity.copy(), ) if ilx_data.get('ilx'): ilx_id = ilx_data['ilx'] else: ilx_id = ilx_data['fragment'] entity['label'] = entity.pop('term') entity['ilx'] = ilx_id output = self.post( url = add_entity_url, data = entity.copy(), ) if output.get('errormsg'): if 'already exists' in output['errormsg'].lower(): prexisting_data = self.check_scicrunch_for_label(entity['label']) if prexisting_data: print( 'You already added entity', entity['label'], 'with ILX ID:', prexisting_data['ilx']) return prexisting_data self.Error(output) self.Error(output) output = self.get_entity(output['ilx']) return output
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 1, 19; 2, function_name:delete_annotation; 3, parameters; 3, 4; 3, 5; 3, 9; 3, 13; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:term_ilx_id; 7, type; 7, 8; 8, identifier:str; 9, typed_parameter; 9, 10; 9, 11; 10, identifier:annotation_type_ilx_id; 11, type; 11, 12; 12, identifier:str; 13, typed_parameter; 13, 14; 13, 15; 14, identifier:annotation_value; 15, type; 15, 16; 16, identifier:str; 17, type; 17, 18; 18, identifier:dict; 19, block; 19, 20; 19, 29; 19, 44; 19, 53; 19, 68; 19, 79; 19, 83; 19, 137; 19, 148; 19, 163; 19, 182; 19, 196; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:term_data; 23, call; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:self; 26, identifier:get_entity; 27, argument_list; 27, 28; 28, identifier:term_ilx_id; 29, if_statement; 29, 30; 29, 34; 30, not_operator; 30, 31; 31, subscript; 31, 32; 31, 33; 32, identifier:term_data; 33, string:'id'; 34, block; 34, 35; 35, expression_statement; 35, 36; 36, call; 36, 37; 36, 38; 37, identifier:exit; 38, argument_list; 38, 39; 39, binary_operator:+; 39, 40; 39, 43; 40, binary_operator:+; 40, 41; 40, 42; 41, string:'term_ilx_id: '; 42, identifier:term_ilx_id; 43, string:' does not exist'; 44, expression_statement; 44, 45; 45, assignment; 45, 46; 45, 47; 46, identifier:anno_data; 47, call; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, identifier:self; 50, identifier:get_entity; 51, argument_list; 51, 52; 52, identifier:annotation_type_ilx_id; 53, if_statement; 53, 54; 53, 58; 54, not_operator; 54, 55; 55, subscript; 55, 56; 55, 57; 56, identifier:anno_data; 57, string:'id'; 58, block; 58, 59; 59, expression_statement; 59, 60; 60, call; 60, 61; 60, 62; 61, identifier:exit; 62, argument_list; 62, 63; 63, binary_operator:+; 63, 64; 63, 67; 64, binary_operator:+; 64, 65; 64, 66; 65, string:'annotation_type_ilx_id: '; 66, identifier:annotation_type_ilx_id; 67, string:' does not exist'; 68, expression_statement; 68, 69; 69, assignment; 69, 70; 69, 71; 70, identifier:entity_annotations; 71, call; 71, 72; 71, 75; 72, attribute; 72, 73; 72, 74; 73, identifier:self; 74, identifier:get_annotation_via_tid; 75, argument_list; 75, 76; 76, subscript; 76, 77; 76, 78; 77, identifier:term_data; 78, string:'id'; 79, expression_statement; 79, 80; 80, assignment; 80, 81; 80, 82; 81, identifier:annotation_id; 82, string:''; 83, for_statement; 83, 84; 83, 85; 83, 86; 84, identifier:annotation; 85, identifier:entity_annotations; 86, block; 86, 87; 87, if_statement; 87, 88; 87, 101; 88, comparison_operator:==; 88, 89; 88, 95; 89, call; 89, 90; 89, 91; 90, identifier:str; 91, argument_list; 91, 92; 92, subscript; 92, 93; 92, 94; 93, identifier:annotation; 94, string:'tid'; 95, call; 95, 96; 95, 97; 96, identifier:str; 97, argument_list; 97, 98; 98, subscript; 98, 99; 98, 100; 99, identifier:term_data; 100, string:'id'; 101, block; 101, 102; 102, if_statement; 102, 103; 102, 116; 103, comparison_operator:==; 103, 104; 103, 110; 104, call; 104, 105; 104, 106; 105, identifier:str; 106, argument_list; 106, 107; 107, subscript; 107, 108; 107, 109; 108, identifier:annotation; 109, string:'annotation_tid'; 110, call; 110, 111; 110, 112; 111, identifier:str; 112, argument_list; 112, 113; 113, subscript; 113, 114; 113, 115; 114, identifier:anno_data; 115, string:'id'; 116, block; 116, 117; 117, if_statement; 117, 118; 117, 129; 118, comparison_operator:==; 118, 119; 118, 125; 119, call; 119, 120; 119, 121; 120, identifier:str; 121, argument_list; 121, 122; 122, subscript; 122, 123; 122, 124; 123, identifier:annotation; 124, string:'value'; 125, call; 125, 126; 125, 127; 126, identifier:str; 127, argument_list; 127, 128; 128, identifier:annotation_value; 129, block; 129, 130; 129, 136; 130, expression_statement; 130, 131; 131, assignment; 131, 132; 131, 133; 132, identifier:annotation_id; 133, subscript; 133, 134; 133, 135; 134, identifier:annotation; 135, string:'id'; 136, break_statement; 137, if_statement; 137, 138; 137, 140; 138, not_operator; 138, 139; 139, identifier:annotation_id; 140, block; 140, 141; 140, 146; 141, expression_statement; 141, 142; 142, call; 142, 143; 142, 144; 143, identifier:print; 144, argument_list; 144, 145; 145, string:'''WARNING: Annotation you wanted to delete does not exist '''; 146, return_statement; 146, 147; 147, None; 148, expression_statement; 148, 149; 149, assignment; 149, 150; 149, 151; 150, identifier:url; 151, binary_operator:+; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:self; 154, identifier:base_url; 155, call; 155, 156; 155, 159; 156, attribute; 156, 157; 156, 158; 157, string:'term/edit-annotation/{annotation_id}'; 158, identifier:format; 159, argument_list; 159, 160; 160, keyword_argument; 160, 161; 160, 162; 161, identifier:annotation_id; 162, identifier:annotation_id; 163, expression_statement; 163, 164; 164, assignment; 164, 165; 164, 166; 165, identifier:data; 166, dictionary; 166, 167; 166, 170; 166, 173; 166, 176; 166, 179; 167, pair; 167, 168; 167, 169; 168, string:'tid'; 169, string:' '; 170, pair; 170, 171; 170, 172; 171, string:'annotation_tid'; 172, string:' '; 173, pair; 173, 174; 173, 175; 174, string:'value'; 175, string:' '; 176, pair; 176, 177; 176, 178; 177, string:'term_version'; 178, string:' '; 179, pair; 179, 180; 179, 181; 180, string:'annotation_term_version'; 181, string:' '; 182, expression_statement; 182, 183; 183, assignment; 183, 184; 183, 185; 184, identifier:output; 185, call; 185, 186; 185, 189; 186, attribute; 186, 187; 186, 188; 187, identifier:self; 188, identifier:post; 189, argument_list; 189, 190; 189, 193; 190, keyword_argument; 190, 191; 190, 192; 191, identifier:url; 192, identifier:url; 193, keyword_argument; 193, 194; 193, 195; 194, identifier:data; 195, identifier:data; 196, return_statement; 196, 197; 197, identifier:output
def delete_annotation( self, term_ilx_id: str, annotation_type_ilx_id: str, annotation_value: str) -> dict: term_data = self.get_entity(term_ilx_id) if not term_data['id']: exit( 'term_ilx_id: ' + term_ilx_id + ' does not exist' ) anno_data = self.get_entity(annotation_type_ilx_id) if not anno_data['id']: exit( 'annotation_type_ilx_id: ' + annotation_type_ilx_id + ' does not exist' ) entity_annotations = self.get_annotation_via_tid(term_data['id']) annotation_id = '' for annotation in entity_annotations: if str(annotation['tid']) == str(term_data['id']): if str(annotation['annotation_tid']) == str(anno_data['id']): if str(annotation['value']) == str(annotation_value): annotation_id = annotation['id'] break if not annotation_id: print('''WARNING: Annotation you wanted to delete does not exist ''') return None url = self.base_url + 'term/edit-annotation/{annotation_id}'.format( annotation_id = annotation_id ) data = { 'tid': ' ', 'annotation_tid': ' ', 'value': ' ', 'term_version': ' ', 'annotation_term_version': ' ', } output = self.post( url = url, data = data, ) return output
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:configfilepopulator; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 18; 5, 30; 5, 88; 5, 124; 5, 140; 5, 148; 5, 320; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:forwardlength; 11, attribute; 11, 12; 11, 17; 12, attribute; 12, 13; 12, 16; 13, attribute; 13, 14; 13, 15; 14, identifier:self; 15, identifier:metadata; 16, identifier:header; 17, identifier:forwardlength; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:self; 22, identifier:reverselength; 23, attribute; 23, 24; 23, 29; 24, attribute; 24, 25; 24, 28; 25, attribute; 25, 26; 25, 27; 26, identifier:self; 27, identifier:metadata; 28, identifier:header; 29, identifier:reverselength; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 33; 32, identifier:cycles; 33, list:[[1, self.forwardlength, self.runid], [self.forwardlength + 1, self.forwardlength + 8, self.runid], [self.forwardlength + 9, self.forwardlength + 16, self.runid], [self.forwardlength + 17, self.forwardlength + 16 + self.reverselength, self.runid]]; 33, 34; 33, 42; 33, 56; 33, 70; 34, list:[1, self.forwardlength, self.runid]; 34, 35; 34, 36; 34, 39; 35, integer:1; 36, attribute; 36, 37; 36, 38; 37, identifier:self; 38, identifier:forwardlength; 39, attribute; 39, 40; 39, 41; 40, identifier:self; 41, identifier:runid; 42, list:[self.forwardlength + 1, self.forwardlength + 8, self.runid]; 42, 43; 42, 48; 42, 53; 43, binary_operator:+; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:self; 46, identifier:forwardlength; 47, integer:1; 48, binary_operator:+; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, identifier:self; 51, identifier:forwardlength; 52, integer:8; 53, attribute; 53, 54; 53, 55; 54, identifier:self; 55, identifier:runid; 56, list:[self.forwardlength + 9, self.forwardlength + 16, self.runid]; 56, 57; 56, 62; 56, 67; 57, binary_operator:+; 57, 58; 57, 61; 58, attribute; 58, 59; 58, 60; 59, identifier:self; 60, identifier:forwardlength; 61, integer:9; 62, binary_operator:+; 62, 63; 62, 66; 63, attribute; 63, 64; 63, 65; 64, identifier:self; 65, identifier:forwardlength; 66, integer:16; 67, attribute; 67, 68; 67, 69; 68, identifier:self; 69, identifier:runid; 70, list:[self.forwardlength + 17, self.forwardlength + 16 + self.reverselength, self.runid]; 70, 71; 70, 76; 70, 85; 71, binary_operator:+; 71, 72; 71, 75; 72, attribute; 72, 73; 72, 74; 73, identifier:self; 74, identifier:forwardlength; 75, integer:17; 76, binary_operator:+; 76, 77; 76, 82; 77, binary_operator:+; 77, 78; 77, 81; 78, attribute; 78, 79; 78, 80; 79, identifier:self; 80, identifier:forwardlength; 81, integer:16; 82, attribute; 82, 83; 82, 84; 83, identifier:self; 84, identifier:reverselength; 85, attribute; 85, 86; 85, 87; 86, identifier:self; 87, identifier:runid; 88, expression_statement; 88, 89; 89, assignment; 89, 90; 89, 91; 90, identifier:parameters; 91, dictionary; 91, 92; 91, 97; 91, 110; 91, 117; 92, pair; 92, 93; 92, 94; 93, string:'RunFolder'; 94, attribute; 94, 95; 94, 96; 95, identifier:self; 96, identifier:runid; 97, pair; 97, 98; 97, 99; 98, string:'RunFolderDate'; 99, call; 99, 100; 99, 107; 100, attribute; 100, 101; 100, 106; 101, attribute; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, identifier:self; 104, identifier:metadata; 105, identifier:date; 106, identifier:replace; 107, argument_list; 107, 108; 107, 109; 108, string:"-"; 109, string:""; 110, pair; 110, 111; 110, 112; 111, string:'RunFolderId'; 112, attribute; 112, 113; 112, 116; 113, attribute; 113, 114; 113, 115; 114, identifier:self; 115, identifier:metadata; 116, identifier:runnumber; 117, pair; 117, 118; 117, 119; 118, string:'RunFlowcellId'; 119, attribute; 119, 120; 119, 123; 120, attribute; 120, 121; 120, 122; 121, identifier:self; 122, identifier:metadata; 123, identifier:flowcell; 124, expression_statement; 124, 125; 125, assignment; 125, 126; 125, 127; 126, identifier:config; 127, call; 127, 128; 127, 131; 128, attribute; 128, 129; 128, 130; 129, identifier:ElementTree; 130, identifier:parse; 131, argument_list; 131, 132; 132, call; 132, 133; 132, 136; 133, attribute; 133, 134; 133, 135; 134, string:"{}/config.xml"; 135, identifier:format; 136, argument_list; 136, 137; 137, attribute; 137, 138; 137, 139; 138, identifier:self; 139, identifier:homepath; 140, expression_statement; 140, 141; 141, assignment; 141, 142; 141, 143; 142, identifier:configroot; 143, call; 143, 144; 143, 147; 144, attribute; 144, 145; 144, 146; 145, identifier:config; 146, identifier:getroot; 147, argument_list; 148, for_statement; 148, 149; 148, 150; 148, 151; 149, identifier:run; 150, identifier:configroot; 151, block; 151, 152; 152, for_statement; 152, 153; 152, 154; 152, 155; 153, identifier:child; 154, identifier:run; 155, block; 155, 156; 156, if_statement; 156, 157; 156, 162; 156, 198; 157, comparison_operator:==; 157, 158; 157, 161; 158, attribute; 158, 159; 158, 160; 159, identifier:child; 160, identifier:tag; 161, string:'Cycles'; 162, block; 162, 163; 163, expression_statement; 163, 164; 164, assignment; 164, 165; 164, 168; 165, attribute; 165, 166; 165, 167; 166, identifier:child; 167, identifier:attrib; 168, dictionary; 168, 169; 168, 185; 168, 195; 169, pair; 169, 170; 169, 171; 170, string:'Last'; 171, call; 171, 172; 171, 175; 172, attribute; 172, 173; 172, 174; 173, string:'{}'; 174, identifier:format; 175, argument_list; 175, 176; 176, binary_operator:+; 176, 177; 176, 182; 177, binary_operator:+; 177, 178; 177, 181; 178, attribute; 178, 179; 178, 180; 179, identifier:self; 180, identifier:forwardlength; 181, integer:16; 182, attribute; 182, 183; 182, 184; 183, identifier:self; 184, identifier:reverselength; 185, pair; 185, 186; 185, 187; 186, string:'Number'; 187, call; 187, 188; 187, 191; 188, attribute; 188, 189; 188, 190; 189, string:'{}'; 190, identifier:format; 191, argument_list; 191, 192; 192, attribute; 192, 193; 192, 194; 193, identifier:self; 194, identifier:totalreads; 195, pair; 195, 196; 195, 197; 196, string:'First'; 197, string:'1'; 198, elif_clause; 198, 199; 198, 204; 199, comparison_operator:==; 199, 200; 199, 203; 200, attribute; 200, 201; 200, 202; 201, identifier:child; 202, identifier:tag; 203, string:'RunParameters'; 204, block; 204, 205; 204, 209; 205, expression_statement; 205, 206; 206, assignment; 206, 207; 206, 208; 207, identifier:runparameters; 208, identifier:child; 209, for_statement; 209, 210; 209, 211; 209, 212; 210, identifier:runparameter; 211, identifier:runparameters; 212, block; 212, 213; 212, 255; 212, 270; 212, 289; 213, if_statement; 213, 214; 213, 219; 214, comparison_operator:in; 214, 215; 214, 216; 215, string:'Reads'; 216, attribute; 216, 217; 216, 218; 217, identifier:runparameter; 218, identifier:tag; 219, block; 219, 220; 220, for_statement; 220, 221; 220, 224; 220, 228; 221, pattern_list; 221, 222; 221, 223; 222, identifier:indexcount; 223, identifier:reads; 224, call; 224, 225; 224, 226; 225, identifier:enumerate; 226, argument_list; 226, 227; 227, identifier:runparameter; 228, block; 228, 229; 228, 242; 229, expression_statement; 229, 230; 230, assignment; 230, 231; 230, 232; 231, identifier:index; 232, binary_operator:-; 232, 233; 232, 241; 233, call; 233, 234; 233, 235; 234, identifier:int; 235, argument_list; 235, 236; 236, subscript; 236, 237; 236, 240; 237, attribute; 237, 238; 237, 239; 238, identifier:runparameter; 239, identifier:attrib; 240, string:'Index'; 241, integer:1; 242, expression_statement; 242, 243; 243, assignment; 243, 244; 243, 247; 244, attribute; 244, 245; 244, 246; 245, identifier:reads; 246, identifier:text; 247, call; 247, 248; 247, 249; 248, identifier:str; 249, argument_list; 249, 250; 250, subscript; 250, 251; 250, 254; 251, subscript; 251, 252; 251, 253; 252, identifier:cycles; 253, identifier:index; 254, identifier:indexcount; 255, if_statement; 255, 256; 255, 261; 256, comparison_operator:==; 256, 257; 256, 260; 257, attribute; 257, 258; 257, 259; 258, identifier:runparameter; 259, identifier:tag; 260, string:'Instrument'; 261, block; 261, 262; 262, expression_statement; 262, 263; 263, assignment; 263, 264; 263, 267; 264, attribute; 264, 265; 264, 266; 265, identifier:runparameter; 266, identifier:text; 267, attribute; 267, 268; 267, 269; 268, identifier:self; 269, identifier:instrument; 270, for_statement; 270, 271; 270, 272; 270, 273; 271, identifier:parameter; 272, identifier:parameters; 273, block; 273, 274; 274, if_statement; 274, 275; 274, 280; 275, comparison_operator:==; 275, 276; 275, 279; 276, attribute; 276, 277; 276, 278; 277, identifier:runparameter; 278, identifier:tag; 279, identifier:parameter; 280, block; 280, 281; 281, expression_statement; 281, 282; 282, assignment; 282, 283; 282, 286; 283, attribute; 283, 284; 283, 285; 284, identifier:runparameter; 285, identifier:text; 286, subscript; 286, 287; 286, 288; 287, identifier:parameters; 288, identifier:parameter; 289, if_statement; 289, 290; 289, 295; 290, comparison_operator:in; 290, 291; 290, 292; 291, string:'Barcode'; 292, attribute; 292, 293; 292, 294; 293, identifier:runparameter; 294, identifier:tag; 295, block; 295, 296; 296, for_statement; 296, 297; 296, 300; 296, 304; 297, pattern_list; 297, 298; 297, 299; 298, identifier:cycle; 299, identifier:barcode; 300, call; 300, 301; 300, 302; 301, identifier:enumerate; 302, argument_list; 302, 303; 303, identifier:runparameter; 304, block; 304, 305; 305, expression_statement; 305, 306; 306, assignment; 306, 307; 306, 310; 307, attribute; 307, 308; 307, 309; 308, identifier:barcode; 309, identifier:text; 310, call; 310, 311; 310, 312; 311, identifier:str; 312, argument_list; 312, 313; 313, binary_operator:+; 313, 314; 313, 319; 314, binary_operator:+; 314, 315; 314, 318; 315, attribute; 315, 316; 315, 317; 316, identifier:self; 317, identifier:forwardlength; 318, integer:1; 319, identifier:cycle; 320, expression_statement; 320, 321; 321, call; 321, 322; 321, 325; 322, attribute; 322, 323; 322, 324; 323, identifier:config; 324, identifier:write; 325, argument_list; 325, 326; 326, call; 326, 327; 326, 330; 327, attribute; 327, 328; 327, 329; 328, string:'{}Data/Intensities/BaseCalls/config.xml'; 329, identifier:format; 330, argument_list; 330, 331; 331, attribute; 331, 332; 331, 333; 332, identifier:self; 333, identifier:miseqfolder
def configfilepopulator(self): self.forwardlength = self.metadata.header.forwardlength self.reverselength = self.metadata.header.reverselength cycles = [[1, self.forwardlength, self.runid], [self.forwardlength + 1, self.forwardlength + 8, self.runid], [self.forwardlength + 9, self.forwardlength + 16, self.runid], [self.forwardlength + 17, self.forwardlength + 16 + self.reverselength, self.runid]] parameters = {'RunFolder': self.runid, 'RunFolderDate': self.metadata.date.replace("-", ""), 'RunFolderId': self.metadata.runnumber, 'RunFlowcellId': self.metadata.flowcell} config = ElementTree.parse("{}/config.xml".format(self.homepath)) configroot = config.getroot() for run in configroot: for child in run: if child.tag == 'Cycles': child.attrib = {'Last': '{}'.format(self.forwardlength + 16 + self.reverselength), 'Number': '{}'.format(self.totalreads), 'First': '1'} elif child.tag == 'RunParameters': runparameters = child for runparameter in runparameters: if 'Reads' in runparameter.tag: for indexcount, reads in enumerate(runparameter): index = int(runparameter.attrib['Index']) - 1 reads.text = str(cycles[index][indexcount]) if runparameter.tag == 'Instrument': runparameter.text = self.instrument for parameter in parameters: if runparameter.tag == parameter: runparameter.text = parameters[parameter] if 'Barcode' in runparameter.tag: for cycle, barcode in enumerate(runparameter): barcode.text = str(self.forwardlength + 1 + cycle) config.write('{}Data/Intensities/BaseCalls/config.xml'.format(self.miseqfolder))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_check_time_format; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:labels; 6, identifier:values; 7, block; 7, 8; 8, for_statement; 8, 9; 8, 12; 8, 17; 9, pattern_list; 9, 10; 9, 11; 10, identifier:label; 11, identifier:value; 12, call; 12, 13; 12, 14; 13, identifier:zip; 14, argument_list; 14, 15; 14, 16; 15, identifier:labels; 16, identifier:values; 17, block; 17, 18; 17, 24; 17, 72; 17, 96; 18, if_statement; 18, 19; 18, 22; 19, comparison_operator:==; 19, 20; 19, 21; 20, identifier:value; 21, string:"*"; 22, block; 22, 23; 23, continue_statement; 24, if_statement; 24, 25; 24, 28; 25, comparison_operator:==; 25, 26; 25, 27; 26, identifier:label; 27, string:"day_of_week"; 28, block; 28, 29; 29, if_statement; 29, 30; 29, 35; 29, 57; 30, call; 30, 31; 30, 32; 31, identifier:isinstance; 32, argument_list; 32, 33; 32, 34; 33, identifier:value; 34, identifier:string_types; 35, block; 35, 36; 36, if_statement; 36, 37; 36, 40; 37, comparison_operator:not; 37, 38; 37, 39; 38, identifier:value; 39, identifier:ORDER_WEEK; 40, block; 40, 41; 41, raise_statement; 41, 42; 42, call; 42, 43; 42, 44; 43, identifier:ParseError; 44, argument_list; 44, 45; 45, binary_operator:%; 45, 46; 45, 49; 46, concatenated_string; 46, 47; 46, 48; 47, string:"'%s' is not day of the week. "; 48, string:"character is the only '%s'"; 49, tuple; 49, 50; 49, 51; 50, identifier:value; 51, call; 51, 52; 51, 55; 52, attribute; 52, 53; 52, 54; 53, string:', '; 54, identifier:join; 55, argument_list; 55, 56; 56, identifier:ORDER_WEEK; 57, elif_clause; 57, 58; 57, 64; 58, not_operator; 58, 59; 59, call; 59, 60; 59, 61; 60, identifier:isinstance; 61, argument_list; 61, 62; 61, 63; 62, identifier:value; 63, identifier:int; 64, block; 64, 65; 65, raise_statement; 65, 66; 66, call; 66, 67; 66, 68; 67, identifier:TypeError; 68, argument_list; 68, 69; 69, binary_operator:%; 69, 70; 69, 71; 70, string:"'%s' is not an int"; 71, identifier:value; 72, if_statement; 72, 73; 72, 80; 73, comparison_operator:in; 73, 74; 73, 75; 74, identifier:label; 75, list:["year", "month", "day", "num_of_week"]; 75, 76; 75, 77; 75, 78; 75, 79; 76, string:"year"; 77, string:"month"; 78, string:"day"; 79, string:"num_of_week"; 80, block; 80, 81; 81, if_statement; 81, 82; 81, 88; 82, not_operator; 82, 83; 83, call; 83, 84; 83, 85; 84, identifier:isinstance; 85, argument_list; 85, 86; 85, 87; 86, identifier:value; 87, identifier:int; 88, block; 88, 89; 89, raise_statement; 89, 90; 90, call; 90, 91; 90, 92; 91, identifier:TypeError; 92, argument_list; 92, 93; 93, binary_operator:%; 93, 94; 93, 95; 94, string:"'%s' is not an int"; 95, identifier:value; 96, if_statement; 96, 97; 96, 102; 97, call; 97, 98; 97, 99; 98, identifier:isinstance; 99, argument_list; 99, 100; 99, 101; 100, identifier:value; 101, identifier:int; 102, block; 102, 103; 102, 111; 103, expression_statement; 103, 104; 104, assignment; 104, 105; 104, 108; 105, pattern_list; 105, 106; 105, 107; 106, identifier:start; 107, identifier:end; 108, subscript; 108, 109; 108, 110; 109, identifier:TIME_INFO; 110, identifier:label; 111, if_statement; 111, 112; 111, 117; 112, not_operator; 112, 113; 113, comparison_operator:<=; 113, 114; 113, 115; 113, 116; 114, identifier:start; 115, identifier:value; 116, identifier:end; 117, block; 117, 118; 118, raise_statement; 118, 119; 119, call; 119, 120; 119, 121; 120, identifier:PeriodRangeError; 121, argument_list; 121, 122; 122, binary_operator:%; 122, 123; 122, 126; 123, concatenated_string; 123, 124; 123, 125; 124, string:"'%d' is outside the scope of the period "; 125, string:"'%s' range: '%d' to '%d'"; 126, tuple; 126, 127; 126, 128; 126, 129; 126, 130; 127, identifier:value; 128, identifier:label; 129, identifier:start; 130, identifier:end
def _check_time_format(self, labels, values): for label, value in zip(labels, values): if value == "*": continue if label == "day_of_week": if isinstance(value, string_types): if value not in ORDER_WEEK: raise ParseError("'%s' is not day of the week. " "character is the only '%s'" % ( value, ', '.join(ORDER_WEEK))) elif not isinstance(value, int): raise TypeError("'%s' is not an int" % value) if label in ["year", "month", "day", "num_of_week"]: if not isinstance(value, int): raise TypeError("'%s' is not an int" % value) if isinstance(value, int): start, end = TIME_INFO[label] if not start <= value <= end: raise PeriodRangeError("'%d' is outside the scope of the period " "'%s' range: '%d' to '%d'" % ( value, label, start, end))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:readlength; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 13; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:logging; 10, identifier:info; 11, argument_list; 11, 12; 12, string:'Estimating read lengths of FASTQ files'; 13, for_statement; 13, 14; 13, 15; 13, 18; 14, identifier:sample; 15, attribute; 15, 16; 15, 17; 16, identifier:self; 17, identifier:samples; 18, block; 18, 19; 18, 27; 18, 35; 18, 43; 18, 51; 18, 59; 18, 67; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 26; 21, attribute; 21, 22; 21, 25; 22, attribute; 22, 23; 22, 24; 23, identifier:sample; 24, identifier:run; 25, identifier:Date; 26, string:'NA'; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 34; 29, attribute; 29, 30; 29, 33; 30, attribute; 30, 31; 30, 32; 31, identifier:sample; 32, identifier:run; 33, identifier:InvestigatorName; 34, string:'NA'; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 42; 37, attribute; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:sample; 40, identifier:run; 41, identifier:TotalClustersinRun; 42, string:'NA'; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 50; 45, attribute; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:sample; 48, identifier:run; 49, identifier:NumberofClustersPF; 50, string:'NA'; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 58; 53, attribute; 53, 54; 53, 57; 54, attribute; 54, 55; 54, 56; 55, identifier:sample; 56, identifier:run; 57, identifier:PercentOfClusters; 58, string:'NA'; 59, expression_statement; 59, 60; 60, assignment; 60, 61; 60, 66; 61, attribute; 61, 62; 61, 65; 62, attribute; 62, 63; 62, 64; 63, identifier:sample; 64, identifier:run; 65, identifier:SampleProject; 66, string:'NA'; 67, if_statement; 67, 68; 67, 89; 68, boolean_operator:and; 68, 69; 68, 79; 69, not_operator; 69, 70; 70, call; 70, 71; 70, 74; 71, attribute; 71, 72; 71, 73; 72, identifier:GenObject; 73, identifier:isattr; 74, argument_list; 74, 75; 74, 78; 75, attribute; 75, 76; 75, 77; 76, identifier:sample; 77, identifier:run; 78, string:'forwardlength'; 79, not_operator; 79, 80; 80, call; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:GenObject; 83, identifier:isattr; 84, argument_list; 84, 85; 84, 88; 85, attribute; 85, 86; 85, 87; 86, identifier:sample; 87, identifier:run; 88, string:'reverselength'; 89, block; 89, 90; 89, 98; 89, 106; 89, 116; 90, expression_statement; 90, 91; 91, assignment; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:sample; 94, identifier:header; 95, call; 95, 96; 95, 97; 96, identifier:GenObject; 97, argument_list; 98, expression_statement; 98, 99; 99, assignment; 99, 100; 99, 103; 100, attribute; 100, 101; 100, 102; 101, identifier:sample; 102, identifier:commands; 103, call; 103, 104; 103, 105; 104, identifier:GenObject; 105, argument_list; 106, expression_statement; 106, 107; 107, assignment; 107, 108; 107, 109; 108, identifier:devnull; 109, call; 109, 110; 109, 111; 110, identifier:open; 111, argument_list; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, identifier:os; 114, identifier:devnull; 115, string:'wb'; 116, if_statement; 116, 117; 116, 127; 117, comparison_operator:is; 117, 118; 117, 126; 118, call; 118, 119; 118, 120; 119, identifier:type; 120, argument_list; 120, 121; 121, attribute; 121, 122; 121, 125; 122, attribute; 122, 123; 122, 124; 123, identifier:sample; 124, identifier:general; 125, identifier:fastqfiles; 126, identifier:list; 127, block; 127, 128; 127, 141; 127, 156; 127, 192; 127, 214; 127, 267; 128, expression_statement; 128, 129; 129, assignment; 129, 130; 129, 131; 130, identifier:forwardfastq; 131, subscript; 131, 132; 131, 140; 132, call; 132, 133; 132, 134; 133, identifier:sorted; 134, argument_list; 134, 135; 135, attribute; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:sample; 138, identifier:general; 139, identifier:fastqfiles; 140, integer:0; 141, if_statement; 141, 142; 141, 145; 141, 150; 142, comparison_operator:in; 142, 143; 142, 144; 143, string:'.gz'; 144, identifier:forwardfastq; 145, block; 145, 146; 146, expression_statement; 146, 147; 147, assignment; 147, 148; 147, 149; 148, identifier:command; 149, string:'zcat'; 150, else_clause; 150, 151; 151, block; 151, 152; 152, expression_statement; 152, 153; 153, assignment; 153, 154; 153, 155; 154, identifier:command; 155, string:'cat'; 156, expression_statement; 156, 157; 157, assignment; 157, 158; 157, 159; 158, identifier:forwardreads; 159, call; 159, 160; 159, 191; 160, attribute; 160, 161; 160, 190; 161, subscript; 161, 162; 161, 189; 162, call; 162, 163; 162, 188; 163, attribute; 163, 164; 163, 187; 164, call; 164, 165; 164, 168; 165, attribute; 165, 166; 165, 167; 166, identifier:subprocess; 167, identifier:Popen; 168, argument_list; 168, 169; 168, 176; 168, 179; 168, 184; 169, call; 169, 170; 169, 173; 170, attribute; 170, 171; 170, 172; 171, string:"{} {} | head -n 1000"; 172, identifier:format; 173, argument_list; 173, 174; 173, 175; 174, identifier:command; 175, identifier:forwardfastq; 176, keyword_argument; 176, 177; 176, 178; 177, identifier:shell; 178, True; 179, keyword_argument; 179, 180; 179, 181; 180, identifier:stdout; 181, attribute; 181, 182; 181, 183; 182, identifier:subprocess; 183, identifier:PIPE; 184, keyword_argument; 184, 185; 184, 186; 185, identifier:stderr; 186, identifier:devnull; 187, identifier:communicate; 188, argument_list; 189, integer:0; 190, identifier:rstrip; 191, argument_list; 192, try_statement; 192, 193; 192, 203; 193, block; 193, 194; 194, expression_statement; 194, 195; 195, assignment; 195, 196; 195, 197; 196, identifier:forwardreads; 197, call; 197, 198; 197, 201; 198, attribute; 198, 199; 198, 200; 199, identifier:forwardreads; 200, identifier:decode; 201, argument_list; 201, 202; 202, string:'utf-8'; 203, except_clause; 203, 204; 203, 205; 204, identifier:UnicodeDecodeError; 205, block; 205, 206; 206, expression_statement; 206, 207; 207, assignment; 207, 208; 207, 213; 208, attribute; 208, 209; 208, 212; 209, attribute; 209, 210; 209, 211; 210, identifier:sample; 211, identifier:run; 212, identifier:forwardlength; 213, integer:0; 214, try_statement; 214, 215; 214, 254; 215, block; 215, 216; 215, 246; 216, expression_statement; 216, 217; 217, assignment; 217, 218; 217, 219; 218, identifier:forwardlength; 219, call; 219, 220; 219, 221; 220, identifier:max; 221, argument_list; 221, 222; 222, list_comprehension; 222, 223; 222, 227; 222, 240; 223, call; 223, 224; 223, 225; 224, identifier:len; 225, argument_list; 225, 226; 226, identifier:sequence; 227, for_in_clause; 227, 228; 227, 231; 228, pattern_list; 228, 229; 228, 230; 229, identifier:iterator; 230, identifier:sequence; 231, call; 231, 232; 231, 233; 232, identifier:enumerate; 233, argument_list; 233, 234; 234, call; 234, 235; 234, 238; 235, attribute; 235, 236; 235, 237; 236, identifier:forwardreads; 237, identifier:split; 238, argument_list; 238, 239; 239, string:'\n'; 240, if_clause; 240, 241; 241, comparison_operator:==; 241, 242; 241, 245; 242, binary_operator:%; 242, 243; 242, 244; 243, identifier:iterator; 244, integer:4; 245, integer:1; 246, expression_statement; 246, 247; 247, assignment; 247, 248; 247, 253; 248, attribute; 248, 249; 248, 252; 249, attribute; 249, 250; 249, 251; 250, identifier:sample; 251, identifier:run; 252, identifier:forwardlength; 253, identifier:forwardlength; 254, except_clause; 254, 255; 254, 258; 255, tuple; 255, 256; 255, 257; 256, identifier:ValueError; 257, identifier:TypeError; 258, block; 258, 259; 259, expression_statement; 259, 260; 260, assignment; 260, 261; 260, 266; 261, attribute; 261, 262; 261, 265; 262, attribute; 262, 263; 262, 264; 263, identifier:sample; 264, identifier:run; 265, identifier:forwardlength; 266, integer:0; 267, if_statement; 267, 268; 267, 278; 267, 399; 268, comparison_operator:==; 268, 269; 268, 277; 269, call; 269, 270; 269, 271; 270, identifier:len; 271, argument_list; 271, 272; 272, attribute; 272, 273; 272, 276; 273, attribute; 273, 274; 273, 275; 274, identifier:sample; 275, identifier:general; 276, identifier:fastqfiles; 277, integer:2; 278, block; 278, 279; 278, 292; 278, 328; 278, 350; 279, expression_statement; 279, 280; 280, assignment; 280, 281; 280, 282; 281, identifier:reversefastq; 282, subscript; 282, 283; 282, 291; 283, call; 283, 284; 283, 285; 284, identifier:sorted; 285, argument_list; 285, 286; 286, attribute; 286, 287; 286, 290; 287, attribute; 287, 288; 287, 289; 288, identifier:sample; 289, identifier:general; 290, identifier:fastqfiles; 291, integer:1; 292, expression_statement; 292, 293; 293, assignment; 293, 294; 293, 295; 294, identifier:reversereads; 295, call; 295, 296; 295, 327; 296, attribute; 296, 297; 296, 326; 297, subscript; 297, 298; 297, 325; 298, call; 298, 299; 298, 324; 299, attribute; 299, 300; 299, 323; 300, call; 300, 301; 300, 304; 301, attribute; 301, 302; 301, 303; 302, identifier:subprocess; 303, identifier:Popen; 304, argument_list; 304, 305; 304, 312; 304, 315; 304, 320; 305, call; 305, 306; 305, 309; 306, attribute; 306, 307; 306, 308; 307, string:"{} {} | head -n 1000"; 308, identifier:format; 309, argument_list; 309, 310; 309, 311; 310, identifier:command; 311, identifier:reversefastq; 312, keyword_argument; 312, 313; 312, 314; 313, identifier:shell; 314, True; 315, keyword_argument; 315, 316; 315, 317; 316, identifier:stdout; 317, attribute; 317, 318; 317, 319; 318, identifier:subprocess; 319, identifier:PIPE; 320, keyword_argument; 320, 321; 320, 322; 321, identifier:stderr; 322, identifier:devnull; 323, identifier:communicate; 324, argument_list; 325, integer:0; 326, identifier:rstrip; 327, argument_list; 328, try_statement; 328, 329; 328, 339; 329, block; 329, 330; 330, expression_statement; 330, 331; 331, assignment; 331, 332; 331, 333; 332, identifier:reversereads; 333, call; 333, 334; 333, 337; 334, attribute; 334, 335; 334, 336; 335, identifier:reversereads; 336, identifier:decode; 337, argument_list; 337, 338; 338, string:'utf-8'; 339, except_clause; 339, 340; 339, 341; 340, identifier:UnicodeDecodeError; 341, block; 341, 342; 342, expression_statement; 342, 343; 343, assignment; 343, 344; 343, 349; 344, attribute; 344, 345; 344, 348; 345, attribute; 345, 346; 345, 347; 346, identifier:sample; 347, identifier:run; 348, identifier:reverselength; 349, integer:0; 350, try_statement; 350, 351; 350, 386; 351, block; 351, 352; 352, expression_statement; 352, 353; 353, assignment; 353, 354; 353, 359; 354, attribute; 354, 355; 354, 358; 355, attribute; 355, 356; 355, 357; 356, identifier:sample; 357, identifier:run; 358, identifier:reverselength; 359, call; 359, 360; 359, 361; 360, identifier:max; 361, argument_list; 361, 362; 362, list_comprehension; 362, 363; 362, 367; 362, 380; 363, call; 363, 364; 363, 365; 364, identifier:len; 365, argument_list; 365, 366; 366, identifier:sequence; 367, for_in_clause; 367, 368; 367, 371; 368, pattern_list; 368, 369; 368, 370; 369, identifier:iterator; 370, identifier:sequence; 371, call; 371, 372; 371, 373; 372, identifier:enumerate; 373, argument_list; 373, 374; 374, call; 374, 375; 374, 378; 375, attribute; 375, 376; 375, 377; 376, identifier:reversereads; 377, identifier:split; 378, argument_list; 378, 379; 379, string:'\n'; 380, if_clause; 380, 381; 381, comparison_operator:==; 381, 382; 381, 385; 382, binary_operator:%; 382, 383; 382, 384; 383, identifier:iterator; 384, integer:4; 385, integer:1; 386, except_clause; 386, 387; 386, 390; 387, tuple; 387, 388; 387, 389; 388, identifier:ValueError; 389, identifier:TypeError; 390, block; 390, 391; 391, expression_statement; 391, 392; 392, assignment; 392, 393; 392, 398; 393, attribute; 393, 394; 393, 397; 394, attribute; 394, 395; 394, 396; 395, identifier:sample; 396, identifier:run; 397, identifier:reverselength; 398, integer:0; 399, else_clause; 399, 400; 400, block; 400, 401; 401, expression_statement; 401, 402; 402, assignment; 402, 403; 402, 408; 403, attribute; 403, 404; 403, 407; 404, attribute; 404, 405; 404, 406; 405, identifier:sample; 406, identifier:run; 407, identifier:reverselength; 408, integer:0
def readlength(self): logging.info('Estimating read lengths of FASTQ files') for sample in self.samples: sample.run.Date = 'NA' sample.run.InvestigatorName = 'NA' sample.run.TotalClustersinRun = 'NA' sample.run.NumberofClustersPF = 'NA' sample.run.PercentOfClusters = 'NA' sample.run.SampleProject = 'NA' if not GenObject.isattr(sample.run, 'forwardlength') and not GenObject.isattr(sample.run, 'reverselength'): sample.header = GenObject() sample.commands = GenObject() devnull = open(os.devnull, 'wb') if type(sample.general.fastqfiles) is list: forwardfastq = sorted(sample.general.fastqfiles)[0] if '.gz' in forwardfastq: command = 'zcat' else: command = 'cat' forwardreads = subprocess.Popen("{} {} | head -n 1000".format(command, forwardfastq), shell=True, stdout=subprocess.PIPE, stderr=devnull).communicate()[0].rstrip() try: forwardreads = forwardreads.decode('utf-8') except UnicodeDecodeError: sample.run.forwardlength = 0 try: forwardlength = max([len(sequence) for iterator, sequence in enumerate(forwardreads.split('\n')) if iterator % 4 == 1]) sample.run.forwardlength = forwardlength except (ValueError, TypeError): sample.run.forwardlength = 0 if len(sample.general.fastqfiles) == 2: reversefastq = sorted(sample.general.fastqfiles)[1] reversereads = subprocess.Popen("{} {} | head -n 1000".format(command, reversefastq), shell=True, stdout=subprocess.PIPE, stderr=devnull).communicate()[0].rstrip() try: reversereads = reversereads.decode('utf-8') except UnicodeDecodeError: sample.run.reverselength = 0 try: sample.run.reverselength = max([len(sequence) for iterator, sequence in enumerate(reversereads.split('\n')) if iterator % 4 == 1]) except (ValueError, TypeError): sample.run.reverselength = 0 else: sample.run.reverselength = 0
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:confirm; 3, parameters; 3, 4; 3, 7; 3, 10; 3, 15; 3, 18; 4, default_parameter; 4, 5; 4, 6; 5, identifier:prompt; 6, string:'Really?'; 7, default_parameter; 7, 8; 7, 9; 8, identifier:color; 9, string:'warning'; 10, default_parameter; 10, 11; 10, 12; 11, identifier:yes_values; 12, tuple; 12, 13; 12, 14; 13, string:'y'; 14, string:'yes'; 15, default_parameter; 15, 16; 15, 17; 16, identifier:abort_on_unconfirmed; 17, False; 18, default_parameter; 18, 19; 18, 20; 19, identifier:abort_options; 20, None; 21, block; 21, 22; 21, 34; 21, 50; 21, 65; 21, 105; 21, 125; 21, 196; 22, if_statement; 22, 23; 22, 28; 23, call; 23, 24; 23, 25; 24, identifier:isinstance; 25, argument_list; 25, 26; 25, 27; 26, identifier:yes_values; 27, identifier:str; 28, block; 28, 29; 29, expression_statement; 29, 30; 30, assignment; 30, 31; 30, 32; 31, identifier:yes_values; 32, tuple; 32, 33; 33, identifier:yes_values; 34, expression_statement; 34, 35; 35, assignment; 35, 36; 35, 37; 36, identifier:prompt; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, string:'{prompt} [{yes_value}/N] '; 40, identifier:format; 41, argument_list; 41, 42; 41, 45; 42, keyword_argument; 42, 43; 42, 44; 43, identifier:prompt; 44, identifier:prompt; 45, keyword_argument; 45, 46; 45, 47; 46, identifier:yes_value; 47, subscript; 47, 48; 47, 49; 48, identifier:yes_values; 49, integer:0; 50, if_statement; 50, 51; 50, 52; 51, identifier:color; 52, block; 52, 53; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 56; 55, identifier:prompt; 56, call; 56, 57; 56, 60; 57, attribute; 57, 58; 57, 59; 58, identifier:printer; 59, identifier:colorize; 60, argument_list; 60, 61; 60, 62; 61, identifier:prompt; 62, keyword_argument; 62, 63; 62, 64; 63, identifier:color; 64, identifier:color; 65, try_statement; 65, 66; 65, 74; 65, 85; 66, block; 66, 67; 67, expression_statement; 67, 68; 68, assignment; 68, 69; 68, 70; 69, identifier:answer; 70, call; 70, 71; 70, 72; 71, identifier:input; 72, argument_list; 72, 73; 73, identifier:prompt; 74, except_clause; 74, 75; 74, 76; 75, identifier:KeyboardInterrupt; 76, block; 76, 77; 76, 81; 77, expression_statement; 77, 78; 78, call; 78, 79; 78, 80; 79, identifier:print; 80, argument_list; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 84; 83, identifier:confirmed; 84, False; 85, else_clause; 85, 86; 86, block; 86, 87; 86, 99; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 90; 89, identifier:answer; 90, call; 90, 91; 90, 98; 91, attribute; 91, 92; 91, 97; 92, call; 92, 93; 92, 96; 93, attribute; 93, 94; 93, 95; 94, identifier:answer; 95, identifier:strip; 96, argument_list; 97, identifier:lower; 98, argument_list; 99, expression_statement; 99, 100; 100, assignment; 100, 101; 100, 102; 101, identifier:confirmed; 102, comparison_operator:in; 102, 103; 102, 104; 103, identifier:answer; 104, identifier:yes_values; 105, expression_statement; 105, 106; 106, assignment; 106, 107; 106, 108; 107, identifier:do_abort_on_unconfirmed; 108, boolean_operator:and; 108, 109; 108, 111; 109, not_operator; 109, 110; 110, identifier:confirmed; 111, parenthesized_expression; 111, 112; 112, boolean_operator:or; 112, 113; 112, 117; 113, call; 113, 114; 113, 115; 114, identifier:bool; 115, argument_list; 115, 116; 116, identifier:abort_on_unconfirmed; 117, parenthesized_expression; 117, 118; 118, boolean_operator:and; 118, 119; 118, 122; 119, comparison_operator:==; 119, 120; 119, 121; 120, identifier:abort_on_unconfirmed; 121, integer:0; 122, comparison_operator:is; 122, 123; 122, 124; 123, identifier:abort_on_unconfirmed; 124, False; 125, if_statement; 125, 126; 125, 127; 126, identifier:do_abort_on_unconfirmed; 127, block; 127, 128; 127, 137; 127, 190; 128, if_statement; 128, 129; 128, 132; 129, comparison_operator:is; 129, 130; 129, 131; 130, identifier:abort_options; 131, None; 132, block; 132, 133; 133, expression_statement; 133, 134; 134, assignment; 134, 135; 134, 136; 135, identifier:abort_options; 136, dictionary; 137, if_statement; 137, 138; 137, 141; 137, 150; 137, 165; 137, 180; 138, comparison_operator:is; 138, 139; 138, 140; 139, identifier:abort_on_unconfirmed; 140, True; 141, block; 141, 142; 142, expression_statement; 142, 143; 143, call; 143, 144; 143, 147; 144, attribute; 144, 145; 144, 146; 145, identifier:abort_options; 146, identifier:setdefault; 147, argument_list; 147, 148; 147, 149; 148, string:'return_code'; 149, integer:0; 150, elif_clause; 150, 151; 150, 156; 151, call; 151, 152; 151, 153; 152, identifier:isinstance; 153, argument_list; 153, 154; 153, 155; 154, identifier:abort_on_unconfirmed; 155, identifier:int; 156, block; 156, 157; 157, expression_statement; 157, 158; 158, call; 158, 159; 158, 162; 159, attribute; 159, 160; 159, 161; 160, identifier:abort_options; 161, identifier:setdefault; 162, argument_list; 162, 163; 162, 164; 163, string:'return_code'; 164, identifier:abort_on_unconfirmed; 165, elif_clause; 165, 166; 165, 171; 166, call; 166, 167; 166, 168; 167, identifier:isinstance; 168, argument_list; 168, 169; 168, 170; 169, identifier:abort_on_unconfirmed; 170, identifier:str; 171, block; 171, 172; 172, expression_statement; 172, 173; 173, call; 173, 174; 173, 177; 174, attribute; 174, 175; 174, 176; 175, identifier:abort_options; 176, identifier:setdefault; 177, argument_list; 177, 178; 177, 179; 178, string:'message'; 179, identifier:abort_on_unconfirmed; 180, else_clause; 180, 181; 181, block; 181, 182; 182, expression_statement; 182, 183; 183, call; 183, 184; 183, 187; 184, attribute; 184, 185; 184, 186; 185, identifier:abort_options; 186, identifier:setdefault; 187, argument_list; 187, 188; 187, 189; 188, string:'return_code'; 189, integer:0; 190, expression_statement; 190, 191; 191, call; 191, 192; 191, 193; 192, identifier:abort; 193, argument_list; 193, 194; 194, dictionary_splat; 194, 195; 195, identifier:abort_options; 196, return_statement; 196, 197; 197, identifier:confirmed
def confirm(prompt='Really?', color='warning', yes_values=('y', 'yes'), abort_on_unconfirmed=False, abort_options=None): if isinstance(yes_values, str): yes_values = (yes_values,) prompt = '{prompt} [{yes_value}/N] '.format(prompt=prompt, yes_value=yes_values[0]) if color: prompt = printer.colorize(prompt, color=color) try: answer = input(prompt) except KeyboardInterrupt: print() confirmed = False else: answer = answer.strip().lower() confirmed = answer in yes_values do_abort_on_unconfirmed = not confirmed and ( bool(abort_on_unconfirmed) or (abort_on_unconfirmed == 0 and abort_on_unconfirmed is not False) ) if do_abort_on_unconfirmed: if abort_options is None: abort_options = {} if abort_on_unconfirmed is True: abort_options.setdefault('return_code', 0) elif isinstance(abort_on_unconfirmed, int): abort_options.setdefault('return_code', abort_on_unconfirmed) elif isinstance(abort_on_unconfirmed, str): abort_options.setdefault('message', abort_on_unconfirmed) else: abort_options.setdefault('return_code', 0) abort(**abort_options) return confirmed
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:from_string; 3, parameters; 3, 4; 3, 5; 4, identifier:cls; 5, identifier:action_str; 6, block; 6, 7; 6, 11; 6, 181; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:args; 10, dictionary; 11, try_statement; 11, 12; 11, 22; 11, 32; 12, block; 12, 13; 13, expression_statement; 13, 14; 14, assignment; 14, 15; 14, 16; 15, identifier:mod_obj; 16, call; 16, 17; 16, 20; 17, attribute; 17, 18; 17, 19; 18, identifier:ast; 19, identifier:parse; 20, argument_list; 20, 21; 21, identifier:action_str; 22, except_clause; 22, 23; 22, 29; 23, as_pattern; 23, 24; 23, 27; 24, tuple; 24, 25; 24, 26; 25, identifier:SyntaxError; 26, identifier:ValueError; 27, as_pattern_target; 27, 28; 28, identifier:e; 29, block; 29, 30; 30, raise_statement; 30, 31; 31, identifier:e; 32, else_clause; 32, 33; 33, block; 33, 34; 33, 44; 34, expression_statement; 34, 35; 35, assignment; 35, 36; 35, 37; 36, identifier:call_obj; 37, attribute; 37, 38; 37, 43; 38, subscript; 38, 39; 38, 42; 39, attribute; 39, 40; 39, 41; 40, identifier:mod_obj; 41, identifier:body; 42, integer:0; 43, identifier:value; 44, if_statement; 44, 45; 44, 52; 44, 67; 44, 174; 45, call; 45, 46; 45, 47; 46, identifier:isinstance; 47, argument_list; 47, 48; 47, 49; 48, identifier:call_obj; 49, attribute; 49, 50; 49, 51; 50, identifier:ast; 51, identifier:Attribute; 52, block; 52, 53; 52, 61; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 56; 55, identifier:module; 56, attribute; 56, 57; 56, 60; 57, attribute; 57, 58; 57, 59; 58, identifier:call_obj; 59, identifier:value; 60, identifier:id; 61, expression_statement; 61, 62; 62, assignment; 62, 63; 62, 64; 63, identifier:func; 64, attribute; 64, 65; 64, 66; 65, identifier:call_obj; 66, identifier:attr; 67, elif_clause; 67, 68; 67, 75; 68, call; 68, 69; 68, 70; 69, identifier:isinstance; 70, argument_list; 70, 71; 70, 72; 71, identifier:call_obj; 72, attribute; 72, 73; 72, 74; 73, identifier:ast; 74, identifier:Call; 75, block; 75, 76; 76, try_statement; 76, 77; 76, 96; 76, 104; 77, block; 77, 78; 77, 88; 78, expression_statement; 78, 79; 79, assignment; 79, 80; 79, 81; 80, identifier:module; 81, attribute; 81, 82; 81, 87; 82, attribute; 82, 83; 82, 86; 83, attribute; 83, 84; 83, 85; 84, identifier:call_obj; 85, identifier:func; 86, identifier:value; 87, identifier:id; 88, expression_statement; 88, 89; 89, assignment; 89, 90; 89, 91; 90, identifier:func; 91, attribute; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:call_obj; 94, identifier:func; 95, identifier:attr; 96, except_clause; 96, 97; 96, 98; 97, identifier:AttributeError; 98, block; 98, 99; 99, raise_statement; 99, 100; 100, call; 100, 101; 100, 102; 101, identifier:UnsupportedActionError; 102, argument_list; 102, 103; 103, identifier:action_str; 104, else_clause; 104, 105; 105, block; 105, 106; 106, for_statement; 106, 107; 106, 108; 106, 111; 107, identifier:kwarg; 108, attribute; 108, 109; 108, 110; 109, identifier:call_obj; 110, identifier:keywords; 111, block; 111, 112; 112, if_statement; 112, 113; 112, 122; 112, 139; 112, 166; 113, call; 113, 114; 113, 115; 114, identifier:isinstance; 115, argument_list; 115, 116; 115, 119; 116, attribute; 116, 117; 116, 118; 117, identifier:kwarg; 118, identifier:value; 119, attribute; 119, 120; 119, 121; 120, identifier:ast; 121, identifier:Num; 122, block; 122, 123; 123, expression_statement; 123, 124; 124, call; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:args; 127, identifier:update; 128, argument_list; 128, 129; 129, dictionary; 129, 130; 130, pair; 130, 131; 130, 134; 131, attribute; 131, 132; 131, 133; 132, identifier:kwarg; 133, identifier:arg; 134, attribute; 134, 135; 134, 138; 135, attribute; 135, 136; 135, 137; 136, identifier:kwarg; 137, identifier:value; 138, identifier:n; 139, elif_clause; 139, 140; 139, 149; 140, call; 140, 141; 140, 142; 141, identifier:isinstance; 142, argument_list; 142, 143; 142, 146; 143, attribute; 143, 144; 143, 145; 144, identifier:kwarg; 145, identifier:value; 146, attribute; 146, 147; 146, 148; 147, identifier:ast; 148, identifier:Str; 149, block; 149, 150; 150, expression_statement; 150, 151; 151, call; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:args; 154, identifier:update; 155, argument_list; 155, 156; 156, dictionary; 156, 157; 157, pair; 157, 158; 157, 161; 158, attribute; 158, 159; 158, 160; 159, identifier:kwarg; 160, identifier:arg; 161, attribute; 161, 162; 161, 165; 162, attribute; 162, 163; 162, 164; 163, identifier:kwarg; 164, identifier:value; 165, identifier:s; 166, else_clause; 166, 167; 167, block; 167, 168; 168, raise_statement; 168, 169; 169, call; 169, 170; 169, 171; 170, identifier:UnsupportedActionArgumentError; 171, argument_list; 171, 172; 171, 173; 172, identifier:action_str; 173, identifier:kwarg; 174, else_clause; 174, 175; 175, block; 175, 176; 176, raise_statement; 176, 177; 177, call; 177, 178; 177, 179; 178, identifier:UnsupportedActionError; 179, argument_list; 179, 180; 180, identifier:action_str; 181, return_statement; 181, 182; 182, call; 182, 183; 182, 184; 183, identifier:cls; 184, argument_list; 184, 185; 184, 186; 184, 187; 185, identifier:module; 186, identifier:func; 187, identifier:args
def from_string(cls, action_str): args = {} try: mod_obj = ast.parse(action_str) except (SyntaxError, ValueError) as e: raise e else: call_obj = mod_obj.body[0].value if isinstance(call_obj, ast.Attribute): module = call_obj.value.id func = call_obj.attr elif isinstance(call_obj, ast.Call): try: module = call_obj.func.value.id func = call_obj.func.attr except AttributeError: raise UnsupportedActionError(action_str) else: for kwarg in call_obj.keywords: if isinstance(kwarg.value, ast.Num): args.update({kwarg.arg: kwarg.value.n}) elif isinstance(kwarg.value, ast.Str): args.update({kwarg.arg: kwarg.value.s}) else: raise UnsupportedActionArgumentError(action_str, kwarg) else: raise UnsupportedActionError(action_str) return cls(module, func, args)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:epcrparsethreads; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 11; 5, 53; 6, import_from_statement; 6, 7; 6, 9; 7, dotted_name; 7, 8; 8, identifier:Bio; 9, dotted_name; 9, 10; 10, identifier:SeqIO; 11, for_statement; 11, 12; 11, 13; 11, 16; 12, identifier:sample; 13, attribute; 13, 14; 13, 15; 14, identifier:self; 15, identifier:metadata; 16, block; 16, 17; 17, if_statement; 17, 18; 17, 25; 18, comparison_operator:!=; 18, 19; 18, 24; 19, attribute; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:sample; 22, identifier:general; 23, identifier:bestassemblyfile; 24, string:'NA'; 25, block; 25, 26; 25, 40; 25, 47; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:threads; 29, call; 29, 30; 29, 31; 30, identifier:Thread; 31, argument_list; 31, 32; 31, 37; 32, keyword_argument; 32, 33; 32, 34; 33, identifier:target; 34, attribute; 34, 35; 34, 36; 35, identifier:self; 36, identifier:epcrparse; 37, keyword_argument; 37, 38; 37, 39; 38, identifier:args; 39, tuple; 40, expression_statement; 40, 41; 41, call; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:threads; 44, identifier:setDaemon; 45, argument_list; 45, 46; 46, True; 47, expression_statement; 47, 48; 48, call; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, identifier:threads; 51, identifier:start; 52, argument_list; 53, for_statement; 53, 54; 53, 55; 53, 58; 54, identifier:sample; 55, attribute; 55, 56; 55, 57; 56, identifier:self; 57, identifier:metadata; 58, block; 58, 59; 59, if_statement; 59, 60; 59, 67; 60, comparison_operator:!=; 60, 61; 60, 66; 61, attribute; 61, 62; 61, 65; 62, attribute; 62, 63; 62, 64; 63, identifier:sample; 64, identifier:general; 65, identifier:bestassemblyfile; 66, string:'NA'; 67, block; 67, 68; 68, if_statement; 68, 69; 68, 78; 69, comparison_operator:!=; 69, 70; 69, 77; 70, attribute; 70, 71; 70, 76; 71, subscript; 71, 72; 71, 73; 72, identifier:sample; 73, attribute; 73, 74; 73, 75; 74, identifier:self; 75, identifier:analysistype; 76, identifier:primers; 77, string:'NA'; 78, block; 78, 79; 78, 85; 78, 97; 78, 109; 78, 136; 79, expression_statement; 79, 80; 80, assignment; 80, 81; 80, 82; 81, identifier:record; 82, call; 82, 83; 82, 84; 83, identifier:dict; 84, argument_list; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 94; 87, attribute; 87, 88; 87, 93; 88, subscript; 88, 89; 88, 90; 89, identifier:sample; 90, attribute; 90, 91; 90, 92; 91, identifier:self; 92, identifier:analysistype; 93, identifier:blastresults; 94, call; 94, 95; 94, 96; 95, identifier:dict; 96, argument_list; 97, expression_statement; 97, 98; 98, assignment; 98, 99; 98, 106; 99, attribute; 99, 100; 99, 105; 100, subscript; 100, 101; 100, 102; 101, identifier:sample; 102, attribute; 102, 103; 102, 104; 103, identifier:self; 104, identifier:analysistype; 105, identifier:rawblastresults; 106, call; 106, 107; 106, 108; 107, identifier:dict; 108, argument_list; 109, for_statement; 109, 110; 109, 111; 109, 122; 110, identifier:rec; 111, call; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, identifier:SeqIO; 114, identifier:parse; 115, argument_list; 115, 116; 115, 121; 116, attribute; 116, 117; 116, 120; 117, attribute; 117, 118; 117, 119; 118, identifier:sample; 119, identifier:general; 120, identifier:bestassemblyfile; 121, string:'fasta'; 122, block; 122, 123; 123, expression_statement; 123, 124; 124, assignment; 124, 125; 124, 130; 125, subscript; 125, 126; 125, 127; 126, identifier:record; 127, attribute; 127, 128; 127, 129; 128, identifier:rec; 129, identifier:id; 130, call; 130, 131; 130, 132; 131, identifier:str; 132, argument_list; 132, 133; 133, attribute; 133, 134; 133, 135; 134, identifier:rec; 135, identifier:seq; 136, for_statement; 136, 137; 136, 138; 136, 145; 136, 168; 137, identifier:line; 138, attribute; 138, 139; 138, 144; 139, subscript; 139, 140; 139, 141; 140, identifier:sample; 141, attribute; 141, 142; 141, 143; 142, identifier:self; 143, identifier:analysistype; 144, identifier:epcrresults; 145, ERROR; 145, 146; 145, 149; 145, 161; 146, attribute; 146, 147; 146, 148; 147, identifier:line; 148, identifier:startswith; 149, ERROR; 149, 150; 150, call; 150, 151; 150, 156; 151, attribute; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:self; 154, identifier:epcrparsequeue; 155, identifier:put; 156, argument_list; 156, 157; 157, tuple; 157, 158; 157, 159; 157, 160; 158, identifier:sample; 159, identifier:record; 160, identifier:line; 161, call; 161, 162; 161, 167; 162, attribute; 162, 163; 162, 166; 163, attribute; 163, 164; 163, 165; 164, identifier:self; 165, identifier:epcrparsequeue; 166, identifier:join; 167, argument_list; 168, block:
def epcrparsethreads(self): from Bio import SeqIO for sample in self.metadata: if sample.general.bestassemblyfile != 'NA': threads = Thread(target=self.epcrparse, args=()) threads.setDaemon(True) threads.start() for sample in self.metadata: if sample.general.bestassemblyfile != 'NA': if sample[self.analysistype].primers != 'NA': record = dict() sample[self.analysistype].blastresults = dict() sample[self.analysistype].rawblastresults = dict() for rec in SeqIO.parse(sample.general.bestassemblyfile, 'fasta'): record[rec.id] = str(rec.seq) for line in sample[self.analysistype].epcrresults: if not line.startswith(' self.epcrparsequeue.put((sample, record, line)) self.epcrparsequeue.join()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:trimquality; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 13; 5, 392; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:logging; 10, identifier:info; 11, argument_list; 11, 12; 12, string:"Trimming fastq files"; 13, with_statement; 13, 14; 13, 25; 14, with_clause; 14, 15; 15, with_item; 15, 16; 16, as_pattern; 16, 17; 16, 23; 17, call; 17, 18; 17, 19; 18, identifier:progressbar; 19, argument_list; 19, 20; 20, attribute; 20, 21; 20, 22; 21, identifier:self; 22, identifier:metadata; 23, as_pattern_target; 23, 24; 24, identifier:bar; 25, block; 25, 26; 26, for_statement; 26, 27; 26, 28; 26, 29; 27, identifier:sample; 28, identifier:bar; 29, block; 29, 30; 30, if_statement; 30, 31; 30, 41; 31, comparison_operator:is; 31, 32; 31, 40; 32, call; 32, 33; 32, 34; 33, identifier:type; 34, argument_list; 34, 35; 35, attribute; 35, 36; 35, 39; 36, attribute; 36, 37; 36, 38; 37, identifier:sample; 38, identifier:general; 39, identifier:fastqfiles; 40, identifier:list; 41, block; 41, 42; 41, 53; 41, 61; 41, 80; 41, 99; 41, 137; 41, 146; 41, 150; 41, 315; 41, 336; 41, 357; 41, 379; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:fastqfiles; 45, call; 45, 46; 45, 47; 46, identifier:sorted; 47, argument_list; 47, 48; 48, attribute; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, identifier:sample; 51, identifier:general; 52, identifier:fastqfiles; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 56; 55, identifier:outputdir; 56, attribute; 56, 57; 56, 60; 57, attribute; 57, 58; 57, 59; 58, identifier:sample; 59, identifier:general; 60, identifier:outputdirectory; 61, expression_statement; 61, 62; 62, assignment; 62, 63; 62, 64; 63, identifier:cleanforward; 64, call; 64, 65; 64, 70; 65, attribute; 65, 66; 65, 69; 66, attribute; 66, 67; 66, 68; 67, identifier:os; 68, identifier:path; 69, identifier:join; 70, argument_list; 70, 71; 70, 72; 71, identifier:outputdir; 72, call; 72, 73; 72, 76; 73, attribute; 73, 74; 73, 75; 74, string:'{}_R1_trimmed.fastq.gz'; 75, identifier:format; 76, argument_list; 76, 77; 77, attribute; 77, 78; 77, 79; 78, identifier:sample; 79, identifier:name; 80, expression_statement; 80, 81; 81, assignment; 81, 82; 81, 83; 82, identifier:cleanreverse; 83, call; 83, 84; 83, 89; 84, attribute; 84, 85; 84, 88; 85, attribute; 85, 86; 85, 87; 86, identifier:os; 87, identifier:path; 88, identifier:join; 89, argument_list; 89, 90; 89, 91; 90, identifier:outputdir; 91, call; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, string:'{}_R2_trimmed.fastq.gz'; 94, identifier:format; 95, argument_list; 95, 96; 96, attribute; 96, 97; 96, 98; 97, identifier:sample; 98, identifier:name; 99, try_statement; 99, 100; 99, 123; 100, block; 100, 101; 101, expression_statement; 101, 102; 102, assignment; 102, 103; 102, 104; 103, identifier:lesser_length; 104, call; 104, 105; 104, 106; 105, identifier:min; 106, argument_list; 106, 107; 106, 115; 107, call; 107, 108; 107, 109; 108, identifier:int; 109, argument_list; 109, 110; 110, attribute; 110, 111; 110, 114; 111, attribute; 111, 112; 111, 113; 112, identifier:sample; 113, identifier:run; 114, identifier:forwardlength; 115, call; 115, 116; 115, 117; 116, identifier:int; 117, argument_list; 117, 118; 118, attribute; 118, 119; 118, 122; 119, attribute; 119, 120; 119, 121; 120, identifier:sample; 121, identifier:run; 122, identifier:reverselength; 123, except_clause; 123, 124; 123, 125; 124, identifier:ValueError; 125, block; 125, 126; 126, expression_statement; 126, 127; 127, assignment; 127, 128; 127, 129; 128, identifier:lesser_length; 129, call; 129, 130; 129, 131; 130, identifier:int; 131, argument_list; 131, 132; 132, attribute; 132, 133; 132, 136; 133, attribute; 133, 134; 133, 135; 134, identifier:sample; 135, identifier:run; 136, identifier:forwardlength; 137, expression_statement; 137, 138; 138, assignment; 138, 139; 138, 140; 139, identifier:min_len; 140, conditional_expression:if; 140, 141; 140, 142; 140, 145; 141, integer:50; 142, comparison_operator:>=; 142, 143; 142, 144; 143, identifier:lesser_length; 144, integer:50; 145, identifier:lesser_length; 146, expression_statement; 146, 147; 147, assignment; 147, 148; 147, 149; 148, identifier:trim_left; 149, integer:0; 150, try_statement; 150, 151; 150, 292; 151, block; 151, 152; 152, if_statement; 152, 153; 152, 158; 152, 226; 153, comparison_operator:in; 153, 154; 153, 155; 154, string:'R2'; 155, subscript; 155, 156; 155, 157; 156, identifier:fastqfiles; 157, integer:0; 158, block; 158, 159; 159, if_statement; 159, 160; 159, 169; 159, 206; 160, not_operator; 160, 161; 161, call; 161, 162; 161, 167; 162, attribute; 162, 163; 162, 166; 163, attribute; 163, 164; 163, 165; 164, identifier:os; 165, identifier:path; 166, identifier:isfile; 167, argument_list; 167, 168; 168, identifier:cleanreverse; 169, block; 169, 170; 170, expression_statement; 170, 171; 171, assignment; 171, 172; 171, 178; 172, pattern_list; 172, 173; 172, 174; 172, 175; 172, 176; 172, 177; 173, identifier:out; 174, line_continuation:\; 175, identifier:err; 176, line_continuation:\; 177, identifier:bbdukcall; 178, call; 178, 179; 178, 182; 179, attribute; 179, 180; 179, 181; 180, identifier:bbtools; 181, identifier:bbduk_trim; 182, argument_list; 182, 183; 182, 188; 182, 191; 182, 194; 182, 197; 182, 200; 182, 203; 183, keyword_argument; 183, 184; 183, 185; 184, identifier:forward_in; 185, subscript; 185, 186; 185, 187; 186, identifier:fastqfiles; 187, integer:0; 188, keyword_argument; 188, 189; 188, 190; 189, identifier:reverse_in; 190, None; 191, keyword_argument; 191, 192; 191, 193; 192, identifier:forward_out; 193, identifier:cleanreverse; 194, keyword_argument; 194, 195; 194, 196; 195, identifier:trimq; 196, integer:10; 197, keyword_argument; 197, 198; 197, 199; 198, identifier:minlength; 199, identifier:min_len; 200, keyword_argument; 200, 201; 200, 202; 201, identifier:forcetrimleft; 202, identifier:trim_left; 203, keyword_argument; 203, 204; 203, 205; 204, identifier:returncmd; 205, True; 206, else_clause; 206, 207; 207, block; 207, 208; 207, 214; 207, 220; 208, expression_statement; 208, 209; 209, assignment; 209, 210; 209, 211; 210, identifier:bbdukcall; 211, call; 211, 212; 211, 213; 212, identifier:str; 213, argument_list; 214, expression_statement; 214, 215; 215, assignment; 215, 216; 215, 217; 216, identifier:out; 217, call; 217, 218; 217, 219; 218, identifier:str; 219, argument_list; 220, expression_statement; 220, 221; 221, assignment; 221, 222; 221, 223; 222, identifier:err; 223, call; 223, 224; 223, 225; 224, identifier:str; 225, argument_list; 226, else_clause; 226, 227; 227, block; 227, 228; 228, if_statement; 228, 229; 228, 238; 228, 272; 229, not_operator; 229, 230; 230, call; 230, 231; 230, 236; 231, attribute; 231, 232; 231, 235; 232, attribute; 232, 233; 232, 234; 233, identifier:os; 234, identifier:path; 235, identifier:isfile; 236, argument_list; 236, 237; 237, identifier:cleanforward; 238, block; 238, 239; 239, expression_statement; 239, 240; 240, assignment; 240, 241; 240, 247; 241, pattern_list; 241, 242; 241, 243; 241, 244; 241, 245; 241, 246; 242, identifier:out; 243, line_continuation:\; 244, identifier:err; 245, line_continuation:\; 246, identifier:bbdukcall; 247, call; 247, 248; 247, 251; 248, attribute; 248, 249; 248, 250; 249, identifier:bbtools; 250, identifier:bbduk_trim; 251, argument_list; 251, 252; 251, 257; 251, 260; 251, 263; 251, 266; 251, 269; 252, keyword_argument; 252, 253; 252, 254; 253, identifier:forward_in; 254, subscript; 254, 255; 254, 256; 255, identifier:fastqfiles; 256, integer:0; 257, keyword_argument; 257, 258; 257, 259; 258, identifier:forward_out; 259, identifier:cleanforward; 260, keyword_argument; 260, 261; 260, 262; 261, identifier:trimq; 262, integer:10; 263, keyword_argument; 263, 264; 263, 265; 264, identifier:minlength; 265, identifier:min_len; 266, keyword_argument; 266, 267; 266, 268; 267, identifier:forcetrimleft; 268, identifier:trim_left; 269, keyword_argument; 269, 270; 269, 271; 270, identifier:returncmd; 271, True; 272, else_clause; 272, 273; 273, block; 273, 274; 273, 280; 273, 286; 274, expression_statement; 274, 275; 275, assignment; 275, 276; 275, 277; 276, identifier:bbdukcall; 277, call; 277, 278; 277, 279; 278, identifier:str; 279, argument_list; 280, expression_statement; 280, 281; 281, assignment; 281, 282; 281, 283; 282, identifier:out; 283, call; 283, 284; 283, 285; 284, identifier:str; 285, argument_list; 286, expression_statement; 286, 287; 287, assignment; 287, 288; 287, 289; 288, identifier:err; 289, call; 289, 290; 289, 291; 290, identifier:str; 291, argument_list; 292, except_clause; 292, 293; 292, 296; 293, tuple; 293, 294; 293, 295; 294, identifier:IndexError; 295, identifier:CalledProcessError; 296, block; 296, 297; 296, 303; 296, 309; 297, expression_statement; 297, 298; 298, assignment; 298, 299; 298, 300; 299, identifier:bbdukcall; 300, call; 300, 301; 300, 302; 301, identifier:str; 302, argument_list; 303, expression_statement; 303, 304; 304, assignment; 304, 305; 304, 306; 305, identifier:out; 306, call; 306, 307; 306, 308; 307, identifier:str; 308, argument_list; 309, expression_statement; 309, 310; 310, assignment; 310, 311; 310, 312; 311, identifier:err; 312, call; 312, 313; 312, 314; 313, identifier:str; 314, argument_list; 315, expression_statement; 315, 316; 316, call; 316, 317; 316, 318; 317, identifier:write_to_logfile; 318, argument_list; 318, 319; 318, 320; 318, 321; 318, 324; 318, 329; 318, 334; 318, 335; 319, identifier:bbdukcall; 320, identifier:bbdukcall; 321, attribute; 321, 322; 321, 323; 322, identifier:self; 323, identifier:logfile; 324, attribute; 324, 325; 324, 328; 325, attribute; 325, 326; 325, 327; 326, identifier:sample; 327, identifier:general; 328, identifier:logout; 329, attribute; 329, 330; 329, 333; 330, attribute; 330, 331; 330, 332; 331, identifier:sample; 332, identifier:general; 333, identifier:logerr; 334, None; 335, None; 336, expression_statement; 336, 337; 337, call; 337, 338; 337, 339; 338, identifier:write_to_logfile; 339, argument_list; 339, 340; 339, 341; 339, 342; 339, 345; 339, 350; 339, 355; 339, 356; 340, identifier:out; 341, identifier:err; 342, attribute; 342, 343; 342, 344; 343, identifier:self; 344, identifier:logfile; 345, attribute; 345, 346; 345, 349; 346, attribute; 346, 347; 346, 348; 347, identifier:sample; 348, identifier:general; 349, identifier:logout; 350, attribute; 350, 351; 350, 354; 351, attribute; 351, 352; 351, 353; 352, identifier:sample; 353, identifier:general; 354, identifier:logerr; 355, None; 356, None; 357, expression_statement; 357, 358; 358, assignment; 358, 359; 358, 360; 359, identifier:trimmedfastqfiles; 360, call; 360, 361; 360, 362; 361, identifier:sorted; 362, argument_list; 362, 363; 363, call; 363, 364; 363, 365; 364, identifier:glob; 365, argument_list; 365, 366; 366, call; 366, 367; 366, 372; 367, attribute; 367, 368; 367, 371; 368, attribute; 368, 369; 368, 370; 369, identifier:os; 370, identifier:path; 371, identifier:join; 372, argument_list; 372, 373; 372, 378; 373, attribute; 373, 374; 373, 377; 374, attribute; 374, 375; 374, 376; 375, identifier:sample; 376, identifier:general; 377, identifier:outputdirectory; 378, string:'*trimmed.fastq.gz'; 379, expression_statement; 379, 380; 380, assignment; 380, 381; 380, 386; 381, attribute; 381, 382; 381, 385; 382, attribute; 382, 383; 382, 384; 383, identifier:sample; 384, identifier:general; 385, identifier:trimmedfastqfiles; 386, conditional_expression:if; 386, 387; 386, 388; 386, 389; 387, identifier:trimmedfastqfiles; 388, identifier:trimmedfastqfiles; 389, call; 389, 390; 389, 391; 390, identifier:list; 391, argument_list; 392, expression_statement; 392, 393; 393, call; 393, 394; 393, 397; 394, attribute; 394, 395; 394, 396; 395, identifier:logging; 396, identifier:info; 397, argument_list; 397, 398; 398, string:'Fastq files trimmed'
def trimquality(self): logging.info("Trimming fastq files") with progressbar(self.metadata) as bar: for sample in bar: if type(sample.general.fastqfiles) is list: fastqfiles = sorted(sample.general.fastqfiles) outputdir = sample.general.outputdirectory cleanforward = os.path.join(outputdir, '{}_R1_trimmed.fastq.gz'.format(sample.name)) cleanreverse = os.path.join(outputdir, '{}_R2_trimmed.fastq.gz'.format(sample.name)) try: lesser_length = min(int(sample.run.forwardlength), int(sample.run.reverselength)) except ValueError: lesser_length = int(sample.run.forwardlength) min_len = 50 if lesser_length >= 50 else lesser_length trim_left = 0 try: if 'R2' in fastqfiles[0]: if not os.path.isfile(cleanreverse): out, \ err, \ bbdukcall = bbtools.bbduk_trim(forward_in=fastqfiles[0], reverse_in=None, forward_out=cleanreverse, trimq=10, minlength=min_len, forcetrimleft=trim_left, returncmd=True) else: bbdukcall = str() out = str() err = str() else: if not os.path.isfile(cleanforward): out, \ err, \ bbdukcall = bbtools.bbduk_trim(forward_in=fastqfiles[0], forward_out=cleanforward, trimq=10, minlength=min_len, forcetrimleft=trim_left, returncmd=True) else: bbdukcall = str() out = str() err = str() except (IndexError, CalledProcessError): bbdukcall = str() out = str() err = str() write_to_logfile(bbdukcall, bbdukcall, self.logfile, sample.general.logout, sample.general.logerr, None, None) write_to_logfile(out, err, self.logfile, sample.general.logout, sample.general.logerr, None, None) trimmedfastqfiles = sorted(glob(os.path.join(sample.general.outputdirectory, '*trimmed.fastq.gz'))) sample.general.trimmedfastqfiles = trimmedfastqfiles if trimmedfastqfiles else list() logging.info('Fastq files trimmed')
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:contamination_finder; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:input_path; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:report_path; 10, None; 11, block; 11, 12; 11, 19; 11, 36; 11, 59; 11, 72; 11, 84; 11, 192; 11, 210; 11, 395; 12, expression_statement; 12, 13; 13, call; 13, 14; 13, 17; 14, attribute; 14, 15; 14, 16; 15, identifier:logging; 16, identifier:info; 17, argument_list; 17, 18; 18, string:'Calculating contamination in reads'; 19, if_statement; 19, 20; 19, 23; 19, 28; 20, comparison_operator:is; 20, 21; 20, 22; 21, identifier:input_path; 22, None; 23, block; 23, 24; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 27; 26, identifier:input_dir; 27, identifier:input_path; 28, else_clause; 28, 29; 29, block; 29, 30; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 33; 32, identifier:input_dir; 33, attribute; 33, 34; 33, 35; 34, identifier:self; 35, identifier:path; 36, if_statement; 36, 37; 36, 40; 36, 45; 37, comparison_operator:is; 37, 38; 37, 39; 38, identifier:report_path; 39, None; 40, block; 40, 41; 41, expression_statement; 41, 42; 42, assignment; 42, 43; 42, 44; 43, identifier:reportpath; 44, identifier:report_path; 45, else_clause; 45, 46; 46, block; 46, 47; 47, expression_statement; 47, 48; 48, assignment; 48, 49; 48, 50; 49, identifier:reportpath; 50, call; 50, 51; 50, 56; 51, attribute; 51, 52; 51, 55; 52, attribute; 52, 53; 52, 54; 53, identifier:os; 54, identifier:path; 55, identifier:join; 56, argument_list; 56, 57; 56, 58; 57, identifier:input_dir; 58, string:'confindr'; 59, expression_statement; 59, 60; 60, assignment; 60, 61; 60, 62; 61, identifier:confindr_report; 62, call; 62, 63; 62, 68; 63, attribute; 63, 64; 63, 67; 64, attribute; 64, 65; 64, 66; 65, identifier:os; 66, identifier:path; 67, identifier:join; 68, argument_list; 68, 69; 68, 70; 68, 71; 69, identifier:input_dir; 70, string:'confindr'; 71, string:'confindr_report.csv'; 72, expression_statement; 72, 73; 73, assignment; 73, 74; 73, 75; 74, identifier:pipeline_report; 75, call; 75, 76; 75, 81; 76, attribute; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, identifier:os; 79, identifier:path; 80, identifier:join; 81, argument_list; 81, 82; 81, 83; 82, identifier:reportpath; 83, string:'confindr_report.csv'; 84, if_statement; 84, 85; 84, 94; 85, not_operator; 85, 86; 86, call; 86, 87; 86, 92; 87, attribute; 87, 88; 87, 91; 88, attribute; 88, 89; 88, 90; 89, identifier:os; 90, identifier:path; 91, identifier:isfile; 92, argument_list; 92, 93; 93, identifier:confindr_report; 94, block; 94, 95; 94, 108; 94, 113; 94, 150; 94, 159; 94, 172; 94, 185; 95, try_statement; 95, 96; 95, 104; 96, block; 96, 97; 97, expression_statement; 97, 98; 98, call; 98, 99; 98, 102; 99, attribute; 99, 100; 99, 101; 100, identifier:shutil; 101, identifier:rmtree; 102, argument_list; 102, 103; 103, identifier:reportpath; 104, except_clause; 104, 105; 104, 106; 105, identifier:IOError; 106, block; 106, 107; 107, pass_statement; 108, expression_statement; 108, 109; 109, call; 109, 110; 109, 111; 110, identifier:make_path; 111, argument_list; 111, 112; 112, identifier:reportpath; 113, expression_statement; 113, 114; 114, assignment; 114, 115; 114, 116; 115, identifier:systemcall; 116, call; 116, 117; 116, 121; 117, attribute; 117, 118; 117, 119; 117, 120; 118, string:'confindr.py -i {input_dir} -o {output_dir} -d {database_dir} -bf 0.05'; 119, line_continuation:\; 120, identifier:format; 121, argument_list; 121, 122; 121, 125; 121, 136; 122, keyword_argument; 122, 123; 122, 124; 123, identifier:input_dir; 124, identifier:input_dir; 125, keyword_argument; 125, 126; 125, 127; 126, identifier:output_dir; 127, call; 127, 128; 127, 133; 128, attribute; 128, 129; 128, 132; 129, attribute; 129, 130; 129, 131; 130, identifier:os; 131, identifier:path; 132, identifier:join; 133, argument_list; 133, 134; 133, 135; 134, identifier:input_dir; 135, string:'confindr'; 136, keyword_argument; 136, 137; 136, 138; 137, identifier:database_dir; 138, call; 138, 139; 138, 144; 139, attribute; 139, 140; 139, 143; 140, attribute; 140, 141; 140, 142; 141, identifier:os; 142, identifier:path; 143, identifier:join; 144, argument_list; 144, 145; 144, 148; 144, 149; 145, attribute; 145, 146; 145, 147; 146, identifier:self; 147, identifier:reffilepath; 148, string:'ConFindr'; 149, string:'databases'; 150, expression_statement; 150, 151; 151, assignment; 151, 152; 151, 155; 152, pattern_list; 152, 153; 152, 154; 153, identifier:out; 154, identifier:err; 155, call; 155, 156; 155, 157; 156, identifier:run_subprocess; 157, argument_list; 157, 158; 158, identifier:systemcall; 159, expression_statement; 159, 160; 160, call; 160, 161; 160, 162; 161, identifier:write_to_logfile; 162, argument_list; 162, 163; 162, 164; 162, 165; 162, 168; 162, 169; 162, 170; 162, 171; 163, identifier:systemcall; 164, identifier:systemcall; 165, attribute; 165, 166; 165, 167; 166, identifier:self; 167, identifier:logfile; 168, None; 169, None; 170, None; 171, None; 172, expression_statement; 172, 173; 173, call; 173, 174; 173, 175; 174, identifier:write_to_logfile; 175, argument_list; 175, 176; 175, 177; 175, 178; 175, 181; 175, 182; 175, 183; 175, 184; 176, identifier:out; 177, identifier:err; 178, attribute; 178, 179; 178, 180; 179, identifier:self; 180, identifier:logfile; 181, None; 182, None; 183, None; 184, None; 185, expression_statement; 185, 186; 186, call; 186, 187; 186, 190; 187, attribute; 187, 188; 187, 189; 188, identifier:logging; 189, identifier:info; 190, argument_list; 190, 191; 191, string:'Contamination detection complete!'; 192, expression_statement; 192, 193; 193, assignment; 193, 194; 193, 195; 194, identifier:confindr_results; 195, call; 195, 196; 195, 209; 196, attribute; 196, 197; 196, 208; 197, attribute; 197, 198; 197, 207; 198, call; 198, 199; 198, 202; 199, attribute; 199, 200; 199, 201; 200, identifier:pandas; 201, identifier:read_csv; 202, argument_list; 202, 203; 202, 204; 203, identifier:confindr_report; 204, keyword_argument; 204, 205; 204, 206; 205, identifier:index_col; 206, integer:0; 207, identifier:T; 208, identifier:to_dict; 209, argument_list; 210, for_statement; 210, 211; 210, 212; 210, 215; 211, identifier:sample; 212, attribute; 212, 213; 212, 214; 213, identifier:self; 214, identifier:metadata; 215, block; 215, 216; 215, 224; 216, expression_statement; 216, 217; 217, assignment; 217, 218; 217, 221; 218, attribute; 218, 219; 218, 220; 219, identifier:sample; 220, identifier:confindr; 221, call; 221, 222; 221, 223; 222, identifier:GenObject; 223, argument_list; 224, for_statement; 224, 225; 224, 226; 224, 227; 225, identifier:line; 226, identifier:confindr_results; 227, block; 227, 228; 228, if_statement; 228, 229; 228, 234; 229, comparison_operator:in; 229, 230; 229, 233; 230, attribute; 230, 231; 230, 232; 231, identifier:sample; 232, identifier:name; 233, identifier:line; 234, block; 234, 235; 234, 260; 234, 272; 234, 284; 234, 322; 234, 361; 235, expression_statement; 235, 236; 236, assignment; 236, 237; 236, 242; 237, attribute; 237, 238; 237, 241; 238, attribute; 238, 239; 238, 240; 239, identifier:sample; 240, identifier:confindr; 241, identifier:genus; 242, conditional_expression:if; 242, 243; 242, 248; 242, 259; 243, subscript; 243, 244; 243, 247; 244, subscript; 244, 245; 244, 246; 245, identifier:confindr_results; 246, identifier:line; 247, string:'Genus'; 248, comparison_operator:is; 248, 249; 248, 257; 248, 258; 249, call; 249, 250; 249, 251; 250, identifier:type; 251, argument_list; 251, 252; 252, subscript; 252, 253; 252, 256; 253, subscript; 253, 254; 253, 255; 254, identifier:confindr_results; 255, identifier:line; 256, string:'Genus'; 257, line_continuation:\; 258, identifier:float; 259, string:'ND'; 260, expression_statement; 260, 261; 261, assignment; 261, 262; 261, 267; 262, attribute; 262, 263; 262, 266; 263, attribute; 263, 264; 263, 265; 264, identifier:sample; 265, identifier:confindr; 266, identifier:num_contaminated_snvs; 267, subscript; 267, 268; 267, 271; 268, subscript; 268, 269; 268, 270; 269, identifier:confindr_results; 270, identifier:line; 271, string:'NumContamSNVs'; 272, expression_statement; 272, 273; 273, assignment; 273, 274; 273, 279; 274, attribute; 274, 275; 274, 278; 275, attribute; 275, 276; 275, 277; 276, identifier:sample; 277, identifier:confindr; 278, identifier:contam_status; 279, subscript; 279, 280; 279, 283; 280, subscript; 280, 281; 280, 282; 281, identifier:confindr_results; 282, identifier:line; 283, string:'ContamStatus'; 284, try_statement; 284, 285; 284, 311; 285, block; 285, 286; 286, expression_statement; 286, 287; 287, assignment; 287, 288; 287, 293; 288, attribute; 288, 289; 288, 292; 289, attribute; 289, 290; 289, 291; 290, identifier:sample; 291, identifier:confindr; 292, identifier:percent_contam; 293, conditional_expression:if; 293, 294; 293, 299; 293, 300; 293, 310; 294, subscript; 294, 295; 294, 298; 295, subscript; 295, 296; 295, 297; 296, identifier:confindr_results; 297, identifier:line; 298, string:'PercentContam'; 299, line_continuation:\; 300, comparison_operator:!=; 300, 301; 300, 309; 301, call; 301, 302; 301, 303; 302, identifier:str; 303, argument_list; 303, 304; 304, subscript; 304, 305; 304, 308; 305, subscript; 305, 306; 305, 307; 306, identifier:confindr_results; 307, identifier:line; 308, string:'PercentContam'; 309, string:'nan'; 310, integer:0; 311, except_clause; 311, 312; 311, 313; 312, identifier:KeyError; 313, block; 313, 314; 314, expression_statement; 314, 315; 315, assignment; 315, 316; 315, 321; 316, attribute; 316, 317; 316, 320; 317, attribute; 317, 318; 317, 319; 318, identifier:sample; 319, identifier:confindr; 320, identifier:percent_contam; 321, string:'ND'; 322, try_statement; 322, 323; 322, 350; 323, block; 323, 324; 324, expression_statement; 324, 325; 325, assignment; 325, 326; 325, 331; 325, 332; 326, attribute; 326, 327; 326, 330; 327, attribute; 327, 328; 327, 329; 328, identifier:sample; 329, identifier:confindr; 330, identifier:percent_contam_std; 331, line_continuation:\; 332, conditional_expression:if; 332, 333; 332, 338; 332, 339; 332, 349; 333, subscript; 333, 334; 333, 337; 334, subscript; 334, 335; 334, 336; 335, identifier:confindr_results; 336, identifier:line; 337, string:'PercentContamStandardDeviation'; 338, line_continuation:\; 339, comparison_operator:!=; 339, 340; 339, 348; 340, call; 340, 341; 340, 342; 341, identifier:str; 342, argument_list; 342, 343; 343, subscript; 343, 344; 343, 347; 344, subscript; 344, 345; 344, 346; 345, identifier:confindr_results; 346, identifier:line; 347, string:'PercentContamStandardDeviation'; 348, string:'nan'; 349, integer:0; 350, except_clause; 350, 351; 350, 352; 351, identifier:KeyError; 352, block; 352, 353; 353, expression_statement; 353, 354; 354, assignment; 354, 355; 354, 360; 355, attribute; 355, 356; 355, 359; 356, attribute; 356, 357; 356, 358; 357, identifier:sample; 358, identifier:confindr; 359, identifier:percent_contam_std; 360, string:'ND'; 361, if_statement; 361, 362; 361, 369; 361, 378; 362, comparison_operator:is; 362, 363; 362, 368; 363, attribute; 363, 364; 363, 367; 364, attribute; 364, 365; 364, 366; 365, identifier:sample; 366, identifier:confindr; 367, identifier:contam_status; 368, True; 369, block; 369, 370; 370, expression_statement; 370, 371; 371, assignment; 371, 372; 371, 377; 372, attribute; 372, 373; 372, 376; 373, attribute; 373, 374; 373, 375; 374, identifier:sample; 375, identifier:confindr; 376, identifier:contam_status; 377, string:'Contaminated'; 378, elif_clause; 378, 379; 378, 386; 379, comparison_operator:is; 379, 380; 379, 385; 380, attribute; 380, 381; 380, 384; 381, attribute; 381, 382; 381, 383; 382, identifier:sample; 383, identifier:confindr; 384, identifier:contam_status; 385, False; 386, block; 386, 387; 387, expression_statement; 387, 388; 388, assignment; 388, 389; 388, 394; 389, attribute; 389, 390; 389, 393; 390, attribute; 390, 391; 390, 392; 391, identifier:sample; 392, identifier:confindr; 393, identifier:contam_status; 394, string:'Clean'; 395, with_statement; 395, 396; 395, 406; 396, with_clause; 396, 397; 397, with_item; 397, 398; 398, as_pattern; 398, 399; 398, 404; 399, call; 399, 400; 399, 401; 400, identifier:open; 401, argument_list; 401, 402; 401, 403; 402, identifier:pipeline_report; 403, string:'w'; 404, as_pattern_target; 404, 405; 405, identifier:csv; 406, block; 406, 407; 406, 411; 406, 465; 407, expression_statement; 407, 408; 408, assignment; 408, 409; 408, 410; 409, identifier:data; 410, string:'Strain,Genus,NumContamSNVs,ContamStatus,PercentContam,PercentContamSTD\n'; 411, for_statement; 411, 412; 411, 413; 411, 416; 412, identifier:sample; 413, attribute; 413, 414; 413, 415; 414, identifier:self; 415, identifier:metadata; 416, block; 416, 417; 417, expression_statement; 417, 418; 418, augmented_assignment:+=; 418, 419; 418, 420; 419, identifier:data; 420, call; 420, 421; 420, 424; 421, attribute; 421, 422; 421, 423; 422, string:'{str},{genus},{numcontamsnv},{status},{pc},{pcs}\n'; 423, identifier:format; 424, argument_list; 424, 425; 424, 430; 424, 437; 424, 444; 424, 451; 424, 458; 425, keyword_argument; 425, 426; 425, 427; 426, identifier:str; 427, attribute; 427, 428; 427, 429; 428, identifier:sample; 429, identifier:name; 430, keyword_argument; 430, 431; 430, 432; 431, identifier:genus; 432, attribute; 432, 433; 432, 436; 433, attribute; 433, 434; 433, 435; 434, identifier:sample; 435, identifier:confindr; 436, identifier:genus; 437, keyword_argument; 437, 438; 437, 439; 438, identifier:numcontamsnv; 439, attribute; 439, 440; 439, 443; 440, attribute; 440, 441; 440, 442; 441, identifier:sample; 442, identifier:confindr; 443, identifier:num_contaminated_snvs; 444, keyword_argument; 444, 445; 444, 446; 445, identifier:status; 446, attribute; 446, 447; 446, 450; 447, attribute; 447, 448; 447, 449; 448, identifier:sample; 449, identifier:confindr; 450, identifier:contam_status; 451, keyword_argument; 451, 452; 451, 453; 452, identifier:pc; 453, attribute; 453, 454; 453, 457; 454, attribute; 454, 455; 454, 456; 455, identifier:sample; 456, identifier:confindr; 457, identifier:percent_contam; 458, keyword_argument; 458, 459; 458, 460; 459, identifier:pcs; 460, attribute; 460, 461; 460, 464; 461, attribute; 461, 462; 461, 463; 462, identifier:sample; 463, identifier:confindr; 464, identifier:percent_contam_std; 465, expression_statement; 465, 466; 466, call; 466, 467; 466, 470; 467, attribute; 467, 468; 467, 469; 468, identifier:csv; 469, identifier:write; 470, argument_list; 470, 471; 471, identifier:data
def contamination_finder(self, input_path=None, report_path=None): logging.info('Calculating contamination in reads') if input_path is not None: input_dir = input_path else: input_dir = self.path if report_path is not None: reportpath = report_path else: reportpath = os.path.join(input_dir, 'confindr') confindr_report = os.path.join(input_dir, 'confindr', 'confindr_report.csv') pipeline_report = os.path.join(reportpath, 'confindr_report.csv') if not os.path.isfile(confindr_report): try: shutil.rmtree(reportpath) except IOError: pass make_path(reportpath) systemcall = 'confindr.py -i {input_dir} -o {output_dir} -d {database_dir} -bf 0.05'\ .format(input_dir=input_dir, output_dir=os.path.join(input_dir, 'confindr'), database_dir=os.path.join(self.reffilepath, 'ConFindr', 'databases')) out, err = run_subprocess(systemcall) write_to_logfile(systemcall, systemcall, self.logfile, None, None, None, None) write_to_logfile(out, err, self.logfile, None, None, None, None) logging.info('Contamination detection complete!') confindr_results = pandas.read_csv(confindr_report, index_col=0).T.to_dict() for sample in self.metadata: sample.confindr = GenObject() for line in confindr_results: if sample.name in line: sample.confindr.genus = confindr_results[line]['Genus'] if type(confindr_results[line]['Genus']) \ is not float else 'ND' sample.confindr.num_contaminated_snvs = confindr_results[line]['NumContamSNVs'] sample.confindr.contam_status = confindr_results[line]['ContamStatus'] try: sample.confindr.percent_contam = confindr_results[line]['PercentContam'] if \ str(confindr_results[line]['PercentContam']) != 'nan' else 0 except KeyError: sample.confindr.percent_contam = 'ND' try: sample.confindr.percent_contam_std = \ confindr_results[line]['PercentContamStandardDeviation'] if \ str(confindr_results[line]['PercentContamStandardDeviation']) != 'nan' else 0 except KeyError: sample.confindr.percent_contam_std = 'ND' if sample.confindr.contam_status is True: sample.confindr.contam_status = 'Contaminated' elif sample.confindr.contam_status is False: sample.confindr.contam_status = 'Clean' with open(pipeline_report, 'w') as csv: data = 'Strain,Genus,NumContamSNVs,ContamStatus,PercentContam,PercentContamSTD\n' for sample in self.metadata: data += '{str},{genus},{numcontamsnv},{status},{pc},{pcs}\n'.format( str=sample.name, genus=sample.confindr.genus, numcontamsnv=sample.confindr.num_contaminated_snvs, status=sample.confindr.contam_status, pc=sample.confindr.percent_contam, pcs=sample.confindr.percent_contam_std ) csv.write(data)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:subclass_genesis; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:genesisclass; 6, block; 6, 7; 6, 454; 6, 465; 7, class_definition; 7, 8; 7, 9; 7, 11; 8, identifier:MayaGenesisWin; 9, argument_list; 9, 10; 10, identifier:genesisclass; 11, block; 11, 12; 11, 25; 11, 46; 11, 59; 11, 80; 11, 146; 11, 187; 11, 250; 11, 312; 11, 362; 12, function_definition; 12, 13; 12, 14; 12, 17; 13, function_name:open_shot; 14, parameters; 14, 15; 14, 16; 15, identifier:self; 16, identifier:taskfile; 17, block; 17, 18; 18, return_statement; 18, 19; 19, call; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:self; 22, identifier:open_file; 23, argument_list; 23, 24; 24, identifier:taskfile; 25, function_definition; 25, 26; 25, 27; 25, 31; 26, function_name:save_shot; 27, parameters; 27, 28; 27, 29; 27, 30; 28, identifier:self; 29, identifier:jbfile; 30, identifier:tf; 31, block; 31, 32; 31, 39; 32, expression_statement; 32, 33; 33, call; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, identifier:self; 36, identifier:update_scene_node; 37, argument_list; 37, 38; 38, identifier:tf; 39, expression_statement; 39, 40; 40, call; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:self; 43, identifier:save_file; 44, argument_list; 44, 45; 45, identifier:jbfile; 46, function_definition; 46, 47; 46, 48; 46, 51; 47, function_name:open_asset; 48, parameters; 48, 49; 48, 50; 49, identifier:self; 50, identifier:taskfile; 51, block; 51, 52; 52, return_statement; 52, 53; 53, call; 53, 54; 53, 57; 54, attribute; 54, 55; 54, 56; 55, identifier:self; 56, identifier:open_file; 57, argument_list; 57, 58; 58, identifier:taskfile; 59, function_definition; 59, 60; 59, 61; 59, 65; 60, function_name:save_asset; 61, parameters; 61, 62; 61, 63; 61, 64; 62, identifier:self; 63, identifier:jbfile; 64, identifier:tf; 65, block; 65, 66; 65, 73; 66, expression_statement; 66, 67; 67, call; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, identifier:self; 70, identifier:update_scene_node; 71, argument_list; 71, 72; 72, identifier:tf; 73, expression_statement; 73, 74; 74, call; 74, 75; 74, 78; 75, attribute; 75, 76; 75, 77; 76, identifier:self; 77, identifier:save_file; 78, argument_list; 78, 79; 79, identifier:jbfile; 80, function_definition; 80, 81; 80, 82; 80, 85; 81, function_name:save_file; 82, parameters; 82, 83; 82, 84; 83, identifier:self; 84, identifier:jbfile; 85, block; 85, 86; 85, 94; 85, 105; 85, 109; 85, 122; 85, 131; 86, expression_statement; 86, 87; 87, assignment; 87, 88; 87, 89; 88, identifier:p; 89, call; 89, 90; 89, 93; 90, attribute; 90, 91; 90, 92; 91, identifier:jbfile; 92, identifier:get_fullpath; 93, argument_list; 94, expression_statement; 94, 95; 95, assignment; 95, 96; 95, 97; 96, identifier:p; 97, call; 97, 98; 97, 103; 98, attribute; 98, 99; 98, 102; 99, attribute; 99, 100; 99, 101; 100, identifier:os; 101, identifier:path; 102, identifier:expanduser; 103, argument_list; 103, 104; 104, identifier:p; 105, expression_statement; 105, 106; 106, assignment; 106, 107; 106, 108; 107, identifier:typ; 108, string:'mayaBinary'; 109, if_statement; 109, 110; 109, 117; 110, comparison_operator:==; 110, 111; 110, 116; 111, call; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, identifier:jbfile; 114, identifier:get_ext; 115, argument_list; 116, string:'ma'; 117, block; 117, 118; 118, expression_statement; 118, 119; 119, assignment; 119, 120; 119, 121; 120, identifier:typ; 121, string:'mayaAscii'; 122, expression_statement; 122, 123; 123, call; 123, 124; 123, 127; 124, attribute; 124, 125; 124, 126; 125, identifier:cmds; 126, identifier:file; 127, argument_list; 127, 128; 128, keyword_argument; 128, 129; 128, 130; 129, identifier:rename; 130, identifier:p; 131, expression_statement; 131, 132; 132, call; 132, 133; 132, 136; 133, attribute; 133, 134; 133, 135; 134, identifier:cmds; 135, identifier:file; 136, argument_list; 136, 137; 136, 140; 136, 143; 137, keyword_argument; 137, 138; 137, 139; 138, identifier:save; 139, True; 140, keyword_argument; 140, 141; 140, 142; 141, identifier:defaultExtensions; 142, False; 143, keyword_argument; 143, 144; 143, 145; 144, identifier:type; 145, identifier:typ; 146, function_definition; 146, 147; 146, 148; 146, 151; 147, function_name:open_file; 148, parameters; 148, 149; 148, 150; 149, identifier:self; 150, identifier:taskfile; 151, block; 151, 152; 151, 160; 151, 167; 151, 185; 152, expression_statement; 152, 153; 153, assignment; 153, 154; 153, 155; 154, identifier:r; 155, call; 155, 156; 155, 159; 156, attribute; 156, 157; 156, 158; 157, identifier:self; 158, identifier:check_modified; 159, argument_list; 160, if_statement; 160, 161; 160, 164; 161, comparison_operator:is; 161, 162; 161, 163; 162, identifier:r; 163, False; 164, block; 164, 165; 165, return_statement; 165, 166; 166, False; 167, expression_statement; 167, 168; 168, call; 168, 169; 168, 172; 169, attribute; 169, 170; 169, 171; 170, identifier:cmds; 171, identifier:file; 172, argument_list; 172, 173; 172, 176; 172, 179; 172, 182; 173, attribute; 173, 174; 173, 175; 174, identifier:taskfile; 175, identifier:path; 176, keyword_argument; 176, 177; 176, 178; 177, identifier:open; 178, True; 179, keyword_argument; 179, 180; 179, 181; 180, identifier:force; 181, True; 182, keyword_argument; 182, 183; 182, 184; 183, identifier:ignoreVersion; 184, True; 185, return_statement; 185, 186; 186, True; 187, function_definition; 187, 188; 187, 189; 187, 191; 188, function_name:get_current_file; 189, parameters; 189, 190; 190, identifier:self; 191, block; 191, 192; 191, 200; 191, 205; 191, 216; 192, expression_statement; 192, 193; 193, assignment; 193, 194; 193, 195; 194, identifier:node; 195, call; 195, 196; 195, 199; 196, attribute; 196, 197; 196, 198; 197, identifier:jbscene; 198, identifier:get_current_scene_node; 199, argument_list; 200, if_statement; 200, 201; 200, 203; 201, not_operator; 201, 202; 202, identifier:node; 203, block; 203, 204; 204, return_statement; 205, expression_statement; 205, 206; 206, assignment; 206, 207; 206, 208; 207, identifier:tfid; 208, call; 208, 209; 208, 212; 209, attribute; 209, 210; 209, 211; 210, identifier:cmds; 211, identifier:getAttr; 212, argument_list; 212, 213; 213, binary_operator:%; 213, 214; 213, 215; 214, string:'%s.taskfile_id'; 215, identifier:node; 216, try_statement; 216, 217; 216, 229; 217, block; 217, 218; 218, return_statement; 218, 219; 219, call; 219, 220; 219, 225; 220, attribute; 220, 221; 220, 224; 221, attribute; 221, 222; 221, 223; 222, identifier:djadapter; 223, identifier:taskfiles; 224, identifier:get; 225, argument_list; 225, 226; 226, keyword_argument; 226, 227; 226, 228; 227, identifier:id; 228, identifier:tfid; 229, except_clause; 229, 230; 229, 237; 230, attribute; 230, 231; 230, 236; 231, attribute; 231, 232; 231, 235; 232, attribute; 232, 233; 232, 234; 233, identifier:djadapter; 234, identifier:models; 235, identifier:TaskFile; 236, identifier:DoesNotExist; 237, block; 237, 238; 237, 249; 238, expression_statement; 238, 239; 239, call; 239, 240; 239, 243; 240, attribute; 240, 241; 240, 242; 241, identifier:log; 242, identifier:error; 243, argument_list; 243, 244; 244, binary_operator:%; 244, 245; 244, 246; 245, string:"No taskfile with id %s was found. Get current scene failed. Check your jb_sceneNode \'%s\'."; 246, tuple; 246, 247; 246, 248; 247, identifier:tfid; 248, identifier:node; 249, return_statement; 250, function_definition; 250, 251; 250, 252; 250, 254; 251, function_name:get_scene_node; 252, parameters; 252, 253; 253, identifier:self; 254, block; 254, 255; 254, 264; 254, 279; 254, 287; 254, 310; 255, expression_statement; 255, 256; 256, assignment; 256, 257; 256, 258; 257, identifier:scenenodes; 258, call; 258, 259; 258, 262; 259, attribute; 259, 260; 259, 261; 260, identifier:cmds; 261, identifier:ls; 262, argument_list; 262, 263; 263, string:':jb_sceneNode*'; 264, if_statement; 264, 265; 264, 271; 265, comparison_operator:>; 265, 266; 265, 270; 266, call; 266, 267; 266, 268; 267, identifier:len; 268, argument_list; 268, 269; 269, identifier:scenenodes; 270, integer:1; 271, block; 271, 272; 272, expression_statement; 272, 273; 273, call; 273, 274; 273, 277; 274, attribute; 274, 275; 274, 276; 275, identifier:cmds; 276, identifier:delete; 277, argument_list; 277, 278; 278, identifier:scenenodes; 279, expression_statement; 279, 280; 280, assignment; 280, 281; 280, 282; 281, identifier:node; 282, call; 282, 283; 282, 286; 283, attribute; 283, 284; 283, 285; 284, identifier:jbscene; 285, identifier:get_current_scene_node; 286, argument_list; 287, if_statement; 287, 288; 287, 291; 288, comparison_operator:is; 288, 289; 288, 290; 289, identifier:node; 290, None; 291, block; 291, 292; 291, 301; 292, expression_statement; 292, 293; 293, call; 293, 294; 293, 297; 294, attribute; 294, 295; 294, 296; 295, identifier:cmds; 296, identifier:namespace; 297, argument_list; 297, 298; 298, keyword_argument; 298, 299; 298, 300; 299, identifier:set; 300, string:':'; 301, expression_statement; 301, 302; 302, assignment; 302, 303; 302, 304; 303, identifier:node; 304, call; 304, 305; 304, 308; 305, attribute; 305, 306; 305, 307; 306, identifier:cmds; 307, identifier:createNode; 308, argument_list; 308, 309; 309, string:'jb_sceneNode'; 310, return_statement; 310, 311; 311, identifier:node; 312, function_definition; 312, 313; 312, 314; 312, 317; 313, function_name:update_scene_node; 314, parameters; 314, 315; 314, 316; 315, identifier:self; 316, identifier:tf; 317, block; 317, 318; 317, 326; 317, 338; 317, 350; 318, expression_statement; 318, 319; 319, assignment; 319, 320; 319, 321; 320, identifier:node; 321, call; 321, 322; 321, 325; 322, attribute; 322, 323; 322, 324; 323, identifier:self; 324, identifier:get_scene_node; 325, argument_list; 326, expression_statement; 326, 327; 327, call; 327, 328; 327, 331; 328, attribute; 328, 329; 328, 330; 329, identifier:cmds; 330, identifier:setAttr; 331, argument_list; 331, 332; 331, 335; 332, binary_operator:%; 332, 333; 332, 334; 333, string:'%s.taskfile_id'; 334, identifier:node; 335, keyword_argument; 335, 336; 335, 337; 336, identifier:lock; 337, False; 338, expression_statement; 338, 339; 339, call; 339, 340; 339, 343; 340, attribute; 340, 341; 340, 342; 341, identifier:cmds; 342, identifier:setAttr; 343, argument_list; 343, 344; 343, 347; 344, binary_operator:%; 344, 345; 344, 346; 345, string:'%s.taskfile_id'; 346, identifier:node; 347, attribute; 347, 348; 347, 349; 348, identifier:tf; 349, identifier:id; 350, expression_statement; 350, 351; 351, call; 351, 352; 351, 355; 352, attribute; 352, 353; 352, 354; 353, identifier:cmds; 354, identifier:setAttr; 355, argument_list; 355, 356; 355, 359; 356, binary_operator:%; 356, 357; 356, 358; 357, string:'%s.taskfile_id'; 358, identifier:node; 359, keyword_argument; 359, 360; 359, 361; 360, identifier:lock; 361, True; 362, function_definition; 362, 363; 362, 364; 362, 366; 363, function_name:check_modified; 364, parameters; 364, 365; 365, identifier:self; 366, block; 366, 367; 366, 383; 366, 397; 366, 428; 366, 435; 366, 452; 367, if_statement; 367, 368; 367, 380; 368, not_operator; 368, 369; 369, call; 369, 370; 369, 373; 370, attribute; 370, 371; 370, 372; 371, identifier:cmds; 372, identifier:file; 373, argument_list; 373, 374; 373, 377; 374, keyword_argument; 374, 375; 374, 376; 375, identifier:q; 376, integer:1; 377, keyword_argument; 377, 378; 377, 379; 378, identifier:modified; 379, integer:1; 380, block; 380, 381; 381, return_statement; 381, 382; 382, True; 383, expression_statement; 383, 384; 384, assignment; 384, 385; 384, 386; 385, identifier:curfile; 386, call; 386, 387; 386, 390; 387, attribute; 387, 388; 387, 389; 388, identifier:cmds; 389, identifier:file; 390, argument_list; 390, 391; 390, 394; 391, keyword_argument; 391, 392; 391, 393; 392, identifier:q; 393, integer:1; 394, keyword_argument; 394, 395; 394, 396; 395, identifier:sceneName; 396, integer:1; 397, expression_statement; 397, 398; 398, assignment; 398, 399; 398, 400; 399, identifier:r; 400, call; 400, 401; 400, 404; 401, attribute; 401, 402; 401, 403; 402, identifier:cmds; 403, identifier:confirmDialog; 404, argument_list; 404, 405; 404, 408; 404, 413; 404, 419; 404, 422; 404, 425; 405, keyword_argument; 405, 406; 405, 407; 406, identifier:title; 407, string:'Save Changes'; 408, keyword_argument; 408, 409; 408, 410; 409, identifier:message; 410, binary_operator:%; 410, 411; 410, 412; 411, string:'Save changes to %s?'; 412, identifier:curfile; 413, keyword_argument; 413, 414; 413, 415; 414, identifier:button; 415, list:['Save', 'Don\'t Save' ,'Cancel']; 415, 416; 415, 417; 415, 418; 416, string:'Save'; 417, string:'Don\'t Save'; 418, string:'Cancel'; 419, keyword_argument; 419, 420; 419, 421; 420, identifier:defaultButton; 421, string:'Save'; 422, keyword_argument; 422, 423; 422, 424; 423, identifier:cancelButton; 424, string:'Cancel'; 425, keyword_argument; 425, 426; 425, 427; 426, identifier:dismissString; 427, string:'Cancel'; 428, if_statement; 428, 429; 428, 432; 429, comparison_operator:==; 429, 430; 429, 431; 430, identifier:r; 431, string:'Cancel'; 432, block; 432, 433; 433, return_statement; 433, 434; 434, False; 435, if_statement; 435, 436; 435, 439; 436, comparison_operator:==; 436, 437; 436, 438; 437, identifier:r; 438, string:'Save'; 439, block; 439, 440; 440, expression_statement; 440, 441; 441, call; 441, 442; 441, 445; 442, attribute; 442, 443; 442, 444; 443, identifier:cmds; 444, identifier:file; 445, argument_list; 445, 446; 445, 449; 446, keyword_argument; 446, 447; 446, 448; 447, identifier:save; 448, True; 449, keyword_argument; 449, 450; 449, 451; 450, identifier:force; 451, True; 452, return_statement; 452, 453; 453, True; 454, expression_statement; 454, 455; 455, call; 455, 456; 455, 459; 456, attribute; 456, 457; 456, 458; 457, identifier:MayaGenesisWin; 458, identifier:set_filetype; 459, argument_list; 459, 460; 460, subscript; 460, 461; 460, 464; 461, attribute; 461, 462; 461, 463; 462, identifier:djadapter; 463, identifier:FILETYPES; 464, string:'mayamainscene'; 465, return_statement; 465, 466; 466, identifier:MayaGenesisWin
def subclass_genesis(self, genesisclass): class MayaGenesisWin(genesisclass): def open_shot(self, taskfile): return self.open_file(taskfile) def save_shot(self, jbfile, tf): self.update_scene_node(tf) self.save_file(jbfile) def open_asset(self, taskfile): return self.open_file(taskfile) def save_asset(self, jbfile, tf): self.update_scene_node(tf) self.save_file(jbfile) def save_file(self, jbfile): p = jbfile.get_fullpath() p = os.path.expanduser(p) typ = 'mayaBinary' if jbfile.get_ext() == 'ma': typ = 'mayaAscii' cmds.file(rename = p) cmds.file(save=True, defaultExtensions=False, type=typ) def open_file(self, taskfile): r = self.check_modified() if r is False: return False cmds.file(taskfile.path, open=True, force=True, ignoreVersion=True) return True def get_current_file(self, ): node = jbscene.get_current_scene_node() if not node: return tfid = cmds.getAttr('%s.taskfile_id' % node) try: return djadapter.taskfiles.get(id=tfid) except djadapter.models.TaskFile.DoesNotExist: log.error("No taskfile with id %s was found. Get current scene failed. Check your jb_sceneNode \'%s\'." % (tfid, node)) return def get_scene_node(self, ): scenenodes = cmds.ls(':jb_sceneNode*') if len(scenenodes) > 1: cmds.delete(scenenodes) node = jbscene.get_current_scene_node() if node is None: cmds.namespace(set=':') node = cmds.createNode('jb_sceneNode') return node def update_scene_node(self, tf): node = self.get_scene_node() cmds.setAttr('%s.taskfile_id' % node, lock=False) cmds.setAttr('%s.taskfile_id' % node, tf.id) cmds.setAttr('%s.taskfile_id' % node, lock=True) def check_modified(self, ): if not cmds.file(q=1, modified=1): return True curfile = cmds.file(q=1, sceneName=1) r = cmds.confirmDialog( title='Save Changes', message='Save changes to %s?' % curfile, button=['Save', 'Don\'t Save' ,'Cancel'], defaultButton='Save', cancelButton='Cancel', dismissString='Cancel') if r == 'Cancel': return False if r == 'Save': cmds.file(save=True, force=True) return True MayaGenesisWin.set_filetype(djadapter.FILETYPES['mayamainscene'],) return MayaGenesisWin
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 35; 1, 37; 2, function_name:override_options; 3, parameters; 3, 4; 3, 8; 3, 18; 3, 30; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:config; 6, type; 6, 7; 7, identifier:DictLike; 8, typed_parameter; 8, 9; 8, 10; 9, identifier:selected_options; 10, type; 10, 11; 11, generic_type; 11, 12; 11, 13; 12, identifier:Tuple; 13, type_parameter; 13, 14; 13, 16; 14, type; 14, 15; 15, identifier:Any; 16, type; 16, 17; 17, ellipsis:...; 18, typed_parameter; 18, 19; 18, 20; 19, identifier:set_of_possible_options; 20, type; 20, 21; 21, generic_type; 21, 22; 21, 23; 22, identifier:Tuple; 23, type_parameter; 23, 24; 23, 28; 24, type; 24, 25; 25, attribute; 25, 26; 25, 27; 26, identifier:enum; 27, identifier:Enum; 28, type; 28, 29; 29, ellipsis:...; 30, typed_default_parameter; 30, 31; 30, 32; 30, 34; 31, identifier:config_containing_override; 32, type; 32, 33; 33, identifier:DictLike; 34, None; 35, type; 35, 36; 36, identifier:DictLike; 37, block; 37, 38; 37, 47; 37, 56; 37, 65; 37, 72; 37, 232; 38, if_statement; 38, 39; 38, 42; 39, comparison_operator:is; 39, 40; 39, 41; 40, identifier:config_containing_override; 41, None; 42, block; 42, 43; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 46; 45, identifier:config_containing_override; 46, identifier:config; 47, expression_statement; 47, 48; 48, assignment; 48, 49; 48, 50; 49, identifier:override_opts; 50, call; 50, 51; 50, 54; 51, attribute; 51, 52; 51, 53; 52, identifier:config_containing_override; 53, identifier:pop; 54, argument_list; 54, 55; 55, string:"override"; 56, expression_statement; 56, 57; 57, assignment; 57, 58; 57, 59; 58, identifier:override_dict; 59, call; 59, 60; 59, 61; 60, identifier:determine_override_options; 61, argument_list; 61, 62; 61, 63; 61, 64; 62, identifier:selected_options; 63, identifier:override_opts; 64, identifier:set_of_possible_options; 65, expression_statement; 65, 66; 66, call; 66, 67; 66, 70; 67, attribute; 67, 68; 67, 69; 68, identifier:logger; 69, identifier:debug; 70, argument_list; 70, 71; 71, string:f"override_dict: {override_dict}"; 72, for_statement; 72, 73; 72, 76; 72, 81; 73, pattern_list; 73, 74; 73, 75; 74, identifier:k; 75, identifier:v; 76, call; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, identifier:override_dict; 79, identifier:items; 80, argument_list; 81, block; 81, 82; 82, if_statement; 82, 83; 82, 86; 82, 224; 83, comparison_operator:in; 83, 84; 83, 85; 84, identifier:k; 85, identifier:config; 86, block; 86, 87; 87, try_statement; 87, 88; 87, 215; 88, block; 88, 89; 88, 95; 88, 102; 89, expression_statement; 89, 90; 90, attribute; 90, 91; 90, 94; 91, subscript; 91, 92; 91, 93; 92, identifier:config; 93, identifier:k; 94, identifier:anchor; 95, expression_statement; 95, 96; 96, call; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, identifier:logger; 99, identifier:debug; 100, argument_list; 100, 101; 101, string:f"type: {type(config[k])}, k: {k}"; 102, if_statement; 102, 103; 102, 110; 102, 155; 102, 183; 102, 208; 103, call; 103, 104; 103, 105; 104, identifier:isinstance; 105, argument_list; 105, 106; 105, 109; 106, subscript; 106, 107; 106, 108; 107, identifier:config; 108, identifier:k; 109, identifier:list; 110, block; 110, 111; 110, 118; 111, delete_statement; 111, 112; 112, subscript; 112, 113; 112, 116; 113, subscript; 113, 114; 113, 115; 114, identifier:config; 115, identifier:k; 116, slice; 116, 117; 117, colon; 118, if_statement; 118, 119; 118, 130; 118, 142; 119, call; 119, 120; 119, 121; 120, identifier:isinstance; 121, argument_list; 121, 122; 121, 125; 122, subscript; 122, 123; 122, 124; 123, identifier:override_dict; 124, identifier:k; 125, tuple; 125, 126; 125, 127; 125, 128; 125, 129; 126, identifier:str; 127, identifier:int; 128, identifier:float; 129, identifier:bool; 130, block; 130, 131; 131, expression_statement; 131, 132; 132, call; 132, 133; 132, 138; 133, attribute; 133, 134; 133, 137; 134, subscript; 134, 135; 134, 136; 135, identifier:config; 136, identifier:k; 137, identifier:append; 138, argument_list; 138, 139; 139, subscript; 139, 140; 139, 141; 140, identifier:override_dict; 141, identifier:k; 142, else_clause; 142, 143; 143, block; 143, 144; 144, expression_statement; 144, 145; 145, call; 145, 146; 145, 151; 146, attribute; 146, 147; 146, 150; 147, subscript; 147, 148; 147, 149; 148, identifier:config; 149, identifier:k; 150, identifier:extend; 151, argument_list; 151, 152; 152, subscript; 152, 153; 152, 154; 153, identifier:override_dict; 154, identifier:k; 155, elif_clause; 155, 156; 155, 163; 156, call; 156, 157; 156, 158; 157, identifier:isinstance; 158, argument_list; 158, 159; 158, 162; 159, subscript; 159, 160; 159, 161; 160, identifier:config; 161, identifier:k; 162, identifier:dict; 163, block; 163, 164; 163, 172; 164, expression_statement; 164, 165; 165, call; 165, 166; 165, 171; 166, attribute; 166, 167; 166, 170; 167, subscript; 167, 168; 167, 169; 168, identifier:config; 169, identifier:k; 170, identifier:clear; 171, argument_list; 172, expression_statement; 172, 173; 173, call; 173, 174; 173, 179; 174, attribute; 174, 175; 174, 178; 175, subscript; 175, 176; 175, 177; 176, identifier:config; 177, identifier:k; 178, identifier:update; 179, argument_list; 179, 180; 180, subscript; 180, 181; 180, 182; 181, identifier:override_dict; 182, identifier:k; 183, elif_clause; 183, 184; 183, 194; 184, call; 184, 185; 184, 186; 185, identifier:isinstance; 186, argument_list; 186, 187; 186, 190; 187, subscript; 187, 188; 187, 189; 188, identifier:config; 189, identifier:k; 190, tuple; 190, 191; 190, 192; 190, 193; 191, identifier:int; 192, identifier:float; 193, identifier:bool; 194, block; 194, 195; 194, 202; 195, expression_statement; 195, 196; 196, call; 196, 197; 196, 200; 197, attribute; 197, 198; 197, 199; 198, identifier:logger; 199, identifier:debug; 200, argument_list; 200, 201; 201, string:"Overwriting YAML anchor object. It is currently unclear how to reassign this value."; 202, expression_statement; 202, 203; 203, assignment; 203, 204; 203, 207; 204, subscript; 204, 205; 204, 206; 205, identifier:config; 206, identifier:k; 207, identifier:v; 208, else_clause; 208, 209; 209, block; 209, 210; 210, raise_statement; 210, 211; 211, call; 211, 212; 211, 213; 212, identifier:ValueError; 213, argument_list; 213, 214; 214, string:f"Object {k} (type {type(config[k])}) somehow has an anchor, but is something other than a list or dict. Attempting to assign directly to it."; 215, except_clause; 215, 216; 215, 217; 216, identifier:AttributeError; 217, block; 217, 218; 218, expression_statement; 218, 219; 219, assignment; 219, 220; 219, 223; 220, subscript; 220, 221; 220, 222; 221, identifier:config; 222, identifier:k; 223, identifier:v; 224, else_clause; 224, 225; 225, block; 225, 226; 226, raise_statement; 226, 227; 227, call; 227, 228; 227, 229; 228, identifier:KeyError; 229, argument_list; 229, 230; 229, 231; 230, identifier:k; 231, string:f"Trying to override key \"{k}\" that it is not in the config."; 232, return_statement; 232, 233; 233, identifier:config
def override_options(config: DictLike, selected_options: Tuple[Any, ...], set_of_possible_options: Tuple[enum.Enum, ...], config_containing_override: DictLike = None) -> DictLike: if config_containing_override is None: config_containing_override = config override_opts = config_containing_override.pop("override") override_dict = determine_override_options(selected_options, override_opts, set_of_possible_options) logger.debug(f"override_dict: {override_dict}") for k, v in override_dict.items(): if k in config: try: config[k].anchor logger.debug(f"type: {type(config[k])}, k: {k}") if isinstance(config[k], list): del config[k][:] if isinstance(override_dict[k], (str, int, float, bool)): config[k].append(override_dict[k]) else: config[k].extend(override_dict[k]) elif isinstance(config[k], dict): config[k].clear() config[k].update(override_dict[k]) elif isinstance(config[k], (int, float, bool)): logger.debug("Overwriting YAML anchor object. It is currently unclear how to reassign this value.") config[k] = v else: raise ValueError(f"Object {k} (type {type(config[k])}) somehow has an anchor, but is something other than a list or dict. Attempting to assign directly to it.") except AttributeError: config[k] = v else: raise KeyError(k, f"Trying to override key \"{k}\" that it is not in the config.") return config
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 24; 1, 36; 2, function_name:determine_selection_of_iterable_values_from_config; 3, parameters; 3, 4; 3, 8; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:config; 6, type; 6, 7; 7, identifier:DictLike; 8, typed_parameter; 8, 9; 8, 10; 9, identifier:possible_iterables; 10, type; 10, 11; 11, generic_type; 11, 12; 11, 13; 12, identifier:Mapping; 13, type_parameter; 13, 14; 13, 16; 14, type; 14, 15; 15, identifier:str; 16, type; 16, 17; 17, generic_type; 17, 18; 17, 19; 18, identifier:Type; 19, type_parameter; 19, 20; 20, type; 20, 21; 21, attribute; 21, 22; 21, 23; 22, identifier:enum; 23, identifier:Enum; 24, type; 24, 25; 25, generic_type; 25, 26; 25, 27; 26, identifier:Dict; 27, type_parameter; 27, 28; 27, 30; 28, type; 28, 29; 29, identifier:str; 30, type; 30, 31; 31, generic_type; 31, 32; 31, 33; 32, identifier:List; 33, type_parameter; 33, 34; 34, type; 34, 35; 35, identifier:Any; 36, block; 36, 37; 36, 41; 36, 47; 36, 160; 37, expression_statement; 37, 38; 38, assignment; 38, 39; 38, 40; 39, identifier:iterables; 40, dictionary; 41, expression_statement; 41, 42; 42, assignment; 42, 43; 42, 44; 43, identifier:requested_iterables; 44, subscript; 44, 45; 44, 46; 45, identifier:config; 46, string:"iterables"; 47, for_statement; 47, 48; 47, 51; 47, 56; 48, pattern_list; 48, 49; 48, 50; 49, identifier:k; 50, identifier:v; 51, call; 51, 52; 51, 55; 52, attribute; 52, 53; 52, 54; 53, identifier:requested_iterables; 54, identifier:items; 55, argument_list; 56, block; 56, 57; 56, 68; 56, 75; 56, 85; 56, 91; 56, 107; 56, 154; 57, if_statement; 57, 58; 57, 61; 58, comparison_operator:not; 58, 59; 58, 60; 59, identifier:k; 60, identifier:possible_iterables; 61, block; 61, 62; 62, raise_statement; 62, 63; 63, call; 63, 64; 63, 65; 64, identifier:KeyError; 65, argument_list; 65, 66; 65, 67; 66, identifier:k; 67, string:f"Cannot find requested iterable in possible_iterables: {possible_iterables}"; 68, expression_statement; 68, 69; 69, call; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:logger; 72, identifier:debug; 73, argument_list; 73, 74; 74, string:f"k: {k}, v: {v}"; 75, expression_statement; 75, 76; 76, assignment; 76, 77; 76, 78; 76, 84; 77, identifier:additional_iterable; 78, type; 78, 79; 79, generic_type; 79, 80; 79, 81; 80, identifier:List; 81, type_parameter; 81, 82; 82, type; 82, 83; 83, identifier:Any; 84, list:[]; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 88; 87, identifier:enum_values; 88, subscript; 88, 89; 88, 90; 89, identifier:possible_iterables; 90, identifier:k; 91, if_statement; 91, 92; 91, 97; 92, call; 92, 93; 92, 94; 93, identifier:isinstance; 94, argument_list; 94, 95; 94, 96; 95, identifier:v; 96, identifier:str; 97, block; 97, 98; 98, raise_statement; 98, 99; 99, call; 99, 100; 99, 101; 100, identifier:TypeError; 101, argument_list; 101, 102; 101, 106; 102, call; 102, 103; 102, 104; 103, identifier:type; 104, argument_list; 104, 105; 105, identifier:v; 106, string:f"Passed string {v} when must be either bool or list"; 107, if_statement; 107, 108; 107, 111; 107, 113; 107, 125; 108, comparison_operator:is; 108, 109; 108, 110; 109, identifier:v; 110, False; 111, block; 111, 112; 112, continue_statement; 113, elif_clause; 113, 114; 113, 117; 114, comparison_operator:is; 114, 115; 114, 116; 115, identifier:v; 116, True; 117, block; 117, 118; 118, expression_statement; 118, 119; 119, assignment; 119, 120; 119, 121; 120, identifier:additional_iterable; 121, call; 121, 122; 121, 123; 122, identifier:list; 123, argument_list; 123, 124; 124, identifier:enum_values; 125, else_clause; 125, 126; 126, block; 126, 127; 127, if_statement; 127, 128; 127, 131; 127, 139; 128, comparison_operator:is; 128, 129; 128, 130; 129, identifier:enum_values; 130, None; 131, block; 131, 132; 132, expression_statement; 132, 133; 133, assignment; 133, 134; 133, 135; 134, identifier:additional_iterable; 135, call; 135, 136; 135, 137; 136, identifier:list; 137, argument_list; 137, 138; 138, identifier:v; 139, else_clause; 139, 140; 140, block; 140, 141; 141, for_statement; 141, 142; 141, 143; 141, 144; 142, identifier:el; 143, identifier:v; 144, block; 144, 145; 145, expression_statement; 145, 146; 146, call; 146, 147; 146, 150; 147, attribute; 147, 148; 147, 149; 148, identifier:additional_iterable; 149, identifier:append; 150, argument_list; 150, 151; 151, subscript; 151, 152; 151, 153; 152, identifier:enum_values; 153, identifier:el; 154, expression_statement; 154, 155; 155, assignment; 155, 156; 155, 159; 156, subscript; 156, 157; 156, 158; 157, identifier:iterables; 158, identifier:k; 159, identifier:additional_iterable; 160, return_statement; 160, 161; 161, identifier:iterables
def determine_selection_of_iterable_values_from_config(config: DictLike, possible_iterables: Mapping[str, Type[enum.Enum]]) -> Dict[str, List[Any]]: iterables = {} requested_iterables = config["iterables"] for k, v in requested_iterables.items(): if k not in possible_iterables: raise KeyError(k, f"Cannot find requested iterable in possible_iterables: {possible_iterables}") logger.debug(f"k: {k}, v: {v}") additional_iterable: List[Any] = [] enum_values = possible_iterables[k] if isinstance(v, str): raise TypeError(type(v), f"Passed string {v} when must be either bool or list") if v is False: continue elif v is True: additional_iterable = list(enum_values) else: if enum_values is None: additional_iterable = list(v) else: for el in v: additional_iterable.append(enum_values[el]) iterables[k] = additional_iterable return iterables
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 1, 20; 2, function_name:create_key_index_object; 3, parameters; 3, 4; 3, 8; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:key_index_name; 6, type; 6, 7; 7, identifier:str; 8, typed_parameter; 8, 9; 8, 10; 9, identifier:iterables; 10, type; 10, 11; 11, generic_type; 11, 12; 11, 13; 12, identifier:Dict; 13, type_parameter; 13, 14; 13, 16; 14, type; 14, 15; 15, identifier:str; 16, type; 16, 17; 17, identifier:Any; 18, type; 18, 19; 19, identifier:Any; 20, block; 20, 21; 20, 49; 20, 74; 20, 87; 20, 93; 21, for_statement; 21, 22; 21, 25; 21, 30; 22, pattern_list; 22, 23; 22, 24; 23, identifier:name; 24, identifier:iterable; 25, call; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:iterables; 28, identifier:items; 29, argument_list; 30, block; 30, 31; 31, if_statement; 31, 32; 31, 41; 32, comparison_operator:==; 32, 33; 32, 37; 33, call; 33, 34; 33, 35; 34, identifier:iter; 35, argument_list; 35, 36; 36, identifier:iterable; 37, call; 37, 38; 37, 39; 38, identifier:iter; 39, argument_list; 39, 40; 40, identifier:iterable; 41, block; 41, 42; 42, raise_statement; 42, 43; 43, call; 43, 44; 43, 45; 44, identifier:TypeError; 45, argument_list; 45, 46; 46, concatenated_string; 46, 47; 46, 48; 47, string:f"Iterable {name} is in iterator which can be exhausted. Please pass the iterable"; 48, string:f" in a container that can recreate the iterable. See the comments here for more info."; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 52; 51, identifier:fields; 52, list_comprehension; 52, 53; 52, 65; 53, tuple; 53, 54; 53, 55; 54, identifier:name; 55, call; 55, 56; 55, 57; 56, identifier:type; 57, argument_list; 57, 58; 58, call; 58, 59; 58, 60; 59, identifier:next; 60, argument_list; 60, 61; 61, call; 61, 62; 61, 63; 62, identifier:iter; 63, argument_list; 63, 64; 64, identifier:iterable; 65, for_in_clause; 65, 66; 65, 69; 66, pattern_list; 66, 67; 66, 68; 67, identifier:name; 68, identifier:iterable; 69, call; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:iterables; 72, identifier:items; 73, argument_list; 74, expression_statement; 74, 75; 75, assignment; 75, 76; 75, 77; 76, identifier:KeyIndex; 77, call; 77, 78; 77, 81; 78, attribute; 78, 79; 78, 80; 79, identifier:dataclasses; 80, identifier:make_dataclass; 81, argument_list; 81, 82; 81, 83; 81, 84; 82, identifier:key_index_name; 83, identifier:fields; 84, keyword_argument; 84, 85; 84, 86; 85, identifier:frozen; 86, True; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 92; 89, attribute; 89, 90; 89, 91; 90, identifier:KeyIndex; 91, identifier:__iter__; 92, identifier:_key_index_iter; 93, return_statement; 93, 94; 94, identifier:KeyIndex
def create_key_index_object(key_index_name: str, iterables: Dict[str, Any]) -> Any: for name, iterable in iterables.items(): if iter(iterable) == iter(iterable): raise TypeError( f"Iterable {name} is in iterator which can be exhausted. Please pass the iterable" f" in a container that can recreate the iterable. See the comments here for more info." ) fields = [(name, type(next(iter(iterable)))) for name, iterable in iterables.items()] KeyIndex = dataclasses.make_dataclass( key_index_name, fields, frozen = True ) KeyIndex.__iter__ = _key_index_iter return KeyIndex
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 34; 1, 50; 2, function_name:create_objects_from_iterables; 3, parameters; 3, 4; 3, 5; 3, 9; 3, 19; 3, 29; 4, identifier:obj; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:args; 7, type; 7, 8; 8, identifier:dict; 9, typed_parameter; 9, 10; 9, 11; 10, identifier:iterables; 11, type; 11, 12; 12, generic_type; 12, 13; 12, 14; 13, identifier:Dict; 14, type_parameter; 14, 15; 14, 17; 15, type; 15, 16; 16, identifier:str; 17, type; 17, 18; 18, identifier:Any; 19, typed_parameter; 19, 20; 19, 21; 20, identifier:formatting_options; 21, type; 21, 22; 22, generic_type; 22, 23; 22, 24; 23, identifier:Dict; 24, type_parameter; 24, 25; 24, 27; 25, type; 25, 26; 26, identifier:str; 27, type; 27, 28; 28, identifier:Any; 29, typed_default_parameter; 29, 30; 29, 31; 29, 33; 30, identifier:key_index_name; 31, type; 31, 32; 32, identifier:str; 33, string:"KeyIndex"; 34, type; 34, 35; 35, generic_type; 35, 36; 35, 37; 36, identifier:Tuple; 37, type_parameter; 37, 38; 37, 40; 37, 48; 38, type; 38, 39; 39, identifier:Any; 40, type; 40, 41; 41, generic_type; 41, 42; 41, 43; 42, identifier:Dict; 43, type_parameter; 43, 44; 43, 46; 44, type; 44, 45; 45, identifier:str; 46, type; 46, 47; 47, identifier:Any; 48, type; 48, 49; 49, identifier:dict; 50, block; 50, 51; 50, 55; 50, 62; 50, 69; 50, 81; 50, 203; 50, 213; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 54; 53, identifier:objects; 54, dictionary; 55, expression_statement; 55, 56; 56, assignment; 56, 57; 56, 58; 57, identifier:names; 58, call; 58, 59; 58, 60; 59, identifier:list; 60, argument_list; 60, 61; 61, identifier:iterables; 62, expression_statement; 62, 63; 63, call; 63, 64; 63, 67; 64, attribute; 64, 65; 64, 66; 65, identifier:logger; 66, identifier:debug; 67, argument_list; 67, 68; 68, string:f"iterables: {iterables}"; 69, expression_statement; 69, 70; 70, assignment; 70, 71; 70, 72; 71, identifier:KeyIndex; 72, call; 72, 73; 72, 74; 73, identifier:create_key_index_object; 74, argument_list; 74, 75; 74, 78; 75, keyword_argument; 75, 76; 75, 77; 76, identifier:key_index_name; 77, identifier:key_index_name; 78, keyword_argument; 78, 79; 78, 80; 79, identifier:iterables; 80, identifier:iterables; 81, for_statement; 81, 82; 81, 83; 81, 94; 82, identifier:values; 83, call; 83, 84; 83, 87; 84, attribute; 84, 85; 84, 86; 85, identifier:itertools; 86, identifier:product; 87, argument_list; 87, 88; 88, list_splat; 88, 89; 89, call; 89, 90; 89, 93; 90, attribute; 90, 91; 90, 92; 91, identifier:iterables; 92, identifier:values; 93, argument_list; 94, block; 94, 95; 94, 102; 94, 107; 94, 132; 94, 141; 94, 148; 94, 156; 94, 176; 94, 182; 94, 189; 95, expression_statement; 95, 96; 96, call; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, identifier:logger; 99, identifier:debug; 100, argument_list; 100, 101; 101, string:f"Values: {values}"; 102, if_statement; 102, 103; 102, 105; 103, not_operator; 103, 104; 104, identifier:values; 105, block; 105, 106; 106, continue_statement; 107, for_statement; 107, 108; 107, 111; 107, 116; 108, pattern_list; 108, 109; 108, 110; 109, identifier:name; 110, identifier:val; 111, call; 111, 112; 111, 113; 112, identifier:zip; 113, argument_list; 113, 114; 113, 115; 114, identifier:names; 115, identifier:values; 116, block; 116, 117; 116, 123; 117, expression_statement; 117, 118; 118, assignment; 118, 119; 118, 122; 119, subscript; 119, 120; 119, 121; 120, identifier:args; 121, identifier:name; 122, identifier:val; 123, expression_statement; 123, 124; 124, assignment; 124, 125; 124, 128; 125, subscript; 125, 126; 125, 127; 126, identifier:formatting_options; 127, identifier:name; 128, call; 128, 129; 128, 130; 129, identifier:str; 130, argument_list; 130, 131; 131, identifier:val; 132, expression_statement; 132, 133; 133, assignment; 133, 134; 133, 135; 134, identifier:object_args; 135, call; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:copy; 138, identifier:copy; 139, argument_list; 139, 140; 140, identifier:args; 141, expression_statement; 141, 142; 142, call; 142, 143; 142, 146; 143, attribute; 143, 144; 143, 145; 144, identifier:logger; 145, identifier:debug; 146, argument_list; 146, 147; 147, string:f"object_args pre format: {object_args}"; 148, expression_statement; 148, 149; 149, assignment; 149, 150; 149, 151; 150, identifier:object_args; 151, call; 151, 152; 151, 153; 152, identifier:apply_formatting_dict; 153, argument_list; 153, 154; 153, 155; 154, identifier:object_args; 155, identifier:formatting_options; 156, expression_statement; 156, 157; 157, assignment; 157, 158; 157, 159; 158, identifier:print_args; 159, dictionary_comprehension; 159, 160; 159, 163; 159, 172; 160, pair; 160, 161; 160, 162; 161, identifier:k; 162, identifier:v; 163, for_in_clause; 163, 164; 163, 167; 164, pattern_list; 164, 165; 164, 166; 165, identifier:k; 166, identifier:v; 167, call; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, identifier:object_args; 170, identifier:items; 171, argument_list; 172, if_clause; 172, 173; 173, comparison_operator:!=; 173, 174; 173, 175; 174, identifier:k; 175, string:"config"; 176, expression_statement; 176, 177; 177, assignment; 177, 178; 177, 181; 178, subscript; 178, 179; 178, 180; 179, identifier:print_args; 180, string:"config"; 181, string:"..."; 182, expression_statement; 182, 183; 183, call; 183, 184; 183, 187; 184, attribute; 184, 185; 184, 186; 185, identifier:logger; 186, identifier:debug; 187, argument_list; 187, 188; 188, string:f"Constructing obj \"{obj}\" with args: \"{print_args}\""; 189, expression_statement; 189, 190; 190, assignment; 190, 191; 190, 198; 191, subscript; 191, 192; 191, 193; 192, identifier:objects; 193, call; 193, 194; 193, 195; 194, identifier:KeyIndex; 195, argument_list; 195, 196; 196, list_splat; 196, 197; 197, identifier:values; 198, call; 198, 199; 198, 200; 199, identifier:obj; 200, argument_list; 200, 201; 201, dictionary_splat; 201, 202; 202, identifier:object_args; 203, if_statement; 203, 204; 203, 206; 204, not_operator; 204, 205; 205, identifier:objects; 206, block; 206, 207; 207, raise_statement; 207, 208; 208, call; 208, 209; 208, 210; 209, identifier:ValueError; 210, argument_list; 210, 211; 210, 212; 211, identifier:iterables; 212, string:"There appear to be no iterables to use in creating objects."; 213, return_statement; 213, 214; 214, tuple; 214, 215; 214, 216; 214, 217; 215, identifier:KeyIndex; 216, identifier:iterables; 217, identifier:objects
def create_objects_from_iterables(obj, args: dict, iterables: Dict[str, Any], formatting_options: Dict[str, Any], key_index_name: str = "KeyIndex") -> Tuple[Any, Dict[str, Any], dict]: objects = {} names = list(iterables) logger.debug(f"iterables: {iterables}") KeyIndex = create_key_index_object( key_index_name = key_index_name, iterables = iterables, ) for values in itertools.product(*iterables.values()): logger.debug(f"Values: {values}") if not values: continue for name, val in zip(names, values): args[name] = val formatting_options[name] = str(val) object_args = copy.copy(args) logger.debug(f"object_args pre format: {object_args}") object_args = apply_formatting_dict(object_args, formatting_options) print_args = {k: v for k, v in object_args.items() if k != "config"} print_args["config"] = "..." logger.debug(f"Constructing obj \"{obj}\" with args: \"{print_args}\"") objects[KeyIndex(*values)] = obj(**object_args) if not objects: raise ValueError(iterables, "There appear to be no iterables to use in creating objects.") return (KeyIndex, iterables, objects)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 42; 1, 58; 2, function_name:iterate_with_selected_objects_in_order; 3, parameters; 3, 4; 3, 14; 3, 28; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:analysis_objects; 6, type; 6, 7; 7, generic_type; 7, 8; 7, 9; 8, identifier:Mapping; 9, type_parameter; 9, 10; 9, 12; 10, type; 10, 11; 11, identifier:Any; 12, type; 12, 13; 13, identifier:Any; 14, typed_parameter; 14, 15; 14, 16; 15, identifier:analysis_iterables; 16, type; 16, 17; 17, generic_type; 17, 18; 17, 19; 18, identifier:Dict; 19, type_parameter; 19, 20; 19, 22; 20, type; 20, 21; 21, identifier:str; 22, type; 22, 23; 23, generic_type; 23, 24; 23, 25; 24, identifier:Sequence; 25, type_parameter; 25, 26; 26, type; 26, 27; 27, identifier:Any; 28, typed_parameter; 28, 29; 28, 30; 29, identifier:selection; 30, type; 30, 31; 31, generic_type; 31, 32; 31, 33; 32, identifier:Union; 33, type_parameter; 33, 34; 33, 36; 34, type; 34, 35; 35, identifier:str; 36, type; 36, 37; 37, generic_type; 37, 38; 37, 39; 38, identifier:Sequence; 39, type_parameter; 39, 40; 40, type; 40, 41; 41, identifier:str; 42, type; 42, 43; 43, generic_type; 43, 44; 43, 45; 44, identifier:Iterator; 45, type_parameter; 45, 46; 46, type; 46, 47; 47, generic_type; 47, 48; 47, 49; 48, identifier:List; 49, type_parameter; 49, 50; 50, type; 50, 51; 51, generic_type; 51, 52; 51, 53; 52, identifier:Tuple; 53, type_parameter; 53, 54; 53, 56; 54, type; 54, 55; 55, identifier:Any; 56, type; 56, 57; 57, identifier:Any; 58, block; 58, 59; 58, 71; 58, 78; 58, 87; 58, 91; 58, 106; 58, 113; 58, 120; 58, 140; 58, 160; 58, 167; 58, 174; 59, if_statement; 59, 60; 59, 65; 60, call; 60, 61; 60, 62; 61, identifier:isinstance; 62, argument_list; 62, 63; 62, 64; 63, identifier:selection; 64, identifier:str; 65, block; 65, 66; 66, expression_statement; 66, 67; 67, assignment; 67, 68; 67, 69; 68, identifier:selection; 69, list:[selection]; 69, 70; 70, identifier:selection; 71, assert_statement; 71, 72; 72, not_operator; 72, 73; 73, call; 73, 74; 73, 75; 74, identifier:isinstance; 75, argument_list; 75, 76; 75, 77; 76, identifier:selection; 77, identifier:str; 78, expression_statement; 78, 79; 79, assignment; 79, 80; 79, 81; 80, identifier:analysis_iterables; 81, call; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:copy; 84, identifier:copy; 85, argument_list; 85, 86; 86, identifier:analysis_iterables; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 90; 89, identifier:selected_iterators; 90, dictionary; 91, for_statement; 91, 92; 91, 93; 91, 94; 92, identifier:s; 93, identifier:selection; 94, block; 94, 95; 95, expression_statement; 95, 96; 96, assignment; 96, 97; 96, 100; 97, subscript; 97, 98; 97, 99; 98, identifier:selected_iterators; 99, identifier:s; 100, call; 100, 101; 100, 104; 101, attribute; 101, 102; 101, 103; 102, identifier:analysis_iterables; 103, identifier:pop; 104, argument_list; 104, 105; 105, identifier:s; 106, expression_statement; 106, 107; 107, call; 107, 108; 107, 111; 108, attribute; 108, 109; 108, 110; 109, identifier:logger; 110, identifier:debug; 111, argument_list; 111, 112; 112, string:f"Initial analysis_iterables: {analysis_iterables}"; 113, expression_statement; 113, 114; 114, call; 114, 115; 114, 118; 115, attribute; 115, 116; 115, 117; 116, identifier:logger; 117, identifier:debug; 118, argument_list; 118, 119; 119, string:f"Initial selected_iterators: {selected_iterators}"; 120, expression_statement; 120, 121; 121, assignment; 121, 122; 121, 123; 122, identifier:selected_iterators; 123, list_comprehension; 123, 124; 123, 131; 124, list_comprehension; 124, 125; 124, 128; 125, tuple; 125, 126; 125, 127; 126, identifier:k; 127, identifier:v; 128, for_in_clause; 128, 129; 128, 130; 129, identifier:v; 130, identifier:values; 131, for_in_clause; 131, 132; 131, 135; 132, pattern_list; 132, 133; 132, 134; 133, identifier:k; 134, identifier:values; 135, call; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:selected_iterators; 138, identifier:items; 139, argument_list; 140, expression_statement; 140, 141; 141, assignment; 141, 142; 141, 143; 142, identifier:analysis_iterables; 143, list_comprehension; 143, 144; 143, 151; 144, list_comprehension; 144, 145; 144, 148; 145, tuple; 145, 146; 145, 147; 146, identifier:k; 147, identifier:v; 148, for_in_clause; 148, 149; 148, 150; 149, identifier:v; 150, identifier:values; 151, for_in_clause; 151, 152; 151, 155; 152, pattern_list; 152, 153; 152, 154; 153, identifier:k; 154, identifier:values; 155, call; 155, 156; 155, 159; 156, attribute; 156, 157; 156, 158; 157, identifier:analysis_iterables; 158, identifier:items; 159, argument_list; 160, expression_statement; 160, 161; 161, call; 161, 162; 161, 165; 162, attribute; 162, 163; 162, 164; 163, identifier:logger; 164, identifier:debug; 165, argument_list; 165, 166; 166, string:f"Final analysis_iterables: {analysis_iterables}"; 167, expression_statement; 167, 168; 168, call; 168, 169; 168, 172; 169, attribute; 169, 170; 169, 171; 170, identifier:logger; 171, identifier:debug; 172, argument_list; 172, 173; 173, string:f"Final selected_iterators: {selected_iterators}"; 174, for_statement; 174, 175; 174, 176; 174, 183; 175, identifier:values; 176, call; 176, 177; 176, 180; 177, attribute; 177, 178; 177, 179; 178, identifier:itertools; 179, identifier:product; 180, argument_list; 180, 181; 181, list_splat; 181, 182; 182, identifier:analysis_iterables; 183, block; 183, 184; 183, 188; 183, 262; 183, 269; 184, expression_statement; 184, 185; 185, assignment; 185, 186; 185, 187; 186, identifier:selected_analysis_objects; 187, list:[]; 188, for_statement; 188, 189; 188, 190; 188, 197; 189, identifier:selected_values; 190, call; 190, 191; 190, 194; 191, attribute; 191, 192; 191, 193; 192, identifier:itertools; 193, identifier:product; 194, argument_list; 194, 195; 195, list_splat; 195, 196; 196, identifier:selected_iterators; 197, block; 197, 198; 198, for_statement; 198, 199; 198, 202; 198, 207; 199, pattern_list; 199, 200; 199, 201; 200, identifier:key_index; 201, identifier:obj; 202, call; 202, 203; 202, 206; 203, attribute; 203, 204; 203, 205; 204, identifier:analysis_objects; 205, identifier:items; 206, argument_list; 207, block; 207, 208; 207, 226; 207, 244; 207, 250; 208, expression_statement; 208, 209; 209, assignment; 209, 210; 209, 211; 210, identifier:selected_via_analysis_iterables; 211, call; 211, 212; 211, 213; 212, identifier:all; 213, generator_expression; 213, 214; 213, 221; 214, comparison_operator:==; 214, 215; 214, 220; 215, call; 215, 216; 215, 217; 216, identifier:getattr; 217, argument_list; 217, 218; 217, 219; 218, identifier:key_index; 219, identifier:k; 220, identifier:v; 221, for_in_clause; 221, 222; 221, 225; 222, pattern_list; 222, 223; 222, 224; 223, identifier:k; 224, identifier:v; 225, identifier:values; 226, expression_statement; 226, 227; 227, assignment; 227, 228; 227, 229; 228, identifier:selected_via_selected_iterators; 229, call; 229, 230; 229, 231; 230, identifier:all; 231, generator_expression; 231, 232; 231, 239; 232, comparison_operator:==; 232, 233; 232, 238; 233, call; 233, 234; 233, 235; 234, identifier:getattr; 235, argument_list; 235, 236; 235, 237; 236, identifier:key_index; 237, identifier:k; 238, identifier:v; 239, for_in_clause; 239, 240; 239, 243; 240, pattern_list; 240, 241; 240, 242; 241, identifier:k; 242, identifier:v; 243, identifier:selected_values; 244, expression_statement; 244, 245; 245, assignment; 245, 246; 245, 247; 246, identifier:selected_obj; 247, boolean_operator:and; 247, 248; 247, 249; 248, identifier:selected_via_analysis_iterables; 249, identifier:selected_via_selected_iterators; 250, if_statement; 250, 251; 250, 252; 251, identifier:selected_obj; 252, block; 252, 253; 253, expression_statement; 253, 254; 254, call; 254, 255; 254, 258; 255, attribute; 255, 256; 255, 257; 256, identifier:selected_analysis_objects; 257, identifier:append; 258, argument_list; 258, 259; 259, tuple; 259, 260; 259, 261; 260, identifier:key_index; 261, identifier:obj; 262, expression_statement; 262, 263; 263, call; 263, 264; 263, 267; 264, attribute; 264, 265; 264, 266; 265, identifier:logger; 266, identifier:debug; 267, argument_list; 267, 268; 268, string:f"Yielding: {selected_analysis_objects}"; 269, expression_statement; 269, 270; 270, yield; 270, 271; 271, identifier:selected_analysis_objects
def iterate_with_selected_objects_in_order(analysis_objects: Mapping[Any, Any], analysis_iterables: Dict[str, Sequence[Any]], selection: Union[str, Sequence[str]]) -> Iterator[List[Tuple[Any, Any]]]: if isinstance(selection, str): selection = [selection] assert not isinstance(selection, str) analysis_iterables = copy.copy(analysis_iterables) selected_iterators = {} for s in selection: selected_iterators[s] = analysis_iterables.pop(s) logger.debug(f"Initial analysis_iterables: {analysis_iterables}") logger.debug(f"Initial selected_iterators: {selected_iterators}") selected_iterators = [[(k, v) for v in values] for k, values in selected_iterators.items()] analysis_iterables = [[(k, v) for v in values] for k, values in analysis_iterables.items()] logger.debug(f"Final analysis_iterables: {analysis_iterables}") logger.debug(f"Final selected_iterators: {selected_iterators}") for values in itertools.product(*analysis_iterables): selected_analysis_objects = [] for selected_values in itertools.product(*selected_iterators): for key_index, obj in analysis_objects.items(): selected_via_analysis_iterables = all( getattr(key_index, k) == v for k, v in values ) selected_via_selected_iterators = all( getattr(key_index, k) == v for k, v in selected_values ) selected_obj = selected_via_analysis_iterables and selected_via_selected_iterators if selected_obj: selected_analysis_objects.append((key_index, obj)) logger.debug(f"Yielding: {selected_analysis_objects}") yield selected_analysis_objects
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:phenotypes_to_scored; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:phenotypes; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:overwrite; 10, False; 11, block; 11, 12; 11, 25; 11, 48; 11, 123; 11, 131; 11, 156; 12, if_statement; 12, 13; 12, 19; 13, not_operator; 13, 14; 14, call; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:self; 17, identifier:is_uniform; 18, argument_list; 19, block; 19, 20; 20, raise_statement; 20, 21; 21, call; 21, 22; 21, 23; 22, identifier:ValueError; 23, argument_list; 23, 24; 24, string:"inconsistent phenotypes"; 25, if_statement; 25, 26; 25, 29; 25, 36; 26, comparison_operator:is; 26, 27; 26, 28; 27, identifier:phenotypes; 28, None; 29, block; 29, 30; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 33; 32, identifier:phenotypes; 33, attribute; 33, 34; 33, 35; 34, identifier:self; 35, identifier:phenotypes; 36, elif_clause; 36, 37; 36, 42; 37, call; 37, 38; 37, 39; 38, identifier:isinstance; 39, argument_list; 39, 40; 39, 41; 40, identifier:phenotypes; 41, identifier:str; 42, block; 42, 43; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 46; 45, identifier:phenotypes; 46, list:[phenotypes]; 46, 47; 47, identifier:phenotypes; 48, function_definition; 48, 49; 48, 50; 48, 55; 49, function_name:_post; 50, parameters; 50, 51; 50, 52; 50, 53; 50, 54; 51, identifier:binary; 52, identifier:phenotype_label; 53, identifier:phenotypes; 54, identifier:overwrite; 55, block; 55, 56; 55, 64; 55, 96; 55, 106; 55, 121; 56, expression_statement; 56, 57; 57, assignment; 57, 58; 57, 59; 58, identifier:d; 59, call; 59, 60; 59, 63; 60, attribute; 60, 61; 60, 62; 61, identifier:binary; 62, identifier:copy; 63, argument_list; 64, if_statement; 64, 65; 64, 90; 65, boolean_operator:and; 65, 66; 65, 87; 66, comparison_operator:>; 66, 67; 66, 86; 67, call; 67, 68; 67, 69; 68, identifier:len; 69, argument_list; 69, 70; 70, binary_operator:&; 70, 71; 70, 75; 71, call; 71, 72; 71, 73; 72, identifier:set; 73, argument_list; 73, 74; 74, identifier:phenotypes; 75, call; 75, 76; 75, 77; 76, identifier:set; 77, argument_list; 77, 78; 78, call; 78, 79; 78, 80; 79, identifier:list; 80, argument_list; 80, 81; 81, call; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:binary; 84, identifier:keys; 85, argument_list; 86, integer:0; 87, comparison_operator:==; 87, 88; 87, 89; 88, identifier:overwrite; 89, False; 90, block; 90, 91; 91, raise_statement; 91, 92; 92, call; 92, 93; 92, 94; 93, identifier:ValueError; 94, argument_list; 94, 95; 95, string:"Error, phenotype already exists as a scored type"; 96, for_statement; 96, 97; 96, 98; 96, 99; 97, identifier:label; 98, identifier:phenotypes; 99, block; 99, 100; 100, expression_statement; 100, 101; 101, assignment; 101, 102; 101, 105; 102, subscript; 102, 103; 102, 104; 103, identifier:d; 104, identifier:label; 105, integer:0; 106, if_statement; 106, 107; 106, 114; 107, boolean_operator:and; 107, 108; 107, 111; 108, comparison_operator:==; 108, 109; 108, 110; 109, identifier:phenotype_label; 110, identifier:phenotype_label; 111, comparison_operator:in; 111, 112; 111, 113; 112, identifier:phenotype_label; 113, identifier:phenotypes; 114, block; 114, 115; 115, expression_statement; 115, 116; 116, assignment; 116, 117; 116, 120; 117, subscript; 117, 118; 117, 119; 118, identifier:d; 119, identifier:phenotype_label; 120, integer:1; 121, return_statement; 121, 122; 122, identifier:d; 123, expression_statement; 123, 124; 124, assignment; 124, 125; 124, 126; 125, identifier:output; 126, call; 126, 127; 126, 130; 127, attribute; 127, 128; 127, 129; 128, identifier:self; 129, identifier:copy; 130, argument_list; 131, expression_statement; 131, 132; 132, assignment; 132, 133; 132, 136; 133, subscript; 133, 134; 133, 135; 134, identifier:output; 135, string:'scored_calls'; 136, call; 136, 137; 136, 140; 137, attribute; 137, 138; 137, 139; 138, identifier:output; 139, identifier:apply; 140, argument_list; 140, 141; 140, 155; 141, lambda; 141, 142; 141, 144; 142, lambda_parameters; 142, 143; 143, identifier:x; 144, call; 144, 145; 144, 146; 145, identifier:_post; 146, argument_list; 146, 147; 146, 150; 146, 153; 146, 154; 147, subscript; 147, 148; 147, 149; 148, identifier:x; 149, string:'scored_calls'; 150, subscript; 150, 151; 150, 152; 151, identifier:x; 152, string:'phenotype_label'; 153, identifier:phenotypes; 154, identifier:overwrite; 155, integer:1; 156, return_statement; 156, 157; 157, identifier:output
def phenotypes_to_scored(self,phenotypes=None,overwrite=False): if not self.is_uniform(): raise ValueError("inconsistent phenotypes") if phenotypes is None: phenotypes = self.phenotypes elif isinstance(phenotypes,str): phenotypes = [phenotypes] def _post(binary,phenotype_label,phenotypes,overwrite): d = binary.copy() if len(set(phenotypes)&set(list(binary.keys()))) > 0 and overwrite==False: raise ValueError("Error, phenotype already exists as a scored type") for label in phenotypes: d[label] = 0 if phenotype_label == phenotype_label and phenotype_label in phenotypes: d[phenotype_label] = 1 return d output = self.copy() output['scored_calls'] = output.apply(lambda x: _post(x['scored_calls'],x['phenotype_label'],phenotypes,overwrite) ,1) return output
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:subset; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:logic; 6, default_parameter; 6, 7; 6, 8; 7, identifier:update; 8, False; 9, block; 9, 10; 9, 16; 9, 22; 9, 30; 9, 34; 9, 40; 9, 52; 9, 66; 9, 165; 9, 174; 9, 227; 9, 235; 9, 259; 9, 268; 9, 276; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12, identifier:pnames; 13, attribute; 13, 14; 13, 15; 14, identifier:self; 15, identifier:phenotypes; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 19; 18, identifier:snames; 19, attribute; 19, 20; 19, 21; 20, identifier:self; 21, identifier:scored_names; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 25; 24, identifier:data; 25, call; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:self; 28, identifier:copy; 29, argument_list; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 33; 32, identifier:values; 33, list:[]; 34, expression_statement; 34, 35; 35, assignment; 35, 36; 35, 37; 36, identifier:phenotypes; 37, attribute; 37, 38; 37, 39; 38, identifier:logic; 39, identifier:phenotypes; 40, if_statement; 40, 41; 40, 47; 41, comparison_operator:==; 41, 42; 41, 46; 42, call; 42, 43; 42, 44; 43, identifier:len; 44, argument_list; 44, 45; 45, identifier:phenotypes; 46, integer:0; 47, block; 47, 48; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:phenotypes; 51, identifier:pnames; 52, expression_statement; 52, 53; 53, assignment; 53, 54; 53, 55; 54, identifier:removing; 55, binary_operator:-; 55, 56; 55, 62; 56, call; 56, 57; 56, 58; 57, identifier:set; 58, argument_list; 58, 59; 59, attribute; 59, 60; 59, 61; 60, identifier:self; 61, identifier:phenotypes; 62, call; 62, 63; 62, 64; 63, identifier:set; 64, argument_list; 64, 65; 65, identifier:phenotypes; 66, for_statement; 66, 67; 66, 68; 66, 69; 67, identifier:k; 68, identifier:phenotypes; 69, block; 69, 70; 69, 80; 69, 106; 69, 158; 70, if_statement; 70, 71; 70, 74; 71, comparison_operator:not; 71, 72; 71, 73; 72, identifier:k; 73, identifier:pnames; 74, block; 74, 75; 75, raise_statement; 75, 76; 76, call; 76, 77; 76, 78; 77, identifier:ValueError; 78, argument_list; 78, 79; 79, string:"phenotype must exist in defined"; 80, expression_statement; 80, 81; 81, assignment; 81, 82; 81, 83; 82, identifier:temp; 83, call; 83, 84; 83, 105; 84, attribute; 84, 85; 84, 104; 85, subscript; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:data; 88, identifier:loc; 89, call; 89, 90; 89, 95; 90, attribute; 90, 91; 90, 94; 91, subscript; 91, 92; 91, 93; 92, identifier:data; 93, string:'phenotype_calls'; 94, identifier:apply; 95, argument_list; 95, 96; 96, lambda; 96, 97; 96, 99; 97, lambda_parameters; 97, 98; 98, identifier:x; 99, comparison_operator:==; 99, 100; 99, 103; 100, subscript; 100, 101; 100, 102; 101, identifier:x; 102, identifier:k; 103, integer:1; 104, identifier:copy; 105, argument_list; 106, if_statement; 106, 107; 106, 121; 107, boolean_operator:and; 107, 108; 107, 114; 108, comparison_operator:>; 108, 109; 108, 113; 109, call; 109, 110; 109, 111; 110, identifier:len; 111, argument_list; 111, 112; 112, identifier:removing; 113, integer:0; 114, comparison_operator:>; 114, 115; 114, 120; 115, subscript; 115, 116; 115, 119; 116, attribute; 116, 117; 116, 118; 117, identifier:temp; 118, identifier:shape; 119, integer:0; 120, integer:0; 121, block; 121, 122; 122, expression_statement; 122, 123; 123, assignment; 123, 124; 123, 127; 124, subscript; 124, 125; 124, 126; 125, identifier:temp; 126, string:'phenotype_calls'; 127, call; 127, 128; 127, 131; 128, attribute; 128, 129; 128, 130; 129, identifier:temp; 130, identifier:apply; 131, argument_list; 131, 132; 131, 157; 132, lambda; 132, 133; 132, 135; 133, lambda_parameters; 133, 134; 134, identifier:x; 135, call; 135, 136; 135, 137; 136, identifier:dict; 137, argument_list; 137, 138; 138, list_comprehension; 138, 139; 138, 142; 138, 153; 139, tuple; 139, 140; 139, 141; 140, identifier:k; 141, identifier:v; 142, for_in_clause; 142, 143; 142, 146; 143, pattern_list; 143, 144; 143, 145; 144, identifier:k; 145, identifier:v; 146, call; 146, 147; 146, 152; 147, attribute; 147, 148; 147, 151; 148, subscript; 148, 149; 148, 150; 149, identifier:x; 150, string:'phenotype_calls'; 151, identifier:items; 152, argument_list; 153, if_clause; 153, 154; 154, comparison_operator:not; 154, 155; 154, 156; 155, identifier:k; 156, identifier:removing; 157, integer:1; 158, expression_statement; 158, 159; 159, call; 159, 160; 159, 163; 160, attribute; 160, 161; 160, 162; 161, identifier:values; 162, identifier:append; 163, argument_list; 163, 164; 164, identifier:temp; 165, expression_statement; 165, 166; 166, assignment; 166, 167; 166, 168; 167, identifier:data; 168, call; 168, 169; 168, 172; 169, attribute; 169, 170; 169, 171; 170, identifier:pd; 171, identifier:concat; 172, argument_list; 172, 173; 173, identifier:values; 174, for_statement; 174, 175; 174, 178; 174, 185; 175, pattern_list; 175, 176; 175, 177; 176, identifier:k; 177, identifier:v; 178, call; 178, 179; 178, 184; 179, attribute; 179, 180; 179, 183; 180, attribute; 180, 181; 180, 182; 181, identifier:logic; 182, identifier:scored_calls; 183, identifier:items; 184, argument_list; 185, block; 185, 186; 185, 196; 185, 205; 186, if_statement; 186, 187; 186, 190; 187, comparison_operator:not; 187, 188; 187, 189; 188, identifier:k; 189, identifier:snames; 190, block; 190, 191; 191, raise_statement; 191, 192; 192, call; 192, 193; 192, 194; 193, identifier:ValueError; 194, argument_list; 194, 195; 195, string:"Scored name must exist in defined"; 196, expression_statement; 196, 197; 197, assignment; 197, 198; 197, 199; 198, identifier:myfilter; 199, conditional_expression:if; 199, 200; 199, 201; 199, 204; 200, integer:0; 201, comparison_operator:==; 201, 202; 201, 203; 202, identifier:v; 203, string:'-'; 204, integer:1; 205, expression_statement; 205, 206; 206, assignment; 206, 207; 206, 208; 207, identifier:data; 208, subscript; 208, 209; 208, 212; 209, attribute; 209, 210; 209, 211; 210, identifier:data; 211, identifier:loc; 212, call; 212, 213; 212, 218; 213, attribute; 213, 214; 213, 217; 214, subscript; 214, 215; 214, 216; 215, identifier:data; 216, string:'scored_calls'; 217, identifier:apply; 218, argument_list; 218, 219; 219, lambda; 219, 220; 219, 222; 220, lambda_parameters; 220, 221; 221, identifier:x; 222, comparison_operator:==; 222, 223; 222, 226; 223, subscript; 223, 224; 223, 225; 224, identifier:x; 225, identifier:k; 226, identifier:myfilter; 227, expression_statement; 227, 228; 228, assignment; 228, 229; 228, 232; 229, attribute; 229, 230; 229, 231; 230, identifier:data; 231, identifier:microns_per_pixel; 232, attribute; 232, 233; 232, 234; 233, identifier:self; 234, identifier:microns_per_pixel; 235, if_statement; 235, 236; 235, 237; 236, identifier:update; 237, block; 237, 238; 238, expression_statement; 238, 239; 239, assignment; 239, 240; 239, 243; 240, subscript; 240, 241; 240, 242; 241, identifier:data; 242, string:'phenotype_calls'; 243, call; 243, 244; 243, 249; 244, attribute; 244, 245; 244, 248; 245, subscript; 245, 246; 245, 247; 246, identifier:data; 247, string:'phenotype_calls'; 248, identifier:apply; 249, argument_list; 249, 250; 250, lambda; 250, 251; 250, 253; 251, lambda_parameters; 251, 252; 252, identifier:x; 253, dictionary; 253, 254; 254, pair; 254, 255; 254, 258; 255, attribute; 255, 256; 255, 257; 256, identifier:logic; 257, identifier:label; 258, integer:1; 259, expression_statement; 259, 260; 260, call; 260, 261; 260, 264; 261, attribute; 261, 262; 261, 263; 262, identifier:data; 263, identifier:fill_phenotype_label; 264, argument_list; 264, 265; 265, keyword_argument; 265, 266; 265, 267; 266, identifier:inplace; 267, True; 268, expression_statement; 268, 269; 269, assignment; 269, 270; 269, 273; 270, attribute; 270, 271; 270, 272; 271, identifier:data; 272, identifier:db; 273, attribute; 273, 274; 273, 275; 274, identifier:self; 275, identifier:db; 276, return_statement; 276, 277; 277, identifier:data
def subset(self,logic,update=False): pnames = self.phenotypes snames = self.scored_names data = self.copy() values = [] phenotypes = logic.phenotypes if len(phenotypes)==0: phenotypes = pnames removing = set(self.phenotypes)-set(phenotypes) for k in phenotypes: if k not in pnames: raise ValueError("phenotype must exist in defined") temp = data.loc[data['phenotype_calls'].apply(lambda x: x[k]==1)].copy() if len(removing) > 0 and temp.shape[0] > 0: temp['phenotype_calls'] = temp.apply(lambda x: dict([(k,v) for k,v in x['phenotype_calls'].items() if k not in removing]) ,1) values.append(temp) data = pd.concat(values) for k,v in logic.scored_calls.items(): if k not in snames: raise ValueError("Scored name must exist in defined") myfilter = 0 if v == '-' else 1 data = data.loc[data['scored_calls'].apply(lambda x: x[k]==myfilter)] data.microns_per_pixel = self.microns_per_pixel if update: data['phenotype_calls'] = data['phenotype_calls'].apply(lambda x: {logic.label:1}) data.fill_phenotype_label(inplace=True) data.db = self.db return data
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:collapse_phenotypes; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:input_phenotype_labels; 6, identifier:output_phenotype_label; 7, default_parameter; 7, 8; 7, 9; 8, identifier:verbose; 9, True; 10, block; 10, 11; 10, 23; 10, 37; 10, 57; 10, 65; 10, 75; 10, 148; 10, 170; 10, 207; 10, 227; 11, if_statement; 11, 12; 11, 17; 12, call; 12, 13; 12, 14; 13, identifier:isinstance; 14, argument_list; 14, 15; 14, 16; 15, identifier:input_phenotype_labels; 16, identifier:str; 17, block; 17, 18; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:input_phenotype_labels; 21, list:[input_phenotype_labels]; 21, 22; 22, identifier:input_phenotype_labels; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 26; 25, identifier:bad_phenotypes; 26, binary_operator:-; 26, 27; 26, 31; 27, call; 27, 28; 27, 29; 28, identifier:set; 29, argument_list; 29, 30; 30, identifier:input_phenotype_labels; 31, call; 31, 32; 31, 33; 32, identifier:set; 33, argument_list; 33, 34; 34, attribute; 34, 35; 34, 36; 35, identifier:self; 36, identifier:phenotypes; 37, if_statement; 37, 38; 37, 44; 38, comparison_operator:>; 38, 39; 38, 43; 39, call; 39, 40; 39, 41; 40, identifier:len; 41, argument_list; 41, 42; 42, identifier:bad_phenotypes; 43, integer:0; 44, block; 44, 45; 45, raise_statement; 45, 46; 46, call; 46, 47; 46, 48; 47, identifier:ValueError; 48, argument_list; 48, 49; 49, binary_operator:+; 49, 50; 49, 56; 50, binary_operator:+; 50, 51; 50, 52; 51, string:"Error phenotype(s) "; 52, call; 52, 53; 52, 54; 53, identifier:str; 54, argument_list; 54, 55; 55, identifier:bad_phenotypes; 56, string:" are not in the data."; 57, expression_statement; 57, 58; 58, assignment; 58, 59; 58, 60; 59, identifier:data; 60, call; 60, 61; 60, 64; 61, attribute; 61, 62; 61, 63; 62, identifier:self; 63, identifier:copy; 64, argument_list; 65, if_statement; 65, 66; 65, 72; 66, comparison_operator:==; 66, 67; 66, 71; 67, call; 67, 68; 67, 69; 68, identifier:len; 69, argument_list; 69, 70; 70, identifier:input_phenotype_labels; 71, integer:0; 72, block; 72, 73; 73, return_statement; 73, 74; 74, identifier:data; 75, function_definition; 75, 76; 75, 77; 75, 81; 76, function_name:_swap_in; 77, parameters; 77, 78; 77, 79; 77, 80; 78, identifier:d; 79, identifier:inputs; 80, identifier:output; 81, block; 81, 82; 81, 98; 81, 108; 81, 128; 82, expression_statement; 82, 83; 83, assignment; 83, 84; 83, 85; 84, identifier:overlap; 85, call; 85, 86; 85, 96; 86, attribute; 86, 87; 86, 95; 87, call; 87, 88; 87, 89; 88, identifier:set; 89, argument_list; 89, 90; 90, call; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, identifier:d; 93, identifier:keys; 94, argument_list; 95, identifier:intersection; 96, argument_list; 96, 97; 97, identifier:inputs; 98, if_statement; 98, 99; 98, 105; 99, comparison_operator:==; 99, 100; 99, 104; 100, call; 100, 101; 100, 102; 101, identifier:len; 102, argument_list; 102, 103; 103, identifier:overlap; 104, integer:0; 105, block; 105, 106; 106, return_statement; 106, 107; 107, identifier:d; 108, expression_statement; 108, 109; 109, assignment; 109, 110; 109, 111; 110, identifier:keepers; 111, list_comprehension; 111, 112; 111, 115; 111, 124; 112, tuple; 112, 113; 112, 114; 113, identifier:k; 114, identifier:v; 115, for_in_clause; 115, 116; 115, 119; 116, pattern_list; 116, 117; 116, 118; 117, identifier:k; 118, identifier:v; 119, call; 119, 120; 119, 123; 120, attribute; 120, 121; 120, 122; 121, identifier:d; 122, identifier:items; 123, argument_list; 124, if_clause; 124, 125; 125, comparison_operator:not; 125, 126; 125, 127; 126, identifier:k; 127, identifier:inputs; 128, return_statement; 128, 129; 129, call; 129, 130; 129, 131; 130, identifier:dict; 131, argument_list; 131, 132; 132, binary_operator:+; 132, 133; 132, 134; 132, 135; 133, identifier:keepers; 134, line_continuation:\; 135, list:[(output_phenotype_label,max([d[x] for x in overlap]))]; 135, 136; 136, tuple; 136, 137; 136, 138; 137, identifier:output_phenotype_label; 138, call; 138, 139; 138, 140; 139, identifier:max; 140, argument_list; 140, 141; 141, list_comprehension; 141, 142; 141, 145; 142, subscript; 142, 143; 142, 144; 143, identifier:d; 144, identifier:x; 145, for_in_clause; 145, 146; 145, 147; 146, identifier:x; 147, identifier:overlap; 148, expression_statement; 148, 149; 149, assignment; 149, 150; 149, 153; 150, subscript; 150, 151; 150, 152; 151, identifier:data; 152, string:'phenotype_calls'; 153, call; 153, 154; 153, 157; 154, attribute; 154, 155; 154, 156; 155, identifier:data; 156, identifier:apply; 157, argument_list; 157, 158; 157, 169; 158, lambda; 158, 159; 158, 161; 159, lambda_parameters; 159, 160; 160, identifier:x; 161, call; 161, 162; 161, 163; 162, identifier:_swap_in; 163, argument_list; 163, 164; 163, 167; 163, 168; 164, subscript; 164, 165; 164, 166; 165, identifier:x; 166, string:'phenotype_calls'; 167, identifier:input_phenotype_labels; 168, identifier:output_phenotype_label; 169, integer:1; 170, function_definition; 170, 171; 170, 172; 170, 174; 171, function_name:_set_label; 172, parameters; 172, 173; 173, identifier:d; 174, block; 174, 175; 174, 193; 175, expression_statement; 175, 176; 176, assignment; 176, 177; 176, 178; 177, identifier:vals; 178, list_comprehension; 178, 179; 178, 180; 178, 189; 179, identifier:k; 180, for_in_clause; 180, 181; 180, 184; 181, pattern_list; 181, 182; 181, 183; 182, identifier:k; 183, identifier:v; 184, call; 184, 185; 184, 188; 185, attribute; 185, 186; 185, 187; 186, identifier:d; 187, identifier:items; 188, argument_list; 189, if_clause; 189, 190; 190, comparison_operator:==; 190, 191; 190, 192; 191, identifier:v; 192, integer:1; 193, return_statement; 193, 194; 194, conditional_expression:if; 194, 195; 194, 198; 194, 204; 195, attribute; 195, 196; 195, 197; 196, identifier:np; 197, identifier:nan; 198, comparison_operator:==; 198, 199; 198, 203; 199, call; 199, 200; 199, 201; 200, identifier:len; 201, argument_list; 201, 202; 202, identifier:vals; 203, integer:0; 204, subscript; 204, 205; 204, 206; 205, identifier:vals; 206, integer:0; 207, expression_statement; 207, 208; 208, assignment; 208, 209; 208, 212; 209, subscript; 209, 210; 209, 211; 210, identifier:data; 211, string:'phenotype_label'; 212, call; 212, 213; 212, 216; 213, attribute; 213, 214; 213, 215; 214, identifier:data; 215, identifier:apply; 216, argument_list; 216, 217; 216, 226; 217, lambda; 217, 218; 217, 220; 218, lambda_parameters; 218, 219; 219, identifier:x; 220, call; 220, 221; 220, 222; 221, identifier:_set_label; 222, argument_list; 222, 223; 223, subscript; 223, 224; 223, 225; 224, identifier:x; 225, string:'phenotype_calls'; 226, integer:1; 227, return_statement; 227, 228; 228, identifier:data
def collapse_phenotypes(self,input_phenotype_labels,output_phenotype_label,verbose=True): if isinstance(input_phenotype_labels,str): input_phenotype_labels = [input_phenotype_labels] bad_phenotypes = set(input_phenotype_labels)-set(self.phenotypes) if len(bad_phenotypes) > 0: raise ValueError("Error phenotype(s) "+str(bad_phenotypes)+" are not in the data.") data = self.copy() if len(input_phenotype_labels) == 0: return data def _swap_in(d,inputs,output): overlap = set(d.keys()).intersection(inputs) if len(overlap) == 0: return d keepers = [(k,v) for k,v in d.items() if k not in inputs] return dict(keepers+\ [(output_phenotype_label,max([d[x] for x in overlap]))]) data['phenotype_calls'] = data.apply(lambda x: _swap_in(x['phenotype_calls'],input_phenotype_labels,output_phenotype_label) ,1) def _set_label(d): vals = [k for k,v in d.items() if v==1] return np.nan if len(vals) == 0 else vals[0] data['phenotype_label'] = data.apply(lambda x: _set_label(x['phenotype_calls']),1) return data
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:scored_to_phenotype; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:phenotypes; 6, block; 6, 7; 6, 85; 6, 93; 6, 114; 6, 145; 7, function_definition; 7, 8; 7, 9; 7, 12; 8, function_name:_apply_score; 9, parameters; 9, 10; 9, 11; 10, identifier:scored_calls; 11, identifier:phenotypes; 12, block; 12, 13; 12, 35; 12, 48; 12, 58; 12, 67; 12, 80; 13, expression_statement; 13, 14; 14, assignment; 14, 15; 14, 16; 15, identifier:present; 16, call; 16, 17; 16, 18; 17, identifier:sorted; 18, argument_list; 18, 19; 19, call; 19, 20; 19, 21; 20, identifier:list; 21, argument_list; 21, 22; 22, binary_operator:&; 22, 23; 22, 27; 23, call; 23, 24; 23, 25; 24, identifier:set; 25, argument_list; 25, 26; 26, identifier:phenotypes; 27, call; 27, 28; 27, 29; 28, identifier:set; 29, argument_list; 29, 30; 30, call; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:scored_calls; 33, identifier:keys; 34, argument_list; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 38; 37, identifier:total; 38, call; 38, 39; 38, 40; 39, identifier:sum; 40, argument_list; 40, 41; 41, list_comprehension; 41, 42; 41, 45; 42, subscript; 42, 43; 42, 44; 43, identifier:scored_calls; 44, identifier:x; 45, for_in_clause; 45, 46; 45, 47; 46, identifier:x; 47, identifier:present; 48, if_statement; 48, 49; 48, 52; 49, comparison_operator:>; 49, 50; 49, 51; 50, identifier:total; 51, integer:1; 52, block; 52, 53; 53, raise_statement; 53, 54; 54, call; 54, 55; 54, 56; 55, identifier:ValueError; 56, argument_list; 56, 57; 57, string:"You cant extract phenotypes from scores if they are not mutually exclusive"; 58, if_statement; 58, 59; 58, 62; 59, comparison_operator:==; 59, 60; 59, 61; 60, identifier:total; 61, integer:0; 62, block; 62, 63; 63, return_statement; 63, 64; 64, attribute; 64, 65; 64, 66; 65, identifier:np; 66, identifier:nan; 67, for_statement; 67, 68; 67, 69; 67, 70; 68, identifier:label; 69, identifier:present; 70, block; 70, 71; 71, if_statement; 71, 72; 71, 77; 72, comparison_operator:==; 72, 73; 72, 76; 73, subscript; 73, 74; 73, 75; 74, identifier:scored_calls; 75, identifier:label; 76, integer:1; 77, block; 77, 78; 78, return_statement; 78, 79; 79, identifier:label; 80, raise_statement; 80, 81; 81, call; 81, 82; 81, 83; 82, identifier:ValueError; 83, argument_list; 83, 84; 84, string:"Should have hit an exit criteria already"; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 88; 87, identifier:output; 88, call; 88, 89; 88, 92; 89, attribute; 89, 90; 89, 91; 90, identifier:self; 91, identifier:copy; 92, argument_list; 93, expression_statement; 93, 94; 94, assignment; 94, 95; 94, 98; 95, subscript; 95, 96; 95, 97; 96, identifier:output; 97, string:'phenotype_label'; 98, call; 98, 99; 98, 102; 99, attribute; 99, 100; 99, 101; 100, identifier:output; 101, identifier:apply; 102, argument_list; 102, 103; 102, 113; 103, lambda; 103, 104; 103, 106; 104, lambda_parameters; 104, 105; 105, identifier:x; 106, call; 106, 107; 106, 108; 107, identifier:_apply_score; 108, argument_list; 108, 109; 108, 112; 109, subscript; 109, 110; 109, 111; 110, identifier:x; 111, string:'scored_calls'; 112, identifier:phenotypes; 113, integer:1; 114, expression_statement; 114, 115; 115, assignment; 115, 116; 115, 119; 116, subscript; 116, 117; 116, 118; 117, identifier:output; 118, string:'phenotype_calls'; 119, call; 119, 120; 119, 123; 120, attribute; 120, 121; 120, 122; 121, identifier:output; 122, identifier:apply; 123, argument_list; 123, 124; 123, 144; 124, lambda; 124, 125; 124, 127; 125, lambda_parameters; 125, 126; 126, identifier:x; 127, call; 127, 128; 127, 129; 128, identifier:dict; 129, argument_list; 129, 130; 130, list_comprehension; 130, 131; 130, 141; 131, tuple; 131, 132; 131, 133; 132, identifier:y; 133, conditional_expression:if; 133, 134; 133, 135; 133, 140; 134, integer:1; 135, comparison_operator:==; 135, 136; 135, 139; 136, subscript; 136, 137; 136, 138; 137, identifier:x; 138, string:'phenotype_label'; 139, identifier:y; 140, integer:0; 141, for_in_clause; 141, 142; 141, 143; 142, identifier:y; 143, identifier:phenotypes; 144, integer:1; 145, return_statement; 145, 146; 146, identifier:output
def scored_to_phenotype(self,phenotypes): def _apply_score(scored_calls,phenotypes): present = sorted(list(set(phenotypes)&set(scored_calls.keys()))) total = sum([scored_calls[x] for x in present]) if total > 1: raise ValueError("You cant extract phenotypes from scores if they are not mutually exclusive") if total == 0: return np.nan for label in present: if scored_calls[label] == 1: return label raise ValueError("Should have hit an exit criteria already") output = self.copy() output['phenotype_label'] = output.apply(lambda x: _apply_score(x['scored_calls'],phenotypes),1) output['phenotype_calls'] = output.apply(lambda x: dict([(y,1 if x['phenotype_label']==y else 0) for y in phenotypes]) ,1) return output
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:spike_times; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:signal; 5, identifier:threshold; 6, identifier:fs; 7, default_parameter; 7, 8; 7, 9; 8, identifier:absval; 9, True; 10, block; 10, 11; 10, 15; 10, 27; 10, 39; 10, 56; 10, 297; 11, expression_statement; 11, 12; 12, assignment; 12, 13; 12, 14; 13, identifier:times; 14, list:[]; 15, if_statement; 15, 16; 15, 17; 16, identifier:absval; 17, block; 17, 18; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:signal; 21, call; 21, 22; 21, 25; 22, attribute; 22, 23; 22, 24; 23, identifier:np; 24, identifier:abs; 25, argument_list; 25, 26; 26, identifier:signal; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 31; 29, pattern_list; 29, 30; 30, identifier:over; 31, call; 31, 32; 31, 35; 32, attribute; 32, 33; 32, 34; 33, identifier:np; 34, identifier:where; 35, argument_list; 35, 36; 36, comparison_operator:>; 36, 37; 36, 38; 37, identifier:signal; 38, identifier:threshold; 39, expression_statement; 39, 40; 40, assignment; 40, 41; 40, 43; 41, pattern_list; 41, 42; 42, identifier:segments; 43, call; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:np; 46, identifier:where; 47, argument_list; 47, 48; 48, comparison_operator:>; 48, 49; 48, 55; 49, call; 49, 50; 49, 53; 50, attribute; 50, 51; 50, 52; 51, identifier:np; 52, identifier:diff; 53, argument_list; 53, 54; 54, identifier:over; 55, integer:1; 56, if_statement; 56, 57; 56, 63; 56, 275; 57, comparison_operator:>; 57, 58; 57, 62; 58, call; 58, 59; 58, 60; 59, identifier:len; 60, argument_list; 60, 61; 61, identifier:over; 62, integer:1; 63, block; 63, 64; 63, 183; 64, if_statement; 64, 65; 64, 71; 64, 83; 65, comparison_operator:==; 65, 66; 65, 70; 66, call; 66, 67; 66, 68; 67, identifier:len; 68, argument_list; 68, 69; 69, identifier:segments; 70, integer:0; 71, block; 71, 72; 72, expression_statement; 72, 73; 73, assignment; 73, 74; 73, 75; 74, identifier:segments; 75, list:[0, len(over)-1]; 75, 76; 75, 77; 76, integer:0; 77, binary_operator:-; 77, 78; 77, 82; 78, call; 78, 79; 78, 80; 79, identifier:len; 80, argument_list; 80, 81; 81, identifier:over; 82, integer:1; 83, else_clause; 83, 84; 84, block; 84, 85; 84, 132; 85, if_statement; 85, 86; 85, 91; 85, 105; 86, comparison_operator:!=; 86, 87; 86, 90; 87, subscript; 87, 88; 87, 89; 88, identifier:segments; 89, integer:0; 90, integer:0; 91, block; 91, 92; 92, expression_statement; 92, 93; 93, assignment; 93, 94; 93, 95; 94, identifier:segments; 95, call; 95, 96; 95, 99; 96, attribute; 96, 97; 96, 98; 97, identifier:np; 98, identifier:insert; 99, argument_list; 99, 100; 99, 101; 99, 103; 100, identifier:segments; 101, list:[0]; 101, 102; 102, integer:0; 103, list:[0]; 103, 104; 104, integer:0; 105, else_clause; 105, 106; 106, block; 106, 107; 106, 121; 107, expression_statement; 107, 108; 108, call; 108, 109; 108, 112; 109, attribute; 109, 110; 109, 111; 110, identifier:times; 111, identifier:append; 112, argument_list; 112, 113; 113, binary_operator:/; 113, 114; 113, 120; 114, call; 114, 115; 114, 116; 115, identifier:float; 116, argument_list; 116, 117; 117, subscript; 117, 118; 117, 119; 118, identifier:over; 119, integer:0; 120, identifier:fs; 121, if_statement; 121, 122; 121, 125; 122, comparison_operator:not; 122, 123; 122, 124; 123, integer:1; 124, identifier:segments; 125, block; 125, 126; 126, expression_statement; 126, 127; 127, assignment; 127, 128; 127, 131; 128, subscript; 128, 129; 128, 130; 129, identifier:segments; 130, integer:0; 131, integer:1; 132, if_statement; 132, 133; 132, 144; 132, 166; 133, comparison_operator:!=; 133, 134; 133, 138; 134, subscript; 134, 135; 134, 136; 135, identifier:segments; 136, unary_operator:-; 136, 137; 137, integer:1; 138, binary_operator:-; 138, 139; 138, 143; 139, call; 139, 140; 139, 141; 140, identifier:len; 141, argument_list; 141, 142; 142, identifier:over; 143, integer:1; 144, block; 144, 145; 145, expression_statement; 145, 146; 146, assignment; 146, 147; 146, 148; 147, identifier:segments; 148, call; 148, 149; 148, 152; 149, attribute; 149, 150; 149, 151; 150, identifier:np; 151, identifier:insert; 152, argument_list; 152, 153; 152, 154; 152, 159; 153, identifier:segments; 154, list:[len(segments)]; 154, 155; 155, call; 155, 156; 155, 157; 156, identifier:len; 157, argument_list; 157, 158; 158, identifier:segments; 159, list:[len(over)-1]; 159, 160; 160, binary_operator:-; 160, 161; 160, 165; 161, call; 161, 162; 161, 163; 162, identifier:len; 163, argument_list; 163, 164; 164, identifier:over; 165, integer:1; 166, else_clause; 166, 167; 167, block; 167, 168; 168, expression_statement; 168, 169; 169, call; 169, 170; 169, 173; 170, attribute; 170, 171; 170, 172; 171, identifier:times; 172, identifier:append; 173, argument_list; 173, 174; 174, binary_operator:/; 174, 175; 174, 182; 175, call; 175, 176; 175, 177; 176, identifier:float; 177, argument_list; 177, 178; 178, subscript; 178, 179; 178, 180; 179, identifier:over; 180, unary_operator:-; 180, 181; 181, integer:1; 182, identifier:fs; 183, for_statement; 183, 184; 183, 185; 183, 193; 184, identifier:iseg; 185, call; 185, 186; 185, 187; 186, identifier:range; 187, argument_list; 187, 188; 187, 189; 188, integer:1; 189, call; 189, 190; 189, 191; 190, identifier:len; 191, argument_list; 191, 192; 192, identifier:segments; 193, block; 193, 194; 193, 263; 194, if_statement; 194, 195; 194, 206; 194, 215; 195, comparison_operator:==; 195, 196; 195, 205; 196, binary_operator:-; 196, 197; 196, 200; 197, subscript; 197, 198; 197, 199; 198, identifier:segments; 199, identifier:iseg; 200, subscript; 200, 201; 200, 202; 201, identifier:segments; 202, binary_operator:-; 202, 203; 202, 204; 203, identifier:iseg; 204, integer:1; 205, integer:1; 206, block; 206, 207; 207, expression_statement; 207, 208; 208, assignment; 208, 209; 208, 210; 209, identifier:idx; 210, subscript; 210, 211; 210, 212; 211, identifier:over; 212, subscript; 212, 213; 212, 214; 213, identifier:segments; 214, identifier:iseg; 215, else_clause; 215, 216; 216, block; 216, 217; 216, 227; 217, expression_statement; 217, 218; 218, assignment; 218, 219; 218, 222; 219, subscript; 219, 220; 219, 221; 220, identifier:segments; 221, integer:0; 222, binary_operator:-; 222, 223; 222, 226; 223, subscript; 223, 224; 223, 225; 224, identifier:segments; 225, integer:0; 226, integer:1; 227, expression_statement; 227, 228; 228, assignment; 228, 229; 228, 230; 229, identifier:idx; 230, binary_operator:+; 230, 231; 230, 240; 231, subscript; 231, 232; 231, 233; 232, identifier:over; 233, binary_operator:+; 233, 234; 233, 239; 234, subscript; 234, 235; 234, 236; 235, identifier:segments; 236, binary_operator:-; 236, 237; 236, 238; 237, identifier:iseg; 238, integer:1; 239, integer:1; 240, call; 240, 241; 240, 244; 241, attribute; 241, 242; 241, 243; 242, identifier:np; 243, identifier:argmax; 244, argument_list; 244, 245; 245, subscript; 245, 246; 245, 247; 246, identifier:signal; 247, slice; 247, 248; 247, 257; 247, 258; 248, subscript; 248, 249; 248, 250; 249, identifier:over; 250, binary_operator:+; 250, 251; 250, 256; 251, subscript; 251, 252; 251, 253; 252, identifier:segments; 253, binary_operator:-; 253, 254; 253, 255; 254, identifier:iseg; 255, integer:1; 256, integer:1; 257, colon; 258, subscript; 258, 259; 258, 260; 259, identifier:over; 260, subscript; 260, 261; 260, 262; 261, identifier:segments; 262, identifier:iseg; 263, expression_statement; 263, 264; 264, call; 264, 265; 264, 268; 265, attribute; 265, 266; 265, 267; 266, identifier:times; 267, identifier:append; 268, argument_list; 268, 269; 269, binary_operator:/; 269, 270; 269, 274; 270, call; 270, 271; 270, 272; 271, identifier:float; 272, argument_list; 272, 273; 273, identifier:idx; 274, identifier:fs; 275, elif_clause; 275, 276; 275, 282; 276, comparison_operator:==; 276, 277; 276, 281; 277, call; 277, 278; 277, 279; 278, identifier:len; 279, argument_list; 279, 280; 280, identifier:over; 281, integer:1; 282, block; 282, 283; 283, expression_statement; 283, 284; 284, call; 284, 285; 284, 288; 285, attribute; 285, 286; 285, 287; 286, identifier:times; 287, identifier:append; 288, argument_list; 288, 289; 289, binary_operator:/; 289, 290; 289, 296; 290, call; 290, 291; 290, 292; 291, identifier:float; 292, argument_list; 292, 293; 293, subscript; 293, 294; 293, 295; 294, identifier:over; 295, integer:0; 296, identifier:fs; 297, if_statement; 297, 298; 297, 304; 297, 310; 298, comparison_operator:>; 298, 299; 298, 303; 299, call; 299, 300; 299, 301; 300, identifier:len; 301, argument_list; 301, 302; 302, identifier:times; 303, integer:0; 304, block; 304, 305; 305, return_statement; 305, 306; 306, call; 306, 307; 306, 308; 307, identifier:refractory; 308, argument_list; 308, 309; 309, identifier:times; 310, else_clause; 310, 311; 311, block; 311, 312; 312, return_statement; 312, 313; 313, identifier:times
def spike_times(signal, threshold, fs, absval=True): times = [] if absval: signal = np.abs(signal) over, = np.where(signal>threshold) segments, = np.where(np.diff(over) > 1) if len(over) > 1: if len(segments) == 0: segments = [0, len(over)-1] else: if segments[0] != 0: segments = np.insert(segments, [0], [0]) else: times.append(float(over[0])/fs) if 1 not in segments: segments[0] = 1 if segments[-1] != len(over)-1: segments = np.insert(segments, [len(segments)], [len(over)-1]) else: times.append(float(over[-1])/fs) for iseg in range(1,len(segments)): if segments[iseg] - segments[iseg-1] == 1: idx = over[segments[iseg]] else: segments[0] = segments[0]-1 idx = over[segments[iseg-1]+1] + np.argmax(signal[over[segments[iseg-1]+1]:over[segments[iseg]]]) times.append(float(idx)/fs) elif len(over) == 1: times.append(float(over[0])/fs) if len(times)>0: return refractory(times) else: return times
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:bin_spikes; 3, parameters; 3, 4; 3, 5; 4, identifier:spike_times; 5, identifier:binsz; 6, block; 6, 7; 6, 23; 6, 51; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:bins; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:np; 13, identifier:empty; 14, argument_list; 14, 15; 14, 20; 15, tuple; 15, 16; 16, call; 16, 17; 16, 18; 17, identifier:len; 18, argument_list; 18, 19; 19, identifier:spike_times; 20, keyword_argument; 20, 21; 20, 22; 21, identifier:dtype; 22, identifier:int; 23, for_statement; 23, 24; 23, 27; 23, 31; 24, pattern_list; 24, 25; 24, 26; 25, identifier:i; 26, identifier:stime; 27, call; 27, 28; 27, 29; 28, identifier:enumerate; 29, argument_list; 29, 30; 30, identifier:spike_times; 31, block; 31, 32; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 37; 34, subscript; 34, 35; 34, 36; 35, identifier:bins; 36, identifier:i; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:np; 40, identifier:floor; 41, argument_list; 41, 42; 42, call; 42, 43; 42, 46; 43, attribute; 43, 44; 43, 45; 44, identifier:np; 45, identifier:around; 46, argument_list; 46, 47; 46, 50; 47, binary_operator:/; 47, 48; 47, 49; 48, identifier:stime; 49, identifier:binsz; 50, integer:5; 51, return_statement; 51, 52; 52, identifier:bins
def bin_spikes(spike_times, binsz): bins = np.empty((len(spike_times),), dtype=int) for i, stime in enumerate(spike_times): bins[i] = np.floor(np.around(stime/binsz, 5)) return bins
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:corewriter; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 243; 5, 288; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 9; 8, identifier:printtime; 9, argument_list; 9, 10; 9, 11; 10, string:'Creating core allele files'; 11, attribute; 11, 12; 11, 13; 12, identifier:self; 13, identifier:start; 14, for_statement; 14, 15; 14, 16; 14, 22; 15, identifier:gene; 16, call; 16, 17; 16, 18; 17, identifier:sorted; 18, argument_list; 18, 19; 19, attribute; 19, 20; 19, 21; 20, identifier:self; 21, identifier:genesequence; 22, block; 22, 23; 22, 32; 22, 51; 23, expression_statement; 23, 24; 24, call; 24, 25; 24, 30; 25, attribute; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:self; 28, identifier:geneset; 29, identifier:add; 30, argument_list; 30, 31; 31, identifier:gene; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 35; 34, identifier:genefile; 35, call; 35, 36; 35, 41; 36, attribute; 36, 37; 36, 40; 37, attribute; 37, 38; 37, 39; 38, identifier:os; 39, identifier:path; 40, identifier:join; 41, argument_list; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:self; 44, identifier:coregenelocation; 45, call; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, string:'{}.fasta'; 48, identifier:format; 49, argument_list; 49, 50; 50, identifier:gene; 51, if_statement; 51, 52; 51, 61; 51, 176; 52, not_operator; 52, 53; 53, call; 53, 54; 53, 59; 54, attribute; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:os; 57, identifier:path; 58, identifier:isfile; 59, argument_list; 59, 60; 60, identifier:genefile; 61, block; 61, 62; 62, with_statement; 62, 63; 62, 73; 63, with_clause; 63, 64; 64, with_item; 64, 65; 65, as_pattern; 65, 66; 65, 71; 66, call; 66, 67; 66, 68; 67, identifier:open; 68, argument_list; 68, 69; 68, 70; 69, identifier:genefile; 70, string:'w'; 71, as_pattern_target; 71, 72; 72, identifier:core; 73, block; 73, 74; 74, for_statement; 74, 75; 74, 78; 74, 86; 75, pattern_list; 75, 76; 75, 77; 76, identifier:count; 77, identifier:sequence; 78, call; 78, 79; 78, 80; 79, identifier:enumerate; 80, argument_list; 80, 81; 81, subscript; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:self; 84, identifier:genesequence; 85, identifier:gene; 86, block; 86, 87; 86, 99; 86, 115; 86, 124; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 90; 89, identifier:definitionline; 90, call; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, string:'{}-{}'; 93, identifier:format; 94, argument_list; 94, 95; 94, 96; 95, identifier:gene; 96, binary_operator:+; 96, 97; 96, 98; 97, identifier:count; 98, integer:1; 99, expression_statement; 99, 100; 100, assignment; 100, 101; 100, 102; 101, identifier:fasta; 102, call; 102, 103; 102, 104; 103, identifier:SeqRecord; 104, argument_list; 104, 105; 104, 109; 104, 112; 105, call; 105, 106; 105, 107; 106, identifier:Seq; 107, argument_list; 107, 108; 108, identifier:sequence; 109, keyword_argument; 109, 110; 109, 111; 110, identifier:description; 111, string:''; 112, keyword_argument; 112, 113; 112, 114; 113, identifier:id; 114, identifier:definitionline; 115, expression_statement; 115, 116; 116, call; 116, 117; 116, 120; 117, attribute; 117, 118; 117, 119; 118, identifier:SeqIO; 119, identifier:write; 120, argument_list; 120, 121; 120, 122; 120, 123; 121, identifier:fasta; 122, identifier:core; 123, string:'fasta'; 124, for_statement; 124, 125; 124, 126; 124, 131; 125, identifier:strain; 126, subscript; 126, 127; 126, 130; 127, attribute; 127, 128; 127, 129; 128, identifier:self; 129, identifier:coresequence; 130, identifier:sequence; 131, block; 131, 132; 132, try_statement; 132, 133; 132, 155; 133, block; 133, 134; 134, expression_statement; 134, 135; 135, call; 135, 136; 135, 148; 136, attribute; 136, 137; 136, 147; 137, subscript; 137, 138; 137, 141; 138, attribute; 138, 139; 138, 140; 139, identifier:self; 140, identifier:corealleles; 141, subscript; 141, 142; 141, 143; 142, identifier:strain; 143, slice; 143, 144; 143, 145; 144, colon; 145, unary_operator:-; 145, 146; 146, integer:6; 147, identifier:update; 148, argument_list; 148, 149; 149, dictionary; 149, 150; 150, pair; 150, 151; 150, 152; 151, identifier:gene; 152, binary_operator:+; 152, 153; 152, 154; 153, identifier:count; 154, integer:1; 155, except_clause; 155, 156; 155, 157; 156, identifier:KeyError; 157, block; 157, 158; 158, expression_statement; 158, 159; 159, assignment; 159, 160; 159, 170; 160, subscript; 160, 161; 160, 164; 161, attribute; 161, 162; 161, 163; 162, identifier:self; 163, identifier:corealleles; 164, subscript; 164, 165; 164, 166; 165, identifier:strain; 166, slice; 166, 167; 166, 168; 167, colon; 168, unary_operator:-; 168, 169; 169, integer:6; 170, dictionary; 170, 171; 171, pair; 171, 172; 171, 173; 172, identifier:gene; 173, binary_operator:+; 173, 174; 173, 175; 174, identifier:count; 175, integer:1; 176, else_clause; 176, 177; 177, block; 177, 178; 178, for_statement; 178, 179; 178, 182; 178, 190; 179, pattern_list; 179, 180; 179, 181; 180, identifier:count; 181, identifier:sequence; 182, call; 182, 183; 182, 184; 183, identifier:enumerate; 184, argument_list; 184, 185; 185, subscript; 185, 186; 185, 189; 186, attribute; 186, 187; 186, 188; 187, identifier:self; 188, identifier:genesequence; 189, identifier:gene; 190, block; 190, 191; 191, for_statement; 191, 192; 191, 193; 191, 198; 192, identifier:strain; 193, subscript; 193, 194; 193, 197; 194, attribute; 194, 195; 194, 196; 195, identifier:self; 196, identifier:coresequence; 197, identifier:sequence; 198, block; 198, 199; 199, try_statement; 199, 200; 199, 222; 200, block; 200, 201; 201, expression_statement; 201, 202; 202, call; 202, 203; 202, 215; 203, attribute; 203, 204; 203, 214; 204, subscript; 204, 205; 204, 208; 205, attribute; 205, 206; 205, 207; 206, identifier:self; 207, identifier:corealleles; 208, subscript; 208, 209; 208, 210; 209, identifier:strain; 210, slice; 210, 211; 210, 212; 211, colon; 212, unary_operator:-; 212, 213; 213, integer:6; 214, identifier:update; 215, argument_list; 215, 216; 216, dictionary; 216, 217; 217, pair; 217, 218; 217, 219; 218, identifier:gene; 219, binary_operator:+; 219, 220; 219, 221; 220, identifier:count; 221, integer:1; 222, except_clause; 222, 223; 222, 224; 223, identifier:KeyError; 224, block; 224, 225; 225, expression_statement; 225, 226; 226, assignment; 226, 227; 226, 237; 227, subscript; 227, 228; 227, 231; 228, attribute; 228, 229; 228, 230; 229, identifier:self; 230, identifier:corealleles; 231, subscript; 231, 232; 231, 233; 232, identifier:strain; 233, slice; 233, 234; 233, 235; 234, colon; 235, unary_operator:-; 235, 236; 236, integer:6; 237, dictionary; 237, 238; 238, pair; 238, 239; 238, 240; 239, identifier:gene; 240, binary_operator:+; 240, 241; 240, 242; 241, identifier:count; 242, integer:1; 243, if_statement; 243, 244; 243, 263; 244, not_operator; 244, 245; 245, call; 245, 246; 245, 251; 246, attribute; 246, 247; 246, 250; 247, attribute; 247, 248; 247, 249; 248, identifier:os; 249, identifier:path; 250, identifier:isfile; 251, argument_list; 251, 252; 252, call; 252, 253; 252, 258; 253, attribute; 253, 254; 253, 257; 254, attribute; 254, 255; 254, 256; 255, identifier:os; 256, identifier:path; 257, identifier:join; 258, argument_list; 258, 259; 258, 262; 259, attribute; 259, 260; 259, 261; 260, identifier:self; 261, identifier:coregenelocation; 262, string:'core_combined.fasta'; 263, block; 263, 264; 263, 281; 264, expression_statement; 264, 265; 265, assignment; 265, 266; 265, 267; 266, identifier:fastafiles; 267, call; 267, 268; 267, 269; 268, identifier:glob; 269, argument_list; 269, 270; 270, call; 270, 271; 270, 276; 271, attribute; 271, 272; 271, 275; 272, attribute; 272, 273; 272, 274; 273, identifier:os; 274, identifier:path; 275, identifier:join; 276, argument_list; 276, 277; 276, 280; 277, attribute; 277, 278; 277, 279; 278, identifier:self; 279, identifier:coregenelocation; 280, string:'*.fasta'; 281, expression_statement; 281, 282; 282, call; 282, 283; 282, 286; 283, attribute; 283, 284; 283, 285; 284, identifier:self; 285, identifier:combinealleles; 286, argument_list; 286, 287; 287, identifier:fastafiles; 288, expression_statement; 288, 289; 289, call; 289, 290; 289, 293; 290, attribute; 290, 291; 290, 292; 291, identifier:self; 292, identifier:profiler; 293, argument_list
def corewriter(self): printtime('Creating core allele files', self.start) for gene in sorted(self.genesequence): self.geneset.add(gene) genefile = os.path.join(self.coregenelocation, '{}.fasta'.format(gene)) if not os.path.isfile(genefile): with open(genefile, 'w') as core: for count, sequence in enumerate(self.genesequence[gene]): definitionline = '{}-{}'.format(gene, count + 1) fasta = SeqRecord(Seq(sequence), description='', id=definitionline) SeqIO.write(fasta, core, 'fasta') for strain in self.coresequence[sequence]: try: self.corealleles[strain[:-6]].update({gene: count + 1}) except KeyError: self.corealleles[strain[:-6]] = {gene: count + 1} else: for count, sequence in enumerate(self.genesequence[gene]): for strain in self.coresequence[sequence]: try: self.corealleles[strain[:-6]].update({gene: count + 1}) except KeyError: self.corealleles[strain[:-6]] = {gene: count + 1} if not os.path.isfile(os.path.join(self.coregenelocation, 'core_combined.fasta')): fastafiles = glob(os.path.join(self.coregenelocation, '*.fasta')) self.combinealleles(fastafiles) self.profiler()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:profiler; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 43; 5, 62; 5, 66; 5, 148; 5, 184; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 9; 8, identifier:printtime; 9, argument_list; 9, 10; 9, 11; 10, string:'Calculating core profiles'; 11, attribute; 11, 12; 11, 13; 12, identifier:self; 13, identifier:start; 14, for_statement; 14, 15; 14, 16; 14, 19; 15, identifier:strain; 16, attribute; 16, 17; 16, 18; 17, identifier:self; 18, identifier:corealleles; 19, block; 19, 20; 20, expression_statement; 20, 21; 21, call; 21, 22; 21, 27; 22, attribute; 22, 23; 22, 26; 23, attribute; 23, 24; 23, 25; 24, identifier:self; 25, identifier:coreset; 26, identifier:add; 27, argument_list; 27, 28; 28, call; 28, 29; 28, 30; 29, identifier:tuple; 30, argument_list; 30, 31; 31, call; 31, 32; 31, 33; 32, identifier:sorted; 33, argument_list; 33, 34; 34, call; 34, 35; 34, 42; 35, attribute; 35, 36; 35, 41; 36, subscript; 36, 37; 36, 40; 37, attribute; 37, 38; 37, 39; 38, identifier:self; 39, identifier:corealleles; 40, identifier:strain; 41, identifier:items; 42, argument_list; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 46; 45, identifier:header; 46, call; 46, 47; 46, 50; 47, attribute; 47, 48; 47, 49; 48, string:'ST,{}\n'; 49, identifier:format; 50, argument_list; 50, 51; 51, call; 51, 52; 51, 55; 52, attribute; 52, 53; 52, 54; 53, string:','; 54, identifier:join; 55, argument_list; 55, 56; 56, call; 56, 57; 56, 58; 57, identifier:sorted; 58, argument_list; 58, 59; 59, attribute; 59, 60; 59, 61; 60, identifier:self; 61, identifier:geneset; 62, expression_statement; 62, 63; 63, assignment; 63, 64; 63, 65; 64, identifier:data; 65, string:''; 66, for_statement; 66, 67; 66, 70; 66, 79; 67, pattern_list; 67, 68; 67, 69; 68, identifier:count; 69, identifier:core; 70, call; 70, 71; 70, 72; 71, identifier:sorted; 72, argument_list; 72, 73; 73, call; 73, 74; 73, 75; 74, identifier:enumerate; 75, argument_list; 75, 76; 76, attribute; 76, 77; 76, 78; 77, identifier:self; 78, identifier:coreset; 79, block; 79, 80; 79, 84; 79, 93; 79, 126; 79, 144; 80, expression_statement; 80, 81; 81, augmented_assignment:+=; 81, 82; 81, 83; 82, identifier:count; 83, integer:1; 84, expression_statement; 84, 85; 85, augmented_assignment:+=; 85, 86; 85, 87; 86, identifier:data; 87, call; 87, 88; 87, 91; 88, attribute; 88, 89; 88, 90; 89, string:'{}'; 90, identifier:format; 91, argument_list; 91, 92; 92, identifier:count; 93, for_statement; 93, 94; 93, 95; 93, 98; 94, identifier:strain; 95, attribute; 95, 96; 95, 97; 96, identifier:self; 97, identifier:corealleles; 98, block; 98, 99; 99, if_statement; 99, 100; 99, 117; 100, comparison_operator:==; 100, 101; 100, 116; 101, call; 101, 102; 101, 103; 102, identifier:tuple; 103, argument_list; 103, 104; 104, call; 104, 105; 104, 106; 105, identifier:sorted; 106, argument_list; 106, 107; 107, call; 107, 108; 107, 115; 108, attribute; 108, 109; 108, 114; 109, subscript; 109, 110; 109, 113; 110, attribute; 110, 111; 110, 112; 111, identifier:self; 112, identifier:corealleles; 113, identifier:strain; 114, identifier:items; 115, argument_list; 116, identifier:core; 117, block; 117, 118; 118, expression_statement; 118, 119; 119, assignment; 119, 120; 119, 125; 120, subscript; 120, 121; 120, 124; 121, attribute; 121, 122; 121, 123; 122, identifier:self; 123, identifier:profiles; 124, identifier:strain; 125, identifier:count; 126, for_statement; 126, 127; 126, 128; 126, 132; 127, identifier:gene; 128, call; 128, 129; 128, 130; 129, identifier:sorted; 130, argument_list; 130, 131; 131, identifier:core; 132, block; 132, 133; 133, expression_statement; 133, 134; 134, augmented_assignment:+=; 134, 135; 134, 136; 135, identifier:data; 136, call; 136, 137; 136, 140; 137, attribute; 137, 138; 137, 139; 138, string:',{}'; 139, identifier:format; 140, argument_list; 140, 141; 141, subscript; 141, 142; 141, 143; 142, identifier:gene; 143, integer:1; 144, expression_statement; 144, 145; 145, augmented_assignment:+=; 145, 146; 145, 147; 146, identifier:data; 147, string:'\n'; 148, with_statement; 148, 149; 148, 169; 149, with_clause; 149, 150; 150, with_item; 150, 151; 151, as_pattern; 151, 152; 151, 167; 152, call; 152, 153; 152, 154; 153, identifier:open; 154, argument_list; 154, 155; 154, 166; 155, call; 155, 156; 155, 161; 156, attribute; 156, 157; 156, 160; 157, attribute; 157, 158; 157, 159; 158, identifier:os; 159, identifier:path; 160, identifier:join; 161, argument_list; 161, 162; 161, 165; 162, attribute; 162, 163; 162, 164; 163, identifier:self; 164, identifier:profilelocation; 165, string:'profile.txt'; 166, string:'w'; 167, as_pattern_target; 167, 168; 168, identifier:profile; 169, block; 169, 170; 169, 177; 170, expression_statement; 170, 171; 171, call; 171, 172; 171, 175; 172, attribute; 172, 173; 172, 174; 173, identifier:profile; 174, identifier:write; 175, argument_list; 175, 176; 176, identifier:header; 177, expression_statement; 177, 178; 178, call; 178, 179; 178, 182; 179, attribute; 179, 180; 179, 181; 180, identifier:profile; 181, identifier:write; 182, argument_list; 182, 183; 183, identifier:data; 184, expression_statement; 184, 185; 185, call; 185, 186; 185, 189; 186, attribute; 186, 187; 186, 188; 187, identifier:self; 188, identifier:linker; 189, argument_list
def profiler(self): printtime('Calculating core profiles', self.start) for strain in self.corealleles: self.coreset.add(tuple(sorted(self.corealleles[strain].items()))) header = 'ST,{}\n'.format(','.join(sorted(self.geneset))) data = '' for count, core in sorted(enumerate(self.coreset)): count += 1 data += '{}'.format(count) for strain in self.corealleles: if tuple(sorted(self.corealleles[strain].items())) == core: self.profiles[strain] = count for gene in sorted(core): data += ',{}'.format(gene[1]) data += '\n' with open(os.path.join(self.profilelocation, 'profile.txt'), 'w') as profile: profile.write(header) profile.write(data) self.linker()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:row2dict; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:row; 5, default_parameter; 5, 6; 5, 7; 6, identifier:depth; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:exclude; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:exclude_pk; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:exclude_underscore; 16, None; 17, default_parameter; 17, 18; 17, 19; 18, identifier:only; 19, None; 20, default_parameter; 20, 21; 20, 22; 21, identifier:fk_suffix; 22, None; 23, block; 23, 24; 23, 31; 23, 42; 23, 64; 23, 78; 23, 92; 23, 106; 23, 120; 23, 134; 23, 192; 23, 306; 24, if_statement; 24, 25; 24, 28; 25, comparison_operator:==; 25, 26; 25, 27; 26, identifier:depth; 27, integer:0; 28, block; 28, 29; 29, return_statement; 29, 30; 30, None; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 36; 33, pattern_list; 33, 34; 33, 35; 34, identifier:d; 35, identifier:mapper; 36, expression_list; 36, 37; 36, 38; 37, dictionary; 38, call; 38, 39; 38, 40; 39, identifier:get_mapper; 40, argument_list; 40, 41; 41, identifier:row; 42, if_statement; 42, 43; 42, 46; 42, 58; 43, comparison_operator:is; 43, 44; 43, 45; 44, identifier:depth; 45, None; 46, block; 46, 47; 47, expression_statement; 47, 48; 48, assignment; 48, 49; 48, 50; 49, identifier:depth; 50, binary_operator:-; 50, 51; 50, 57; 51, call; 51, 52; 51, 53; 52, identifier:getattr; 53, argument_list; 53, 54; 53, 55; 53, 56; 54, identifier:row; 55, identifier:ATTR_DEPTH; 56, identifier:DEFAULT_DEPTH; 57, integer:1; 58, else_clause; 58, 59; 59, block; 59, 60; 60, expression_statement; 60, 61; 61, augmented_assignment:-=; 61, 62; 61, 63; 62, identifier:depth; 63, integer:1; 64, if_statement; 64, 65; 64, 68; 65, comparison_operator:is; 65, 66; 65, 67; 66, identifier:exclude; 67, None; 68, block; 68, 69; 69, expression_statement; 69, 70; 70, assignment; 70, 71; 70, 72; 71, identifier:exclude; 72, call; 72, 73; 72, 74; 73, identifier:getattr; 74, argument_list; 74, 75; 74, 76; 74, 77; 75, identifier:row; 76, identifier:ATTR_EXCLUDE; 77, identifier:DEFAULT_EXCLUDE; 78, if_statement; 78, 79; 78, 82; 79, comparison_operator:is; 79, 80; 79, 81; 80, identifier:exclude_pk; 81, None; 82, block; 82, 83; 83, expression_statement; 83, 84; 84, assignment; 84, 85; 84, 86; 85, identifier:exclude_pk; 86, call; 86, 87; 86, 88; 87, identifier:getattr; 88, argument_list; 88, 89; 88, 90; 88, 91; 89, identifier:row; 90, identifier:ATTR_EXCLUDE_PK; 91, identifier:DEFAULT_EXCLUDE_PK; 92, if_statement; 92, 93; 92, 96; 93, comparison_operator:is; 93, 94; 93, 95; 94, identifier:exclude_underscore; 95, None; 96, block; 96, 97; 97, expression_statement; 97, 98; 98, assignment; 98, 99; 98, 100; 99, identifier:exclude_underscore; 100, call; 100, 101; 100, 102; 101, identifier:getattr; 102, argument_list; 102, 103; 102, 104; 102, 105; 103, identifier:row; 104, identifier:ATTR_EXCLUDE_UNDERSCORE; 105, identifier:DEFAULT_EXCLUDE_UNDERSCORE; 106, if_statement; 106, 107; 106, 110; 107, comparison_operator:is; 107, 108; 107, 109; 108, identifier:only; 109, None; 110, block; 110, 111; 111, expression_statement; 111, 112; 112, assignment; 112, 113; 112, 114; 113, identifier:only; 114, call; 114, 115; 114, 116; 115, identifier:getattr; 116, argument_list; 116, 117; 116, 118; 116, 119; 117, identifier:row; 118, identifier:ATTR_ONLY; 119, identifier:DEFAULT_ONLY; 120, if_statement; 120, 121; 120, 124; 121, comparison_operator:is; 121, 122; 121, 123; 122, identifier:fk_suffix; 123, None; 124, block; 124, 125; 125, expression_statement; 125, 126; 126, assignment; 126, 127; 126, 128; 127, identifier:fk_suffix; 128, call; 128, 129; 128, 130; 129, identifier:getattr; 130, argument_list; 130, 131; 130, 132; 130, 133; 131, identifier:row; 132, identifier:ATTR_FK_SUFFIX; 133, identifier:DEFAULT_FK_SUFFIX; 134, for_statement; 134, 135; 134, 136; 134, 151; 135, identifier:c; 136, binary_operator:+; 136, 137; 136, 144; 137, call; 137, 138; 137, 143; 138, attribute; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:mapper; 141, identifier:columns; 142, identifier:keys; 143, argument_list; 144, call; 144, 145; 144, 150; 145, attribute; 145, 146; 145, 149; 146, attribute; 146, 147; 146, 148; 147, identifier:mapper; 148, identifier:synonyms; 149, identifier:keys; 150, argument_list; 151, block; 151, 152; 151, 182; 152, if_statement; 152, 153; 152, 180; 153, boolean_operator:or; 153, 154; 153, 174; 153, 175; 154, boolean_operator:or; 154, 155; 154, 168; 154, 169; 155, boolean_operator:or; 155, 156; 155, 159; 155, 160; 156, comparison_operator:in; 156, 157; 156, 158; 157, identifier:c; 158, identifier:exclude; 159, line_continuation:\; 160, call; 160, 161; 160, 162; 161, identifier:check_exclude_pk; 162, argument_list; 162, 163; 162, 164; 162, 165; 163, identifier:c; 164, identifier:exclude_pk; 165, keyword_argument; 165, 166; 165, 167; 166, identifier:fk_suffix; 167, identifier:fk_suffix; 168, line_continuation:\; 169, call; 169, 170; 169, 171; 170, identifier:check_exclude_underscore; 171, argument_list; 171, 172; 171, 173; 172, identifier:c; 173, identifier:exclude_underscore; 174, line_continuation:\; 175, call; 175, 176; 175, 177; 176, identifier:check_only; 177, argument_list; 177, 178; 177, 179; 178, identifier:c; 179, identifier:only; 180, block; 180, 181; 181, continue_statement; 182, expression_statement; 182, 183; 183, assignment; 183, 184; 183, 187; 184, subscript; 184, 185; 184, 186; 185, identifier:d; 186, identifier:c; 187, call; 187, 188; 187, 189; 188, identifier:getattr; 189, argument_list; 189, 190; 189, 191; 190, identifier:row; 191, identifier:c; 192, for_statement; 192, 193; 192, 194; 192, 201; 193, identifier:r; 194, call; 194, 195; 194, 200; 195, attribute; 195, 196; 195, 199; 196, attribute; 196, 197; 196, 198; 197, identifier:mapper; 198, identifier:relationships; 199, identifier:keys; 200, argument_list; 201, block; 201, 202; 201, 214; 201, 222; 201, 233; 201, 243; 201, 267; 202, if_statement; 202, 203; 202, 212; 203, boolean_operator:or; 203, 204; 203, 207; 204, comparison_operator:in; 204, 205; 204, 206; 205, identifier:r; 206, identifier:exclude; 207, call; 207, 208; 207, 209; 208, identifier:check_only; 209, argument_list; 209, 210; 209, 211; 210, identifier:r; 211, identifier:only; 212, block; 212, 213; 213, continue_statement; 214, expression_statement; 214, 215; 215, assignment; 215, 216; 215, 217; 216, identifier:attr; 217, call; 217, 218; 217, 219; 218, identifier:getattr; 219, argument_list; 219, 220; 219, 221; 220, identifier:row; 221, identifier:r; 222, expression_statement; 222, 223; 223, assignment; 223, 224; 223, 225; 224, identifier:backref; 225, call; 225, 226; 225, 227; 226, identifier:get_backref; 227, argument_list; 227, 228; 228, subscript; 228, 229; 228, 232; 229, attribute; 229, 230; 229, 231; 230, identifier:mapper; 231, identifier:relationships; 232, identifier:r; 233, if_statement; 233, 234; 233, 235; 234, identifier:backref; 235, block; 235, 236; 236, expression_statement; 236, 237; 237, call; 237, 238; 237, 241; 238, attribute; 238, 239; 238, 240; 239, identifier:exclude; 240, identifier:add; 241, argument_list; 241, 242; 242, identifier:backref; 243, expression_statement; 243, 244; 244, assignment; 244, 245; 244, 246; 245, identifier:kwargs; 246, call; 246, 247; 246, 248; 247, identifier:dict; 248, argument_list; 248, 249; 248, 252; 248, 255; 248, 258; 248, 261; 248, 264; 249, keyword_argument; 249, 250; 249, 251; 250, identifier:depth; 251, identifier:depth; 252, keyword_argument; 252, 253; 252, 254; 253, identifier:exclude; 254, identifier:exclude; 255, keyword_argument; 255, 256; 255, 257; 256, identifier:exclude_pk; 257, identifier:exclude_pk; 258, keyword_argument; 258, 259; 258, 260; 259, identifier:exclude_underscore; 260, identifier:exclude_underscore; 261, keyword_argument; 261, 262; 261, 263; 262, identifier:only; 263, identifier:only; 264, keyword_argument; 264, 265; 264, 266; 265, identifier:fk_suffix; 266, identifier:fk_suffix; 267, if_statement; 267, 268; 267, 275; 267, 293; 268, call; 268, 269; 268, 270; 269, identifier:isinstance; 270, argument_list; 270, 271; 270, 272; 271, identifier:attr; 272, attribute; 272, 273; 272, 274; 273, identifier:collections; 274, identifier:InstrumentedList; 275, block; 275, 276; 276, expression_statement; 276, 277; 277, assignment; 277, 278; 277, 281; 278, subscript; 278, 279; 278, 280; 279, identifier:d; 280, identifier:r; 281, list_comprehension; 281, 282; 281, 288; 281, 291; 282, call; 282, 283; 282, 284; 283, identifier:row2dict; 284, argument_list; 284, 285; 284, 286; 285, identifier:i; 286, dictionary_splat; 286, 287; 287, identifier:kwargs; 288, for_in_clause; 288, 289; 288, 290; 289, identifier:i; 290, identifier:attr; 291, if_clause; 291, 292; 292, identifier:depth; 293, else_clause; 293, 294; 294, block; 294, 295; 295, expression_statement; 295, 296; 296, assignment; 296, 297; 296, 300; 297, subscript; 297, 298; 297, 299; 298, identifier:d; 299, identifier:r; 300, call; 300, 301; 300, 302; 301, identifier:row2dict; 302, argument_list; 302, 303; 302, 304; 303, identifier:attr; 304, dictionary_splat; 304, 305; 305, identifier:kwargs; 306, return_statement; 306, 307; 307, identifier:d
def row2dict(row, depth=None, exclude=None, exclude_pk=None, exclude_underscore=None, only=None, fk_suffix=None): if depth == 0: return None d, mapper = {}, get_mapper(row) if depth is None: depth = getattr(row, ATTR_DEPTH, DEFAULT_DEPTH) - 1 else: depth -= 1 if exclude is None: exclude = getattr(row, ATTR_EXCLUDE, DEFAULT_EXCLUDE) if exclude_pk is None: exclude_pk = getattr(row, ATTR_EXCLUDE_PK, DEFAULT_EXCLUDE_PK) if exclude_underscore is None: exclude_underscore = getattr(row, ATTR_EXCLUDE_UNDERSCORE, DEFAULT_EXCLUDE_UNDERSCORE) if only is None: only = getattr(row, ATTR_ONLY, DEFAULT_ONLY) if fk_suffix is None: fk_suffix = getattr(row, ATTR_FK_SUFFIX, DEFAULT_FK_SUFFIX) for c in mapper.columns.keys() + mapper.synonyms.keys(): if c in exclude or \ check_exclude_pk(c, exclude_pk, fk_suffix=fk_suffix) or \ check_exclude_underscore(c, exclude_underscore) or \ check_only(c, only): continue d[c] = getattr(row, c) for r in mapper.relationships.keys(): if r in exclude or check_only(r, only): continue attr = getattr(row, r) backref = get_backref(mapper.relationships[r]) if backref: exclude.add(backref) kwargs = dict(depth=depth, exclude=exclude, exclude_pk=exclude_pk, exclude_underscore=exclude_underscore, only=only, fk_suffix=fk_suffix) if isinstance(attr, collections.InstrumentedList): d[r] = [row2dict(i, **kwargs) for i in attr if depth] else: d[r] = row2dict(attr, **kwargs) return d
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 24; 2, function_name:dict2row; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 4, identifier:d; 5, identifier:model; 6, default_parameter; 6, 7; 6, 8; 7, identifier:rel; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:exclude; 11, None; 12, default_parameter; 12, 13; 12, 14; 13, identifier:exclude_pk; 14, None; 15, default_parameter; 15, 16; 15, 17; 16, identifier:exclude_underscore; 17, None; 18, default_parameter; 18, 19; 18, 20; 19, identifier:only; 20, None; 21, default_parameter; 21, 22; 21, 23; 22, identifier:fk_suffix; 23, None; 24, block; 24, 25; 24, 45; 24, 51; 24, 58; 24, 72; 24, 86; 24, 100; 24, 114; 24, 128; 24, 142; 24, 203; 24, 350; 25, if_statement; 25, 26; 25, 32; 26, not_operator; 26, 27; 27, call; 27, 28; 27, 29; 28, identifier:isinstance; 29, argument_list; 29, 30; 29, 31; 30, identifier:d; 31, identifier:dict; 32, block; 32, 33; 33, raise_statement; 33, 34; 34, call; 34, 35; 34, 36; 35, identifier:TypeError; 36, argument_list; 36, 37; 37, binary_operator:%; 37, 38; 37, 39; 38, string:'Source must be instance of dict, got %s instead'; 39, attribute; 39, 40; 39, 44; 40, call; 40, 41; 40, 42; 41, identifier:type; 42, argument_list; 42, 43; 43, identifier:d; 44, identifier:__name__; 45, expression_statement; 45, 46; 46, assignment; 46, 47; 46, 48; 47, identifier:row; 48, call; 48, 49; 48, 50; 49, identifier:model; 50, argument_list; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 54; 53, identifier:mapper; 54, call; 54, 55; 54, 56; 55, identifier:get_mapper; 56, argument_list; 56, 57; 57, identifier:row; 58, if_statement; 58, 59; 58, 62; 59, comparison_operator:is; 59, 60; 59, 61; 60, identifier:rel; 61, None; 62, block; 62, 63; 63, expression_statement; 63, 64; 64, assignment; 64, 65; 64, 66; 65, identifier:rel; 66, call; 66, 67; 66, 68; 67, identifier:getattr; 68, argument_list; 68, 69; 68, 70; 68, 71; 69, identifier:row; 70, identifier:ATTR_REL; 71, identifier:DEFAULT_REL; 72, if_statement; 72, 73; 72, 76; 73, comparison_operator:is; 73, 74; 73, 75; 74, identifier:exclude; 75, None; 76, block; 76, 77; 77, expression_statement; 77, 78; 78, assignment; 78, 79; 78, 80; 79, identifier:exclude; 80, call; 80, 81; 80, 82; 81, identifier:getattr; 82, argument_list; 82, 83; 82, 84; 82, 85; 83, identifier:row; 84, identifier:ATTR_EXCLUDE; 85, identifier:DEFAULT_EXCLUDE; 86, if_statement; 86, 87; 86, 90; 87, comparison_operator:is; 87, 88; 87, 89; 88, identifier:exclude_pk; 89, None; 90, block; 90, 91; 91, expression_statement; 91, 92; 92, assignment; 92, 93; 92, 94; 93, identifier:exclude_pk; 94, call; 94, 95; 94, 96; 95, identifier:getattr; 96, argument_list; 96, 97; 96, 98; 96, 99; 97, identifier:row; 98, identifier:ATTR_EXCLUDE_PK; 99, identifier:DEFAULT_EXCLUDE_PK; 100, if_statement; 100, 101; 100, 104; 101, comparison_operator:is; 101, 102; 101, 103; 102, identifier:exclude_underscore; 103, None; 104, block; 104, 105; 105, expression_statement; 105, 106; 106, assignment; 106, 107; 106, 108; 107, identifier:exclude_underscore; 108, call; 108, 109; 108, 110; 109, identifier:getattr; 110, argument_list; 110, 111; 110, 112; 110, 113; 111, identifier:row; 112, identifier:ATTR_EXCLUDE_UNDERSCORE; 113, identifier:DEFAULT_EXCLUDE_UNDERSCORE; 114, if_statement; 114, 115; 114, 118; 115, comparison_operator:is; 115, 116; 115, 117; 116, identifier:only; 117, None; 118, block; 118, 119; 119, expression_statement; 119, 120; 120, assignment; 120, 121; 120, 122; 121, identifier:only; 122, call; 122, 123; 122, 124; 123, identifier:getattr; 124, argument_list; 124, 125; 124, 126; 124, 127; 125, identifier:row; 126, identifier:ATTR_ONLY; 127, identifier:DEFAULT_ONLY; 128, if_statement; 128, 129; 128, 132; 129, comparison_operator:is; 129, 130; 129, 131; 130, identifier:fk_suffix; 131, None; 132, block; 132, 133; 133, expression_statement; 133, 134; 134, assignment; 134, 135; 134, 136; 135, identifier:fk_suffix; 136, call; 136, 137; 136, 138; 137, identifier:getattr; 138, argument_list; 138, 139; 138, 140; 138, 141; 139, identifier:row; 140, identifier:ATTR_FK_SUFFIX; 141, identifier:DEFAULT_FK_SUFFIX; 142, for_statement; 142, 143; 142, 144; 142, 159; 143, identifier:c; 144, binary_operator:+; 144, 145; 144, 152; 145, call; 145, 146; 145, 151; 146, attribute; 146, 147; 146, 150; 147, attribute; 147, 148; 147, 149; 148, identifier:mapper; 149, identifier:columns; 150, identifier:keys; 151, argument_list; 152, call; 152, 153; 152, 158; 153, attribute; 153, 154; 153, 157; 154, attribute; 154, 155; 154, 156; 155, identifier:mapper; 156, identifier:synonyms; 157, identifier:keys; 158, argument_list; 159, block; 159, 160; 159, 194; 160, if_statement; 160, 161; 160, 192; 161, boolean_operator:or; 161, 162; 161, 186; 161, 187; 162, boolean_operator:or; 162, 163; 162, 180; 162, 181; 163, boolean_operator:or; 163, 164; 163, 171; 163, 172; 164, boolean_operator:or; 164, 165; 164, 168; 165, comparison_operator:not; 165, 166; 165, 167; 166, identifier:c; 167, identifier:d; 168, comparison_operator:in; 168, 169; 168, 170; 169, identifier:c; 170, identifier:exclude; 171, line_continuation:\; 172, call; 172, 173; 172, 174; 173, identifier:check_exclude_pk; 174, argument_list; 174, 175; 174, 176; 174, 177; 175, identifier:c; 176, identifier:exclude_pk; 177, keyword_argument; 177, 178; 177, 179; 178, identifier:fk_suffix; 179, identifier:fk_suffix; 180, line_continuation:\; 181, call; 181, 182; 181, 183; 182, identifier:check_exclude_underscore; 183, argument_list; 183, 184; 183, 185; 184, identifier:c; 185, identifier:exclude_underscore; 186, line_continuation:\; 187, call; 187, 188; 187, 189; 188, identifier:check_only; 189, argument_list; 189, 190; 189, 191; 190, identifier:c; 191, identifier:only; 192, block; 192, 193; 193, continue_statement; 194, expression_statement; 194, 195; 195, call; 195, 196; 195, 197; 196, identifier:setattr; 197, argument_list; 197, 198; 197, 199; 197, 200; 198, identifier:row; 199, identifier:c; 200, subscript; 200, 201; 200, 202; 201, identifier:d; 202, identifier:c; 203, for_statement; 203, 204; 203, 205; 203, 212; 204, identifier:r; 205, call; 205, 206; 205, 211; 206, attribute; 206, 207; 206, 210; 207, attribute; 207, 208; 207, 209; 208, identifier:mapper; 209, identifier:relationships; 210, identifier:keys; 211, argument_list; 212, block; 212, 213; 212, 229; 212, 253; 213, if_statement; 213, 214; 213, 227; 214, boolean_operator:or; 214, 215; 214, 222; 215, boolean_operator:or; 215, 216; 215, 219; 216, comparison_operator:not; 216, 217; 216, 218; 217, identifier:r; 218, identifier:d; 219, comparison_operator:not; 219, 220; 219, 221; 220, identifier:r; 221, identifier:rel; 222, call; 222, 223; 222, 224; 223, identifier:check_only; 224, argument_list; 224, 225; 224, 226; 225, identifier:r; 226, identifier:only; 227, block; 227, 228; 228, continue_statement; 229, expression_statement; 229, 230; 230, assignment; 230, 231; 230, 232; 231, identifier:kwargs; 232, call; 232, 233; 232, 234; 233, identifier:dict; 234, argument_list; 234, 235; 234, 238; 234, 241; 234, 244; 234, 247; 234, 250; 235, keyword_argument; 235, 236; 235, 237; 236, identifier:rel; 237, identifier:rel; 238, keyword_argument; 238, 239; 238, 240; 239, identifier:exclude; 240, identifier:exclude; 241, keyword_argument; 241, 242; 241, 243; 242, identifier:exclude_pk; 243, identifier:exclude_pk; 244, keyword_argument; 244, 245; 244, 246; 245, identifier:exclude_underscore; 246, identifier:exclude_underscore; 247, keyword_argument; 247, 248; 247, 249; 248, identifier:only; 249, identifier:only; 250, keyword_argument; 250, 251; 250, 252; 251, identifier:fk_suffix; 252, identifier:fk_suffix; 253, if_statement; 253, 254; 253, 261; 253, 298; 254, call; 254, 255; 254, 256; 255, identifier:isinstance; 256, argument_list; 256, 257; 256, 260; 257, subscript; 257, 258; 257, 259; 258, identifier:d; 259, identifier:r; 260, identifier:list; 261, block; 261, 262; 261, 273; 262, expression_statement; 262, 263; 263, call; 263, 264; 263, 265; 264, identifier:setattr; 265, argument_list; 265, 266; 265, 267; 265, 268; 266, identifier:row; 267, identifier:r; 268, call; 268, 269; 268, 272; 269, attribute; 269, 270; 269, 271; 270, identifier:collections; 271, identifier:InstrumentedList; 272, argument_list; 273, for_statement; 273, 274; 273, 275; 273, 278; 274, identifier:i; 275, subscript; 275, 276; 275, 277; 276, identifier:d; 277, identifier:r; 278, block; 278, 279; 279, expression_statement; 279, 280; 280, call; 280, 281; 280, 288; 281, attribute; 281, 282; 281, 287; 282, call; 282, 283; 282, 284; 283, identifier:getattr; 284, argument_list; 284, 285; 284, 286; 285, identifier:row; 286, identifier:r; 287, identifier:append; 288, argument_list; 288, 289; 289, call; 289, 290; 289, 291; 290, identifier:dict2row; 291, argument_list; 291, 292; 291, 293; 291, 296; 292, identifier:i; 293, subscript; 293, 294; 293, 295; 294, identifier:rel; 295, identifier:r; 296, dictionary_splat; 296, 297; 297, identifier:kwargs; 298, else_clause; 298, 299; 299, block; 299, 300; 299, 333; 300, if_statement; 300, 301; 300, 303; 301, not_operator; 301, 302; 302, identifier:exclude_pk; 303, block; 303, 304; 303, 324; 304, expression_statement; 304, 305; 305, assignment; 305, 306; 305, 307; 306, identifier:rpk; 307, conditional_expression:if; 307, 308; 307, 316; 307, 323; 308, call; 308, 309; 308, 314; 309, attribute; 309, 310; 309, 313; 310, subscript; 310, 311; 310, 312; 311, identifier:d; 312, identifier:r; 313, identifier:get; 314, argument_list; 314, 315; 315, string:'id'; 316, call; 316, 317; 316, 318; 317, identifier:isinstance; 318, argument_list; 318, 319; 318, 322; 319, subscript; 319, 320; 319, 321; 320, identifier:d; 321, identifier:r; 322, identifier:dict; 323, None; 324, expression_statement; 324, 325; 325, call; 325, 326; 325, 327; 326, identifier:setattr; 327, argument_list; 327, 328; 327, 329; 327, 332; 328, identifier:row; 329, binary_operator:+; 329, 330; 329, 331; 330, identifier:r; 331, identifier:fk_suffix; 332, identifier:rpk; 333, expression_statement; 333, 334; 334, call; 334, 335; 334, 336; 335, identifier:setattr; 336, argument_list; 336, 337; 336, 338; 336, 339; 337, identifier:row; 338, identifier:r; 339, call; 339, 340; 339, 341; 340, identifier:dict2row; 341, argument_list; 341, 342; 341, 345; 341, 348; 342, subscript; 342, 343; 342, 344; 343, identifier:d; 344, identifier:r; 345, subscript; 345, 346; 345, 347; 346, identifier:rel; 347, identifier:r; 348, dictionary_splat; 348, 349; 349, identifier:kwargs; 350, return_statement; 350, 351; 351, identifier:row
def dict2row(d, model, rel=None, exclude=None, exclude_pk=None, exclude_underscore=None, only=None, fk_suffix=None): if not isinstance(d, dict): raise TypeError('Source must be instance of dict, got %s instead' % type(d).__name__) row = model() mapper = get_mapper(row) if rel is None: rel = getattr(row, ATTR_REL, DEFAULT_REL) if exclude is None: exclude = getattr(row, ATTR_EXCLUDE, DEFAULT_EXCLUDE) if exclude_pk is None: exclude_pk = getattr(row, ATTR_EXCLUDE_PK, DEFAULT_EXCLUDE_PK) if exclude_underscore is None: exclude_underscore = getattr(row, ATTR_EXCLUDE_UNDERSCORE, DEFAULT_EXCLUDE_UNDERSCORE) if only is None: only = getattr(row, ATTR_ONLY, DEFAULT_ONLY) if fk_suffix is None: fk_suffix = getattr(row, ATTR_FK_SUFFIX, DEFAULT_FK_SUFFIX) for c in mapper.columns.keys() + mapper.synonyms.keys(): if c not in d or c in exclude or \ check_exclude_pk(c, exclude_pk, fk_suffix=fk_suffix) or \ check_exclude_underscore(c, exclude_underscore) or \ check_only(c, only): continue setattr(row, c, d[c]) for r in mapper.relationships.keys(): if r not in d or r not in rel or check_only(r, only): continue kwargs = dict(rel=rel, exclude=exclude, exclude_pk=exclude_pk, exclude_underscore=exclude_underscore, only=only, fk_suffix=fk_suffix) if isinstance(d[r], list): setattr(row, r, collections.InstrumentedList()) for i in d[r]: getattr(row, r).append(dict2row(i, rel[r], **kwargs)) else: if not exclude_pk: rpk = d[r].get('id') if isinstance(d[r], dict) else None setattr(row, r + fk_suffix, rpk) setattr(row, r, dict2row(d[r], rel[r], **kwargs)) return row
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 74; 1, 76; 2, function_name:remote; 3, parameters; 3, 4; 3, 13; 3, 14; 3, 17; 3, 20; 3, 23; 3, 26; 3, 29; 3, 32; 3, 42; 3, 45; 3, 55; 3, 65; 3, 68; 3, 71; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:cmd; 6, type; 6, 7; 7, call; 7, 8; 7, 9; 8, identifier:arg; 9, argument_list; 9, 10; 10, keyword_argument; 10, 11; 10, 12; 11, identifier:container; 12, identifier:list; 13, identifier:host; 14, default_parameter; 14, 15; 14, 16; 15, identifier:user; 16, None; 17, default_parameter; 17, 18; 17, 19; 18, identifier:port; 19, None; 20, default_parameter; 20, 21; 20, 22; 21, identifier:sudo; 22, False; 23, default_parameter; 23, 24; 23, 25; 24, identifier:run_as; 25, None; 26, default_parameter; 26, 27; 26, 28; 27, identifier:shell; 28, string:'/bin/sh'; 29, default_parameter; 29, 30; 29, 31; 30, identifier:cd; 31, None; 32, typed_default_parameter; 32, 33; 32, 34; 32, 41; 33, identifier:environ; 34, type; 34, 35; 35, call; 35, 36; 35, 37; 36, identifier:arg; 37, argument_list; 37, 38; 38, keyword_argument; 38, 39; 38, 40; 39, identifier:container; 40, identifier:dict; 41, None; 42, default_parameter; 42, 43; 42, 44; 43, identifier:paths; 44, tuple; 45, typed_default_parameter; 45, 46; 45, 47; 45, 54; 46, identifier:stdout; 47, type; 47, 48; 48, call; 48, 49; 48, 50; 49, identifier:arg; 50, argument_list; 50, 51; 51, keyword_argument; 51, 52; 51, 53; 52, identifier:type; 53, identifier:StreamOptions; 54, None; 55, typed_default_parameter; 55, 56; 55, 57; 55, 64; 56, identifier:stderr; 57, type; 57, 58; 58, call; 58, 59; 58, 60; 59, identifier:arg; 60, argument_list; 60, 61; 61, keyword_argument; 61, 62; 61, 63; 62, identifier:type; 63, identifier:StreamOptions; 64, None; 65, default_parameter; 65, 66; 65, 67; 66, identifier:echo; 67, False; 68, default_parameter; 68, 69; 68, 70; 69, identifier:raise_on_error; 70, True; 71, default_parameter; 71, 72; 71, 73; 72, identifier:dry_run; 73, False; 74, type; 74, 75; 75, identifier:Result; 76, block; 76, 77; 76, 95; 76, 100; 76, 115; 76, 129; 76, 143; 76, 147; 76, 173; 76, 182; 76, 186; 76, 203; 76, 229; 76, 251; 76, 258; 76, 267; 76, 278; 76, 287; 76, 294; 76, 303; 76, 311; 77, if_statement; 77, 78; 77, 84; 78, not_operator; 78, 79; 79, call; 79, 80; 79, 81; 80, identifier:isinstance; 81, argument_list; 81, 82; 81, 83; 82, identifier:cmd; 83, identifier:str; 84, block; 84, 85; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 88; 87, identifier:cmd; 88, call; 88, 89; 88, 90; 89, identifier:flatten_args; 90, argument_list; 90, 91; 90, 92; 91, identifier:cmd; 92, keyword_argument; 92, 93; 92, 94; 93, identifier:join; 94, True; 95, expression_statement; 95, 96; 96, assignment; 96, 97; 96, 98; 97, identifier:ssh_options; 98, list:['-q']; 98, 99; 99, string:'-q'; 100, if_statement; 100, 101; 100, 107; 101, call; 101, 102; 101, 103; 102, identifier:isatty; 103, argument_list; 103, 104; 104, attribute; 104, 105; 104, 106; 105, identifier:sys; 106, identifier:stdin; 107, block; 107, 108; 108, expression_statement; 108, 109; 109, call; 109, 110; 109, 113; 110, attribute; 110, 111; 110, 112; 111, identifier:ssh_options; 112, identifier:append; 113, argument_list; 113, 114; 114, string:'-t'; 115, if_statement; 115, 116; 115, 119; 116, comparison_operator:is; 116, 117; 116, 118; 117, identifier:port; 118, None; 119, block; 119, 120; 120, expression_statement; 120, 121; 121, call; 121, 122; 121, 125; 122, attribute; 122, 123; 122, 124; 123, identifier:ssh_options; 124, identifier:extend; 125, argument_list; 125, 126; 126, tuple; 126, 127; 126, 128; 127, string:'-p'; 128, identifier:port; 129, expression_statement; 129, 130; 130, assignment; 130, 131; 130, 132; 131, identifier:ssh_connection_str; 132, conditional_expression:if; 132, 133; 132, 141; 132, 142; 133, call; 133, 134; 133, 137; 134, attribute; 134, 135; 134, 136; 135, string:'{user}@{host}'; 136, identifier:format_map; 137, argument_list; 137, 138; 138, call; 138, 139; 138, 140; 139, identifier:locals; 140, argument_list; 141, identifier:user; 142, identifier:host; 143, expression_statement; 143, 144; 144, assignment; 144, 145; 144, 146; 145, identifier:remote_cmd; 146, list:[]; 147, if_statement; 147, 148; 147, 149; 147, 159; 148, identifier:sudo; 149, block; 149, 150; 150, expression_statement; 150, 151; 151, call; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:remote_cmd; 154, identifier:extend; 155, argument_list; 155, 156; 156, tuple; 156, 157; 156, 158; 157, string:'sudo'; 158, string:'-H'; 159, elif_clause; 159, 160; 159, 161; 160, identifier:run_as; 161, block; 161, 162; 162, expression_statement; 162, 163; 163, call; 163, 164; 163, 167; 164, attribute; 164, 165; 164, 166; 165, identifier:remote_cmd; 166, identifier:extend; 167, argument_list; 167, 168; 168, tuple; 168, 169; 168, 170; 168, 171; 168, 172; 169, string:'sudo'; 170, string:'-H'; 171, string:'-u'; 172, identifier:run_as; 173, expression_statement; 173, 174; 174, call; 174, 175; 174, 178; 175, attribute; 175, 176; 175, 177; 176, identifier:remote_cmd; 177, identifier:extend; 178, argument_list; 178, 179; 179, tuple; 179, 180; 179, 181; 180, identifier:shell; 181, string:'-c'; 182, expression_statement; 182, 183; 183, assignment; 183, 184; 183, 185; 184, identifier:inner_cmd; 185, list:[]; 186, if_statement; 186, 187; 186, 188; 187, identifier:cd; 188, block; 188, 189; 189, expression_statement; 189, 190; 190, call; 190, 191; 190, 194; 191, attribute; 191, 192; 191, 193; 192, identifier:inner_cmd; 193, identifier:append; 194, argument_list; 194, 195; 195, call; 195, 196; 195, 199; 196, attribute; 196, 197; 196, 198; 197, string:'cd {cd}'; 198, identifier:format_map; 199, argument_list; 199, 200; 200, call; 200, 201; 200, 202; 201, identifier:locals; 202, argument_list; 203, if_statement; 203, 204; 203, 205; 204, identifier:environ; 205, block; 205, 206; 206, expression_statement; 206, 207; 207, call; 207, 208; 207, 211; 208, attribute; 208, 209; 208, 210; 209, identifier:inner_cmd; 210, identifier:extend; 211, generator_expression; 211, 212; 211, 220; 212, call; 212, 213; 212, 216; 213, attribute; 213, 214; 213, 215; 214, string:'export {k}="{v}"'; 215, identifier:format_map; 216, argument_list; 216, 217; 217, call; 217, 218; 217, 219; 218, identifier:locals; 219, argument_list; 220, for_in_clause; 220, 221; 220, 224; 221, pattern_list; 221, 222; 221, 223; 222, identifier:k; 223, identifier:v; 224, call; 224, 225; 224, 228; 225, attribute; 225, 226; 225, 227; 226, identifier:environ; 227, identifier:items; 228, argument_list; 229, if_statement; 229, 230; 229, 231; 230, identifier:paths; 231, block; 231, 232; 232, expression_statement; 232, 233; 233, call; 233, 234; 233, 237; 234, attribute; 234, 235; 234, 236; 235, identifier:inner_cmd; 236, identifier:append; 237, argument_list; 237, 238; 238, call; 238, 239; 238, 242; 239, attribute; 239, 240; 239, 241; 240, string:'export PATH="{path}:$PATH"'; 241, identifier:format; 242, argument_list; 242, 243; 243, keyword_argument; 243, 244; 243, 245; 244, identifier:path; 245, call; 245, 246; 245, 249; 246, attribute; 246, 247; 246, 248; 247, string:':'; 248, identifier:join; 249, argument_list; 249, 250; 250, identifier:paths; 251, expression_statement; 251, 252; 252, call; 252, 253; 252, 256; 253, attribute; 253, 254; 253, 255; 254, identifier:inner_cmd; 255, identifier:append; 256, argument_list; 256, 257; 257, identifier:cmd; 258, expression_statement; 258, 259; 259, assignment; 259, 260; 259, 261; 260, identifier:inner_cmd; 261, call; 261, 262; 261, 265; 262, attribute; 262, 263; 262, 264; 263, string:' &&\n '; 264, identifier:join; 265, argument_list; 265, 266; 266, identifier:inner_cmd; 267, expression_statement; 267, 268; 268, assignment; 268, 269; 268, 270; 269, identifier:inner_cmd; 270, call; 270, 271; 270, 274; 271, attribute; 271, 272; 271, 273; 272, string:'\n {inner_cmd}\n'; 273, identifier:format_map; 274, argument_list; 274, 275; 275, call; 275, 276; 275, 277; 276, identifier:locals; 277, argument_list; 278, expression_statement; 278, 279; 279, assignment; 279, 280; 279, 281; 280, identifier:inner_cmd; 281, call; 281, 282; 281, 285; 282, attribute; 282, 283; 282, 284; 283, identifier:shlex; 284, identifier:quote; 285, argument_list; 285, 286; 286, identifier:inner_cmd; 287, expression_statement; 287, 288; 288, call; 288, 289; 288, 292; 289, attribute; 289, 290; 289, 291; 290, identifier:remote_cmd; 291, identifier:append; 292, argument_list; 292, 293; 293, identifier:inner_cmd; 294, expression_statement; 294, 295; 295, assignment; 295, 296; 295, 297; 296, identifier:remote_cmd; 297, call; 297, 298; 297, 301; 298, attribute; 298, 299; 298, 300; 299, string:' '; 300, identifier:join; 301, argument_list; 301, 302; 302, identifier:remote_cmd; 303, expression_statement; 303, 304; 304, assignment; 304, 305; 304, 306; 305, identifier:args; 306, tuple; 306, 307; 306, 308; 306, 309; 306, 310; 307, string:'ssh'; 308, identifier:ssh_options; 309, identifier:ssh_connection_str; 310, identifier:remote_cmd; 311, return_statement; 311, 312; 312, call; 312, 313; 312, 314; 313, identifier:local; 314, argument_list; 314, 315; 314, 316; 314, 319; 314, 322; 314, 325; 314, 328; 315, identifier:args; 316, keyword_argument; 316, 317; 316, 318; 317, identifier:stdout; 318, identifier:stdout; 319, keyword_argument; 319, 320; 319, 321; 320, identifier:stderr; 321, identifier:stderr; 322, keyword_argument; 322, 323; 322, 324; 323, identifier:echo; 324, identifier:echo; 325, keyword_argument; 325, 326; 325, 327; 326, identifier:raise_on_error; 327, identifier:raise_on_error; 328, keyword_argument; 328, 329; 328, 330; 329, identifier:dry_run; 330, identifier:dry_run
def remote(cmd: arg(container=list), host, user=None, port=None, sudo=False, run_as=None, shell='/bin/sh', cd=None, environ: arg(container=dict) = None, paths=(), stdout: arg(type=StreamOptions) = None, stderr: arg(type=StreamOptions) = None, echo=False, raise_on_error=True, dry_run=False, ) -> Result: if not isinstance(cmd, str): cmd = flatten_args(cmd, join=True) ssh_options = ['-q'] if isatty(sys.stdin): ssh_options.append('-t') if port is not None: ssh_options.extend(('-p', port)) ssh_connection_str = '{user}@{host}'.format_map(locals()) if user else host remote_cmd = [] if sudo: remote_cmd.extend(('sudo', '-H')) elif run_as: remote_cmd.extend(('sudo', '-H', '-u', run_as)) remote_cmd.extend((shell, '-c')) inner_cmd = [] if cd: inner_cmd.append('cd {cd}'.format_map(locals())) if environ: inner_cmd.extend('export {k}="{v}"'.format_map(locals()) for k, v in environ.items()) if paths: inner_cmd.append('export PATH="{path}:$PATH"'.format(path=':'.join(paths))) inner_cmd.append(cmd) inner_cmd = ' &&\n '.join(inner_cmd) inner_cmd = '\n {inner_cmd}\n'.format_map(locals()) inner_cmd = shlex.quote(inner_cmd) remote_cmd.append(inner_cmd) remote_cmd = ' '.join(remote_cmd) args = ('ssh', ssh_options, ssh_connection_str, remote_cmd) return local( args, stdout=stdout, stderr=stderr, echo=echo, raise_on_error=raise_on_error, dry_run=dry_run)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 69; 1, 71; 2, function_name:sync; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 10; 3, 13; 3, 16; 3, 22; 3, 25; 3, 28; 3, 31; 3, 34; 3, 37; 3, 40; 3, 43; 3, 53; 3, 63; 3, 66; 4, identifier:source; 5, identifier:destination; 6, identifier:host; 7, default_parameter; 7, 8; 7, 9; 8, identifier:user; 9, None; 10, default_parameter; 10, 11; 10, 12; 11, identifier:sudo; 12, False; 13, default_parameter; 13, 14; 13, 15; 14, identifier:run_as; 15, None; 16, default_parameter; 16, 17; 16, 18; 17, identifier:options; 18, tuple; 18, 19; 18, 20; 18, 21; 19, string:'-rltvz'; 20, string:'--no-perms'; 21, string:'--no-group'; 22, default_parameter; 22, 23; 22, 24; 23, identifier:excludes; 24, tuple; 25, default_parameter; 25, 26; 25, 27; 26, identifier:exclude_from; 27, None; 28, default_parameter; 28, 29; 28, 30; 29, identifier:delete; 30, False; 31, default_parameter; 31, 32; 31, 33; 32, identifier:dry_run; 33, False; 34, default_parameter; 34, 35; 34, 36; 35, identifier:mode; 36, string:'u=rwX,g=rwX,o='; 37, default_parameter; 37, 38; 37, 39; 38, identifier:quiet; 39, True; 40, default_parameter; 40, 41; 40, 42; 41, identifier:pull; 42, False; 43, typed_default_parameter; 43, 44; 43, 45; 43, 52; 44, identifier:stdout; 45, type; 45, 46; 46, call; 46, 47; 46, 48; 47, identifier:arg; 48, argument_list; 48, 49; 49, keyword_argument; 49, 50; 49, 51; 50, identifier:type; 51, identifier:StreamOptions; 52, None; 53, typed_default_parameter; 53, 54; 53, 55; 53, 62; 54, identifier:stderr; 55, type; 55, 56; 56, call; 56, 57; 56, 58; 57, identifier:arg; 58, argument_list; 58, 59; 59, keyword_argument; 59, 60; 59, 61; 60, identifier:type; 61, identifier:StreamOptions; 62, None; 63, default_parameter; 63, 64; 63, 65; 64, identifier:echo; 65, False; 66, default_parameter; 66, 67; 66, 68; 67, identifier:raise_on_error; 68, True; 69, type; 69, 70; 70, identifier:Result; 71, block; 71, 72; 71, 82; 71, 92; 71, 106; 71, 111; 71, 142; 71, 169; 71, 211; 72, expression_statement; 72, 73; 73, assignment; 73, 74; 73, 75; 74, identifier:source; 75, call; 75, 76; 75, 77; 76, identifier:abs_path; 77, argument_list; 77, 78; 77, 79; 78, identifier:source; 79, keyword_argument; 79, 80; 79, 81; 80, identifier:keep_slash; 81, True; 82, expression_statement; 82, 83; 83, assignment; 83, 84; 83, 85; 84, identifier:destination; 85, call; 85, 86; 85, 87; 86, identifier:abs_path; 87, argument_list; 87, 88; 87, 89; 88, identifier:destination; 89, keyword_argument; 89, 90; 89, 91; 90, identifier:keep_slash; 91, True; 92, expression_statement; 92, 93; 93, assignment; 93, 94; 93, 95; 94, identifier:connection_str; 95, conditional_expression:if; 95, 96; 95, 104; 95, 105; 96, call; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, string:'{user}@{host}'; 99, identifier:format_map; 100, argument_list; 100, 101; 101, call; 101, 102; 101, 103; 102, identifier:locals; 103, argument_list; 104, identifier:user; 105, identifier:host; 106, expression_statement; 106, 107; 107, assignment; 107, 108; 107, 109; 108, identifier:push; 109, not_operator; 109, 110; 110, identifier:pull; 111, if_statement; 111, 112; 111, 113; 111, 120; 111, 136; 112, identifier:sudo; 113, block; 113, 114; 114, expression_statement; 114, 115; 115, assignment; 115, 116; 115, 117; 116, identifier:rsync_path; 117, tuple; 117, 118; 117, 119; 118, string:'--rsync-path'; 119, string:'sudo rsync'; 120, elif_clause; 120, 121; 120, 122; 121, identifier:run_as; 122, block; 122, 123; 123, expression_statement; 123, 124; 124, assignment; 124, 125; 124, 126; 125, identifier:rsync_path; 126, tuple; 126, 127; 126, 128; 127, string:'--rsync-path'; 128, call; 128, 129; 128, 132; 129, attribute; 129, 130; 129, 131; 130, string:'sudo -u {run_as} rsync'; 131, identifier:format_map; 132, argument_list; 132, 133; 133, call; 133, 134; 133, 135; 134, identifier:locals; 135, argument_list; 136, else_clause; 136, 137; 137, block; 137, 138; 138, expression_statement; 138, 139; 139, assignment; 139, 140; 139, 141; 140, identifier:rsync_path; 141, None; 142, if_statement; 142, 143; 142, 144; 142, 156; 143, identifier:push; 144, block; 144, 145; 145, expression_statement; 145, 146; 146, assignment; 146, 147; 146, 148; 147, identifier:destination; 148, call; 148, 149; 148, 152; 149, attribute; 149, 150; 149, 151; 150, string:'{connection_str}:{destination}'; 151, identifier:format_map; 152, argument_list; 152, 153; 153, call; 153, 154; 153, 155; 154, identifier:locals; 155, argument_list; 156, else_clause; 156, 157; 157, block; 157, 158; 158, expression_statement; 158, 159; 159, assignment; 159, 160; 159, 161; 160, identifier:source; 161, call; 161, 162; 161, 165; 162, attribute; 162, 163; 162, 164; 163, string:'{connection_str}:{source}'; 164, identifier:format_map; 165, argument_list; 165, 166; 166, call; 166, 167; 166, 168; 167, identifier:locals; 168, argument_list; 169, expression_statement; 169, 170; 170, assignment; 170, 171; 170, 172; 171, identifier:args; 172, tuple; 172, 173; 172, 174; 172, 175; 172, 176; 172, 182; 172, 191; 172, 197; 172, 201; 172, 205; 172, 209; 172, 210; 173, string:'rsync'; 174, identifier:rsync_path; 175, identifier:options; 176, conditional_expression:if; 176, 177; 176, 180; 176, 181; 177, tuple; 177, 178; 177, 179; 178, string:'--chmod'; 179, identifier:mode; 180, identifier:mode; 181, None; 182, call; 182, 183; 182, 184; 183, identifier:tuple; 184, generator_expression; 184, 185; 184, 188; 185, tuple; 185, 186; 185, 187; 186, string:'--exclude'; 187, identifier:exclude; 188, for_in_clause; 188, 189; 188, 190; 189, identifier:exclude; 190, identifier:excludes; 191, conditional_expression:if; 191, 192; 191, 195; 191, 196; 192, tuple; 192, 193; 192, 194; 193, string:'--exclude-from'; 194, identifier:exclude_from; 195, identifier:exclude_from; 196, None; 197, conditional_expression:if; 197, 198; 197, 199; 197, 200; 198, string:'--delete'; 199, identifier:delete; 200, None; 201, conditional_expression:if; 201, 202; 201, 203; 201, 204; 202, string:'--dry-run'; 203, identifier:dry_run; 204, None; 205, conditional_expression:if; 205, 206; 205, 207; 205, 208; 206, string:'--quiet'; 207, identifier:quiet; 208, None; 209, identifier:source; 210, identifier:destination; 211, return_statement; 211, 212; 212, call; 212, 213; 212, 214; 213, identifier:local; 214, argument_list; 214, 215; 214, 216; 214, 219; 214, 222; 214, 225; 215, identifier:args; 216, keyword_argument; 216, 217; 216, 218; 217, identifier:stdout; 218, identifier:stdout; 219, keyword_argument; 219, 220; 219, 221; 220, identifier:stderr; 221, identifier:stderr; 222, keyword_argument; 222, 223; 222, 224; 223, identifier:echo; 224, identifier:echo; 225, keyword_argument; 225, 226; 225, 227; 226, identifier:raise_on_error; 227, identifier:raise_on_error
def sync(source, destination, host, user=None, sudo=False, run_as=None, options=('-rltvz', '--no-perms', '--no-group'), excludes=(), exclude_from=None, delete=False, dry_run=False, mode='u=rwX,g=rwX,o=', quiet=True, pull=False, stdout: arg(type=StreamOptions) = None, stderr: arg(type=StreamOptions) = None, echo=False, raise_on_error=True, ) -> Result: source = abs_path(source, keep_slash=True) destination = abs_path(destination, keep_slash=True) connection_str = '{user}@{host}'.format_map(locals()) if user else host push = not pull if sudo: rsync_path = ('--rsync-path', 'sudo rsync') elif run_as: rsync_path = ('--rsync-path', 'sudo -u {run_as} rsync'.format_map(locals())) else: rsync_path = None if push: destination = '{connection_str}:{destination}'.format_map(locals()) else: source = '{connection_str}:{source}'.format_map(locals()) args = ( 'rsync', rsync_path, options, ('--chmod', mode) if mode else None, tuple(('--exclude', exclude) for exclude in excludes), ('--exclude-from', exclude_from) if exclude_from else None, '--delete' if delete else None, '--dry-run' if dry_run else None, '--quiet' if quiet else None, source, destination, ) return local(args, stdout=stdout, stderr=stderr, echo=echo, raise_on_error=raise_on_error)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 1, 24; 2, function_name:_determine_outliers_for_moving_average; 3, parameters; 3, 4; 3, 10; 3, 14; 3, 18; 4, typed_parameter; 4, 5; 4, 6; 5, identifier:moving_average; 6, type; 6, 7; 7, attribute; 7, 8; 7, 9; 8, identifier:np; 9, identifier:ndarray; 10, typed_parameter; 10, 11; 10, 12; 11, identifier:moving_average_threshold; 12, type; 12, 13; 13, identifier:float; 14, typed_parameter; 14, 15; 14, 16; 15, identifier:number_of_values_to_search_ahead; 16, type; 16, 17; 17, identifier:int; 18, typed_parameter; 18, 19; 18, 20; 19, identifier:limit_of_number_of_values_below_threshold; 20, type; 20, 21; 21, identifier:int; 22, type; 22, 23; 23, identifier:int; 24, block; 24, 25; 24, 31; 24, 35; 24, 62; 24, 66; 24, 71; 24, 138; 25, expression_statement; 25, 26; 26, assignment; 26, 27; 26, 28; 27, identifier:below_threshold; 28, comparison_operator:<; 28, 29; 28, 30; 29, identifier:moving_average; 30, identifier:moving_average_threshold; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:values_to_check; 34, list:[]; 35, for_statement; 35, 36; 35, 37; 35, 41; 36, identifier:i; 37, call; 37, 38; 37, 39; 38, identifier:range; 39, argument_list; 39, 40; 40, identifier:limit_of_number_of_values_below_threshold; 41, block; 41, 42; 42, expression_statement; 42, 43; 43, call; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:values_to_check; 46, identifier:append; 47, argument_list; 47, 48; 48, subscript; 48, 49; 48, 50; 49, identifier:below_threshold; 50, slice; 50, 51; 50, 52; 50, 53; 51, identifier:i; 52, colon; 53, boolean_operator:or; 53, 54; 53, 61; 54, unary_operator:-; 54, 55; 55, parenthesized_expression; 55, 56; 56, binary_operator:-; 56, 57; 56, 60; 57, binary_operator:-; 57, 58; 57, 59; 58, identifier:limit_of_number_of_values_below_threshold; 59, integer:1; 60, identifier:i; 61, None; 62, expression_statement; 62, 63; 63, assignment; 63, 64; 63, 65; 64, identifier:found_at_least_one_bin_above_threshold; 65, False; 66, expression_statement; 66, 67; 67, assignment; 67, 68; 67, 69; 68, identifier:cut_index; 69, unary_operator:-; 69, 70; 70, integer:1; 71, for_statement; 71, 72; 71, 75; 71, 83; 72, pattern_list; 72, 73; 72, 74; 73, identifier:i; 74, identifier:values; 75, call; 75, 76; 75, 77; 76, identifier:enumerate; 77, argument_list; 77, 78; 78, call; 78, 79; 78, 80; 79, identifier:zip; 80, argument_list; 80, 81; 81, list_splat; 81, 82; 82, identifier:values_to_check; 83, block; 83, 84; 83, 90; 83, 99; 83, 109; 84, if_statement; 84, 85; 84, 88; 85, comparison_operator:==; 85, 86; 85, 87; 86, identifier:i; 87, integer:0; 88, block; 88, 89; 89, continue_statement; 90, expression_statement; 90, 91; 91, assignment; 91, 92; 91, 93; 92, identifier:above_threshold; 93, list_comprehension; 93, 94; 93, 96; 94, not_operator; 94, 95; 95, identifier:value; 96, for_in_clause; 96, 97; 96, 98; 97, identifier:value; 98, identifier:values; 99, if_statement; 99, 100; 99, 104; 100, call; 100, 101; 100, 102; 101, identifier:any; 102, argument_list; 102, 103; 103, identifier:above_threshold; 104, block; 104, 105; 105, expression_statement; 105, 106; 106, assignment; 106, 107; 106, 108; 107, identifier:found_at_least_one_bin_above_threshold; 108, True; 109, if_statement; 109, 110; 109, 121; 110, boolean_operator:and; 110, 111; 110, 112; 111, identifier:found_at_least_one_bin_above_threshold; 112, call; 112, 113; 112, 114; 113, identifier:all; 114, argument_list; 114, 115; 115, call; 115, 116; 115, 119; 116, attribute; 116, 117; 116, 118; 117, identifier:np; 118, identifier:invert; 119, argument_list; 119, 120; 120, identifier:above_threshold; 121, block; 121, 122; 121, 129; 121, 137; 122, expression_statement; 122, 123; 123, call; 123, 124; 123, 127; 124, attribute; 124, 125; 124, 126; 125, identifier:logger; 126, identifier:debug; 127, argument_list; 127, 128; 128, string:f"i at found cut_index: {i} with moving_average: {moving_average[i]}"; 129, expression_statement; 129, 130; 130, assignment; 130, 131; 130, 132; 131, identifier:cut_index; 132, binary_operator:+; 132, 133; 132, 134; 133, identifier:i; 134, binary_operator://; 134, 135; 134, 136; 135, identifier:limit_of_number_of_values_below_threshold; 136, integer:2; 137, break_statement; 138, return_statement; 138, 139; 139, identifier:cut_index
def _determine_outliers_for_moving_average(moving_average: np.ndarray, moving_average_threshold: float, number_of_values_to_search_ahead: int, limit_of_number_of_values_below_threshold: int) -> int: below_threshold = moving_average < moving_average_threshold values_to_check = [] for i in range(limit_of_number_of_values_below_threshold): values_to_check.append( below_threshold[i:-(limit_of_number_of_values_below_threshold - 1 - i) or None] ) found_at_least_one_bin_above_threshold = False cut_index = -1 for i, values in enumerate(zip(*values_to_check)): if i == 0: continue above_threshold = [not value for value in values] if any(above_threshold): found_at_least_one_bin_above_threshold = True if found_at_least_one_bin_above_threshold and all(np.invert(above_threshold)): logger.debug(f"i at found cut_index: {i} with moving_average: {moving_average[i]}") cut_index = i + limit_of_number_of_values_below_threshold // 2 break return cut_index
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:make_dynamic_class; 3, parameters; 3, 4; 3, 5; 4, identifier:typename; 5, identifier:field_names; 6, block; 6, 7; 6, 28; 6, 36; 6, 44; 6, 65; 6, 71; 6, 77; 6, 83; 6, 100; 6, 106; 6, 120; 6, 156; 7, if_statement; 7, 8; 7, 13; 8, call; 8, 9; 8, 10; 9, identifier:isinstance; 10, argument_list; 10, 11; 10, 12; 11, identifier:field_names; 12, identifier:basestring; 13, block; 13, 14; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 17; 16, identifier:field_names; 17, call; 17, 18; 17, 27; 18, attribute; 18, 19; 18, 26; 19, call; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:field_names; 22, identifier:replace; 23, argument_list; 23, 24; 23, 25; 24, string:","; 25, string:" "; 26, identifier:split; 27, argument_list; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:field_names; 31, call; 31, 32; 31, 33; 32, identifier:map; 33, argument_list; 33, 34; 33, 35; 34, identifier:str; 35, identifier:field_names; 36, expression_statement; 36, 37; 37, assignment; 37, 38; 37, 39; 38, identifier:safe_fields_names; 39, call; 39, 40; 39, 41; 40, identifier:map; 41, argument_list; 41, 42; 41, 43; 42, identifier:_encode_property_name; 43, identifier:field_names; 44, expression_statement; 44, 45; 45, assignment; 45, 46; 45, 47; 46, identifier:attr; 47, call; 47, 48; 47, 49; 48, identifier:dict; 49, generator_expression; 49, 50; 49, 56; 50, tuple; 50, 51; 50, 52; 51, identifier:safe_name; 52, call; 52, 53; 52, 54; 53, identifier:_property; 54, argument_list; 54, 55; 55, identifier:name; 56, for_in_clause; 56, 57; 56, 60; 57, pattern_list; 57, 58; 57, 59; 58, identifier:name; 59, identifier:safe_name; 60, call; 60, 61; 60, 62; 61, identifier:zip; 62, argument_list; 62, 63; 62, 64; 63, identifier:field_names; 64, identifier:safe_fields_names; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 70; 67, subscript; 67, 68; 67, 69; 68, identifier:attr; 69, string:'__doc__'; 70, identifier:typename; 71, expression_statement; 71, 72; 72, assignment; 72, 73; 72, 76; 73, subscript; 73, 74; 73, 75; 74, identifier:attr; 75, string:'__identifier__'; 76, string:"dolphin"; 77, expression_statement; 77, 78; 78, assignment; 78, 79; 78, 82; 79, subscript; 79, 80; 79, 81; 80, identifier:attr; 81, string:'__init__'; 82, identifier:_dynamic__init; 83, expression_statement; 83, 84; 84, assignment; 84, 85; 84, 88; 85, subscript; 85, 86; 85, 87; 86, identifier:attr; 87, string:'__getitem__'; 88, lambda; 88, 89; 88, 92; 89, lambda_parameters; 89, 90; 89, 91; 90, identifier:self; 91, identifier:key; 92, call; 92, 93; 92, 98; 93, attribute; 93, 94; 93, 97; 94, attribute; 94, 95; 94, 96; 95, identifier:self; 96, identifier:__dict__; 97, identifier:get; 98, argument_list; 98, 99; 99, identifier:key; 100, expression_statement; 100, 101; 101, assignment; 101, 102; 101, 105; 102, subscript; 102, 103; 102, 104; 103, identifier:attr; 104, string:'__setitem__'; 105, identifier:_dynamic__setitem; 106, expression_statement; 106, 107; 107, assignment; 107, 108; 107, 111; 108, subscript; 108, 109; 108, 110; 109, identifier:attr; 110, string:'__iter__'; 111, lambda; 111, 112; 111, 114; 112, lambda_parameters; 112, 113; 113, identifier:self; 114, call; 114, 115; 114, 116; 115, identifier:iter; 116, argument_list; 116, 117; 117, attribute; 117, 118; 117, 119; 118, identifier:self; 119, identifier:__dict__; 120, expression_statement; 120, 121; 121, assignment; 121, 122; 121, 125; 122, subscript; 122, 123; 122, 124; 123, identifier:attr; 124, string:'__repr__'; 125, lambda; 125, 126; 125, 128; 126, lambda_parameters; 126, 127; 127, identifier:self; 128, binary_operator:%; 128, 129; 128, 130; 129, string:"{%s}"; 130, parenthesized_expression; 130, 131; 131, call; 131, 132; 131, 135; 132, attribute; 132, 133; 132, 134; 133, string:', '; 134, identifier:join; 135, argument_list; 135, 136; 136, list_comprehension; 136, 137; 136, 144; 137, binary_operator:%; 137, 138; 137, 139; 138, string:"%s=%r"; 139, tuple; 139, 140; 139, 141; 140, identifier:key; 141, subscript; 141, 142; 141, 143; 142, identifier:self; 143, identifier:key; 144, for_in_clause; 144, 145; 144, 146; 145, identifier:key; 146, call; 146, 147; 146, 148; 147, identifier:sorted; 148, argument_list; 148, 149; 149, call; 149, 150; 149, 155; 150, attribute; 150, 151; 150, 154; 151, attribute; 151, 152; 151, 153; 152, identifier:self; 153, identifier:__dict__; 154, identifier:keys; 155, argument_list; 156, return_statement; 156, 157; 157, call; 157, 158; 157, 159; 158, identifier:type; 159, argument_list; 159, 160; 159, 161; 159, 163; 160, identifier:typename; 161, tuple; 161, 162; 162, identifier:object; 163, identifier:attr
def make_dynamic_class(typename, field_names): if isinstance(field_names, basestring): field_names = field_names.replace(",", " ").split() field_names = map(str, field_names) safe_fields_names = map(_encode_property_name, field_names) attr = dict((safe_name, _property(name)) for name, safe_name in zip(field_names, safe_fields_names)) attr['__doc__'] = typename attr['__identifier__'] = "dolphin" attr['__init__'] = _dynamic__init attr['__getitem__'] = lambda self, key: self.__dict__.get(key) attr['__setitem__'] = _dynamic__setitem attr['__iter__'] = lambda self: iter(self.__dict__) attr['__repr__'] = lambda self: "{%s}" % (', '.join([ "%s=%r" % (key, self[key]) for key in sorted(self.__dict__.keys()) ])) return type(typename, (object,), attr)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:verifyInputs; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:mode; 6, block; 6, 7; 6, 34; 6, 431; 7, if_statement; 7, 8; 7, 16; 8, comparison_operator:<; 8, 9; 8, 15; 9, call; 9, 10; 9, 11; 10, identifier:len; 11, argument_list; 11, 12; 12, attribute; 12, 13; 12, 14; 13, identifier:self; 14, identifier:_aichans; 15, integer:1; 16, block; 16, 17; 16, 21; 16, 32; 17, expression_statement; 17, 18; 18, assignment; 18, 19; 18, 20; 19, identifier:failmsg; 20, string:"Must have at least one input channel selected"; 21, expression_statement; 21, 22; 22, call; 22, 23; 22, 28; 23, attribute; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:QtGui; 26, identifier:QMessageBox; 27, identifier:warning; 28, argument_list; 28, 29; 28, 30; 28, 31; 29, identifier:self; 30, string:"Invalid Setting"; 31, identifier:failmsg; 32, return_statement; 32, 33; 33, False; 34, if_statement; 34, 35; 34, 38; 34, 69; 35, comparison_operator:==; 35, 36; 35, 37; 36, identifier:mode; 37, string:'chart'; 38, block; 38, 39; 39, if_statement; 39, 40; 39, 55; 40, comparison_operator:>; 40, 41; 40, 54; 41, binary_operator:*; 41, 42; 41, 51; 42, call; 42, 43; 42, 50; 43, attribute; 43, 44; 43, 49; 44, attribute; 44, 45; 44, 48; 45, attribute; 45, 46; 45, 47; 46, identifier:self; 47, identifier:ui; 48, identifier:aifsSpnbx; 49, identifier:value; 50, argument_list; 51, attribute; 51, 52; 51, 53; 52, identifier:self; 53, identifier:fscale; 54, integer:100000; 55, block; 55, 56; 55, 67; 56, expression_statement; 56, 57; 57, call; 57, 58; 57, 63; 58, attribute; 58, 59; 58, 62; 59, attribute; 59, 60; 59, 61; 60, identifier:QtGui; 61, identifier:QMessageBox; 62, identifier:warning; 63, argument_list; 63, 64; 63, 65; 63, 66; 64, identifier:self; 65, string:"Invalid Input"; 66, string:"Recording samplerate cannot exceed 100kHz for chart acquisition"; 67, return_statement; 67, 68; 68, False; 69, elif_clause; 69, 70; 69, 73; 70, comparison_operator:is; 70, 71; 70, 72; 71, identifier:mode; 72, None; 73, block; 73, 74; 73, 398; 74, if_statement; 74, 75; 74, 90; 74, 138; 74, 201; 75, comparison_operator:==; 75, 76; 75, 89; 76, call; 76, 77; 76, 88; 77, attribute; 77, 78; 77, 87; 78, call; 78, 79; 78, 86; 79, attribute; 79, 80; 79, 85; 80, attribute; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:self; 83, identifier:ui; 84, identifier:tabGroup; 85, identifier:currentWidget; 86, argument_list; 87, identifier:objectName; 88, argument_list; 89, string:'tabExplore'; 90, block; 90, 91; 90, 101; 90, 122; 91, expression_statement; 91, 92; 92, call; 92, 93; 92, 100; 93, attribute; 93, 94; 93, 99; 94, attribute; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:self; 97, identifier:ui; 98, identifier:exploreStimEditor; 99, identifier:saveToObject; 100, argument_list; 101, expression_statement; 101, 102; 102, assignment; 102, 103; 102, 104; 103, identifier:failmsg; 104, call; 104, 105; 104, 112; 105, attribute; 105, 106; 105, 111; 106, attribute; 106, 107; 106, 110; 107, attribute; 107, 108; 107, 109; 108, identifier:self; 109, identifier:ui; 110, identifier:exploreStimEditor; 111, identifier:verify; 112, argument_list; 112, 113; 113, call; 113, 114; 113, 121; 114, attribute; 114, 115; 114, 120; 115, attribute; 115, 116; 115, 119; 116, attribute; 116, 117; 116, 118; 117, identifier:self; 118, identifier:ui; 119, identifier:windowszSpnbx; 120, identifier:value; 121, argument_list; 122, if_statement; 122, 123; 122, 124; 123, identifier:failmsg; 124, block; 124, 125; 124, 136; 125, expression_statement; 125, 126; 126, call; 126, 127; 126, 132; 127, attribute; 127, 128; 127, 131; 128, attribute; 128, 129; 128, 130; 129, identifier:QtGui; 130, identifier:QMessageBox; 131, identifier:warning; 132, argument_list; 132, 133; 132, 134; 132, 135; 133, identifier:self; 134, string:"Invalid Input"; 135, identifier:failmsg; 136, return_statement; 136, 137; 137, False; 138, elif_clause; 138, 139; 138, 154; 139, comparison_operator:==; 139, 140; 139, 153; 140, call; 140, 141; 140, 152; 141, attribute; 141, 142; 141, 151; 142, call; 142, 143; 142, 150; 143, attribute; 143, 144; 143, 149; 144, attribute; 144, 145; 144, 148; 145, attribute; 145, 146; 145, 147; 146, identifier:self; 147, identifier:ui; 148, identifier:tabGroup; 149, identifier:currentWidget; 150, argument_list; 151, identifier:objectName; 152, argument_list; 153, string:'tabProtocol'; 154, block; 154, 155; 154, 165; 154, 185; 155, expression_statement; 155, 156; 156, assignment; 156, 157; 156, 158; 157, identifier:protocol_model; 158, call; 158, 159; 158, 164; 159, attribute; 159, 160; 159, 163; 160, attribute; 160, 161; 160, 162; 161, identifier:self; 162, identifier:acqmodel; 163, identifier:protocol_model; 164, argument_list; 165, expression_statement; 165, 166; 166, assignment; 166, 167; 166, 168; 167, identifier:failure; 168, call; 168, 169; 168, 172; 169, attribute; 169, 170; 169, 171; 170, identifier:protocol_model; 171, identifier:verify; 172, argument_list; 172, 173; 173, call; 173, 174; 173, 175; 174, identifier:float; 175, argument_list; 175, 176; 176, call; 176, 177; 176, 184; 177, attribute; 177, 178; 177, 183; 178, attribute; 178, 179; 178, 182; 179, attribute; 179, 180; 179, 181; 180, identifier:self; 181, identifier:ui; 182, identifier:windowszSpnbx; 183, identifier:value; 184, argument_list; 185, if_statement; 185, 186; 185, 187; 186, identifier:failure; 187, block; 187, 188; 187, 199; 188, expression_statement; 188, 189; 189, call; 189, 190; 189, 195; 190, attribute; 190, 191; 190, 194; 191, attribute; 191, 192; 191, 193; 192, identifier:QtGui; 193, identifier:QMessageBox; 194, identifier:warning; 195, argument_list; 195, 196; 195, 197; 195, 198; 196, identifier:self; 197, string:"Invalid Input"; 198, identifier:failure; 199, return_statement; 199, 200; 200, False; 201, elif_clause; 201, 202; 201, 217; 202, comparison_operator:==; 202, 203; 202, 216; 203, call; 203, 204; 203, 215; 204, attribute; 204, 205; 204, 214; 205, call; 205, 206; 205, 213; 206, attribute; 206, 207; 206, 212; 207, attribute; 207, 208; 207, 211; 208, attribute; 208, 209; 208, 210; 209, identifier:self; 210, identifier:ui; 211, identifier:tabGroup; 212, identifier:currentWidget; 213, argument_list; 214, identifier:objectName; 215, argument_list; 216, string:'tabCalibrate'; 217, block; 217, 218; 217, 255; 217, 317; 217, 337; 217, 353; 217, 372; 218, if_statement; 218, 219; 218, 227; 219, comparison_operator:>; 219, 220; 219, 226; 220, call; 220, 221; 220, 222; 221, identifier:len; 222, argument_list; 222, 223; 223, attribute; 223, 224; 223, 225; 224, identifier:self; 225, identifier:_aichans; 226, integer:1; 227, block; 227, 228; 227, 242; 227, 253; 228, expression_statement; 228, 229; 229, assignment; 229, 230; 229, 231; 230, identifier:failmsg; 231, call; 231, 232; 231, 235; 232, attribute; 232, 233; 232, 234; 233, string:"Speaker calibration only supported for single channel, currently {} channels selected; select 1 input channel."; 234, identifier:format; 235, argument_list; 235, 236; 236, call; 236, 237; 236, 238; 237, identifier:len; 238, argument_list; 238, 239; 239, attribute; 239, 240; 239, 241; 240, identifier:self; 241, identifier:_aichans; 242, expression_statement; 242, 243; 243, call; 243, 244; 243, 249; 244, attribute; 244, 245; 244, 248; 245, attribute; 245, 246; 245, 247; 246, identifier:QtGui; 247, identifier:QMessageBox; 248, identifier:warning; 249, argument_list; 249, 250; 249, 251; 249, 252; 250, identifier:self; 251, string:"Invalid Setting"; 252, identifier:failmsg; 253, return_statement; 253, 254; 254, False; 255, if_statement; 255, 256; 255, 282; 255, 304; 256, boolean_operator:or; 256, 257; 256, 270; 257, call; 257, 258; 257, 269; 258, attribute; 258, 259; 258, 268; 259, attribute; 259, 260; 259, 267; 260, attribute; 260, 261; 260, 266; 261, attribute; 261, 262; 261, 265; 262, attribute; 262, 263; 262, 264; 263, identifier:self; 264, identifier:ui; 265, identifier:calibrationWidget; 266, identifier:ui; 267, identifier:savecalCkbx; 268, identifier:isChecked; 269, argument_list; 270, not_operator; 270, 271; 271, comparison_operator:==; 271, 272; 271, 281; 272, call; 272, 273; 272, 280; 273, attribute; 273, 274; 273, 279; 274, attribute; 274, 275; 274, 278; 275, attribute; 275, 276; 275, 277; 276, identifier:self; 277, identifier:ui; 278, identifier:calibrationWidget; 279, identifier:currentSelection; 280, argument_list; 281, string:'Tone Curve'; 282, block; 282, 283; 282, 294; 283, expression_statement; 283, 284; 284, assignment; 284, 285; 284, 286; 285, identifier:calibration_stimulus; 286, call; 286, 287; 286, 292; 287, attribute; 287, 288; 287, 291; 288, attribute; 288, 289; 288, 290; 289, identifier:self; 290, identifier:acqmodel; 291, identifier:calibration_stimulus; 292, argument_list; 292, 293; 293, string:'noise'; 294, expression_statement; 294, 295; 295, call; 295, 296; 295, 303; 296, attribute; 296, 297; 296, 302; 297, attribute; 297, 298; 297, 301; 298, attribute; 298, 299; 298, 300; 299, identifier:self; 300, identifier:ui; 301, identifier:calibrationWidget; 302, identifier:saveToObject; 303, argument_list; 304, else_clause; 304, 305; 305, block; 305, 306; 306, expression_statement; 306, 307; 307, assignment; 307, 308; 307, 309; 308, identifier:calibration_stimulus; 309, call; 309, 310; 309, 315; 310, attribute; 310, 311; 310, 314; 311, attribute; 311, 312; 311, 313; 312, identifier:self; 313, identifier:acqmodel; 314, identifier:calibration_stimulus; 315, argument_list; 315, 316; 316, string:'tone'; 317, expression_statement; 317, 318; 318, assignment; 318, 319; 318, 320; 319, identifier:failmsg; 320, call; 320, 321; 320, 324; 321, attribute; 321, 322; 321, 323; 322, identifier:calibration_stimulus; 323, identifier:verify; 324, argument_list; 324, 325; 325, call; 325, 326; 325, 327; 326, identifier:float; 327, argument_list; 327, 328; 328, call; 328, 329; 328, 336; 329, attribute; 329, 330; 329, 335; 330, attribute; 330, 331; 330, 334; 331, attribute; 331, 332; 331, 333; 332, identifier:self; 333, identifier:ui; 334, identifier:windowszSpnbx; 335, identifier:value; 336, argument_list; 337, if_statement; 337, 338; 337, 339; 338, identifier:failmsg; 339, block; 339, 340; 339, 351; 340, expression_statement; 340, 341; 341, call; 341, 342; 341, 347; 342, attribute; 342, 343; 342, 346; 343, attribute; 343, 344; 343, 345; 344, identifier:QtGui; 345, identifier:QMessageBox; 346, identifier:warning; 347, argument_list; 347, 348; 347, 349; 347, 350; 348, identifier:self; 349, string:"Invalid Input"; 350, identifier:failmsg; 351, return_statement; 351, 352; 352, False; 353, expression_statement; 353, 354; 354, assignment; 354, 355; 354, 356; 355, identifier:failmsg; 356, call; 356, 357; 356, 360; 357, attribute; 357, 358; 357, 359; 358, identifier:calibration_stimulus; 359, identifier:verifyExpanded; 360, argument_list; 360, 361; 361, keyword_argument; 361, 362; 361, 363; 362, identifier:samplerate; 363, call; 363, 364; 363, 371; 364, attribute; 364, 365; 364, 370; 365, attribute; 365, 366; 365, 369; 366, attribute; 366, 367; 366, 368; 367, identifier:self; 368, identifier:ui; 369, identifier:aifsSpnbx; 370, identifier:value; 371, argument_list; 372, if_statement; 372, 373; 372, 374; 373, identifier:failmsg; 374, block; 374, 375; 374, 385; 374, 396; 375, expression_statement; 375, 376; 376, assignment; 376, 377; 376, 378; 377, identifier:failmsg; 378, call; 378, 379; 378, 382; 379, attribute; 379, 380; 379, 381; 380, identifier:failmsg; 381, identifier:replace; 382, argument_list; 382, 383; 382, 384; 383, string:'Generation'; 384, string:'Recording'; 385, expression_statement; 385, 386; 386, call; 386, 387; 386, 392; 387, attribute; 387, 388; 387, 391; 388, attribute; 388, 389; 388, 390; 389, identifier:QtGui; 390, identifier:QMessageBox; 391, identifier:warning; 392, argument_list; 392, 393; 392, 394; 392, 395; 393, identifier:self; 394, string:"Invalid Input"; 395, identifier:failmsg; 396, return_statement; 396, 397; 397, False; 398, if_statement; 398, 399; 398, 413; 399, boolean_operator:and; 399, 400; 399, 405; 400, subscript; 400, 401; 400, 404; 401, attribute; 401, 402; 401, 403; 402, identifier:self; 403, identifier:advanced_options; 404, string:'use_attenuator'; 405, not_operator; 405, 406; 406, call; 406, 407; 406, 412; 407, attribute; 407, 408; 407, 411; 408, attribute; 408, 409; 408, 410; 409, identifier:self; 410, identifier:acqmodel; 411, identifier:attenuator_connection; 412, argument_list; 413, block; 413, 414; 413, 418; 413, 429; 414, expression_statement; 414, 415; 415, assignment; 415, 416; 415, 417; 416, identifier:failmsg; 417, string:"Error Connection to attenuator, make sure it it turned on and connected, and try again"; 418, expression_statement; 418, 419; 419, call; 419, 420; 419, 425; 420, attribute; 420, 421; 420, 424; 421, attribute; 421, 422; 421, 423; 422, identifier:QtGui; 423, identifier:QMessageBox; 424, identifier:warning; 425, argument_list; 425, 426; 425, 427; 425, 428; 426, identifier:self; 427, string:"Connection Error"; 428, identifier:failmsg; 429, return_statement; 429, 430; 430, False; 431, return_statement; 431, 432; 432, True
def verifyInputs(self, mode): if len(self._aichans) < 1: failmsg = "Must have at least one input channel selected" QtGui.QMessageBox.warning(self, "Invalid Setting", failmsg) return False if mode == 'chart': if self.ui.aifsSpnbx.value()*self.fscale > 100000: QtGui.QMessageBox.warning(self, "Invalid Input", "Recording samplerate cannot exceed 100kHz for chart acquisition") return False elif mode is not None: if self.ui.tabGroup.currentWidget().objectName() == 'tabExplore': self.ui.exploreStimEditor.saveToObject() failmsg = self.ui.exploreStimEditor.verify(self.ui.windowszSpnbx.value()) if failmsg: QtGui.QMessageBox.warning(self, "Invalid Input", failmsg) return False elif self.ui.tabGroup.currentWidget().objectName() == 'tabProtocol': protocol_model = self.acqmodel.protocol_model() failure = protocol_model.verify(float(self.ui.windowszSpnbx.value())) if failure: QtGui.QMessageBox.warning(self, "Invalid Input", failure) return False elif self.ui.tabGroup.currentWidget().objectName() == 'tabCalibrate': if len(self._aichans) > 1: failmsg = "Speaker calibration only supported for single channel, currently {} channels selected; select 1 input channel.".format(len(self._aichans)) QtGui.QMessageBox.warning(self, "Invalid Setting", failmsg) return False if self.ui.calibrationWidget.ui.savecalCkbx.isChecked() or not self.ui.calibrationWidget.currentSelection() == 'Tone Curve': calibration_stimulus = self.acqmodel.calibration_stimulus('noise') self.ui.calibrationWidget.saveToObject() else: calibration_stimulus = self.acqmodel.calibration_stimulus('tone') failmsg = calibration_stimulus.verify(float(self.ui.windowszSpnbx.value())) if failmsg: QtGui.QMessageBox.warning(self, "Invalid Input", failmsg) return False failmsg = calibration_stimulus.verifyExpanded(samplerate=self.ui.aifsSpnbx.value()) if failmsg: failmsg = failmsg.replace('Generation', 'Recording') QtGui.QMessageBox.warning(self, "Invalid Input", failmsg) return False if self.advanced_options['use_attenuator'] and not self.acqmodel.attenuator_connection(): failmsg = "Error Connection to attenuator, make sure it it turned on and connected, and try again" QtGui.QMessageBox.warning(self, "Connection Error", failmsg) return False return True
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:complete; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:command_line; 5, identifier:current_token; 6, identifier:position; 7, typed_parameter; 7, 8; 7, 9; 8, identifier:shell; 9, type; 9, 10; 10, call; 10, 11; 10, 12; 11, identifier:arg; 12, argument_list; 12, 13; 13, keyword_argument; 13, 14; 13, 15; 14, identifier:choices; 15, tuple; 15, 16; 15, 17; 16, string:'bash'; 17, string:'fish'; 18, block; 18, 19; 18, 26; 18, 39; 18, 55; 18, 64; 18, 73; 18, 79; 18, 86; 18, 104; 18, 114; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 22; 21, identifier:position; 22, call; 22, 23; 22, 24; 23, identifier:int; 24, argument_list; 24, 25; 25, identifier:position; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:tokens; 29, call; 29, 30; 29, 33; 30, attribute; 30, 31; 30, 32; 31, identifier:shlex; 32, identifier:split; 33, argument_list; 33, 34; 34, subscript; 34, 35; 34, 36; 35, identifier:command_line; 36, slice; 36, 37; 36, 38; 37, colon; 38, identifier:position; 39, expression_statement; 39, 40; 40, assignment; 40, 41; 40, 45; 41, pattern_list; 41, 42; 41, 43; 41, 44; 42, identifier:all_argv; 43, identifier:run_argv; 44, identifier:command_argv; 45, call; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:run; 48, identifier:partition_argv; 49, argument_list; 49, 50; 50, subscript; 50, 51; 50, 52; 51, identifier:tokens; 52, slice; 52, 53; 52, 54; 53, integer:1; 54, colon; 55, expression_statement; 55, 56; 56, assignment; 56, 57; 56, 58; 57, identifier:run_args; 58, call; 58, 59; 58, 62; 59, attribute; 59, 60; 59, 61; 60, identifier:run; 61, identifier:parse_args; 62, argument_list; 62, 63; 63, identifier:run_argv; 64, expression_statement; 64, 65; 65, assignment; 65, 66; 65, 67; 66, identifier:module; 67, call; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, identifier:run_args; 70, identifier:get; 71, argument_list; 71, 72; 72, string:'commands_module'; 73, expression_statement; 73, 74; 74, assignment; 74, 75; 74, 76; 75, identifier:module; 76, boolean_operator:or; 76, 77; 76, 78; 77, identifier:module; 78, identifier:DEFAULT_COMMANDS_MODULE; 79, expression_statement; 79, 80; 80, assignment; 80, 81; 80, 82; 81, identifier:module; 82, call; 82, 83; 82, 84; 83, identifier:normalize_path; 84, argument_list; 84, 85; 85, identifier:module; 86, try_statement; 86, 87; 86, 97; 87, block; 87, 88; 88, expression_statement; 88, 89; 89, assignment; 89, 90; 89, 91; 90, identifier:collection; 91, call; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:Collection; 94, identifier:load_from_module; 95, argument_list; 95, 96; 96, identifier:module; 97, except_clause; 97, 98; 97, 99; 98, identifier:Exception; 99, block; 99, 100; 100, expression_statement; 100, 101; 101, assignment; 101, 102; 101, 103; 102, identifier:collection; 103, dictionary; 104, expression_statement; 104, 105; 105, assignment; 105, 106; 105, 107; 106, identifier:found_command; 107, boolean_operator:or; 107, 108; 107, 113; 108, call; 108, 109; 108, 110; 109, identifier:find_command; 110, argument_list; 110, 111; 110, 112; 111, identifier:collection; 112, identifier:tokens; 113, identifier:run; 114, if_statement; 114, 115; 114, 116; 114, 210; 115, identifier:current_token; 116, block; 116, 117; 117, if_statement; 117, 118; 117, 124; 117, 138; 118, call; 118, 119; 118, 122; 119, attribute; 119, 120; 119, 121; 120, identifier:current_token; 121, identifier:startswith; 122, argument_list; 122, 123; 123, string:'-'; 124, block; 124, 125; 125, if_statement; 125, 126; 125, 131; 126, comparison_operator:not; 126, 127; 126, 128; 127, identifier:current_token; 128, attribute; 128, 129; 128, 130; 129, identifier:found_command; 130, identifier:option_map; 131, block; 131, 132; 132, expression_statement; 132, 133; 133, call; 133, 134; 133, 135; 134, identifier:print_command_options; 135, argument_list; 135, 136; 135, 137; 136, identifier:found_command; 137, identifier:current_token; 138, else_clause; 138, 139; 139, block; 139, 140; 139, 146; 139, 157; 139, 168; 139, 179; 140, expression_statement; 140, 141; 141, call; 141, 142; 141, 143; 142, identifier:print_commands; 143, argument_list; 143, 144; 143, 145; 144, identifier:collection; 145, identifier:shell; 146, expression_statement; 146, 147; 147, assignment; 147, 148; 147, 149; 148, identifier:path; 149, call; 149, 150; 149, 155; 150, attribute; 150, 151; 150, 154; 151, attribute; 151, 152; 151, 153; 152, identifier:os; 153, identifier:path; 154, identifier:expanduser; 155, argument_list; 155, 156; 156, identifier:current_token; 157, expression_statement; 157, 158; 158, assignment; 158, 159; 158, 160; 159, identifier:path; 160, call; 160, 161; 160, 166; 161, attribute; 161, 162; 161, 165; 162, attribute; 162, 163; 162, 164; 163, identifier:os; 164, identifier:path; 165, identifier:expandvars; 166, argument_list; 166, 167; 167, identifier:path; 168, expression_statement; 168, 169; 169, assignment; 169, 170; 169, 171; 170, identifier:paths; 171, call; 171, 172; 171, 175; 172, attribute; 172, 173; 172, 174; 173, identifier:glob; 174, identifier:glob; 175, argument_list; 175, 176; 176, binary_operator:%; 176, 177; 176, 178; 177, string:'%s*'; 178, identifier:path; 179, if_statement; 179, 180; 179, 181; 180, identifier:paths; 181, block; 181, 182; 182, for_statement; 182, 183; 182, 184; 182, 185; 183, identifier:entry; 184, identifier:paths; 185, block; 185, 186; 186, if_statement; 186, 187; 186, 195; 186, 203; 187, call; 187, 188; 187, 193; 188, attribute; 188, 189; 188, 192; 189, attribute; 189, 190; 189, 191; 190, identifier:os; 191, identifier:path; 192, identifier:isdir; 193, argument_list; 193, 194; 194, identifier:entry; 195, block; 195, 196; 196, expression_statement; 196, 197; 197, call; 197, 198; 197, 199; 198, identifier:print; 199, argument_list; 199, 200; 200, binary_operator:%; 200, 201; 200, 202; 201, string:'%s/'; 202, identifier:entry; 203, else_clause; 203, 204; 204, block; 204, 205; 205, expression_statement; 205, 206; 206, call; 206, 207; 206, 208; 207, identifier:print; 208, argument_list; 208, 209; 209, identifier:entry; 210, else_clause; 210, 211; 211, block; 211, 212; 211, 226; 212, expression_statement; 212, 213; 213, assignment; 213, 214; 213, 215; 214, identifier:option; 215, call; 215, 216; 215, 221; 216, attribute; 216, 217; 216, 220; 217, attribute; 217, 218; 217, 219; 218, identifier:found_command; 219, identifier:option_map; 220, identifier:get; 221, argument_list; 221, 222; 222, subscript; 222, 223; 222, 224; 223, identifier:tokens; 224, unary_operator:-; 224, 225; 225, integer:1; 226, if_statement; 226, 227; 226, 232; 226, 283; 227, boolean_operator:and; 227, 228; 227, 229; 228, identifier:option; 229, attribute; 229, 230; 229, 231; 230, identifier:option; 231, identifier:takes_value; 232, block; 232, 233; 233, if_statement; 233, 234; 233, 237; 233, 249; 234, attribute; 234, 235; 234, 236; 235, identifier:option; 236, identifier:choices; 237, block; 237, 238; 238, for_statement; 238, 239; 238, 240; 238, 243; 239, identifier:choice; 240, attribute; 240, 241; 240, 242; 241, identifier:option; 242, identifier:choices; 243, block; 243, 244; 244, expression_statement; 244, 245; 245, call; 245, 246; 245, 247; 246, identifier:print; 247, argument_list; 247, 248; 248, identifier:choice; 249, else_clause; 249, 250; 250, block; 250, 251; 251, for_statement; 251, 252; 251, 253; 251, 258; 252, identifier:entry; 253, call; 253, 254; 253, 257; 254, attribute; 254, 255; 254, 256; 255, identifier:os; 256, identifier:listdir; 257, argument_list; 258, block; 258, 259; 259, if_statement; 259, 260; 259, 268; 259, 276; 260, call; 260, 261; 260, 266; 261, attribute; 261, 262; 261, 265; 262, attribute; 262, 263; 262, 264; 263, identifier:os; 264, identifier:path; 265, identifier:isdir; 266, argument_list; 266, 267; 267, identifier:entry; 268, block; 268, 269; 269, expression_statement; 269, 270; 270, call; 270, 271; 270, 272; 271, identifier:print; 272, argument_list; 272, 273; 273, binary_operator:%; 273, 274; 273, 275; 274, string:'%s/'; 275, identifier:entry; 276, else_clause; 276, 277; 277, block; 277, 278; 278, expression_statement; 278, 279; 279, call; 279, 280; 279, 281; 280, identifier:print; 281, argument_list; 281, 282; 282, identifier:entry; 283, else_clause; 283, 284; 284, block; 284, 285; 284, 290; 285, expression_statement; 285, 286; 286, call; 286, 287; 286, 288; 287, identifier:print_command_options; 288, argument_list; 288, 289; 289, identifier:found_command; 290, expression_statement; 290, 291; 291, call; 291, 292; 291, 293; 292, identifier:print_commands; 293, argument_list; 293, 294; 293, 295; 294, identifier:collection; 295, identifier:shell
def complete(command_line, current_token, position, shell: arg(choices=('bash', 'fish'))): position = int(position) tokens = shlex.split(command_line[:position]) all_argv, run_argv, command_argv = run.partition_argv(tokens[1:]) run_args = run.parse_args(run_argv) module = run_args.get('commands_module') module = module or DEFAULT_COMMANDS_MODULE module = normalize_path(module) try: collection = Collection.load_from_module(module) except Exception: collection = {} found_command = find_command(collection, tokens) or run if current_token: if current_token.startswith('-'): if current_token not in found_command.option_map: print_command_options(found_command, current_token) else: print_commands(collection, shell) path = os.path.expanduser(current_token) path = os.path.expandvars(path) paths = glob.glob('%s*' % path) if paths: for entry in paths: if os.path.isdir(entry): print('%s/' % entry) else: print(entry) else: option = found_command.option_map.get(tokens[-1]) if option and option.takes_value: if option.choices: for choice in option.choices: print(choice) else: for entry in os.listdir(): if os.path.isdir(entry): print('%s/' % entry) else: print(entry) else: print_command_options(found_command) print_commands(collection, shell)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:export; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:context; 5, identifier:keywords; 6, identifier:module; 7, identifier:update; 8, block; 8, 9; 8, 19; 8, 27; 8, 31; 8, 197; 9, expression_statement; 9, 10; 10, call; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:logging; 13, identifier:info; 14, argument_list; 14, 15; 15, call; 15, 16; 15, 17; 16, identifier:_; 17, argument_list; 17, 18; 18, string:'Export Mode'; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 22; 21, identifier:database; 22, subscript; 22, 23; 22, 26; 23, attribute; 23, 24; 23, 25; 24, identifier:context; 25, identifier:obj; 26, string:'sense'; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:none; 30, True; 31, if_statement; 31, 32; 31, 33; 31, 104; 31, 154; 32, identifier:update; 33, block; 33, 34; 33, 40; 33, 48; 33, 93; 33, 100; 34, expression_statement; 34, 35; 35, assignment; 35, 36; 35, 37; 36, identifier:exports; 37, call; 37, 38; 37, 39; 38, identifier:OrderedDict; 39, argument_list; 40, import_from_statement; 40, 41; 40, 46; 41, relative_import; 41, 42; 41, 43; 42, import_prefix; 43, dotted_name; 43, 44; 43, 45; 44, identifier:executables; 45, identifier:pe; 46, dotted_name; 46, 47; 47, identifier:PE; 48, for_statement; 48, 49; 48, 50; 48, 51; 49, identifier:filename; 50, identifier:keywords; 51, block; 51, 52; 51, 64; 52, expression_statement; 52, 53; 53, assignment; 53, 54; 53, 55; 54, identifier:module; 55, subscript; 55, 56; 55, 63; 56, call; 56, 57; 56, 58; 57, identifier:split_ext; 58, argument_list; 58, 59; 58, 60; 59, identifier:filename; 60, keyword_argument; 60, 61; 60, 62; 61, identifier:basename; 62, True; 63, integer:0; 64, with_statement; 64, 65; 64, 75; 65, with_clause; 65, 66; 66, with_item; 66, 67; 67, as_pattern; 67, 68; 67, 73; 68, call; 68, 69; 68, 70; 69, identifier:open; 70, argument_list; 70, 71; 70, 72; 71, identifier:filename; 72, string:'rb'; 73, as_pattern_target; 73, 74; 74, identifier:stream; 75, block; 75, 76; 76, expression_statement; 76, 77; 77, call; 77, 78; 77, 81; 78, attribute; 78, 79; 78, 80; 79, identifier:exports; 80, identifier:update; 81, argument_list; 81, 82; 82, dictionary; 82, 83; 83, pair; 83, 84; 83, 85; 84, identifier:module; 85, call; 85, 86; 85, 92; 86, attribute; 86, 87; 86, 91; 87, call; 87, 88; 87, 89; 88, identifier:PE; 89, argument_list; 89, 90; 90, identifier:stream; 91, identifier:get_export_table; 92, argument_list; 93, expression_statement; 93, 94; 94, call; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:database; 97, identifier:make_export; 98, argument_list; 98, 99; 99, identifier:exports; 100, expression_statement; 100, 101; 101, assignment; 101, 102; 101, 103; 102, identifier:none; 103, False; 104, elif_clause; 104, 105; 104, 106; 105, identifier:module; 106, block; 106, 107; 107, for_statement; 107, 108; 107, 109; 107, 110; 108, identifier:module_name; 109, identifier:keywords; 110, block; 110, 111; 110, 120; 111, expression_statement; 111, 112; 112, assignment; 112, 113; 112, 114; 113, identifier:funcs; 114, call; 114, 115; 114, 118; 115, attribute; 115, 116; 115, 117; 116, identifier:database; 117, identifier:query_module_funcs; 118, argument_list; 118, 119; 119, identifier:module_name; 120, if_statement; 120, 121; 120, 122; 120, 141; 121, identifier:funcs; 122, block; 122, 123; 122, 127; 123, expression_statement; 123, 124; 124, assignment; 124, 125; 124, 126; 125, identifier:none; 126, False; 127, expression_statement; 127, 128; 128, call; 128, 129; 128, 130; 129, identifier:print; 130, argument_list; 130, 131; 131, call; 131, 132; 131, 135; 132, attribute; 132, 133; 132, 134; 133, string:', '; 134, identifier:join; 135, argument_list; 135, 136; 136, call; 136, 137; 136, 138; 137, identifier:map; 138, argument_list; 138, 139; 138, 140; 139, identifier:str; 140, identifier:funcs; 141, else_clause; 141, 142; 142, block; 142, 143; 143, expression_statement; 143, 144; 144, call; 144, 145; 144, 148; 145, attribute; 145, 146; 145, 147; 146, identifier:logging; 147, identifier:warning; 148, argument_list; 148, 149; 148, 153; 149, call; 149, 150; 149, 151; 150, identifier:_; 151, argument_list; 151, 152; 152, string:'No function for module: %s'; 153, identifier:module_name; 154, else_clause; 154, 155; 155, block; 155, 156; 156, for_statement; 156, 157; 156, 158; 156, 159; 157, identifier:func_name; 158, identifier:keywords; 159, block; 159, 160; 159, 169; 160, expression_statement; 160, 161; 161, assignment; 161, 162; 161, 163; 162, identifier:module_name; 163, call; 163, 164; 163, 167; 164, attribute; 164, 165; 164, 166; 165, identifier:database; 166, identifier:query_func_module; 167, argument_list; 167, 168; 168, identifier:func_name; 169, if_statement; 169, 170; 169, 171; 169, 184; 170, identifier:module_name; 171, block; 171, 172; 171, 176; 172, expression_statement; 172, 173; 173, assignment; 173, 174; 173, 175; 174, identifier:none; 175, False; 176, expression_statement; 176, 177; 177, call; 177, 178; 177, 179; 178, identifier:print; 179, argument_list; 179, 180; 180, call; 180, 181; 180, 182; 181, identifier:repr; 182, argument_list; 182, 183; 183, identifier:module_name; 184, else_clause; 184, 185; 185, block; 185, 186; 186, expression_statement; 186, 187; 187, call; 187, 188; 187, 191; 188, attribute; 188, 189; 188, 190; 189, identifier:logging; 190, identifier:warning; 191, argument_list; 191, 192; 191, 196; 192, call; 192, 193; 192, 194; 193, identifier:_; 194, argument_list; 194, 195; 195, string:'No module for function: %s'; 196, identifier:func_name; 197, expression_statement; 197, 198; 198, call; 198, 199; 198, 202; 199, attribute; 199, 200; 199, 201; 200, identifier:sys; 201, identifier:exit; 202, argument_list; 202, 203; 203, conditional_expression:if; 203, 204; 203, 205; 203, 206; 204, integer:1; 205, identifier:none; 206, integer:0
def export(context, keywords, module, update): logging.info(_('Export Mode')) database = context.obj['sense'] none = True if update: exports = OrderedDict() from .executables.pe import PE for filename in keywords: module = split_ext(filename, basename=True)[0] with open(filename, 'rb') as stream: exports.update( {module: PE(stream).get_export_table()}) database.make_export(exports) none = False elif module: for module_name in keywords: funcs = database.query_module_funcs(module_name) if funcs: none = False print(', '.join(map(str, funcs))) else: logging.warning(_('No function for module: %s'), module_name) else: for func_name in keywords: module_name = database.query_func_module(func_name) if module_name: none = False print(repr(module_name)) else: logging.warning(_('No module for function: %s'), func_name) sys.exit(1 if none else 0)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_source; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:label; 5, identifier:source_type; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 27; 8, 53; 9, if_statement; 9, 10; 9, 15; 10, comparison_operator:not; 10, 11; 10, 12; 11, identifier:source_type; 12, attribute; 12, 13; 12, 14; 13, identifier:yapconf; 14, identifier:ALL_SUPPORTED_SOURCES; 15, block; 15, 16; 16, raise_statement; 16, 17; 17, call; 17, 18; 17, 19; 18, identifier:YapconfSourceError; 19, argument_list; 19, 20; 20, binary_operator:%; 20, 21; 20, 22; 21, string:'Invalid source type %s. Supported types are %s.'; 22, tuple; 22, 23; 22, 24; 23, identifier:source_type; 24, attribute; 24, 25; 24, 26; 25, identifier:yapconf; 26, identifier:ALL_SUPPORTED_SOURCES; 27, if_statement; 27, 28; 27, 33; 28, comparison_operator:not; 28, 29; 28, 30; 29, identifier:source_type; 30, attribute; 30, 31; 30, 32; 31, identifier:yapconf; 32, identifier:SUPPORTED_SOURCES; 33, block; 33, 34; 34, raise_statement; 34, 35; 35, call; 35, 36; 35, 37; 36, identifier:YapconfSourceError; 37, argument_list; 37, 38; 38, binary_operator:%; 38, 39; 38, 44; 39, concatenated_string; 39, 40; 39, 41; 39, 42; 39, 43; 40, string:'Unsupported source type "%s". If you want to use this type, you '; 41, string:'will need to install the correct client for it (try `pip install '; 42, string:'yapconf[%s]. Currently supported types are %s. All supported '; 43, string:'types are %s'; 44, tuple; 44, 45; 44, 46; 44, 47; 44, 50; 45, identifier:source_type; 46, identifier:source_type; 47, attribute; 47, 48; 47, 49; 48, identifier:yapconf; 49, identifier:SUPPORTED_SOURCES; 50, attribute; 50, 51; 50, 52; 51, identifier:yapconf; 52, identifier:ALL_SUPPORTED_SOURCES; 53, if_statement; 53, 54; 53, 57; 53, 71; 53, 83; 53, 117; 53, 127; 53, 150; 53, 206; 54, comparison_operator:==; 54, 55; 54, 56; 55, identifier:source_type; 56, string:'dict'; 57, block; 57, 58; 58, return_statement; 58, 59; 59, call; 59, 60; 59, 61; 60, identifier:DictConfigSource; 61, argument_list; 61, 62; 61, 63; 62, identifier:label; 63, keyword_argument; 63, 64; 63, 65; 64, identifier:data; 65, call; 65, 66; 65, 69; 66, attribute; 66, 67; 66, 68; 67, identifier:kwargs; 68, identifier:get; 69, argument_list; 69, 70; 70, string:'data'; 71, elif_clause; 71, 72; 71, 75; 72, comparison_operator:==; 72, 73; 72, 74; 73, identifier:source_type; 74, string:'json'; 75, block; 75, 76; 76, return_statement; 76, 77; 77, call; 77, 78; 77, 79; 78, identifier:JsonConfigSource; 79, argument_list; 79, 80; 79, 81; 80, identifier:label; 81, dictionary_splat; 81, 82; 82, identifier:kwargs; 83, elif_clause; 83, 84; 83, 87; 84, comparison_operator:==; 84, 85; 84, 86; 85, identifier:source_type; 86, string:'yaml'; 87, block; 87, 88; 87, 97; 87, 109; 88, expression_statement; 88, 89; 89, assignment; 89, 90; 89, 91; 90, identifier:filename; 91, call; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:kwargs; 94, identifier:get; 95, argument_list; 95, 96; 96, string:'filename'; 97, if_statement; 97, 98; 97, 101; 98, comparison_operator:in; 98, 99; 98, 100; 99, string:'filename'; 100, identifier:kwargs; 101, block; 101, 102; 102, expression_statement; 102, 103; 103, call; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:kwargs; 106, identifier:pop; 107, argument_list; 107, 108; 108, string:'filename'; 109, return_statement; 109, 110; 110, call; 110, 111; 110, 112; 111, identifier:YamlConfigSource; 112, argument_list; 112, 113; 112, 114; 112, 115; 113, identifier:label; 114, identifier:filename; 115, dictionary_splat; 115, 116; 116, identifier:kwargs; 117, elif_clause; 117, 118; 117, 121; 118, comparison_operator:==; 118, 119; 118, 120; 119, identifier:source_type; 120, string:'environment'; 121, block; 121, 122; 122, return_statement; 122, 123; 123, call; 123, 124; 123, 125; 124, identifier:EnvironmentConfigSource; 125, argument_list; 125, 126; 126, identifier:label; 127, elif_clause; 127, 128; 127, 131; 128, comparison_operator:==; 128, 129; 128, 130; 129, identifier:source_type; 130, string:'etcd'; 131, block; 131, 132; 132, return_statement; 132, 133; 133, call; 133, 134; 133, 135; 134, identifier:EtcdConfigSource; 135, argument_list; 135, 136; 135, 137; 135, 143; 136, identifier:label; 137, call; 137, 138; 137, 141; 138, attribute; 138, 139; 138, 140; 139, identifier:kwargs; 140, identifier:get; 141, argument_list; 141, 142; 142, string:'client'; 143, call; 143, 144; 143, 147; 144, attribute; 144, 145; 144, 146; 145, identifier:kwargs; 146, identifier:get; 147, argument_list; 147, 148; 147, 149; 148, string:'key'; 149, string:'/'; 150, elif_clause; 150, 151; 150, 154; 151, comparison_operator:==; 151, 152; 151, 153; 152, identifier:source_type; 153, string:'kubernetes'; 154, block; 154, 155; 154, 164; 154, 176; 154, 185; 154, 197; 155, expression_statement; 155, 156; 156, assignment; 156, 157; 156, 158; 157, identifier:name; 158, call; 158, 159; 158, 162; 159, attribute; 159, 160; 159, 161; 160, identifier:kwargs; 161, identifier:get; 162, argument_list; 162, 163; 163, string:'name'; 164, if_statement; 164, 165; 164, 168; 165, comparison_operator:in; 165, 166; 165, 167; 166, string:'name'; 167, identifier:kwargs; 168, block; 168, 169; 169, expression_statement; 169, 170; 170, call; 170, 171; 170, 174; 171, attribute; 171, 172; 171, 173; 172, identifier:kwargs; 173, identifier:pop; 174, argument_list; 174, 175; 175, string:'name'; 176, expression_statement; 176, 177; 177, assignment; 177, 178; 177, 179; 178, identifier:client; 179, call; 179, 180; 179, 183; 180, attribute; 180, 181; 180, 182; 181, identifier:kwargs; 182, identifier:get; 183, argument_list; 183, 184; 184, string:'client'; 185, if_statement; 185, 186; 185, 189; 186, comparison_operator:in; 186, 187; 186, 188; 187, string:'client'; 188, identifier:kwargs; 189, block; 189, 190; 190, expression_statement; 190, 191; 191, call; 191, 192; 191, 195; 192, attribute; 192, 193; 192, 194; 193, identifier:kwargs; 194, identifier:pop; 195, argument_list; 195, 196; 196, string:'client'; 197, return_statement; 197, 198; 198, call; 198, 199; 198, 200; 199, identifier:KubernetesConfigSource; 200, argument_list; 200, 201; 200, 202; 200, 203; 200, 204; 201, identifier:label; 202, identifier:client; 203, identifier:name; 204, dictionary_splat; 204, 205; 205, identifier:kwargs; 206, else_clause; 206, 207; 207, block; 207, 208; 208, raise_statement; 208, 209; 209, call; 209, 210; 209, 211; 210, identifier:NotImplementedError; 211, argument_list; 211, 212; 212, binary_operator:%; 212, 213; 212, 214; 213, string:'No implementation for source type %s'; 214, identifier:source_type
def get_source(label, source_type, **kwargs): if source_type not in yapconf.ALL_SUPPORTED_SOURCES: raise YapconfSourceError( 'Invalid source type %s. Supported types are %s.' % (source_type, yapconf.ALL_SUPPORTED_SOURCES) ) if source_type not in yapconf.SUPPORTED_SOURCES: raise YapconfSourceError( 'Unsupported source type "%s". If you want to use this type, you ' 'will need to install the correct client for it (try `pip install ' 'yapconf[%s]. Currently supported types are %s. All supported ' 'types are %s' % (source_type, source_type, yapconf.SUPPORTED_SOURCES, yapconf.ALL_SUPPORTED_SOURCES) ) if source_type == 'dict': return DictConfigSource(label, data=kwargs.get('data')) elif source_type == 'json': return JsonConfigSource(label, **kwargs) elif source_type == 'yaml': filename = kwargs.get('filename') if 'filename' in kwargs: kwargs.pop('filename') return YamlConfigSource(label, filename, **kwargs) elif source_type == 'environment': return EnvironmentConfigSource(label) elif source_type == 'etcd': return EtcdConfigSource( label, kwargs.get('client'), kwargs.get('key', '/') ) elif source_type == 'kubernetes': name = kwargs.get('name') if 'name' in kwargs: kwargs.pop('name') client = kwargs.get('client') if 'client' in kwargs: kwargs.pop('client') return KubernetesConfigSource(label, client, name, **kwargs) else: raise NotImplementedError( 'No implementation for source type %s' % source_type )
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 37; 1, 39; 2, function_name:_project_observable; 3, parameters; 3, 4; 3, 5; 3, 9; 3, 13; 3, 24; 3, 35; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:input_key; 7, type; 7, 8; 8, identifier:str; 9, typed_parameter; 9, 10; 9, 11; 10, identifier:input_observable; 11, type; 11, 12; 12, identifier:Any; 13, typed_default_parameter; 13, 14; 13, 15; 13, 23; 14, identifier:get_hist_args; 15, type; 15, 16; 16, generic_type; 16, 17; 16, 18; 17, identifier:Dict; 18, type_parameter; 18, 19; 18, 21; 19, type; 19, 20; 20, identifier:str; 21, type; 21, 22; 22, identifier:Any; 23, None; 24, typed_default_parameter; 24, 25; 24, 26; 24, 34; 25, identifier:projection_name_args; 26, type; 26, 27; 27, generic_type; 27, 28; 27, 29; 28, identifier:Dict; 29, type_parameter; 29, 30; 29, 32; 30, type; 30, 31; 31, identifier:str; 32, type; 32, 33; 33, identifier:Any; 34, None; 35, dictionary_splat_pattern; 35, 36; 36, identifier:kwargs; 37, type; 37, 38; 38, identifier:Hist; 39, block; 39, 40; 39, 54; 39, 68; 39, 78; 39, 88; 39, 97; 39, 104; 39, 120; 39, 130; 39, 137; 39, 157; 39, 173; 39, 199; 39, 210; 39, 214; 39, 276; 39, 288; 39, 294; 39, 309; 39, 316; 39, 323; 40, if_statement; 40, 41; 40, 44; 41, comparison_operator:is; 41, 42; 41, 43; 42, identifier:get_hist_args; 43, None; 44, block; 44, 45; 45, expression_statement; 45, 46; 46, assignment; 46, 47; 46, 48; 47, identifier:get_hist_args; 48, call; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, identifier:copy; 51, identifier:deepcopy; 52, argument_list; 52, 53; 53, identifier:kwargs; 54, if_statement; 54, 55; 54, 58; 55, comparison_operator:is; 55, 56; 55, 57; 56, identifier:projection_name_args; 57, None; 58, block; 58, 59; 59, expression_statement; 59, 60; 60, assignment; 60, 61; 60, 62; 61, identifier:projection_name_args; 62, call; 62, 63; 62, 66; 63, attribute; 63, 64; 63, 65; 64, identifier:copy; 65, identifier:deepcopy; 66, argument_list; 66, 67; 67, identifier:kwargs; 68, expression_statement; 68, 69; 69, call; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:get_hist_args; 72, identifier:update; 73, argument_list; 73, 74; 74, dictionary; 74, 75; 75, pair; 75, 76; 75, 77; 76, string:"observable"; 77, identifier:input_observable; 78, expression_statement; 78, 79; 79, assignment; 79, 80; 79, 81; 80, identifier:hist; 81, call; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:self; 84, identifier:get_hist; 85, argument_list; 85, 86; 86, dictionary_splat; 86, 87; 87, identifier:get_hist_args; 88, expression_statement; 88, 89; 89, call; 89, 90; 89, 93; 90, attribute; 90, 91; 90, 92; 91, identifier:projection_name_args; 92, identifier:update; 93, argument_list; 93, 94; 94, attribute; 94, 95; 94, 96; 95, identifier:self; 96, identifier:projection_information; 97, expression_statement; 97, 98; 98, call; 98, 99; 98, 102; 99, attribute; 99, 100; 99, 101; 100, identifier:projection_name_args; 101, identifier:update; 102, argument_list; 102, 103; 103, identifier:kwargs; 104, expression_statement; 104, 105; 105, call; 105, 106; 105, 109; 106, attribute; 106, 107; 106, 108; 107, identifier:projection_name_args; 108, identifier:update; 109, argument_list; 109, 110; 110, dictionary; 110, 111; 110, 114; 110, 117; 111, pair; 111, 112; 111, 113; 112, string:"input_key"; 113, identifier:input_key; 114, pair; 114, 115; 114, 116; 115, string:"input_observable"; 116, identifier:input_observable; 117, pair; 117, 118; 117, 119; 118, string:"input_hist"; 119, identifier:hist; 120, expression_statement; 120, 121; 121, assignment; 121, 122; 121, 123; 122, identifier:projection_name; 123, call; 123, 124; 123, 127; 124, attribute; 124, 125; 124, 126; 125, identifier:self; 126, identifier:projection_name; 127, argument_list; 127, 128; 128, dictionary_splat; 128, 129; 129, identifier:projection_name_args; 130, expression_statement; 130, 131; 131, call; 131, 132; 131, 135; 132, attribute; 132, 133; 132, 134; 133, identifier:logger; 134, identifier:debug; 135, argument_list; 135, 136; 136, string:f"hist: {hist}"; 137, for_statement; 137, 138; 137, 139; 137, 142; 138, identifier:axis; 139, attribute; 139, 140; 139, 141; 140, identifier:self; 141, identifier:additional_axis_cuts; 142, block; 142, 143; 142, 150; 143, expression_statement; 143, 144; 144, call; 144, 145; 144, 148; 145, attribute; 145, 146; 145, 147; 146, identifier:logger; 147, identifier:debug; 148, argument_list; 148, 149; 149, string:f"Apply additional axis hist range: {axis.name}"; 150, expression_statement; 150, 151; 151, call; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:axis; 154, identifier:apply_range_set; 155, argument_list; 155, 156; 156, identifier:hist; 157, if_statement; 157, 158; 157, 163; 158, comparison_operator:==; 158, 159; 158, 162; 159, attribute; 159, 160; 159, 161; 160, identifier:self; 161, identifier:projection_dependent_cut_axes; 162, list:[]; 163, block; 163, 164; 164, expression_statement; 164, 165; 165, call; 165, 166; 165, 171; 166, attribute; 166, 167; 166, 170; 167, attribute; 167, 168; 167, 169; 168, identifier:self; 169, identifier:projection_dependent_cut_axes; 170, identifier:append; 171, argument_list; 171, 172; 172, list:[]; 173, expression_statement; 173, 174; 174, assignment; 174, 175; 174, 176; 175, identifier:duplicated_axes; 176, list_comprehension; 176, 177; 176, 178; 176, 183; 176, 188; 176, 191; 177, identifier:PDCA; 178, for_in_clause; 178, 179; 178, 180; 179, identifier:PA; 180, attribute; 180, 181; 180, 182; 181, identifier:self; 182, identifier:projection_axes; 183, for_in_clause; 183, 184; 183, 185; 184, identifier:PDCA_group; 185, attribute; 185, 186; 185, 187; 186, identifier:self; 187, identifier:projection_dependent_cut_axes; 188, for_in_clause; 188, 189; 188, 190; 189, identifier:PDCA; 190, identifier:PDCA_group; 191, if_clause; 191, 192; 192, comparison_operator:==; 192, 193; 192, 196; 193, attribute; 193, 194; 193, 195; 194, identifier:PDCA; 195, identifier:axis_type; 196, attribute; 196, 197; 196, 198; 197, identifier:PA; 198, identifier:axis_type; 199, if_statement; 199, 200; 199, 201; 200, identifier:duplicated_axes; 201, block; 201, 202; 202, raise_statement; 202, 203; 203, call; 203, 204; 203, 205; 204, identifier:ValueError; 205, argument_list; 205, 206; 206, concatenated_string; 206, 207; 206, 208; 206, 209; 207, string:f"Axis {duplicated_axes} is in the projection axes and the projection dependent cut axes."; 208, string:" This configuration is not allowed, as the range in the PDCA will be overwritten by the projection axes!"; 209, string:" Please revise your configuration."; 210, expression_statement; 210, 211; 211, assignment; 211, 212; 211, 213; 212, identifier:hists; 213, list:[]; 214, for_statement; 214, 215; 214, 218; 214, 224; 215, pattern_list; 215, 216; 215, 217; 216, identifier:i; 217, identifier:axes; 218, call; 218, 219; 218, 220; 219, identifier:enumerate; 220, argument_list; 220, 221; 221, attribute; 221, 222; 221, 223; 222, identifier:self; 223, identifier:projection_dependent_cut_axes; 224, block; 224, 225; 224, 243; 224, 252; 224, 259; 224, 266; 225, for_statement; 225, 226; 225, 227; 225, 228; 226, identifier:axis; 227, identifier:axes; 228, block; 228, 229; 228, 236; 229, expression_statement; 229, 230; 230, call; 230, 231; 230, 234; 231, attribute; 231, 232; 231, 233; 232, identifier:logger; 233, identifier:debug; 234, argument_list; 234, 235; 235, string:f"Apply projection dependent hist range: {axis.name}"; 236, expression_statement; 236, 237; 237, call; 237, 238; 237, 241; 238, attribute; 238, 239; 238, 240; 239, identifier:axis; 240, identifier:apply_range_set; 241, argument_list; 241, 242; 242, identifier:hist; 243, expression_statement; 243, 244; 244, assignment; 244, 245; 244, 246; 245, identifier:projected_hist; 246, call; 246, 247; 246, 250; 247, attribute; 247, 248; 247, 249; 248, identifier:self; 249, identifier:call_projection_function; 250, argument_list; 250, 251; 251, identifier:hist; 252, expression_statement; 252, 253; 253, call; 253, 254; 253, 257; 254, attribute; 254, 255; 254, 256; 255, identifier:projected_hist; 256, identifier:SetName; 257, argument_list; 257, 258; 258, string:f"{projection_name}_{i}"; 259, expression_statement; 259, 260; 260, call; 260, 261; 260, 264; 261, attribute; 261, 262; 261, 263; 262, identifier:hists; 263, identifier:append; 264, argument_list; 264, 265; 265, identifier:projected_hist; 266, expression_statement; 266, 267; 267, call; 267, 268; 267, 271; 268, attribute; 268, 269; 268, 270; 269, identifier:self; 270, identifier:cleanup_cuts; 271, argument_list; 271, 272; 271, 273; 272, identifier:hist; 273, keyword_argument; 273, 274; 273, 275; 274, identifier:cut_axes; 275, identifier:axes; 276, expression_statement; 276, 277; 277, call; 277, 278; 277, 281; 278, attribute; 278, 279; 278, 280; 279, identifier:self; 280, identifier:cleanup_cuts; 281, argument_list; 281, 282; 281, 283; 282, identifier:hist; 283, keyword_argument; 283, 284; 283, 285; 284, identifier:cut_axes; 285, attribute; 285, 286; 285, 287; 286, identifier:self; 287, identifier:additional_axis_cuts; 288, expression_statement; 288, 289; 289, assignment; 289, 290; 289, 291; 290, identifier:output_hist; 291, subscript; 291, 292; 291, 293; 292, identifier:hists; 293, integer:0; 294, for_statement; 294, 295; 294, 296; 294, 301; 295, identifier:temp_hist; 296, subscript; 296, 297; 296, 298; 297, identifier:hists; 298, slice; 298, 299; 298, 300; 299, integer:1; 300, colon; 301, block; 301, 302; 302, expression_statement; 302, 303; 303, call; 303, 304; 303, 307; 304, attribute; 304, 305; 304, 306; 305, identifier:output_hist; 306, identifier:Add; 307, argument_list; 307, 308; 308, identifier:temp_hist; 309, expression_statement; 309, 310; 310, call; 310, 311; 310, 314; 311, attribute; 311, 312; 311, 313; 312, identifier:output_hist; 313, identifier:SetName; 314, argument_list; 314, 315; 315, identifier:projection_name; 316, expression_statement; 316, 317; 317, call; 317, 318; 317, 321; 318, attribute; 318, 319; 318, 320; 319, identifier:output_hist; 320, identifier:SetDirectory; 321, argument_list; 321, 322; 322, integer:0; 323, return_statement; 323, 324; 324, expression_list; 324, 325; 324, 326; 324, 327; 325, identifier:output_hist; 326, identifier:projection_name; 327, identifier:projection_name_args
def _project_observable(self, input_key: str, input_observable: Any, get_hist_args: Dict[str, Any] = None, projection_name_args: Dict[str, Any] = None, **kwargs) -> Hist: if get_hist_args is None: get_hist_args = copy.deepcopy(kwargs) if projection_name_args is None: projection_name_args = copy.deepcopy(kwargs) get_hist_args.update({"observable": input_observable}) hist = self.get_hist(**get_hist_args) projection_name_args.update(self.projection_information) projection_name_args.update(kwargs) projection_name_args.update({ "input_key": input_key, "input_observable": input_observable, "input_hist": hist }) projection_name = self.projection_name(**projection_name_args) logger.debug(f"hist: {hist}") for axis in self.additional_axis_cuts: logger.debug(f"Apply additional axis hist range: {axis.name}") axis.apply_range_set(hist) if self.projection_dependent_cut_axes == []: self.projection_dependent_cut_axes.append([]) duplicated_axes = [ PDCA for PA in self.projection_axes for PDCA_group in self.projection_dependent_cut_axes for PDCA in PDCA_group if PDCA.axis_type == PA.axis_type ] if duplicated_axes: raise ValueError( f"Axis {duplicated_axes} is in the projection axes and the projection dependent cut axes." " This configuration is not allowed, as the range in the PDCA will be overwritten by the projection axes!" " Please revise your configuration." ) hists = [] for i, axes in enumerate(self.projection_dependent_cut_axes): for axis in axes: logger.debug(f"Apply projection dependent hist range: {axis.name}") axis.apply_range_set(hist) projected_hist = self.call_projection_function(hist) projected_hist.SetName(f"{projection_name}_{i}") hists.append(projected_hist) self.cleanup_cuts(hist, cut_axes = axes) self.cleanup_cuts(hist, cut_axes = self.additional_axis_cuts) output_hist = hists[0] for temp_hist in hists[1:]: output_hist.Add(temp_hist) output_hist.SetName(projection_name) output_hist.SetDirectory(0) return output_hist, projection_name, projection_name_args
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:getrruleset; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:addRDate; 7, False; 8, block; 8, 9; 8, 13; 8, 469; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifier:rruleset; 12, None; 13, for_statement; 13, 14; 13, 15; 13, 16; 14, identifier:name; 15, identifier:DATESANDRULES; 16, block; 16, 17; 16, 21; 17, expression_statement; 17, 18; 18, assignment; 18, 19; 18, 20; 19, identifier:addfunc; 20, None; 21, for_statement; 21, 22; 21, 23; 21, 32; 22, identifier:line; 23, call; 23, 24; 23, 29; 24, attribute; 24, 25; 24, 28; 25, attribute; 25, 26; 25, 27; 26, identifier:self; 27, identifier:contents; 28, identifier:get; 29, argument_list; 29, 30; 29, 31; 30, identifier:name; 31, tuple; 32, block; 32, 33; 32, 46; 32, 59; 33, if_statement; 33, 34; 33, 37; 34, comparison_operator:is; 34, 35; 34, 36; 35, identifier:rruleset; 36, None; 37, block; 37, 38; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 41; 40, identifier:rruleset; 41, call; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:rrule; 44, identifier:rruleset; 45, argument_list; 46, if_statement; 46, 47; 46, 50; 47, comparison_operator:is; 47, 48; 47, 49; 48, identifier:addfunc; 49, None; 50, block; 50, 51; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 54; 53, identifier:addfunc; 54, call; 54, 55; 54, 56; 55, identifier:getattr; 56, argument_list; 56, 57; 56, 58; 57, identifier:rruleset; 58, identifier:name; 59, if_statement; 59, 60; 59, 63; 59, 127; 60, comparison_operator:in; 60, 61; 60, 62; 61, identifier:name; 62, identifier:DATENAMES; 63, block; 63, 64; 64, if_statement; 64, 65; 64, 77; 64, 86; 64, 124; 65, comparison_operator:==; 65, 66; 65, 74; 66, call; 66, 67; 66, 68; 67, identifier:type; 68, argument_list; 68, 69; 69, subscript; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:line; 72, identifier:value; 73, integer:0; 74, attribute; 74, 75; 74, 76; 75, identifier:datetime; 76, identifier:datetime; 77, block; 77, 78; 78, expression_statement; 78, 79; 79, call; 79, 80; 79, 81; 80, identifier:map; 81, argument_list; 81, 82; 81, 83; 82, identifier:addfunc; 83, attribute; 83, 84; 83, 85; 84, identifier:line; 85, identifier:value; 86, elif_clause; 86, 87; 86, 99; 87, comparison_operator:==; 87, 88; 87, 96; 88, call; 88, 89; 88, 90; 89, identifier:type; 90, argument_list; 90, 91; 91, subscript; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:line; 94, identifier:value; 95, integer:0; 96, attribute; 96, 97; 96, 98; 97, identifier:datetime; 98, identifier:date; 99, block; 99, 100; 100, for_statement; 100, 101; 100, 102; 100, 105; 101, identifier:dt; 102, attribute; 102, 103; 102, 104; 103, identifier:line; 104, identifier:value; 105, block; 105, 106; 106, expression_statement; 106, 107; 107, call; 107, 108; 107, 109; 108, identifier:addfunc; 109, argument_list; 109, 110; 110, call; 110, 111; 110, 114; 111, attribute; 111, 112; 111, 113; 112, identifier:datetime; 113, identifier:datetime; 114, argument_list; 114, 115; 114, 118; 114, 121; 115, attribute; 115, 116; 115, 117; 116, identifier:dt; 117, identifier:year; 118, attribute; 118, 119; 118, 120; 119, identifier:dt; 120, identifier:month; 121, attribute; 121, 122; 121, 123; 122, identifier:dt; 123, identifier:day; 124, else_clause; 124, 125; 125, block; 125, 126; 126, pass_statement; 127, elif_clause; 127, 128; 127, 131; 128, comparison_operator:in; 128, 129; 128, 130; 129, identifier:name; 130, identifier:RULENAMES; 131, block; 131, 132; 131, 185; 131, 200; 131, 212; 131, 218; 131, 363; 131, 368; 132, try_statement; 132, 133; 132, 142; 133, block; 133, 134; 134, expression_statement; 134, 135; 135, assignment; 135, 136; 135, 137; 136, identifier:dtstart; 137, attribute; 137, 138; 137, 141; 138, attribute; 138, 139; 138, 140; 139, identifier:self; 140, identifier:dtstart; 141, identifier:value; 142, except_clause; 142, 143; 142, 146; 143, tuple; 143, 144; 143, 145; 144, identifier:AttributeError; 145, identifier:KeyError; 146, block; 146, 147; 147, try_statement; 147, 148; 147, 173; 148, block; 148, 149; 149, if_statement; 149, 150; 149, 155; 149, 164; 150, comparison_operator:==; 150, 151; 150, 154; 151, attribute; 151, 152; 151, 153; 152, identifier:self; 153, identifier:name; 154, string:"VTODO"; 155, block; 155, 156; 156, expression_statement; 156, 157; 157, assignment; 157, 158; 157, 159; 158, identifier:dtstart; 159, attribute; 159, 160; 159, 163; 160, attribute; 160, 161; 160, 162; 161, identifier:self; 162, identifier:due; 163, identifier:value; 164, else_clause; 164, 165; 165, block; 165, 166; 165, 171; 166, expression_statement; 166, 167; 167, call; 167, 168; 167, 169; 168, identifier:print; 169, argument_list; 169, 170; 170, string:'failed to get dtstart with VTODO'; 171, return_statement; 171, 172; 172, None; 173, except_clause; 173, 174; 173, 177; 174, tuple; 174, 175; 174, 176; 175, identifier:AttributeError; 176, identifier:KeyError; 177, block; 177, 178; 177, 183; 178, expression_statement; 178, 179; 179, call; 179, 180; 179, 181; 180, identifier:print; 181, argument_list; 181, 182; 182, string:'failed to find DUE at all.'; 183, return_statement; 183, 184; 184, None; 185, expression_statement; 185, 186; 186, assignment; 186, 187; 186, 188; 187, identifier:value; 188, call; 188, 189; 188, 197; 189, attribute; 189, 190; 189, 196; 190, call; 190, 191; 190, 192; 191, identifier:str_; 192, argument_list; 192, 193; 193, attribute; 193, 194; 193, 195; 194, identifier:line; 195, identifier:value; 196, identifier:replace; 197, argument_list; 197, 198; 197, 199; 198, string:'\\'; 199, string:''; 200, expression_statement; 200, 201; 201, assignment; 201, 202; 201, 203; 202, identifier:rule; 203, call; 203, 204; 203, 207; 204, attribute; 204, 205; 204, 206; 205, identifier:rrule; 206, identifier:rrulestr; 207, argument_list; 207, 208; 207, 209; 208, identifier:value; 209, keyword_argument; 209, 210; 209, 211; 210, identifier:dtstart; 211, identifier:dtstart; 212, expression_statement; 212, 213; 213, assignment; 213, 214; 213, 215; 214, identifier:until; 215, attribute; 215, 216; 215, 217; 216, identifier:rule; 217, identifier:_until; 218, if_statement; 218, 219; 218, 240; 219, boolean_operator:and; 219, 220; 219, 231; 219, 232; 220, boolean_operator:and; 220, 221; 220, 224; 221, comparison_operator:is; 221, 222; 221, 223; 222, identifier:until; 223, None; 224, call; 224, 225; 224, 226; 225, identifier:isinstance; 226, argument_list; 226, 227; 226, 228; 227, identifier:dtstart; 228, attribute; 228, 229; 228, 230; 229, identifier:datetime; 230, identifier:datetime; 231, line_continuation:\; 232, parenthesized_expression; 232, 233; 233, comparison_operator:!=; 233, 234; 233, 237; 234, attribute; 234, 235; 234, 236; 235, identifier:until; 236, identifier:tzinfo; 237, attribute; 237, 238; 237, 239; 238, identifier:dtstart; 239, identifier:tzinfo; 240, block; 240, 241; 240, 267; 240, 301; 240, 321; 240, 339; 240, 357; 241, expression_statement; 241, 242; 242, assignment; 242, 243; 242, 244; 243, identifier:vals; 244, call; 244, 245; 244, 246; 245, identifier:dict; 246, generator_expression; 246, 247; 246, 253; 247, call; 247, 248; 247, 251; 248, attribute; 248, 249; 248, 250; 249, identifier:pair; 250, identifier:split; 251, argument_list; 251, 252; 252, string:'='; 253, for_in_clause; 253, 254; 253, 255; 254, identifier:pair; 255, call; 255, 256; 255, 265; 256, attribute; 256, 257; 256, 264; 257, call; 257, 258; 257, 263; 258, attribute; 258, 259; 258, 262; 259, attribute; 259, 260; 259, 261; 260, identifier:line; 261, identifier:value; 262, identifier:upper; 263, argument_list; 264, identifier:split; 265, argument_list; 265, 266; 266, string:';'; 267, if_statement; 267, 268; 267, 280; 268, comparison_operator:==; 268, 269; 268, 279; 269, call; 269, 270; 269, 271; 270, identifier:len; 271, argument_list; 271, 272; 272, call; 272, 273; 272, 276; 273, attribute; 273, 274; 273, 275; 274, identifier:vals; 275, identifier:get; 276, argument_list; 276, 277; 276, 278; 277, string:'UNTIL'; 278, string:''; 279, integer:8; 280, block; 280, 281; 281, expression_statement; 281, 282; 282, assignment; 282, 283; 282, 284; 283, identifier:until; 284, call; 284, 285; 284, 290; 285, attribute; 285, 286; 285, 289; 286, attribute; 286, 287; 286, 288; 287, identifier:datetime; 288, identifier:datetime; 289, identifier:combine; 290, argument_list; 290, 291; 290, 296; 291, call; 291, 292; 291, 295; 292, attribute; 292, 293; 292, 294; 293, identifier:until; 294, identifier:date; 295, argument_list; 296, call; 296, 297; 296, 300; 297, attribute; 297, 298; 297, 299; 298, identifier:dtstart; 299, identifier:time; 300, argument_list; 301, if_statement; 301, 302; 301, 307; 302, comparison_operator:is; 302, 303; 302, 306; 303, attribute; 303, 304; 303, 305; 304, identifier:until; 305, identifier:tzinfo; 306, None; 307, block; 307, 308; 308, expression_statement; 308, 309; 309, assignment; 309, 310; 309, 311; 310, identifier:until; 311, call; 311, 312; 311, 315; 312, attribute; 312, 313; 312, 314; 313, identifier:until; 314, identifier:replace; 315, argument_list; 315, 316; 316, keyword_argument; 316, 317; 316, 318; 317, identifier:tzinfo; 318, attribute; 318, 319; 318, 320; 319, identifier:dtstart; 320, identifier:tzinfo; 321, if_statement; 321, 322; 321, 327; 322, comparison_operator:is; 322, 323; 322, 326; 323, attribute; 323, 324; 323, 325; 324, identifier:dtstart; 325, identifier:tzinfo; 326, None; 327, block; 327, 328; 328, expression_statement; 328, 329; 329, assignment; 329, 330; 329, 331; 330, identifier:until; 331, call; 331, 332; 331, 335; 332, attribute; 332, 333; 332, 334; 333, identifier:until; 334, identifier:astimezone; 335, argument_list; 335, 336; 336, attribute; 336, 337; 336, 338; 337, identifier:dtstart; 338, identifier:tzinfo; 339, if_statement; 339, 340; 339, 345; 340, comparison_operator:is; 340, 341; 340, 344; 341, attribute; 341, 342; 341, 343; 342, identifier:dtstart; 343, identifier:tzinfo; 344, None; 345, block; 345, 346; 346, expression_statement; 346, 347; 347, assignment; 347, 348; 347, 349; 348, identifier:until; 349, call; 349, 350; 349, 353; 350, attribute; 350, 351; 350, 352; 351, identifier:until; 352, identifier:replace; 353, argument_list; 353, 354; 354, keyword_argument; 354, 355; 354, 356; 355, identifier:tzinfo; 356, None; 357, expression_statement; 357, 358; 358, assignment; 358, 359; 358, 362; 359, attribute; 359, 360; 359, 361; 360, identifier:rule; 361, identifier:_until; 362, identifier:until; 363, expression_statement; 363, 364; 364, call; 364, 365; 364, 366; 365, identifier:addfunc; 366, argument_list; 366, 367; 367, identifier:rule; 368, if_statement; 368, 369; 368, 374; 369, boolean_operator:and; 369, 370; 369, 373; 370, comparison_operator:==; 370, 371; 370, 372; 371, identifier:name; 372, string:'rrule'; 373, identifier:addRDate; 374, block; 374, 375; 374, 444; 375, try_statement; 375, 376; 375, 437; 376, block; 376, 377; 376, 408; 377, if_statement; 377, 378; 377, 386; 377, 402; 378, not_operator; 378, 379; 379, call; 379, 380; 379, 381; 380, identifier:isinstance; 381, argument_list; 381, 382; 381, 383; 382, identifier:dtstart; 383, attribute; 383, 384; 383, 385; 384, identifier:datetime; 385, identifier:datetime; 386, block; 386, 387; 387, expression_statement; 387, 388; 388, assignment; 388, 389; 388, 390; 389, identifier:adddtstart; 390, call; 390, 391; 390, 396; 391, attribute; 391, 392; 391, 395; 392, attribute; 392, 393; 392, 394; 393, identifier:datetime; 394, identifier:datetime; 395, identifier:fromordinal; 396, argument_list; 396, 397; 397, call; 397, 398; 397, 401; 398, attribute; 398, 399; 398, 400; 399, identifier:dtstart; 400, identifier:toordinal; 401, argument_list; 402, else_clause; 402, 403; 403, block; 403, 404; 404, expression_statement; 404, 405; 405, assignment; 405, 406; 405, 407; 406, identifier:adddtstart; 407, identifier:dtstart; 408, if_statement; 408, 409; 408, 419; 408, 431; 409, comparison_operator:!=; 409, 410; 409, 418; 410, subscript; 410, 411; 410, 417; 411, subscript; 411, 412; 411, 415; 412, attribute; 412, 413; 412, 414; 413, identifier:rruleset; 414, identifier:_rrule; 415, unary_operator:-; 415, 416; 416, integer:1; 417, integer:0; 418, identifier:adddtstart; 419, block; 419, 420; 419, 427; 420, expression_statement; 420, 421; 421, call; 421, 422; 421, 425; 422, attribute; 422, 423; 422, 424; 423, identifier:rruleset; 424, identifier:rdate; 425, argument_list; 425, 426; 426, identifier:adddtstart; 427, expression_statement; 427, 428; 428, assignment; 428, 429; 428, 430; 429, identifier:added; 430, True; 431, else_clause; 431, 432; 432, block; 432, 433; 433, expression_statement; 433, 434; 434, assignment; 434, 435; 434, 436; 435, identifier:added; 436, False; 437, except_clause; 437, 438; 437, 439; 438, identifier:IndexError; 439, block; 439, 440; 440, expression_statement; 440, 441; 441, assignment; 441, 442; 441, 443; 442, identifier:added; 443, False; 444, if_statement; 444, 445; 444, 457; 445, boolean_operator:and; 445, 446; 445, 447; 446, identifier:added; 447, comparison_operator:is; 447, 448; 447, 456; 448, attribute; 448, 449; 448, 455; 449, subscript; 449, 450; 449, 453; 450, attribute; 450, 451; 450, 452; 451, identifier:rruleset; 452, identifier:_rrule; 453, unary_operator:-; 453, 454; 454, integer:1; 455, identifier:_count; 456, None; 457, block; 457, 458; 458, expression_statement; 458, 459; 459, augmented_assignment:-=; 459, 460; 459, 468; 460, attribute; 460, 461; 460, 467; 461, subscript; 461, 462; 461, 465; 462, attribute; 462, 463; 462, 464; 463, identifier:rruleset; 464, identifier:_rrule; 465, unary_operator:-; 465, 466; 466, integer:1; 467, identifier:_count; 468, integer:1; 469, return_statement; 469, 470; 470, identifier:rruleset
def getrruleset(self, addRDate=False): rruleset = None for name in DATESANDRULES: addfunc = None for line in self.contents.get(name, ()): if rruleset is None: rruleset = rrule.rruleset() if addfunc is None: addfunc = getattr(rruleset, name) if name in DATENAMES: if type(line.value[0]) == datetime.datetime: map(addfunc, line.value) elif type(line.value[0]) == datetime.date: for dt in line.value: addfunc(datetime.datetime(dt.year, dt.month, dt.day)) else: pass elif name in RULENAMES: try: dtstart = self.dtstart.value except (AttributeError, KeyError): try: if self.name == "VTODO": dtstart = self.due.value else: print('failed to get dtstart with VTODO') return None except (AttributeError, KeyError): print('failed to find DUE at all.') return None value = str_(line.value).replace('\\', '') rule = rrule.rrulestr(value, dtstart=dtstart) until = rule._until if until is not None and isinstance(dtstart, datetime.datetime) and \ (until.tzinfo != dtstart.tzinfo): vals = dict(pair.split('=') for pair in line.value.upper().split(';')) if len(vals.get('UNTIL', '')) == 8: until = datetime.datetime.combine(until.date(), dtstart.time()) if until.tzinfo is None: until = until.replace(tzinfo=dtstart.tzinfo) if dtstart.tzinfo is not None: until = until.astimezone(dtstart.tzinfo) if dtstart.tzinfo is None: until = until.replace(tzinfo=None) rule._until = until addfunc(rule) if name == 'rrule' and addRDate: try: if not isinstance(dtstart, datetime.datetime): adddtstart = datetime.datetime.fromordinal(dtstart.toordinal()) else: adddtstart = dtstart if rruleset._rrule[-1][0] != adddtstart: rruleset.rdate(adddtstart) added = True else: added = False except IndexError: added = False if added and rruleset._rrule[-1]._count is not None: rruleset._rrule[-1]._count -= 1 return rruleset
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:list_processed_parameter_group_histogram; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:group; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:start; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:stop; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:merge_time; 16, integer:20; 17, block; 17, 18; 17, 22; 17, 33; 17, 47; 17, 61; 17, 77; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:params; 21, dictionary; 22, if_statement; 22, 23; 22, 26; 23, comparison_operator:is; 23, 24; 23, 25; 24, identifier:group; 25, None; 26, block; 26, 27; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 32; 29, subscript; 29, 30; 29, 31; 30, identifier:params; 31, string:'group'; 32, identifier:group; 33, if_statement; 33, 34; 33, 37; 34, comparison_operator:is; 34, 35; 34, 36; 35, identifier:start; 36, None; 37, block; 37, 38; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 43; 40, subscript; 40, 41; 40, 42; 41, identifier:params; 42, string:'start'; 43, call; 43, 44; 43, 45; 44, identifier:to_isostring; 45, argument_list; 45, 46; 46, identifier:start; 47, if_statement; 47, 48; 47, 51; 48, comparison_operator:is; 48, 49; 48, 50; 49, identifier:stop; 50, None; 51, block; 51, 52; 52, expression_statement; 52, 53; 53, assignment; 53, 54; 53, 57; 54, subscript; 54, 55; 54, 56; 55, identifier:params; 56, string:'stop'; 57, call; 57, 58; 57, 59; 58, identifier:to_isostring; 59, argument_list; 59, 60; 60, identifier:stop; 61, if_statement; 61, 62; 61, 65; 62, comparison_operator:is; 62, 63; 62, 64; 63, identifier:merge_time; 64, None; 65, block; 65, 66; 66, expression_statement; 66, 67; 67, assignment; 67, 68; 67, 71; 68, subscript; 68, 69; 68, 70; 69, identifier:params; 70, string:'mergeTime'; 71, call; 71, 72; 71, 73; 72, identifier:int; 73, argument_list; 73, 74; 74, binary_operator:*; 74, 75; 74, 76; 75, identifier:merge_time; 76, integer:1000; 77, return_statement; 77, 78; 78, call; 78, 79; 78, 82; 79, attribute; 79, 80; 79, 81; 80, identifier:pagination; 81, identifier:Iterator; 82, argument_list; 82, 83; 82, 88; 82, 98; 82, 101; 82, 106; 82, 109; 83, keyword_argument; 83, 84; 83, 85; 84, identifier:client; 85, attribute; 85, 86; 85, 87; 86, identifier:self; 87, identifier:_client; 88, keyword_argument; 88, 89; 88, 90; 89, identifier:path; 90, call; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, string:'/archive/{}/parameter-index'; 93, identifier:format; 94, argument_list; 94, 95; 95, attribute; 95, 96; 95, 97; 96, identifier:self; 97, identifier:_instance; 98, keyword_argument; 98, 99; 98, 100; 99, identifier:params; 100, identifier:params; 101, keyword_argument; 101, 102; 101, 103; 102, identifier:response_class; 103, attribute; 103, 104; 103, 105; 104, identifier:archive_pb2; 105, identifier:IndexResponse; 106, keyword_argument; 106, 107; 106, 108; 107, identifier:items_key; 108, string:'group'; 109, keyword_argument; 109, 110; 109, 111; 110, identifier:item_mapper; 111, identifier:IndexGroup
def list_processed_parameter_group_histogram(self, group=None, start=None, stop=None, merge_time=20): params = {} if group is not None: params['group'] = group if start is not None: params['start'] = to_isostring(start) if stop is not None: params['stop'] = to_isostring(stop) if merge_time is not None: params['mergeTime'] = int(merge_time * 1000) return pagination.Iterator( client=self._client, path='/archive/{}/parameter-index'.format(self._instance), params=params, response_class=archive_pb2.IndexResponse, items_key='group', item_mapper=IndexGroup, )
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:list_completeness_index; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:start; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:stop; 10, None; 11, block; 11, 12; 11, 16; 11, 30; 11, 44; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 14, identifier:params; 15, dictionary; 16, if_statement; 16, 17; 16, 20; 17, comparison_operator:is; 17, 18; 17, 19; 18, identifier:start; 19, None; 20, block; 20, 21; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 26; 23, subscript; 23, 24; 23, 25; 24, identifier:params; 25, string:'start'; 26, call; 26, 27; 26, 28; 27, identifier:to_isostring; 28, argument_list; 28, 29; 29, identifier:start; 30, if_statement; 30, 31; 30, 34; 31, comparison_operator:is; 31, 32; 31, 33; 32, identifier:stop; 33, None; 34, block; 34, 35; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 40; 37, subscript; 37, 38; 37, 39; 38, identifier:params; 39, string:'stop'; 40, call; 40, 41; 40, 42; 41, identifier:to_isostring; 42, argument_list; 42, 43; 43, identifier:stop; 44, return_statement; 44, 45; 45, call; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:pagination; 48, identifier:Iterator; 49, argument_list; 49, 50; 49, 55; 49, 65; 49, 68; 49, 73; 49, 76; 50, keyword_argument; 50, 51; 50, 52; 51, identifier:client; 52, attribute; 52, 53; 52, 54; 53, identifier:self; 54, identifier:_client; 55, keyword_argument; 55, 56; 55, 57; 56, identifier:path; 57, call; 57, 58; 57, 61; 58, attribute; 58, 59; 58, 60; 59, string:'/archive/{}/completeness-index'; 60, identifier:format; 61, argument_list; 61, 62; 62, attribute; 62, 63; 62, 64; 63, identifier:self; 64, identifier:_instance; 65, keyword_argument; 65, 66; 65, 67; 66, identifier:params; 67, identifier:params; 68, keyword_argument; 68, 69; 68, 70; 69, identifier:response_class; 70, attribute; 70, 71; 70, 72; 71, identifier:archive_pb2; 72, identifier:IndexResponse; 73, keyword_argument; 73, 74; 73, 75; 74, identifier:items_key; 75, string:'group'; 76, keyword_argument; 76, 77; 76, 78; 77, identifier:item_mapper; 78, identifier:IndexGroup
def list_completeness_index(self, start=None, stop=None): params = {} if start is not None: params['start'] = to_isostring(start) if stop is not None: params['stop'] = to_isostring(stop) return pagination.Iterator( client=self._client, path='/archive/{}/completeness-index'.format(self._instance), params=params, response_class=archive_pb2.IndexResponse, items_key='group', item_mapper=IndexGroup, )
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:list_packets; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:name; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:start; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:stop; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:page_size; 16, integer:500; 17, default_parameter; 17, 18; 17, 19; 18, identifier:descending; 19, False; 20, block; 20, 21; 20, 31; 20, 42; 20, 53; 20, 67; 20, 81; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 24; 23, identifier:params; 24, dictionary; 24, 25; 25, pair; 25, 26; 25, 27; 26, string:'order'; 27, conditional_expression:if; 27, 28; 27, 29; 27, 30; 28, string:'desc'; 29, identifier:descending; 30, string:'asc'; 31, if_statement; 31, 32; 31, 35; 32, comparison_operator:is; 32, 33; 32, 34; 33, identifier:name; 34, None; 35, block; 35, 36; 36, expression_statement; 36, 37; 37, assignment; 37, 38; 37, 41; 38, subscript; 38, 39; 38, 40; 39, identifier:params; 40, string:'name'; 41, identifier:name; 42, if_statement; 42, 43; 42, 46; 43, comparison_operator:is; 43, 44; 43, 45; 44, identifier:page_size; 45, None; 46, block; 46, 47; 47, expression_statement; 47, 48; 48, assignment; 48, 49; 48, 52; 49, subscript; 49, 50; 49, 51; 50, identifier:params; 51, string:'limit'; 52, identifier:page_size; 53, if_statement; 53, 54; 53, 57; 54, comparison_operator:is; 54, 55; 54, 56; 55, identifier:start; 56, None; 57, block; 57, 58; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 63; 60, subscript; 60, 61; 60, 62; 61, identifier:params; 62, string:'start'; 63, call; 63, 64; 63, 65; 64, identifier:to_isostring; 65, argument_list; 65, 66; 66, identifier:start; 67, if_statement; 67, 68; 67, 71; 68, comparison_operator:is; 68, 69; 68, 70; 69, identifier:stop; 70, None; 71, block; 71, 72; 72, expression_statement; 72, 73; 73, assignment; 73, 74; 73, 77; 74, subscript; 74, 75; 74, 76; 75, identifier:params; 76, string:'stop'; 77, call; 77, 78; 77, 79; 78, identifier:to_isostring; 79, argument_list; 79, 80; 80, identifier:stop; 81, return_statement; 81, 82; 82, call; 82, 83; 82, 86; 83, attribute; 83, 84; 83, 85; 84, identifier:pagination; 85, identifier:Iterator; 86, argument_list; 86, 87; 86, 92; 86, 102; 86, 105; 86, 110; 86, 113; 87, keyword_argument; 87, 88; 87, 89; 88, identifier:client; 89, attribute; 89, 90; 89, 91; 90, identifier:self; 91, identifier:_client; 92, keyword_argument; 92, 93; 92, 94; 93, identifier:path; 94, call; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, string:'/archive/{}/packets'; 97, identifier:format; 98, argument_list; 98, 99; 99, attribute; 99, 100; 99, 101; 100, identifier:self; 101, identifier:_instance; 102, keyword_argument; 102, 103; 102, 104; 103, identifier:params; 104, identifier:params; 105, keyword_argument; 105, 106; 105, 107; 106, identifier:response_class; 107, attribute; 107, 108; 107, 109; 108, identifier:rest_pb2; 109, identifier:ListPacketsResponse; 110, keyword_argument; 110, 111; 110, 112; 111, identifier:items_key; 112, string:'packet'; 113, keyword_argument; 113, 114; 113, 115; 114, identifier:item_mapper; 115, identifier:Packet
def list_packets(self, name=None, start=None, stop=None, page_size=500, descending=False): params = { 'order': 'desc' if descending else 'asc', } if name is not None: params['name'] = name if page_size is not None: params['limit'] = page_size if start is not None: params['start'] = to_isostring(start) if stop is not None: params['stop'] = to_isostring(stop) return pagination.Iterator( client=self._client, path='/archive/{}/packets'.format(self._instance), params=params, response_class=rest_pb2.ListPacketsResponse, items_key='packet', item_mapper=Packet, )
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 26; 2, function_name:list_events; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:source; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:severity; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:text_filter; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:start; 16, None; 17, default_parameter; 17, 18; 17, 19; 18, identifier:stop; 19, None; 20, default_parameter; 20, 21; 20, 22; 21, identifier:page_size; 22, integer:500; 23, default_parameter; 23, 24; 23, 25; 24, identifier:descending; 25, False; 26, block; 26, 27; 26, 37; 26, 48; 26, 59; 26, 70; 26, 84; 26, 98; 26, 109; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:params; 30, dictionary; 30, 31; 31, pair; 31, 32; 31, 33; 32, string:'order'; 33, conditional_expression:if; 33, 34; 33, 35; 33, 36; 34, string:'desc'; 35, identifier:descending; 36, string:'asc'; 37, if_statement; 37, 38; 37, 41; 38, comparison_operator:is; 38, 39; 38, 40; 39, identifier:source; 40, None; 41, block; 41, 42; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 47; 44, subscript; 44, 45; 44, 46; 45, identifier:params; 46, string:'source'; 47, identifier:source; 48, if_statement; 48, 49; 48, 52; 49, comparison_operator:is; 49, 50; 49, 51; 50, identifier:page_size; 51, None; 52, block; 52, 53; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 58; 55, subscript; 55, 56; 55, 57; 56, identifier:params; 57, string:'limit'; 58, identifier:page_size; 59, if_statement; 59, 60; 59, 63; 60, comparison_operator:is; 60, 61; 60, 62; 61, identifier:severity; 62, None; 63, block; 63, 64; 64, expression_statement; 64, 65; 65, assignment; 65, 66; 65, 69; 66, subscript; 66, 67; 66, 68; 67, identifier:params; 68, string:'severity'; 69, identifier:severity; 70, if_statement; 70, 71; 70, 74; 71, comparison_operator:is; 71, 72; 71, 73; 72, identifier:start; 73, None; 74, block; 74, 75; 75, expression_statement; 75, 76; 76, assignment; 76, 77; 76, 80; 77, subscript; 77, 78; 77, 79; 78, identifier:params; 79, string:'start'; 80, call; 80, 81; 80, 82; 81, identifier:to_isostring; 82, argument_list; 82, 83; 83, identifier:start; 84, if_statement; 84, 85; 84, 88; 85, comparison_operator:is; 85, 86; 85, 87; 86, identifier:stop; 87, None; 88, block; 88, 89; 89, expression_statement; 89, 90; 90, assignment; 90, 91; 90, 94; 91, subscript; 91, 92; 91, 93; 92, identifier:params; 93, string:'stop'; 94, call; 94, 95; 94, 96; 95, identifier:to_isostring; 96, argument_list; 96, 97; 97, identifier:stop; 98, if_statement; 98, 99; 98, 102; 99, comparison_operator:is; 99, 100; 99, 101; 100, identifier:text_filter; 101, None; 102, block; 102, 103; 103, expression_statement; 103, 104; 104, assignment; 104, 105; 104, 108; 105, subscript; 105, 106; 105, 107; 106, identifier:params; 107, string:'q'; 108, identifier:text_filter; 109, return_statement; 109, 110; 110, call; 110, 111; 110, 114; 111, attribute; 111, 112; 111, 113; 112, identifier:pagination; 113, identifier:Iterator; 114, argument_list; 114, 115; 114, 120; 114, 130; 114, 133; 114, 138; 114, 141; 115, keyword_argument; 115, 116; 115, 117; 116, identifier:client; 117, attribute; 117, 118; 117, 119; 118, identifier:self; 119, identifier:_client; 120, keyword_argument; 120, 121; 120, 122; 121, identifier:path; 122, call; 122, 123; 122, 126; 123, attribute; 123, 124; 123, 125; 124, string:'/archive/{}/events'; 125, identifier:format; 126, argument_list; 126, 127; 127, attribute; 127, 128; 127, 129; 128, identifier:self; 129, identifier:_instance; 130, keyword_argument; 130, 131; 130, 132; 131, identifier:params; 132, identifier:params; 133, keyword_argument; 133, 134; 133, 135; 134, identifier:response_class; 135, attribute; 135, 136; 135, 137; 136, identifier:rest_pb2; 137, identifier:ListEventsResponse; 138, keyword_argument; 138, 139; 138, 140; 139, identifier:items_key; 140, string:'event'; 141, keyword_argument; 141, 142; 141, 143; 142, identifier:item_mapper; 143, identifier:Event
def list_events(self, source=None, severity=None, text_filter=None, start=None, stop=None, page_size=500, descending=False): params = { 'order': 'desc' if descending else 'asc', } if source is not None: params['source'] = source if page_size is not None: params['limit'] = page_size if severity is not None: params['severity'] = severity if start is not None: params['start'] = to_isostring(start) if stop is not None: params['stop'] = to_isostring(stop) if text_filter is not None: params['q'] = text_filter return pagination.Iterator( client=self._client, path='/archive/{}/events'.format(self._instance), params=params, response_class=rest_pb2.ListEventsResponse, items_key='event', item_mapper=Event, )
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:list_parameter_ranges; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:self; 5, identifier:parameter; 6, default_parameter; 6, 7; 6, 8; 7, identifier:start; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:stop; 11, None; 12, default_parameter; 12, 13; 12, 14; 13, identifier:min_gap; 14, None; 15, default_parameter; 15, 16; 15, 17; 16, identifier:max_gap; 17, None; 18, default_parameter; 18, 19; 18, 20; 19, identifier:parameter_cache; 20, string:'realtime'; 21, block; 21, 22; 21, 34; 21, 38; 21, 52; 21, 66; 21, 82; 21, 98; 21, 115; 21, 131; 21, 139; 21, 148; 21, 156; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 25; 24, identifier:path; 25, call; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, string:'/archive/{}/parameters{}/ranges'; 28, identifier:format; 29, argument_list; 29, 30; 29, 33; 30, attribute; 30, 31; 30, 32; 31, identifier:self; 32, identifier:_instance; 33, identifier:parameter; 34, expression_statement; 34, 35; 35, assignment; 35, 36; 35, 37; 36, identifier:params; 37, dictionary; 38, if_statement; 38, 39; 38, 42; 39, comparison_operator:is; 39, 40; 39, 41; 40, identifier:start; 41, None; 42, block; 42, 43; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 48; 45, subscript; 45, 46; 45, 47; 46, identifier:params; 47, string:'start'; 48, call; 48, 49; 48, 50; 49, identifier:to_isostring; 50, argument_list; 50, 51; 51, identifier:start; 52, if_statement; 52, 53; 52, 56; 53, comparison_operator:is; 53, 54; 53, 55; 54, identifier:stop; 55, None; 56, block; 56, 57; 57, expression_statement; 57, 58; 58, assignment; 58, 59; 58, 62; 59, subscript; 59, 60; 59, 61; 60, identifier:params; 61, string:'stop'; 62, call; 62, 63; 62, 64; 63, identifier:to_isostring; 64, argument_list; 64, 65; 65, identifier:stop; 66, if_statement; 66, 67; 66, 70; 67, comparison_operator:is; 67, 68; 67, 69; 68, identifier:min_gap; 69, None; 70, block; 70, 71; 71, expression_statement; 71, 72; 72, assignment; 72, 73; 72, 76; 73, subscript; 73, 74; 73, 75; 74, identifier:params; 75, string:'minGap'; 76, call; 76, 77; 76, 78; 77, identifier:int; 78, argument_list; 78, 79; 79, binary_operator:*; 79, 80; 79, 81; 80, identifier:min_gap; 81, integer:1000; 82, if_statement; 82, 83; 82, 86; 83, comparison_operator:is; 83, 84; 83, 85; 84, identifier:max_gap; 85, None; 86, block; 86, 87; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 92; 89, subscript; 89, 90; 89, 91; 90, identifier:params; 91, string:'maxGap'; 92, call; 92, 93; 92, 94; 93, identifier:int; 94, argument_list; 94, 95; 95, binary_operator:*; 95, 96; 95, 97; 96, identifier:max_gap; 97, integer:1000; 98, if_statement; 98, 99; 98, 100; 98, 107; 99, identifier:parameter_cache; 100, block; 100, 101; 101, expression_statement; 101, 102; 102, assignment; 102, 103; 102, 106; 103, subscript; 103, 104; 103, 105; 104, identifier:params; 105, string:'processor'; 106, identifier:parameter_cache; 107, else_clause; 107, 108; 108, block; 108, 109; 109, expression_statement; 109, 110; 110, assignment; 110, 111; 110, 114; 111, subscript; 111, 112; 111, 113; 112, identifier:params; 113, string:'norealtime'; 114, True; 115, expression_statement; 115, 116; 116, assignment; 116, 117; 116, 118; 117, identifier:response; 118, call; 118, 119; 118, 124; 119, attribute; 119, 120; 119, 123; 120, attribute; 120, 121; 120, 122; 121, identifier:self; 122, identifier:_client; 123, identifier:get_proto; 124, argument_list; 124, 125; 124, 128; 125, keyword_argument; 125, 126; 125, 127; 126, identifier:path; 127, identifier:path; 128, keyword_argument; 128, 129; 128, 130; 129, identifier:params; 130, identifier:params; 131, expression_statement; 131, 132; 132, assignment; 132, 133; 132, 134; 133, identifier:message; 134, call; 134, 135; 134, 138; 135, attribute; 135, 136; 135, 137; 136, identifier:pvalue_pb2; 137, identifier:Ranges; 138, argument_list; 139, expression_statement; 139, 140; 140, call; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, identifier:message; 143, identifier:ParseFromString; 144, argument_list; 144, 145; 145, attribute; 145, 146; 145, 147; 146, identifier:response; 147, identifier:content; 148, expression_statement; 148, 149; 149, assignment; 149, 150; 149, 151; 150, identifier:ranges; 151, call; 151, 152; 151, 153; 152, identifier:getattr; 153, argument_list; 153, 154; 153, 155; 154, identifier:message; 155, string:'range'; 156, return_statement; 156, 157; 157, list_comprehension; 157, 158; 157, 162; 158, call; 158, 159; 158, 160; 159, identifier:ParameterRange; 160, argument_list; 160, 161; 161, identifier:r; 162, for_in_clause; 162, 163; 162, 164; 163, identifier:r; 164, identifier:ranges
def list_parameter_ranges(self, parameter, start=None, stop=None, min_gap=None, max_gap=None, parameter_cache='realtime'): path = '/archive/{}/parameters{}/ranges'.format( self._instance, parameter) params = {} if start is not None: params['start'] = to_isostring(start) if stop is not None: params['stop'] = to_isostring(stop) if min_gap is not None: params['minGap'] = int(min_gap * 1000) if max_gap is not None: params['maxGap'] = int(max_gap * 1000) if parameter_cache: params['processor'] = parameter_cache else: params['norealtime'] = True response = self._client.get_proto(path=path, params=params) message = pvalue_pb2.Ranges() message.ParseFromString(response.content) ranges = getattr(message, 'range') return [ParameterRange(r) for r in ranges]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 18; 2, function_name:copy_file; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:source; 5, identifier:destination; 6, default_parameter; 6, 7; 6, 8; 7, identifier:unique; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:sort; 11, False; 12, default_parameter; 12, 13; 12, 14; 13, identifier:case_sensitive; 14, True; 15, default_parameter; 15, 16; 15, 17; 16, identifier:create_path; 17, False; 18, block; 18, 19; 19, expression_statement; 19, 20; 20, call; 20, 21; 20, 24; 21, attribute; 21, 22; 21, 23; 22, identifier:_File; 23, identifier:copy; 24, argument_list; 24, 25; 24, 26; 24, 27; 24, 28; 24, 29; 24, 30; 25, identifier:source; 26, identifier:destination; 27, identifier:unique; 28, identifier:sort; 29, identifier:case_sensitive; 30, identifier:create_path
def copy_file(source, destination, unique=False, sort=False, case_sensitive=True, create_path=False): _File.copy(source, destination, unique, sort, case_sensitive, create_path)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:tree; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 4, identifier:node; 5, default_parameter; 5, 6; 5, 7; 6, identifier:formatter; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:prefix; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:postfix; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:_depth; 16, integer:1; 17, block; 17, 18; 17, 22; 17, 33; 17, 37; 17, 41; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:current; 21, integer:0; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 25; 24, identifier:length; 25, call; 25, 26; 25, 27; 26, identifier:len; 27, argument_list; 27, 28; 28, call; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, identifier:node; 31, identifier:keys; 32, argument_list; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 36; 35, identifier:tee_joint; 36, string:'\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80'; 37, expression_statement; 37, 38; 38, assignment; 38, 39; 38, 40; 39, identifier:elbow_joint; 40, string:'\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80'; 41, for_statement; 41, 42; 41, 45; 41, 50; 42, pattern_list; 42, 43; 42, 44; 43, identifier:key; 44, identifier:value; 45, call; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:node; 48, identifier:iteritems; 49, argument_list; 50, block; 50, 51; 50, 55; 50, 65; 50, 75; 50, 85; 50, 94; 50, 113; 51, expression_statement; 51, 52; 52, augmented_assignment:+=; 52, 53; 52, 54; 53, identifier:current; 54, integer:1; 55, expression_statement; 55, 56; 56, assignment; 56, 57; 56, 58; 57, identifier:k; 58, conditional_expression:if; 58, 59; 58, 63; 58, 64; 59, call; 59, 60; 59, 61; 60, identifier:formatter; 61, argument_list; 61, 62; 62, identifier:key; 63, identifier:formatter; 64, identifier:key; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:pre; 68, conditional_expression:if; 68, 69; 68, 73; 68, 74; 69, call; 69, 70; 69, 71; 70, identifier:prefix; 71, argument_list; 71, 72; 72, identifier:key; 73, identifier:prefix; 74, string:''; 75, expression_statement; 75, 76; 76, assignment; 76, 77; 76, 78; 77, identifier:post; 78, conditional_expression:if; 78, 79; 78, 83; 78, 84; 79, call; 79, 80; 79, 81; 80, identifier:postfix; 81, argument_list; 81, 82; 82, identifier:key; 83, identifier:postfix; 84, string:''; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 88; 87, identifier:space; 88, conditional_expression:if; 88, 89; 88, 90; 88, 93; 89, identifier:elbow_joint; 90, comparison_operator:==; 90, 91; 90, 92; 91, identifier:current; 92, identifier:length; 93, identifier:tee_joint; 94, expression_statement; 94, 95; 95, yield; 95, 96; 96, call; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, string:' {space} {prefix}{key}{postfix}'; 99, identifier:format; 100, argument_list; 100, 101; 100, 104; 100, 107; 100, 110; 101, keyword_argument; 101, 102; 101, 103; 102, identifier:space; 103, identifier:space; 104, keyword_argument; 104, 105; 104, 106; 105, identifier:key; 106, identifier:k; 107, keyword_argument; 107, 108; 107, 109; 108, identifier:prefix; 109, identifier:pre; 110, keyword_argument; 110, 111; 110, 112; 111, identifier:postfix; 112, identifier:post; 113, if_statement; 113, 114; 113, 115; 114, identifier:value; 115, block; 115, 116; 116, for_statement; 116, 117; 116, 118; 116, 136; 117, identifier:e; 118, call; 118, 119; 118, 120; 119, identifier:tree; 120, argument_list; 120, 121; 120, 122; 120, 125; 120, 128; 120, 131; 121, identifier:value; 122, keyword_argument; 122, 123; 122, 124; 123, identifier:formatter; 124, identifier:formatter; 125, keyword_argument; 125, 126; 125, 127; 126, identifier:prefix; 127, identifier:prefix; 128, keyword_argument; 128, 129; 128, 130; 129, identifier:postfix; 130, identifier:postfix; 131, keyword_argument; 131, 132; 131, 133; 132, identifier:_depth; 133, binary_operator:+; 133, 134; 133, 135; 134, identifier:_depth; 135, integer:1; 136, block; 136, 137; 137, expression_statement; 137, 138; 138, yield; 138, 139; 139, binary_operator:+; 139, 140; 139, 147; 140, parenthesized_expression; 140, 141; 141, conditional_expression:if; 141, 142; 141, 143; 141, 146; 142, string:' | '; 143, comparison_operator:!=; 143, 144; 143, 145; 144, identifier:current; 145, identifier:length; 146, string:' '; 147, identifier:e
def tree(node, formatter=None, prefix=None, postfix=None, _depth=1): current = 0 length = len(node.keys()) tee_joint = '\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80' elbow_joint = '\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80' for key, value in node.iteritems(): current += 1 k = formatter(key) if formatter else key pre = prefix(key) if prefix else '' post = postfix(key) if postfix else '' space = elbow_joint if current == length else tee_joint yield ' {space} {prefix}{key}{postfix}'.format(space=space, key=k, prefix=pre, postfix=post) if value: for e in tree(value, formatter=formatter, prefix=prefix, postfix=postfix, _depth=_depth + 1): yield (' | ' if current != length else ' ') + e
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:run; 3, parameters; 4, block; 4, 5; 4, 11; 4, 20; 4, 26; 4, 35; 4, 44; 4, 81; 4, 87; 4, 99; 4, 136; 4, 148; 4, 163; 4, 175; 4, 177; 4, 195; 4, 206; 4, 220; 4, 224; 4, 240; 4, 290; 4, 314; 4, 346; 4, 350; 4, 384; 4, 388; 4, 404; 4, 429; 5, expression_statement; 5, 6; 6, assignment; 6, 7; 6, 8; 7, identifier:args; 8, call; 8, 9; 8, 10; 9, identifier:parse_args; 10, argument_list; 11, expression_statement; 11, 12; 12, call; 12, 13; 12, 16; 13, attribute; 13, 14; 13, 15; 14, identifier:codetools; 15, identifier:setup_logging; 16, argument_list; 16, 17; 17, attribute; 17, 18; 17, 19; 18, identifier:args; 19, identifier:debug; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:git_tag; 23, attribute; 23, 24; 23, 25; 24, identifier:args; 25, identifier:tag; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:git_email; 29, call; 29, 30; 29, 33; 30, attribute; 30, 31; 30, 32; 31, identifier:codetools; 32, identifier:lookup_email; 33, argument_list; 33, 34; 34, identifier:args; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 38; 37, identifier:git_user; 38, call; 38, 39; 38, 42; 39, attribute; 39, 40; 39, 41; 40, identifier:codetools; 41, identifier:lookup_user; 42, argument_list; 42, 43; 43, identifier:args; 44, if_statement; 44, 45; 44, 49; 45, not_operator; 45, 46; 46, attribute; 46, 47; 46, 48; 47, identifier:args; 48, identifier:manifest_only; 49, block; 49, 50; 49, 56; 49, 69; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 53; 52, identifier:eups_tag; 53, attribute; 53, 54; 53, 55; 54, identifier:args; 55, identifier:eups_tag; 56, if_statement; 56, 57; 56, 59; 57, not_operator; 57, 58; 58, identifier:eups_tag; 59, block; 59, 60; 60, expression_statement; 60, 61; 61, assignment; 61, 62; 61, 63; 62, identifier:eups_tag; 63, call; 63, 64; 63, 67; 64, attribute; 64, 65; 64, 66; 65, identifier:eups; 66, identifier:git_tag2eups_tag; 67, argument_list; 67, 68; 68, identifier:git_tag; 69, expression_statement; 69, 70; 70, call; 70, 71; 70, 72; 71, identifier:debug; 72, argument_list; 72, 73; 73, call; 73, 74; 73, 77; 74, attribute; 74, 75; 74, 76; 75, string:"using eups tag: {eups_tag}"; 76, identifier:format; 77, argument_list; 77, 78; 78, keyword_argument; 78, 79; 78, 80; 79, identifier:eups_tag; 80, identifier:eups_tag; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 84; 83, identifier:manifest; 84, attribute; 84, 85; 84, 86; 85, identifier:args; 86, identifier:manifest; 87, expression_statement; 87, 88; 88, call; 88, 89; 88, 90; 89, identifier:debug; 90, argument_list; 90, 91; 91, call; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, string:"using manifest: {manifest}"; 94, identifier:format; 95, argument_list; 95, 96; 96, keyword_argument; 96, 97; 96, 98; 97, identifier:manifest; 98, identifier:manifest; 99, if_statement; 99, 100; 99, 104; 99, 121; 100, not_operator; 100, 101; 101, attribute; 101, 102; 101, 103; 102, identifier:args; 103, identifier:manifest_only; 104, block; 104, 105; 105, expression_statement; 105, 106; 106, assignment; 106, 107; 106, 108; 107, identifier:message_template; 108, call; 108, 109; 108, 114; 109, attribute; 109, 110; 109, 113; 110, concatenated_string; 110, 111; 110, 112; 111, string:"Version {{git_tag}}"; 112, string:" release from {eups_tag}/{manifest}"; 113, identifier:format; 114, argument_list; 114, 115; 114, 118; 115, keyword_argument; 115, 116; 115, 117; 116, identifier:eups_tag; 117, identifier:eups_tag; 118, keyword_argument; 118, 119; 118, 120; 119, identifier:manifest; 120, identifier:manifest; 121, else_clause; 121, 122; 122, block; 122, 123; 123, expression_statement; 123, 124; 124, assignment; 124, 125; 124, 126; 125, identifier:message_template; 126, call; 126, 127; 126, 132; 127, attribute; 127, 128; 127, 131; 128, concatenated_string; 128, 129; 128, 130; 129, string:"Version {{git_tag}}"; 130, string:" release from manifest {manifest}"; 131, identifier:format; 132, argument_list; 132, 133; 133, keyword_argument; 133, 134; 133, 135; 134, identifier:manifest; 135, identifier:manifest; 136, expression_statement; 136, 137; 137, call; 137, 138; 137, 139; 138, identifier:debug; 139, argument_list; 139, 140; 140, call; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, string:"using tag message: {msg}"; 143, identifier:format; 144, argument_list; 144, 145; 145, keyword_argument; 145, 146; 145, 147; 146, identifier:msg; 147, identifier:message_template; 148, expression_statement; 148, 149; 149, assignment; 149, 150; 149, 151; 150, identifier:tagger; 151, call; 151, 152; 151, 155; 152, attribute; 152, 153; 152, 154; 153, identifier:github; 154, identifier:InputGitAuthor; 155, argument_list; 155, 156; 155, 157; 155, 158; 156, identifier:git_user; 157, identifier:git_email; 158, call; 158, 159; 158, 162; 159, attribute; 159, 160; 159, 161; 160, identifier:codetools; 161, identifier:current_timestamp; 162, argument_list; 163, expression_statement; 163, 164; 164, call; 164, 165; 164, 166; 165, identifier:debug; 166, argument_list; 166, 167; 167, call; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, string:"using taggger: {tagger}"; 170, identifier:format; 171, argument_list; 171, 172; 172, keyword_argument; 172, 173; 172, 174; 173, identifier:tagger; 174, identifier:tagger; 175, global_statement; 175, 176; 176, identifier:g; 177, expression_statement; 177, 178; 178, assignment; 178, 179; 178, 180; 179, identifier:g; 180, call; 180, 181; 180, 184; 181, attribute; 181, 182; 181, 183; 182, identifier:pygithub; 183, identifier:login_github; 184, argument_list; 184, 185; 184, 190; 185, keyword_argument; 185, 186; 185, 187; 186, identifier:token_path; 187, attribute; 187, 188; 187, 189; 188, identifier:args; 189, identifier:token_path; 190, keyword_argument; 190, 191; 190, 192; 191, identifier:token; 192, attribute; 192, 193; 192, 194; 193, identifier:args; 194, identifier:token; 195, expression_statement; 195, 196; 196, assignment; 196, 197; 196, 198; 197, identifier:org; 198, call; 198, 199; 198, 202; 199, attribute; 199, 200; 199, 201; 200, identifier:g; 201, identifier:get_organization; 202, argument_list; 202, 203; 203, attribute; 203, 204; 203, 205; 204, identifier:args; 205, identifier:org; 206, expression_statement; 206, 207; 207, call; 207, 208; 207, 209; 208, identifier:info; 209, argument_list; 209, 210; 210, call; 210, 211; 210, 214; 211, attribute; 211, 212; 211, 213; 212, string:"tagging repos in org: {org}"; 213, identifier:format; 214, argument_list; 214, 215; 215, keyword_argument; 215, 216; 215, 217; 216, identifier:org; 217, attribute; 217, 218; 217, 219; 218, identifier:org; 219, identifier:login; 220, expression_statement; 220, 221; 221, assignment; 221, 222; 221, 223; 222, identifier:problems; 223, list:[]; 224, expression_statement; 224, 225; 225, assignment; 225, 226; 225, 227; 226, identifier:manifest_products; 227, attribute; 227, 228; 227, 239; 228, call; 228, 229; 228, 232; 229, attribute; 229, 230; 229, 231; 230, identifier:versiondb; 231, identifier:Manifest; 232, argument_list; 232, 233; 232, 234; 233, identifier:manifest; 234, keyword_argument; 234, 235; 234, 236; 235, identifier:base_url; 236, attribute; 236, 237; 236, 238; 237, identifier:args; 238, identifier:versiondb_base_url; 239, identifier:products; 240, if_statement; 240, 241; 240, 245; 240, 284; 241, not_operator; 241, 242; 242, attribute; 242, 243; 242, 244; 243, identifier:args; 244, identifier:manifest_only; 245, block; 245, 246; 245, 262; 245, 280; 246, expression_statement; 246, 247; 247, assignment; 247, 248; 247, 249; 248, identifier:eups_products; 249, attribute; 249, 250; 249, 261; 250, call; 250, 251; 250, 254; 251, attribute; 251, 252; 251, 253; 252, identifier:eups; 253, identifier:EupsTag; 254, argument_list; 254, 255; 254, 256; 255, identifier:eups_tag; 256, keyword_argument; 256, 257; 256, 258; 257, identifier:base_url; 258, attribute; 258, 259; 258, 260; 259, identifier:args; 260, identifier:eupstag_base_url; 261, identifier:products; 262, expression_statement; 262, 263; 263, assignment; 263, 264; 263, 267; 264, pattern_list; 264, 265; 264, 266; 265, identifier:products; 266, identifier:err; 267, call; 267, 268; 267, 269; 268, identifier:cross_reference_products; 269, argument_list; 269, 270; 269, 271; 269, 272; 269, 277; 270, identifier:eups_products; 271, identifier:manifest_products; 272, keyword_argument; 272, 273; 272, 274; 273, identifier:ignore_manifest_versions; 274, attribute; 274, 275; 274, 276; 275, identifier:args; 276, identifier:ignore_manifest_versions; 277, keyword_argument; 277, 278; 277, 279; 278, identifier:fail_fast; 279, False; 280, expression_statement; 280, 281; 281, augmented_assignment:+=; 281, 282; 281, 283; 282, identifier:problems; 283, identifier:err; 284, else_clause; 284, 285; 285, block; 285, 286; 286, expression_statement; 286, 287; 287, assignment; 287, 288; 287, 289; 288, identifier:products; 289, identifier:manifest_products; 290, if_statement; 290, 291; 290, 294; 291, attribute; 291, 292; 291, 293; 292, identifier:args; 293, identifier:limit; 294, block; 294, 295; 295, expression_statement; 295, 296; 296, assignment; 296, 297; 296, 298; 297, identifier:products; 298, call; 298, 299; 298, 300; 299, identifier:dict; 300, argument_list; 300, 301; 301, call; 301, 302; 301, 305; 302, attribute; 302, 303; 302, 304; 303, identifier:itertools; 304, identifier:islice; 305, argument_list; 305, 306; 305, 311; 306, call; 306, 307; 306, 310; 307, attribute; 307, 308; 307, 309; 308, identifier:products; 309, identifier:items; 310, argument_list; 311, attribute; 311, 312; 311, 313; 312, identifier:args; 313, identifier:limit; 314, expression_statement; 314, 315; 315, assignment; 315, 316; 315, 319; 316, pattern_list; 316, 317; 316, 318; 317, identifier:products; 318, identifier:err; 319, call; 319, 320; 319, 321; 320, identifier:get_repo_for_products; 321, argument_list; 321, 322; 321, 325; 321, 328; 321, 333; 321, 338; 321, 343; 322, keyword_argument; 322, 323; 322, 324; 323, identifier:org; 324, identifier:org; 325, keyword_argument; 325, 326; 325, 327; 326, identifier:products; 327, identifier:products; 328, keyword_argument; 328, 329; 328, 330; 329, identifier:allow_teams; 330, attribute; 330, 331; 330, 332; 331, identifier:args; 332, identifier:allow_team; 333, keyword_argument; 333, 334; 333, 335; 334, identifier:ext_teams; 335, attribute; 335, 336; 335, 337; 336, identifier:args; 337, identifier:external_team; 338, keyword_argument; 338, 339; 338, 340; 339, identifier:deny_teams; 340, attribute; 340, 341; 340, 342; 341, identifier:args; 342, identifier:deny_team; 343, keyword_argument; 343, 344; 343, 345; 344, identifier:fail_fast; 345, False; 346, expression_statement; 346, 347; 347, augmented_assignment:+=; 347, 348; 347, 349; 348, identifier:problems; 349, identifier:err; 350, expression_statement; 350, 351; 351, assignment; 351, 352; 351, 355; 352, pattern_list; 352, 353; 352, 354; 353, identifier:products_to_tag; 354, identifier:err; 355, call; 355, 356; 355, 357; 356, identifier:check_product_tags; 357, argument_list; 357, 358; 357, 359; 357, 360; 357, 363; 357, 366; 357, 371; 357, 374; 357, 379; 358, identifier:products; 359, identifier:git_tag; 360, keyword_argument; 360, 361; 360, 362; 361, identifier:tag_message_template; 362, identifier:message_template; 363, keyword_argument; 363, 364; 363, 365; 364, identifier:tagger; 365, identifier:tagger; 366, keyword_argument; 366, 367; 366, 368; 367, identifier:force_tag; 368, attribute; 368, 369; 368, 370; 369, identifier:args; 370, identifier:force_tag; 371, keyword_argument; 371, 372; 371, 373; 372, identifier:fail_fast; 373, False; 374, keyword_argument; 374, 375; 374, 376; 375, identifier:ignore_git_message; 376, attribute; 376, 377; 376, 378; 377, identifier:args; 378, identifier:ignore_git_message; 379, keyword_argument; 379, 380; 379, 381; 380, identifier:ignore_git_tagger; 381, attribute; 381, 382; 381, 383; 382, identifier:args; 383, identifier:ignore_git_tagger; 384, expression_statement; 384, 385; 385, augmented_assignment:+=; 385, 386; 385, 387; 386, identifier:problems; 387, identifier:err; 388, if_statement; 388, 389; 388, 392; 389, attribute; 389, 390; 389, 391; 390, identifier:args; 391, identifier:verify; 392, block; 392, 393; 392, 400; 393, expression_statement; 393, 394; 394, assignment; 394, 395; 394, 396; 395, identifier:err; 396, call; 396, 397; 396, 398; 397, identifier:identify_products_missing_tags; 398, argument_list; 398, 399; 399, identifier:products_to_tag; 400, expression_statement; 400, 401; 401, augmented_assignment:+=; 401, 402; 401, 403; 402, identifier:problems; 403, identifier:err; 404, if_statement; 404, 405; 404, 406; 405, identifier:problems; 406, block; 406, 407; 406, 421; 407, expression_statement; 407, 408; 408, assignment; 408, 409; 408, 410; 409, identifier:msg; 410, call; 410, 411; 410, 414; 411, attribute; 411, 412; 411, 413; 412, string:"{n} pre-flight error(s)"; 413, identifier:format; 414, argument_list; 414, 415; 415, keyword_argument; 415, 416; 415, 417; 416, identifier:n; 417, call; 417, 418; 417, 419; 418, identifier:len; 419, argument_list; 419, 420; 420, identifier:problems; 421, raise_statement; 421, 422; 422, call; 422, 423; 422, 426; 423, attribute; 423, 424; 423, 425; 424, identifier:codetools; 425, identifier:DogpileError; 426, argument_list; 426, 427; 426, 428; 427, identifier:problems; 428, identifier:msg; 429, expression_statement; 429, 430; 430, call; 430, 431; 430, 432; 431, identifier:tag_products; 432, argument_list; 432, 433; 432, 434; 432, 439; 433, identifier:products_to_tag; 434, keyword_argument; 434, 435; 434, 436; 435, identifier:fail_fast; 436, attribute; 436, 437; 436, 438; 437, identifier:args; 438, identifier:fail_fast; 439, keyword_argument; 439, 440; 439, 441; 440, identifier:dry_run; 441, attribute; 441, 442; 441, 443; 442, identifier:args; 443, identifier:dry_run
def run(): args = parse_args() codetools.setup_logging(args.debug) git_tag = args.tag git_email = codetools.lookup_email(args) git_user = codetools.lookup_user(args) if not args.manifest_only: eups_tag = args.eups_tag if not eups_tag: eups_tag = eups.git_tag2eups_tag(git_tag) debug("using eups tag: {eups_tag}".format(eups_tag=eups_tag)) manifest = args.manifest debug("using manifest: {manifest}".format(manifest=manifest)) if not args.manifest_only: message_template = "Version {{git_tag}}"\ " release from {eups_tag}/{manifest}".format( eups_tag=eups_tag, manifest=manifest, ) else: message_template = "Version {{git_tag}}"\ " release from manifest {manifest}".format( manifest=manifest, ) debug("using tag message: {msg}".format(msg=message_template)) tagger = github.InputGitAuthor( git_user, git_email, codetools.current_timestamp(), ) debug("using taggger: {tagger}".format(tagger=tagger)) global g g = pygithub.login_github(token_path=args.token_path, token=args.token) org = g.get_organization(args.org) info("tagging repos in org: {org}".format(org=org.login)) problems = [] manifest_products = versiondb.Manifest( manifest, base_url=args.versiondb_base_url).products if not args.manifest_only: eups_products = eups.EupsTag( eups_tag, base_url=args.eupstag_base_url).products products, err = cross_reference_products( eups_products, manifest_products, ignore_manifest_versions=args.ignore_manifest_versions, fail_fast=False, ) problems += err else: products = manifest_products if args.limit: products = dict(itertools.islice(products.items(), args.limit)) products, err = get_repo_for_products( org=org, products=products, allow_teams=args.allow_team, ext_teams=args.external_team, deny_teams=args.deny_team, fail_fast=False, ) problems += err products_to_tag, err = check_product_tags( products, git_tag, tag_message_template=message_template, tagger=tagger, force_tag=args.force_tag, fail_fast=False, ignore_git_message=args.ignore_git_message, ignore_git_tagger=args.ignore_git_tagger, ) problems += err if args.verify: err = identify_products_missing_tags(products_to_tag) problems += err if problems: msg = "{n} pre-flight error(s)".format(n=len(problems)) raise codetools.DogpileError(problems, msg) tag_products( products_to_tag, fail_fast=args.fail_fast, dry_run=args.dry_run, )
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:filter_seq; 3, parameters; 3, 4; 4, identifier:seq; 5, block; 5, 6; 5, 8; 5, 15; 5, 26; 5, 38; 5, 44; 5, 55; 5, 66; 5, 77; 5, 88; 5, 117; 5, 131; 5, 144; 6, expression_statement; 6, 7; 7, string:'''Examines unreserved sequences to see if they are prone to mutation. This currently ignores solely-power-of-2 guides with b > 3'''; 8, if_statement; 8, 9; 8, 12; 9, attribute; 9, 10; 9, 11; 10, identifier:seq; 11, identifier:res; 12, block; 12, 13; 13, return_statement; 13, 14; 14, None; 15, expression_statement; 15, 16; 16, assignment; 16, 17; 16, 18; 17, identifier:n; 18, call; 18, 19; 18, 22; 19, attribute; 19, 20; 19, 21; 20, identifier:nt; 21, identifier:Factors; 22, argument_list; 22, 23; 23, attribute; 23, 24; 23, 25; 24, identifier:seq; 25, identifier:factors; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 32; 28, pattern_list; 28, 29; 28, 30; 28, 31; 29, identifier:guide; 30, identifier:s; 31, identifier:t; 32, call; 32, 33; 32, 36; 33, attribute; 33, 34; 33, 35; 34, identifier:aq; 35, identifier:canonical_form; 36, argument_list; 36, 37; 37, identifier:n; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 43; 40, attribute; 40, 41; 40, 42; 41, identifier:seq; 42, identifier:guide; 43, identifier:guide; 44, expression_statement; 44, 45; 45, assignment; 45, 46; 45, 47; 46, identifier:cls; 47, call; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, identifier:aq; 50, identifier:get_class; 51, argument_list; 51, 52; 52, keyword_argument; 52, 53; 52, 54; 53, identifier:guide; 54, identifier:guide; 55, expression_statement; 55, 56; 56, assignment; 56, 57; 56, 58; 57, identifier:num_larges; 58, call; 58, 59; 58, 64; 59, attribute; 59, 60; 59, 63; 60, attribute; 60, 61; 60, 62; 61, identifier:seq; 62, identifier:factors; 63, identifier:count; 64, argument_list; 64, 65; 65, string:'P'; 66, expression_statement; 66, 67; 67, assignment; 67, 68; 67, 69; 68, identifier:upper_bound_tau; 69, binary_operator:-; 69, 70; 69, 73; 70, binary_operator:-; 70, 71; 70, 72; 71, identifier:cls; 72, identifier:num_larges; 73, call; 73, 74; 73, 75; 74, identifier:len; 75, argument_list; 75, 76; 76, identifier:t; 77, if_statement; 77, 78; 77, 85; 78, boolean_operator:or; 78, 79; 78, 82; 79, comparison_operator:<; 79, 80; 79, 81; 80, identifier:cls; 81, integer:2; 82, comparison_operator:<; 82, 83; 82, 84; 83, identifier:upper_bound_tau; 84, integer:2; 85, block; 85, 86; 86, return_statement; 86, 87; 87, None; 88, expression_statement; 88, 89; 89, assignment; 89, 90; 89, 91; 90, identifier:v; 91, call; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:nt; 94, identifier:Factors; 95, argument_list; 95, 96; 96, dictionary_comprehension; 96, 97; 96, 100; 96, 109; 97, pair; 97, 98; 97, 99; 98, identifier:p; 99, identifier:a; 100, for_in_clause; 100, 101; 100, 104; 101, pattern_list; 101, 102; 101, 103; 102, identifier:p; 103, identifier:a; 104, call; 104, 105; 104, 108; 105, attribute; 105, 106; 105, 107; 106, identifier:guide; 107, identifier:items; 108, argument_list; 109, if_clause; 109, 110; 110, boolean_operator:and; 110, 111; 110, 114; 111, comparison_operator:!=; 111, 112; 111, 113; 112, identifier:p; 113, integer:2; 114, comparison_operator:>; 114, 115; 114, 116; 115, identifier:a; 116, integer:0; 117, if_statement; 117, 118; 117, 128; 118, boolean_operator:and; 118, 119; 118, 125; 119, comparison_operator:==; 119, 120; 119, 124; 120, call; 120, 121; 120, 122; 121, identifier:int; 122, argument_list; 122, 123; 123, identifier:v; 124, integer:1; 125, comparison_operator:>; 125, 126; 125, 127; 126, identifier:cls; 127, integer:3; 128, block; 128, 129; 129, return_statement; 129, 130; 130, None; 131, if_statement; 131, 132; 131, 141; 132, not_operator; 132, 133; 133, call; 133, 134; 133, 137; 134, attribute; 134, 135; 134, 136; 135, identifier:aq; 136, identifier:is_driver; 137, argument_list; 137, 138; 138, keyword_argument; 138, 139; 138, 140; 139, identifier:guide; 140, identifier:guide; 141, block; 141, 142; 142, return_statement; 142, 143; 143, None; 144, return_statement; 144, 145; 145, expression_list; 145, 146; 145, 147; 146, identifier:n; 147, identifier:guide
def filter_seq(seq): '''Examines unreserved sequences to see if they are prone to mutation. This currently ignores solely-power-of-2 guides with b > 3''' if seq.res: return None n = nt.Factors(seq.factors) guide, s, t = aq.canonical_form(n) seq.guide = guide cls = aq.get_class(guide=guide) num_larges = seq.factors.count('P') upper_bound_tau = cls - num_larges - len(t) if cls < 2 or upper_bound_tau < 2: return None v = nt.Factors({p: a for p, a in guide.items() if p != 2 and a > 0}) if int(v) == 1 and cls > 3: return None if not aq.is_driver(guide=guide): return None return n, guide
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:add_data; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:filenames; 6, block; 6, 7; 6, 56; 6, 119; 6, 170; 6, 211; 6, 352; 7, function_definition; 7, 8; 7, 9; 7, 11; 8, function_name:_parse_table; 9, parameters; 9, 10; 10, identifier:table; 11, block; 11, 12; 11, 24; 11, 47; 12, function_definition; 12, 13; 12, 14; 12, 16; 13, function_name:_parse_line; 14, parameters; 14, 15; 15, identifier:line; 16, block; 16, 17; 17, return_statement; 17, 18; 18, call; 18, 19; 18, 22; 19, attribute; 19, 20; 19, 21; 20, identifier:line; 21, identifier:split; 22, argument_list; 22, 23; 23, string:'\t'; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 27; 26, identifier:lines; 27, generator_expression; 27, 28; 27, 32; 27, 39; 28, call; 28, 29; 28, 30; 29, identifier:_parse_line; 30, argument_list; 30, 31; 31, identifier:one; 32, for_in_clause; 32, 33; 32, 34; 33, identifier:one; 34, call; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:table; 37, identifier:splitlines; 38, argument_list; 39, if_clause; 39, 40; 40, call; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:re; 43, identifier:match; 44, argument_list; 44, 45; 44, 46; 45, string:r'^\d'; 46, identifier:one; 47, return_statement; 47, 48; 48, generator_expression; 48, 49; 48, 53; 49, call; 49, 50; 49, 51; 50, identifier:remove_false; 51, argument_list; 51, 52; 52, identifier:one; 53, for_in_clause; 53, 54; 53, 55; 54, identifier:one; 55, identifier:lines; 56, function_definition; 56, 57; 56, 58; 56, 60; 57, function_name:_parse_decl; 58, parameters; 58, 59; 59, identifier:decl; 60, block; 60, 61; 60, 68; 60, 74; 60, 95; 60, 101; 60, 114; 61, expression_statement; 61, 62; 62, assignment; 62, 63; 62, 64; 63, identifier:index; 64, call; 64, 65; 64, 66; 65, identifier:len; 66, argument_list; 66, 67; 67, string:'SYSCALL_DEFINE'; 68, expression_statement; 68, 69; 69, assignment; 69, 70; 69, 71; 70, identifier:argc; 71, subscript; 71, 72; 71, 73; 72, identifier:decl; 73, identifier:index; 74, expression_statement; 74, 75; 75, assignment; 75, 76; 75, 77; 76, identifier:rest; 77, call; 77, 78; 77, 93; 78, attribute; 78, 79; 78, 92; 79, subscript; 79, 80; 79, 87; 80, subscript; 80, 81; 80, 82; 81, identifier:decl; 82, slice; 82, 83; 82, 86; 83, binary_operator:+; 83, 84; 83, 85; 84, identifier:index; 85, integer:1; 86, colon; 87, slice; 87, 88; 87, 89; 87, 90; 88, integer:1; 89, colon; 90, unary_operator:-; 90, 91; 91, integer:1; 92, identifier:split; 93, argument_list; 93, 94; 94, string:','; 95, expression_statement; 95, 96; 96, assignment; 96, 97; 96, 98; 97, identifier:name; 98, subscript; 98, 99; 98, 100; 99, identifier:rest; 100, integer:0; 101, expression_statement; 101, 102; 102, assignment; 102, 103; 102, 104; 103, identifier:args; 104, call; 104, 105; 104, 108; 105, attribute; 105, 106; 105, 107; 106, string:','; 107, identifier:join; 108, argument_list; 108, 109; 109, subscript; 109, 110; 109, 111; 110, identifier:rest; 111, slice; 111, 112; 111, 113; 112, integer:1; 113, colon; 114, return_statement; 114, 115; 115, expression_list; 115, 116; 115, 117; 115, 118; 116, identifier:name; 117, identifier:argc; 118, identifier:args; 119, function_definition; 119, 120; 119, 121; 119, 123; 120, function_name:_parse_line; 121, parameters; 121, 122; 122, identifier:line; 123, block; 123, 124; 123, 133; 123, 145; 123, 153; 123, 163; 124, expression_statement; 124, 125; 125, assignment; 125, 126; 125, 127; 126, identifier:index; 127, call; 127, 128; 127, 131; 128, attribute; 128, 129; 128, 130; 129, identifier:line; 130, identifier:find; 131, argument_list; 131, 132; 132, string:':'; 133, if_statement; 133, 134; 133, 138; 134, comparison_operator:==; 134, 135; 134, 136; 135, identifier:index; 136, unary_operator:-; 136, 137; 137, integer:1; 138, block; 138, 139; 139, raise_statement; 139, 140; 140, call; 140, 141; 140, 142; 141, identifier:RuntimeError; 142, argument_list; 142, 143; 142, 144; 143, string:'This is unexpected: %s'; 144, identifier:line; 145, expression_statement; 145, 146; 146, assignment; 146, 147; 146, 148; 147, identifier:filename; 148, subscript; 148, 149; 148, 150; 149, identifier:line; 150, slice; 150, 151; 150, 152; 151, colon; 152, identifier:index; 153, expression_statement; 153, 154; 154, assignment; 154, 155; 154, 156; 155, identifier:decl; 156, subscript; 156, 157; 156, 158; 157, identifier:line; 158, slice; 158, 159; 158, 162; 159, binary_operator:+; 159, 160; 159, 161; 160, identifier:index; 161, integer:1; 162, colon; 163, return_statement; 163, 164; 164, expression_list; 164, 165; 164, 166; 165, identifier:filename; 166, call; 166, 167; 166, 168; 167, identifier:_parse_decl; 168, argument_list; 168, 169; 169, identifier:decl; 170, function_definition; 170, 171; 170, 172; 170, 174; 171, function_name:_split_into_lines; 172, parameters; 172, 173; 173, identifier:grep_output; 174, block; 174, 175; 174, 185; 174, 201; 175, expression_statement; 175, 176; 176, assignment; 176, 177; 176, 178; 177, identifier:lines; 178, call; 178, 179; 178, 182; 179, attribute; 179, 180; 179, 181; 180, identifier:grep_output; 181, identifier:replace; 182, argument_list; 182, 183; 182, 184; 183, string:'\n\n'; 184, string:'\n'; 185, expression_statement; 185, 186; 186, assignment; 186, 187; 186, 188; 187, identifier:lines; 188, call; 188, 189; 188, 198; 189, attribute; 189, 190; 189, 197; 190, call; 190, 191; 190, 194; 191, attribute; 191, 192; 191, 193; 192, identifier:lines; 193, identifier:replace; 194, argument_list; 194, 195; 194, 196; 195, string:'\n\t'; 196, string:''; 197, identifier:replace; 198, argument_list; 198, 199; 198, 200; 199, string:'\t'; 200, string:' '; 201, return_statement; 201, 202; 202, call; 202, 203; 202, 210; 203, attribute; 203, 204; 203, 209; 204, call; 204, 205; 204, 208; 205, attribute; 205, 206; 205, 207; 206, identifier:lines; 207, identifier:strip; 208, argument_list; 209, identifier:splitlines; 210, argument_list; 211, for_statement; 211, 212; 211, 213; 211, 214; 212, identifier:one; 213, identifier:filenames; 214, block; 214, 215; 215, if_statement; 215, 216; 215, 224; 215, 300; 216, call; 216, 217; 216, 222; 217, attribute; 217, 218; 217, 221; 218, attribute; 218, 219; 218, 220; 219, identifier:one; 220, identifier:name; 221, identifier:endswith; 222, argument_list; 222, 223; 223, string:'.tbl'; 224, block; 224, 225; 225, for_statement; 225, 226; 225, 227; 225, 235; 226, identifier:item; 227, call; 227, 228; 227, 229; 228, identifier:_parse_table; 229, argument_list; 229, 230; 230, call; 230, 231; 230, 234; 231, attribute; 231, 232; 231, 233; 232, identifier:one; 233, identifier:read; 234, argument_list; 235, block; 235, 236; 235, 243; 235, 264; 236, expression_statement; 236, 237; 237, assignment; 237, 238; 237, 239; 238, identifier:args; 239, call; 239, 240; 239, 241; 240, identifier:list; 241, argument_list; 241, 242; 242, identifier:item; 243, if_statement; 243, 244; 243, 250; 244, comparison_operator:!=; 244, 245; 244, 249; 245, call; 245, 246; 245, 247; 246, identifier:len; 247, argument_list; 247, 248; 248, identifier:args; 249, integer:5; 250, block; 250, 251; 251, expression_statement; 251, 252; 252, augmented_assignment:+=; 252, 253; 252, 254; 253, identifier:args; 254, binary_operator:*; 254, 255; 254, 257; 255, list:['']; 255, 256; 256, string:''; 257, parenthesized_expression; 257, 258; 258, binary_operator:-; 258, 259; 258, 260; 259, integer:5; 260, call; 260, 261; 260, 262; 261, identifier:len; 262, argument_list; 262, 263; 263, identifier:args; 264, expression_statement; 264, 265; 265, call; 265, 266; 265, 271; 266, attribute; 266, 267; 266, 270; 267, attribute; 267, 268; 267, 269; 268, identifier:self; 269, identifier:session; 270, identifier:add; 271, argument_list; 271, 272; 272, call; 272, 273; 272, 274; 273, identifier:Item; 274, argument_list; 274, 275; 274, 280; 274, 285; 274, 290; 274, 295; 275, keyword_argument; 275, 276; 275, 277; 276, identifier:name; 277, subscript; 277, 278; 277, 279; 278, identifier:args; 279, integer:2; 280, keyword_argument; 280, 281; 280, 282; 281, identifier:abi; 282, subscript; 282, 283; 282, 284; 283, identifier:args; 284, integer:1; 285, keyword_argument; 285, 286; 285, 287; 286, identifier:number; 287, subscript; 287, 288; 287, 289; 288, identifier:args; 289, integer:0; 290, keyword_argument; 290, 291; 290, 292; 291, identifier:entry; 292, subscript; 292, 293; 292, 294; 293, identifier:args; 294, integer:3; 295, keyword_argument; 295, 296; 295, 297; 296, identifier:compat; 297, subscript; 297, 298; 297, 299; 298, identifier:args; 299, integer:4; 300, else_clause; 300, 301; 301, block; 301, 302; 302, for_statement; 302, 303; 302, 304; 302, 312; 303, identifier:line; 304, call; 304, 305; 304, 306; 305, identifier:_split_into_lines; 306, argument_list; 306, 307; 307, call; 307, 308; 307, 311; 308, attribute; 308, 309; 308, 310; 309, identifier:one; 310, identifier:read; 311, argument_list; 312, block; 312, 313; 312, 323; 313, expression_statement; 313, 314; 314, assignment; 314, 315; 314, 318; 315, pattern_list; 315, 316; 315, 317; 316, identifier:filename; 317, identifier:rest; 318, parenthesized_expression; 318, 319; 319, call; 319, 320; 319, 321; 320, identifier:_parse_line; 321, argument_list; 321, 322; 322, identifier:line; 323, expression_statement; 323, 324; 324, call; 324, 325; 324, 330; 325, attribute; 325, 326; 325, 329; 326, attribute; 326, 327; 326, 328; 327, identifier:self; 328, identifier:session; 329, identifier:add; 330, argument_list; 330, 331; 331, call; 331, 332; 331, 333; 332, identifier:Decl; 333, argument_list; 333, 334; 333, 339; 333, 342; 333, 347; 334, keyword_argument; 334, 335; 334, 336; 335, identifier:name; 336, subscript; 336, 337; 336, 338; 337, identifier:rest; 338, integer:0; 339, keyword_argument; 339, 340; 339, 341; 340, identifier:filename; 341, identifier:filename; 342, keyword_argument; 342, 343; 342, 344; 343, identifier:argc; 344, subscript; 344, 345; 344, 346; 345, identifier:rest; 346, integer:1; 347, keyword_argument; 347, 348; 347, 349; 348, identifier:args; 349, subscript; 349, 350; 349, 351; 350, identifier:rest; 351, integer:2; 352, expression_statement; 352, 353; 353, call; 353, 354; 353, 359; 354, attribute; 354, 355; 354, 358; 355, attribute; 355, 356; 355, 357; 356, identifier:self; 357, identifier:session; 358, identifier:commit; 359, argument_list
def add_data(self, filenames): def _parse_table(table): def _parse_line(line): return line.split('\t') lines = (_parse_line(one) for one in table.splitlines() if re.match(r'^\d', one)) return (remove_false(one) for one in lines) def _parse_decl(decl): index = len('SYSCALL_DEFINE') argc = decl[index] rest = decl[index + 1:][1:-1].split(',') name = rest[0] args = ','.join(rest[1:]) return name, argc, args def _parse_line(line): index = line.find(':') if index == -1: raise RuntimeError('This is unexpected: %s', line) filename = line[:index] decl = line[index + 1:] return filename, _parse_decl(decl) def _split_into_lines(grep_output): lines = grep_output.replace('\n\n', '\n') lines = lines.replace('\n\t', '').replace('\t', ' ') return lines.strip().splitlines() for one in filenames: if one.name.endswith('.tbl'): for item in _parse_table(one.read()): args = list(item) if len(args) != 5: args += [''] * (5 - len(args)) self.session.add( Item(name=args[2], abi=args[1], number=args[0], entry=args[3], compat=args[4])) else: for line in _split_into_lines(one.read()): filename, rest = (_parse_line(line)) self.session.add( Decl(name=rest[0], filename=filename, argc=rest[1], args=rest[2])) self.session.commit()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:check_tags; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:repos; 5, identifier:tags; 6, default_parameter; 6, 7; 6, 8; 7, identifier:ignore_existing; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, identifier:fail_fast; 11, False; 12, block; 12, 13; 12, 28; 12, 44; 12, 59; 12, 77; 12, 81; 12, 85; 12, 89; 12, 201; 12, 232; 13, expression_statement; 13, 14; 14, call; 14, 15; 14, 16; 15, identifier:debug; 16, argument_list; 16, 17; 17, call; 17, 18; 17, 21; 18, attribute; 18, 19; 18, 20; 19, string:"looking for {n} tag(s):"; 20, identifier:format; 21, argument_list; 21, 22; 22, keyword_argument; 22, 23; 22, 24; 23, identifier:n; 24, call; 24, 25; 24, 26; 25, identifier:len; 26, argument_list; 26, 27; 27, identifier:tags; 28, expression_statement; 28, 29; 29, list_comprehension; 29, 30; 29, 41; 30, call; 30, 31; 30, 32; 31, identifier:debug; 32, argument_list; 32, 33; 33, call; 33, 34; 33, 37; 34, attribute; 34, 35; 34, 36; 35, string:" {t}"; 36, identifier:format; 37, argument_list; 37, 38; 38, keyword_argument; 38, 39; 38, 40; 39, identifier:t; 40, identifier:t; 41, for_in_clause; 41, 42; 41, 43; 42, identifier:t; 43, identifier:tags; 44, expression_statement; 44, 45; 45, call; 45, 46; 45, 47; 46, identifier:debug; 47, argument_list; 47, 48; 48, call; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, string:"in {n} repo(s):"; 51, identifier:format; 52, argument_list; 52, 53; 53, keyword_argument; 53, 54; 53, 55; 54, identifier:n; 55, call; 55, 56; 55, 57; 56, identifier:len; 57, argument_list; 57, 58; 58, identifier:repos; 59, expression_statement; 59, 60; 60, list_comprehension; 60, 61; 60, 74; 61, call; 61, 62; 61, 63; 62, identifier:debug; 63, argument_list; 63, 64; 64, call; 64, 65; 64, 68; 65, attribute; 65, 66; 65, 67; 66, string:" {r}"; 67, identifier:format; 68, argument_list; 68, 69; 69, keyword_argument; 69, 70; 69, 71; 70, identifier:r; 71, attribute; 71, 72; 71, 73; 72, identifier:r; 73, identifier:full_name; 74, for_in_clause; 74, 75; 74, 76; 75, identifier:r; 76, identifier:repos; 77, expression_statement; 77, 78; 78, assignment; 78, 79; 78, 80; 79, identifier:present_tags; 80, dictionary; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 84; 83, identifier:absent_tags; 84, dictionary; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 88; 87, identifier:problems; 88, list:[]; 89, for_statement; 89, 90; 89, 91; 89, 92; 90, identifier:r; 91, identifier:repos; 92, block; 92, 93; 92, 101; 92, 172; 92, 184; 93, expression_statement; 93, 94; 94, assignment; 94, 95; 94, 96; 95, identifier:has_tags; 96, call; 96, 97; 96, 98; 97, identifier:find_tags_in_repo; 98, argument_list; 98, 99; 98, 100; 99, identifier:r; 100, identifier:tags; 101, if_statement; 101, 102; 101, 103; 102, identifier:has_tags; 103, block; 103, 104; 103, 151; 104, if_statement; 104, 105; 104, 107; 105, not_operator; 105, 106; 106, identifier:ignore_existing; 107, block; 107, 108; 107, 134; 107, 139; 107, 146; 108, expression_statement; 108, 109; 109, assignment; 109, 110; 109, 111; 110, identifier:yikes; 111, call; 111, 112; 111, 113; 112, identifier:GitTagExistsError; 113, argument_list; 113, 114; 114, call; 114, 115; 114, 118; 115, attribute; 115, 116; 115, 117; 116, string:"tag(s) {tag} already exists in repos {r}"; 117, identifier:format; 118, argument_list; 118, 119; 118, 129; 119, keyword_argument; 119, 120; 119, 121; 120, identifier:tag; 121, call; 121, 122; 121, 123; 122, identifier:list; 123, argument_list; 123, 124; 124, call; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:has_tags; 127, identifier:keys; 128, argument_list; 129, keyword_argument; 129, 130; 129, 131; 130, identifier:r; 131, attribute; 131, 132; 131, 133; 132, identifier:r; 133, identifier:full_name; 134, if_statement; 134, 135; 134, 136; 135, identifier:fail_fast; 136, block; 136, 137; 137, raise_statement; 137, 138; 138, identifier:yikes; 139, expression_statement; 139, 140; 140, call; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, identifier:problems; 143, identifier:append; 144, argument_list; 144, 145; 145, identifier:yikes; 146, expression_statement; 146, 147; 147, call; 147, 148; 147, 149; 148, identifier:error; 149, argument_list; 149, 150; 150, identifier:yikes; 151, expression_statement; 151, 152; 152, assignment; 152, 153; 152, 158; 153, subscript; 153, 154; 153, 155; 154, identifier:present_tags; 155, attribute; 155, 156; 155, 157; 156, identifier:r; 157, identifier:full_name; 158, dictionary; 158, 159; 158, 162; 159, pair; 159, 160; 159, 161; 160, string:'repo'; 161, identifier:r; 162, pair; 162, 163; 162, 164; 163, string:'tags'; 164, call; 164, 165; 164, 166; 165, identifier:list; 166, argument_list; 166, 167; 167, call; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, identifier:has_tags; 170, identifier:values; 171, argument_list; 172, expression_statement; 172, 173; 173, assignment; 173, 174; 173, 175; 174, identifier:missing_tags; 175, list_comprehension; 175, 176; 175, 177; 175, 180; 176, identifier:x; 177, for_in_clause; 177, 178; 177, 179; 178, identifier:x; 179, identifier:tags; 180, if_clause; 180, 181; 181, comparison_operator:not; 181, 182; 181, 183; 182, identifier:x; 183, identifier:has_tags; 184, if_statement; 184, 185; 184, 186; 185, identifier:missing_tags; 186, block; 186, 187; 187, expression_statement; 187, 188; 188, assignment; 188, 189; 188, 194; 189, subscript; 189, 190; 189, 191; 190, identifier:absent_tags; 191, attribute; 191, 192; 191, 193; 192, identifier:r; 193, identifier:full_name; 194, dictionary; 194, 195; 194, 198; 195, pair; 195, 196; 195, 197; 196, string:'repo'; 197, identifier:r; 198, pair; 198, 199; 198, 200; 199, string:'need_tags'; 200, identifier:missing_tags; 201, expression_statement; 201, 202; 202, call; 202, 203; 202, 204; 203, identifier:debug; 204, argument_list; 204, 205; 205, call; 205, 206; 205, 213; 206, attribute; 206, 207; 206, 212; 207, call; 207, 208; 207, 211; 208, attribute; 208, 209; 208, 210; 209, identifier:textwrap; 210, identifier:dedent; 211, argument_list; 212, identifier:format; 213, argument_list; 213, 214; 213, 220; 213, 226; 214, keyword_argument; 214, 215; 214, 216; 215, identifier:n_with; 216, call; 216, 217; 216, 218; 217, identifier:len; 218, argument_list; 218, 219; 219, identifier:present_tags; 220, keyword_argument; 220, 221; 220, 222; 221, identifier:n_none; 222, call; 222, 223; 222, 224; 223, identifier:len; 224, argument_list; 224, 225; 225, identifier:absent_tags; 226, keyword_argument; 226, 227; 226, 228; 227, identifier:errors; 228, call; 228, 229; 228, 230; 229, identifier:len; 230, argument_list; 230, 231; 231, identifier:problems; 232, return_statement; 232, 233; 233, expression_list; 233, 234; 233, 235; 233, 236; 234, identifier:present_tags; 235, identifier:absent_tags; 236, identifier:problems
def check_tags(repos, tags, ignore_existing=False, fail_fast=False): debug("looking for {n} tag(s):".format(n=len(tags))) [debug(" {t}".format(t=t)) for t in tags] debug("in {n} repo(s):".format(n=len(repos))) [debug(" {r}".format(r=r.full_name)) for r in repos] present_tags = {} absent_tags = {} problems = [] for r in repos: has_tags = find_tags_in_repo(r, tags) if has_tags: if not ignore_existing: yikes = GitTagExistsError( "tag(s) {tag} already exists in repos {r}".format( tag=list(has_tags.keys()), r=r.full_name )) if fail_fast: raise yikes problems.append(yikes) error(yikes) present_tags[r.full_name] = { 'repo': r, 'tags': list(has_tags.values()), } missing_tags = [x for x in tags if x not in has_tags] if missing_tags: absent_tags[r.full_name] = { 'repo': r, 'need_tags': missing_tags, } debug(textwrap.dedent( ).format( n_with=len(present_tags), n_none=len(absent_tags), errors=len(problems), )) return present_tags, absent_tags, problems
0, module; 0, 1; 0, 42; 0, 44; 0, 46; 0, 48; 0, 50; 0, 52; 0, 54; 0, 56; 0, 58; 0, 61; 0, 82; 1, function_definition; 1, 2; 1, 3; 1, 8; 1, 37; 1, 39; 2, function_name:getmlsthelper; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:referencefilepath; 5, identifier:start; 6, identifier:organism; 7, identifier:update; 8, ERROR; 8, 9; 8, 36; 9, ERROR; 9, 10; 9, 16; 9, 22; 9, 31; 9, 32; 9, 33; 9, 35; 10, import_from_statement; 10, 11; 10, 14; 11, dotted_name; 11, 12; 11, 13; 12, identifier:accessoryFunctions; 13, identifier:accessoryFunctions; 14, dotted_name; 14, 15; 15, identifier:GenObject; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 19; 18, identifier:organismset; 19, call; 19, 20; 19, 21; 20, identifier:set; 21, argument_list; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 25; 24, identifier:organism; 25, conditional_expression:if; 25, 26; 25, 27; 25, 30; 26, identifier:organism; 27, comparison_operator:!=; 27, 28; 27, 29; 28, identifier:organism; 29, string:'Shigella'; 30, string:'Escherichia'; 31, identifier:organismdictionary; 32, string:'Escherichia'; 33, ERROR; 33, 34; 34, identifier:Escherichia; 35, identifier:coli; 36, string:'Shigella'; 37, ERROR; 37, 38; 38, identifier:Escherichia; 39, block; 39, 40; 40, expression_statement; 40, 41; 41, identifier:coli; 42, ERROR; 42, 43; 43, string:'Vibrio'; 44, expression_statement; 44, 45; 45, string:'Vibrio parahaemolyticus'; 46, ERROR; 46, 47; 47, string:'Campylobacter'; 48, expression_statement; 48, 49; 49, string:'Campylobacter jejuni'; 50, ERROR; 50, 51; 51, string:'Listeria'; 52, expression_statement; 52, 53; 53, string:'Listeria monocytogenes'; 54, ERROR; 54, 55; 55, string:'Bacillus'; 56, expression_statement; 56, 57; 57, string:'Bacillus cereus'; 58, ERROR; 58, 59; 58, 60; 59, string:'Klebsiella'; 60, string:'Klebsiella pneumoniae'; 61, try_statement; 61, 62; 61, 72; 62, block; 62, 63; 63, expression_statement; 63, 64; 64, call; 64, 65; 64, 68; 65, attribute; 65, 66; 65, 67; 66, identifier:organismset; 67, identifier:add; 68, argument_list; 68, 69; 69, subscript; 69, 70; 69, 71; 70, identifier:organismdictionary; 71, identifier:organism; 72, except_clause; 72, 73; 72, 74; 73, identifier:KeyError; 74, block; 74, 75; 75, expression_statement; 75, 76; 76, call; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, identifier:organismset; 79, identifier:add; 80, argument_list; 80, 81; 81, identifier:organism; 82, for_statement; 82, 83; 82, 84; 82, 85; 82, 384; 83, identifier:scheme; 84, identifier:organismset; 85, ERROR; 85, 86; 86, block; 86, 87; 86, 100; 86, 132; 86, 142; 86, 152; 86, 284; 86, 338; 86, 382; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 90; 89, identifier:organismpath; 90, call; 90, 91; 90, 96; 91, attribute; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:os; 94, identifier:path; 95, identifier:join; 96, argument_list; 96, 97; 96, 98; 96, 99; 97, identifier:referencefilepath; 98, string:'MLST'; 99, identifier:organism; 100, try_statement; 100, 101; 100, 125; 101, block; 101, 102; 102, expression_statement; 102, 103; 103, assignment; 103, 104; 103, 105; 104, identifier:lastfolder; 105, call; 105, 106; 105, 123; 106, attribute; 106, 107; 106, 122; 107, subscript; 107, 108; 107, 120; 108, call; 108, 109; 108, 110; 109, identifier:sorted; 110, argument_list; 110, 111; 111, call; 111, 112; 111, 113; 112, identifier:glob; 113, argument_list; 113, 114; 114, call; 114, 115; 114, 118; 115, attribute; 115, 116; 115, 117; 116, string:'{}/*/'; 117, identifier:format; 118, argument_list; 118, 119; 119, identifier:organismpath; 120, unary_operator:-; 120, 121; 121, integer:1; 122, identifier:rstrip; 123, argument_list; 123, 124; 124, string:'/'; 125, except_clause; 125, 126; 125, 127; 126, identifier:IndexError; 127, block; 127, 128; 128, expression_statement; 128, 129; 129, assignment; 129, 130; 129, 131; 130, identifier:lastfolder; 131, list:[]; 132, expression_statement; 132, 133; 133, assignment; 133, 134; 133, 138; 134, pattern_list; 134, 135; 134, 136; 134, 137; 135, identifier:delta; 136, identifier:foldersize; 137, identifier:d1; 138, call; 138, 139; 138, 140; 139, identifier:schemedate; 140, argument_list; 140, 141; 141, identifier:lastfolder; 142, expression_statement; 142, 143; 143, assignment; 143, 144; 143, 145; 144, identifier:newfolder; 145, call; 145, 146; 145, 149; 146, attribute; 146, 147; 146, 148; 147, string:'{}/{}'; 148, identifier:format; 149, argument_list; 149, 150; 149, 151; 150, identifier:organismpath; 151, identifier:d1; 152, if_statement; 152, 153; 152, 154; 152, 278; 153, identifier:update; 154, block; 154, 155; 155, if_statement; 155, 156; 155, 165; 155, 272; 156, boolean_operator:or; 156, 157; 156, 162; 157, comparison_operator:>; 157, 158; 157, 161; 158, attribute; 158, 159; 158, 160; 159, identifier:delta; 160, identifier:days; 161, integer:7; 162, comparison_operator:<; 162, 163; 162, 164; 163, identifier:foldersize; 164, integer:100; 165, block; 165, 166; 165, 177; 165, 183; 165, 189; 165, 195; 165, 201; 165, 207; 165, 214; 165, 221; 165, 251; 166, expression_statement; 166, 167; 167, call; 167, 168; 167, 169; 168, identifier:printtime; 169, argument_list; 169, 170; 169, 176; 170, call; 170, 171; 170, 174; 171, attribute; 171, 172; 171, 173; 172, string:'Downloading {} MLST scheme from pubmlst.org'; 173, identifier:format; 174, argument_list; 174, 175; 175, identifier:organism; 176, identifier:start; 177, expression_statement; 177, 178; 178, assignment; 178, 179; 178, 180; 179, identifier:getmlstargs; 180, call; 180, 181; 180, 182; 181, identifier:GenObject; 182, argument_list; 183, expression_statement; 183, 184; 184, assignment; 184, 185; 184, 188; 185, attribute; 185, 186; 185, 187; 186, identifier:getmlstargs; 187, identifier:species; 188, identifier:scheme; 189, expression_statement; 189, 190; 190, assignment; 190, 191; 190, 194; 191, attribute; 191, 192; 191, 193; 192, identifier:getmlstargs; 193, identifier:repository_url; 194, string:'http://pubmlst.org/data/dbases.xml'; 195, expression_statement; 195, 196; 196, assignment; 196, 197; 196, 200; 197, attribute; 197, 198; 197, 199; 198, identifier:getmlstargs; 199, identifier:force_scheme_name; 200, False; 201, expression_statement; 201, 202; 202, assignment; 202, 203; 202, 206; 203, attribute; 203, 204; 203, 205; 204, identifier:getmlstargs; 205, identifier:path; 206, identifier:newfolder; 207, expression_statement; 207, 208; 208, call; 208, 209; 208, 210; 209, identifier:make_path; 210, argument_list; 210, 211; 211, attribute; 211, 212; 211, 213; 212, identifier:getmlstargs; 213, identifier:path; 214, expression_statement; 214, 215; 215, call; 215, 216; 215, 219; 216, attribute; 216, 217; 216, 218; 217, identifier:getmlst; 218, identifier:main; 219, argument_list; 219, 220; 220, identifier:getmlstargs; 221, try_statement; 221, 222; 221, 244; 222, block; 222, 223; 223, expression_statement; 223, 224; 224, assignment; 224, 225; 224, 226; 225, identifier:profilestart; 226, call; 226, 227; 226, 243; 227, attribute; 227, 228; 227, 242; 228, call; 228, 229; 228, 230; 229, identifier:open; 230, argument_list; 230, 231; 231, subscript; 231, 232; 231, 241; 232, call; 232, 233; 232, 234; 233, identifier:glob; 234, argument_list; 234, 235; 235, call; 235, 236; 235, 239; 236, attribute; 236, 237; 236, 238; 237, string:'{}/*.txt'; 238, identifier:format; 239, argument_list; 239, 240; 240, identifier:newfolder; 241, integer:0; 242, identifier:readline; 243, argument_list; 244, except_clause; 244, 245; 244, 246; 245, identifier:IndexError; 246, block; 246, 247; 247, expression_statement; 247, 248; 248, assignment; 248, 249; 248, 250; 249, identifier:profilestart; 250, list:[]; 251, if_statement; 251, 252; 251, 260; 252, boolean_operator:or; 252, 253; 252, 255; 253, not_operator; 253, 254; 254, identifier:profilestart; 255, comparison_operator:==; 255, 256; 255, 259; 256, subscript; 256, 257; 256, 258; 257, identifier:profilestart; 258, integer:0; 259, string:'<'; 260, block; 260, 261; 260, 268; 261, expression_statement; 261, 262; 262, call; 262, 263; 262, 266; 263, attribute; 263, 264; 263, 265; 264, identifier:shutil; 265, identifier:rmtree; 266, argument_list; 266, 267; 267, identifier:newfolder; 268, expression_statement; 268, 269; 269, assignment; 269, 270; 269, 271; 270, identifier:newfolder; 271, identifier:lastfolder; 272, else_clause; 272, 273; 273, block; 273, 274; 274, expression_statement; 274, 275; 275, assignment; 275, 276; 275, 277; 276, identifier:newfolder; 277, identifier:lastfolder; 278, else_clause; 278, 279; 279, block; 279, 280; 280, expression_statement; 280, 281; 281, assignment; 281, 282; 281, 283; 282, identifier:newfolder; 283, identifier:lastfolder; 284, try_statement; 284, 285; 284, 329; 285, block; 285, 286; 286, expression_statement; 286, 287; 287, assignment; 287, 288; 287, 289; 288, identifier:newfoldersize; 289, call; 289, 290; 289, 291; 290, identifier:sum; 291, generator_expression; 291, 292; 291, 306; 291, 314; 292, call; 292, 293; 292, 298; 293, attribute; 293, 294; 293, 297; 294, attribute; 294, 295; 294, 296; 295, identifier:os; 296, identifier:path; 297, identifier:getsize; 298, argument_list; 298, 299; 299, call; 299, 300; 299, 303; 300, attribute; 300, 301; 300, 302; 301, string:'{}/{}'; 302, identifier:format; 303, argument_list; 303, 304; 303, 305; 304, identifier:newfolder; 305, identifier:f; 306, for_in_clause; 306, 307; 306, 308; 307, identifier:f; 308, call; 308, 309; 308, 312; 309, attribute; 309, 310; 309, 311; 310, identifier:os; 311, identifier:listdir; 312, argument_list; 312, 313; 313, identifier:newfolder; 314, if_clause; 314, 315; 315, call; 315, 316; 315, 321; 316, attribute; 316, 317; 316, 320; 317, attribute; 317, 318; 317, 319; 318, identifier:os; 319, identifier:path; 320, identifier:isfile; 321, argument_list; 321, 322; 322, call; 322, 323; 322, 326; 323, attribute; 323, 324; 323, 325; 324, string:'{}/{}'; 325, identifier:format; 326, argument_list; 326, 327; 326, 328; 327, identifier:newfolder; 328, identifier:f; 329, except_clause; 329, 330; 329, 333; 330, tuple; 330, 331; 330, 332; 331, identifier:OSError; 332, identifier:TypeError; 333, block; 333, 334; 334, expression_statement; 334, 335; 335, assignment; 335, 336; 335, 337; 336, identifier:newfoldersize; 337, integer:100; 338, if_statement; 338, 339; 338, 342; 339, comparison_operator:<; 339, 340; 339, 341; 340, identifier:newfoldersize; 341, integer:100; 342, block; 342, 343; 342, 350; 343, expression_statement; 343, 344; 344, call; 344, 345; 344, 348; 345, attribute; 345, 346; 345, 347; 346, identifier:shutil; 347, identifier:rmtree; 348, argument_list; 348, 349; 349, identifier:newfolder; 350, try_statement; 350, 351; 350, 375; 351, block; 351, 352; 352, expression_statement; 352, 353; 353, assignment; 353, 354; 353, 355; 354, identifier:newfolder; 355, call; 355, 356; 355, 373; 356, attribute; 356, 357; 356, 372; 357, subscript; 357, 358; 357, 370; 358, call; 358, 359; 358, 360; 359, identifier:sorted; 360, argument_list; 360, 361; 361, call; 361, 362; 361, 363; 362, identifier:glob; 363, argument_list; 363, 364; 364, call; 364, 365; 364, 368; 365, attribute; 365, 366; 365, 367; 366, string:'{}/*/'; 367, identifier:format; 368, argument_list; 368, 369; 369, identifier:organismpath; 370, unary_operator:-; 370, 371; 371, integer:1; 372, identifier:rstrip; 373, argument_list; 373, 374; 374, string:'/'; 375, except_clause; 375, 376; 375, 377; 376, identifier:IndexError; 377, block; 377, 378; 378, expression_statement; 378, 379; 379, assignment; 379, 380; 379, 381; 380, identifier:newfolder; 381, identifier:organismpath; 382, return_statement; 382, 383; 383, identifier:newfolder; 384, block:
def getmlsthelper(referencefilepath, start, organism, update): from accessoryFunctions.accessoryFunctions import GenObject organismset = set() organism = organism if organism != 'Shigella' else 'Escherichia' organismdictionary = {'Escherichia': 'Escherichia coli 'Shigella': 'Escherichia coli 'Vibrio': 'Vibrio parahaemolyticus', 'Campylobacter': 'Campylobacter jejuni', 'Listeria': 'Listeria monocytogenes', 'Bacillus': 'Bacillus cereus', 'Klebsiella': 'Klebsiella pneumoniae'} try: organismset.add(organismdictionary[organism]) except KeyError: organismset.add(organism) for scheme in organismset: organismpath = os.path.join(referencefilepath, 'MLST', organism) try: lastfolder = sorted(glob('{}/*/'.format(organismpath)))[-1].rstrip('/') except IndexError: lastfolder = [] delta, foldersize, d1 = schemedate(lastfolder) newfolder = '{}/{}'.format(organismpath, d1) if update: if delta.days > 7 or foldersize < 100: printtime('Downloading {} MLST scheme from pubmlst.org'.format(organism), start) getmlstargs = GenObject() getmlstargs.species = scheme getmlstargs.repository_url = 'http://pubmlst.org/data/dbases.xml' getmlstargs.force_scheme_name = False getmlstargs.path = newfolder make_path(getmlstargs.path) getmlst.main(getmlstargs) try: profilestart = open(glob('{}/*.txt'.format(newfolder))[0]).readline() except IndexError: profilestart = [] if not profilestart or profilestart[0] == '<': shutil.rmtree(newfolder) newfolder = lastfolder else: newfolder = lastfolder else: newfolder = lastfolder try: newfoldersize = sum(os.path.getsize('{}/{}'.format(newfolder, f)) for f in os.listdir(newfolder) if os.path.isfile('{}/{}'.format(newfolder, f))) except (OSError, TypeError): newfoldersize = 100 if newfoldersize < 100: shutil.rmtree(newfolder) try: newfolder = sorted(glob('{}/*/'.format(organismpath)))[-1].rstrip('/') except IndexError: newfolder = organismpath return newfolder
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:set; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, dictionary_splat_pattern; 5, 6; 6, identifier:kwargs; 7, block; 7, 8; 7, 16; 7, 32; 7, 56; 7, 115; 7, 131; 7, 139; 7, 152; 7, 165; 7, 178; 7, 191; 7, 204; 7, 217; 7, 230; 7, 245; 7, 258; 7, 271; 7, 284; 7, 297; 7, 310; 8, expression_statement; 8, 9; 9, call; 9, 10; 9, 15; 10, attribute; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:self; 13, identifier:player_lock; 14, identifier:acquire; 15, argument_list; 16, if_statement; 16, 17; 16, 20; 17, comparison_operator:in; 17, 18; 17, 19; 18, string:'acqtime'; 19, identifier:kwargs; 20, block; 20, 21; 21, expression_statement; 21, 22; 22, call; 22, 23; 22, 28; 23, attribute; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:self; 26, identifier:player; 27, identifier:set_aidur; 28, argument_list; 28, 29; 29, subscript; 29, 30; 29, 31; 30, identifier:kwargs; 31, string:'acqtime'; 32, if_statement; 32, 33; 32, 36; 33, comparison_operator:in; 33, 34; 33, 35; 34, string:'aifs'; 35, identifier:kwargs; 36, block; 36, 37; 36, 48; 37, expression_statement; 37, 38; 38, call; 38, 39; 38, 44; 39, attribute; 39, 40; 39, 43; 40, attribute; 40, 41; 40, 42; 41, identifier:self; 42, identifier:player; 43, identifier:set_aifs; 44, argument_list; 44, 45; 45, subscript; 45, 46; 45, 47; 46, identifier:kwargs; 47, string:'aifs'; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 53; 50, attribute; 50, 51; 50, 52; 51, identifier:self; 52, identifier:aifs; 53, subscript; 53, 54; 53, 55; 54, identifier:kwargs; 55, string:'aifs'; 56, if_statement; 56, 57; 56, 64; 57, boolean_operator:or; 57, 58; 57, 61; 58, comparison_operator:in; 58, 59; 58, 60; 59, string:'aifs'; 60, identifier:kwargs; 61, comparison_operator:in; 61, 62; 61, 63; 62, string:'acqtime'; 63, identifier:kwargs; 64, block; 64, 65; 64, 81; 64, 102; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:t; 68, call; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, identifier:kwargs; 71, identifier:get; 72, argument_list; 72, 73; 72, 74; 73, string:'acqtime'; 74, call; 74, 75; 74, 80; 75, attribute; 75, 76; 75, 79; 76, attribute; 76, 77; 76, 78; 77, identifier:self; 78, identifier:player; 79, identifier:get_aidur; 80, argument_list; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 84; 83, identifier:npoints; 84, binary_operator:*; 84, 85; 84, 86; 85, identifier:t; 86, call; 86, 87; 86, 88; 87, identifier:float; 88, argument_list; 88, 89; 89, call; 89, 90; 89, 93; 90, attribute; 90, 91; 90, 92; 91, identifier:kwargs; 92, identifier:get; 93, argument_list; 93, 94; 93, 95; 94, string:'aifs'; 95, call; 95, 96; 95, 101; 96, attribute; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, identifier:self; 99, identifier:player; 100, identifier:get_aifs; 101, argument_list; 102, expression_statement; 102, 103; 103, assignment; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:self; 106, identifier:aitimes; 107, call; 107, 108; 107, 111; 108, attribute; 108, 109; 108, 110; 109, identifier:np; 110, identifier:linspace; 111, argument_list; 111, 112; 111, 113; 111, 114; 112, integer:0; 113, identifier:t; 114, identifier:npoints; 115, if_statement; 115, 116; 115, 119; 116, comparison_operator:in; 116, 117; 116, 118; 117, string:'trigger'; 118, identifier:kwargs; 119, block; 119, 120; 120, expression_statement; 120, 121; 121, call; 121, 122; 121, 127; 122, attribute; 122, 123; 122, 126; 123, attribute; 123, 124; 123, 125; 124, identifier:self; 125, identifier:player; 126, identifier:set_trigger; 127, argument_list; 127, 128; 128, subscript; 128, 129; 128, 130; 129, identifier:kwargs; 130, string:'trigger'; 131, expression_statement; 131, 132; 132, call; 132, 133; 132, 138; 133, attribute; 133, 134; 133, 137; 134, attribute; 134, 135; 134, 136; 135, identifier:self; 136, identifier:player_lock; 137, identifier:release; 138, argument_list; 139, if_statement; 139, 140; 139, 143; 140, comparison_operator:in; 140, 141; 140, 142; 141, string:'aochan'; 142, identifier:kwargs; 143, block; 143, 144; 144, expression_statement; 144, 145; 145, assignment; 145, 146; 145, 149; 146, attribute; 146, 147; 146, 148; 147, identifier:self; 148, identifier:aochan; 149, subscript; 149, 150; 149, 151; 150, identifier:kwargs; 151, string:'aochan'; 152, if_statement; 152, 153; 152, 156; 153, comparison_operator:in; 153, 154; 153, 155; 154, string:'aichan'; 155, identifier:kwargs; 156, block; 156, 157; 157, expression_statement; 157, 158; 158, assignment; 158, 159; 158, 162; 159, attribute; 159, 160; 159, 161; 160, identifier:self; 161, identifier:aichan; 162, subscript; 162, 163; 162, 164; 163, identifier:kwargs; 164, string:'aichan'; 165, if_statement; 165, 166; 165, 169; 166, comparison_operator:in; 166, 167; 166, 168; 167, string:'binsz'; 168, identifier:kwargs; 169, block; 169, 170; 170, expression_statement; 170, 171; 171, assignment; 171, 172; 171, 175; 172, attribute; 172, 173; 172, 174; 173, identifier:self; 174, identifier:binsz; 175, subscript; 175, 176; 175, 177; 176, identifier:kwargs; 177, string:'binsz'; 178, if_statement; 178, 179; 178, 182; 179, comparison_operator:in; 179, 180; 179, 181; 180, string:'save'; 181, identifier:kwargs; 182, block; 182, 183; 183, expression_statement; 183, 184; 184, assignment; 184, 185; 184, 188; 185, attribute; 185, 186; 185, 187; 186, identifier:self; 187, identifier:save_data; 188, subscript; 188, 189; 188, 190; 189, identifier:kwargs; 190, string:'save'; 191, if_statement; 191, 192; 191, 195; 192, comparison_operator:in; 192, 193; 192, 194; 193, string:'caldb'; 194, identifier:kwargs; 195, block; 195, 196; 196, expression_statement; 196, 197; 197, assignment; 197, 198; 197, 201; 198, attribute; 198, 199; 198, 200; 199, identifier:self; 200, identifier:caldb; 201, subscript; 201, 202; 201, 203; 202, identifier:kwargs; 203, string:'caldb'; 204, if_statement; 204, 205; 204, 208; 205, comparison_operator:in; 205, 206; 205, 207; 206, string:'calv'; 207, identifier:kwargs; 208, block; 208, 209; 209, expression_statement; 209, 210; 210, assignment; 210, 211; 210, 214; 211, attribute; 211, 212; 211, 213; 212, identifier:self; 213, identifier:calv; 214, subscript; 214, 215; 214, 216; 215, identifier:kwargs; 216, string:'calv'; 217, if_statement; 217, 218; 217, 221; 218, comparison_operator:in; 218, 219; 218, 220; 219, string:'calf'; 220, identifier:kwargs; 221, block; 221, 222; 222, expression_statement; 222, 223; 223, assignment; 223, 224; 223, 227; 224, attribute; 224, 225; 224, 226; 225, identifier:self; 226, identifier:calf; 227, subscript; 227, 228; 227, 229; 228, identifier:kwargs; 229, string:'calf'; 230, if_statement; 230, 231; 230, 238; 231, boolean_operator:or; 231, 232; 231, 235; 232, comparison_operator:in; 232, 233; 232, 234; 233, string:'caldb'; 234, identifier:kwargs; 235, comparison_operator:in; 235, 236; 235, 237; 236, string:'calv'; 237, identifier:kwargs; 238, block; 238, 239; 239, expression_statement; 239, 240; 240, call; 240, 241; 240, 244; 241, attribute; 241, 242; 241, 243; 242, identifier:self; 243, identifier:update_reference_voltage; 244, argument_list; 245, if_statement; 245, 246; 245, 249; 246, comparison_operator:in; 246, 247; 246, 248; 247, string:'datafile'; 248, identifier:kwargs; 249, block; 249, 250; 250, expression_statement; 250, 251; 251, assignment; 251, 252; 251, 255; 252, attribute; 252, 253; 252, 254; 253, identifier:self; 254, identifier:datafile; 255, subscript; 255, 256; 255, 257; 256, identifier:kwargs; 257, string:'datafile'; 258, if_statement; 258, 259; 258, 262; 259, comparison_operator:in; 259, 260; 259, 261; 260, string:'reprate'; 261, identifier:kwargs; 262, block; 262, 263; 263, expression_statement; 263, 264; 264, assignment; 264, 265; 264, 268; 265, attribute; 265, 266; 265, 267; 266, identifier:self; 267, identifier:reprate; 268, subscript; 268, 269; 268, 270; 269, identifier:kwargs; 270, string:'reprate'; 271, if_statement; 271, 272; 271, 275; 272, comparison_operator:in; 272, 273; 272, 274; 273, string:'save'; 274, identifier:kwargs; 275, block; 275, 276; 276, expression_statement; 276, 277; 277, assignment; 277, 278; 277, 281; 278, attribute; 278, 279; 278, 280; 279, identifier:self; 280, identifier:save_data; 281, subscript; 281, 282; 281, 283; 282, identifier:kwargs; 283, string:'save'; 284, if_statement; 284, 285; 284, 288; 285, comparison_operator:in; 285, 286; 285, 287; 286, string:'average'; 287, identifier:kwargs; 288, block; 288, 289; 289, expression_statement; 289, 290; 290, assignment; 290, 291; 290, 294; 291, attribute; 291, 292; 291, 293; 292, identifier:self; 293, identifier:average; 294, subscript; 294, 295; 294, 296; 295, identifier:kwargs; 296, string:'average'; 297, if_statement; 297, 298; 297, 301; 298, comparison_operator:in; 298, 299; 298, 300; 299, string:'reject'; 300, identifier:kwargs; 301, block; 301, 302; 302, expression_statement; 302, 303; 303, assignment; 303, 304; 303, 307; 304, attribute; 304, 305; 304, 306; 305, identifier:self; 306, identifier:reject; 307, subscript; 307, 308; 307, 309; 308, identifier:kwargs; 309, string:'reject'; 310, if_statement; 310, 311; 310, 314; 311, comparison_operator:in; 311, 312; 311, 313; 312, string:'rejectrate'; 313, identifier:kwargs; 314, block; 314, 315; 315, expression_statement; 315, 316; 316, assignment; 316, 317; 316, 320; 317, attribute; 317, 318; 317, 319; 318, identifier:self; 319, identifier:rejectrate; 320, subscript; 320, 321; 320, 322; 321, identifier:kwargs; 322, string:'rejectrate'
def set(self, **kwargs): self.player_lock.acquire() if 'acqtime' in kwargs: self.player.set_aidur(kwargs['acqtime']) if 'aifs' in kwargs: self.player.set_aifs(kwargs['aifs']) self.aifs = kwargs['aifs'] if 'aifs' in kwargs or 'acqtime' in kwargs: t = kwargs.get('acqtime', self.player.get_aidur()) npoints = t*float(kwargs.get('aifs', self.player.get_aifs())) self.aitimes = np.linspace(0, t, npoints) if 'trigger' in kwargs: self.player.set_trigger(kwargs['trigger']) self.player_lock.release() if 'aochan' in kwargs: self.aochan = kwargs['aochan'] if 'aichan' in kwargs: self.aichan = kwargs['aichan'] if 'binsz' in kwargs: self.binsz = kwargs['binsz'] if 'save' in kwargs: self.save_data = kwargs['save'] if 'caldb' in kwargs: self.caldb = kwargs['caldb'] if 'calv' in kwargs: self.calv = kwargs['calv'] if 'calf' in kwargs: self.calf = kwargs['calf'] if 'caldb' in kwargs or 'calv' in kwargs: self.update_reference_voltage() if 'datafile' in kwargs: self.datafile = kwargs['datafile'] if 'reprate' in kwargs: self.reprate = kwargs['reprate'] if 'save' in kwargs: self.save_data = kwargs['save'] if 'average' in kwargs: self.average = kwargs['average'] if 'reject' in kwargs: self.reject = kwargs['reject'] if 'rejectrate' in kwargs: self.rejectrate = kwargs['rejectrate']
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:readlist; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 50; 5, 67; 5, 75; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 9; 8, identifier:printtime; 9, argument_list; 9, 10; 9, 11; 10, string:'Sorting reads'; 11, attribute; 11, 12; 11, 13; 12, identifier:self; 13, identifier:start; 14, for_statement; 14, 15; 14, 16; 14, 22; 15, identifier:i; 16, call; 16, 17; 16, 18; 17, identifier:range; 18, argument_list; 18, 19; 19, attribute; 19, 20; 19, 21; 20, identifier:self; 21, identifier:cpus; 22, block; 22, 23; 22, 37; 22, 44; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 26; 25, identifier:threads; 26, call; 26, 27; 26, 28; 27, identifier:Thread; 28, argument_list; 28, 29; 28, 34; 29, keyword_argument; 29, 30; 29, 31; 30, identifier:target; 31, attribute; 31, 32; 31, 33; 32, identifier:self; 33, identifier:listread; 34, keyword_argument; 34, 35; 34, 36; 35, identifier:args; 36, tuple; 37, expression_statement; 37, 38; 38, call; 38, 39; 38, 42; 39, attribute; 39, 40; 39, 41; 40, identifier:threads; 41, identifier:setDaemon; 42, argument_list; 42, 43; 43, True; 44, expression_statement; 44, 45; 45, call; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:threads; 48, identifier:start; 49, argument_list; 50, for_statement; 50, 51; 50, 52; 50, 57; 51, identifier:sample; 52, attribute; 52, 53; 52, 56; 53, attribute; 53, 54; 53, 55; 54, identifier:self; 55, identifier:runmetadata; 56, identifier:samples; 57, block; 57, 58; 58, expression_statement; 58, 59; 59, call; 59, 60; 59, 65; 60, attribute; 60, 61; 60, 64; 61, attribute; 61, 62; 61, 63; 62, identifier:self; 63, identifier:listqueue; 64, identifier:put; 65, argument_list; 65, 66; 66, identifier:sample; 67, expression_statement; 67, 68; 68, call; 68, 69; 68, 74; 69, attribute; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:self; 72, identifier:listqueue; 73, identifier:join; 74, argument_list; 75, expression_statement; 75, 76; 76, call; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, identifier:self; 79, identifier:fastqfilter; 80, argument_list
def readlist(self): printtime('Sorting reads', self.start) for i in range(self.cpus): threads = Thread(target=self.listread, args=()) threads.setDaemon(True) threads.start() for sample in self.runmetadata.samples: self.listqueue.put(sample) self.listqueue.join() self.fastqfilter()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:has_change_permission; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:page; 6, identifier:lang; 7, default_parameter; 7, 8; 7, 9; 8, identifier:method; 9, None; 10, block; 10, 11; 10, 18; 10, 27; 10, 72; 10, 80; 10, 106; 11, if_statement; 11, 12; 11, 15; 12, comparison_operator:!=; 12, 13; 12, 14; 13, identifier:method; 14, string:'POST'; 15, block; 15, 16; 16, return_statement; 16, 17; 17, True; 18, if_statement; 18, 19; 18, 24; 19, call; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:self; 22, identifier:change_page; 23, argument_list; 24, block; 24, 25; 25, return_statement; 25, 26; 26, True; 27, if_statement; 27, 28; 27, 29; 28, identifier:lang; 29, block; 29, 30; 29, 49; 29, 54; 29, 64; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 33; 32, identifier:perm; 33, call; 33, 34; 33, 39; 34, attribute; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:self; 37, identifier:user; 38, identifier:has_perm; 39, argument_list; 39, 40; 40, binary_operator:%; 40, 41; 40, 42; 41, string:'pages.can_manage_%s'; 42, call; 42, 43; 42, 46; 43, attribute; 43, 44; 43, 45; 44, identifier:lang; 45, identifier:replace; 46, argument_list; 46, 47; 46, 48; 47, string:'-'; 48, string:'_'; 49, if_statement; 49, 50; 49, 51; 50, identifier:perm; 51, block; 51, 52; 52, return_statement; 52, 53; 53, True; 54, expression_statement; 54, 55; 55, assignment; 55, 56; 55, 57; 56, identifier:perm_func; 57, call; 57, 58; 57, 59; 58, identifier:getattr; 59, argument_list; 59, 60; 59, 61; 60, identifier:self; 61, binary_operator:%; 61, 62; 61, 63; 62, string:'manage (%s)_page'; 63, identifier:lang; 64, if_statement; 64, 65; 64, 69; 65, call; 65, 66; 65, 67; 66, identifier:perm_func; 67, argument_list; 67, 68; 68, identifier:page; 69, block; 69, 70; 70, return_statement; 70, 71; 71, True; 72, expression_statement; 72, 73; 73, assignment; 73, 74; 73, 75; 74, identifier:perm_func; 75, call; 75, 76; 75, 77; 76, identifier:getattr; 77, argument_list; 77, 78; 77, 79; 78, identifier:self; 79, string:'manage hierarchy_page'; 80, if_statement; 80, 81; 80, 85; 80, 88; 81, call; 81, 82; 81, 83; 82, identifier:perm_func; 83, argument_list; 83, 84; 84, identifier:page; 85, block; 85, 86; 86, return_statement; 86, 87; 87, True; 88, else_clause; 88, 89; 89, block; 89, 90; 90, for_statement; 90, 91; 90, 92; 90, 97; 91, identifier:ancestor; 92, call; 92, 93; 92, 96; 93, attribute; 93, 94; 93, 95; 94, identifier:page; 95, identifier:get_ancestors; 96, argument_list; 97, block; 97, 98; 98, if_statement; 98, 99; 98, 103; 99, call; 99, 100; 99, 101; 100, identifier:perm_func; 101, argument_list; 101, 102; 102, identifier:ancestor; 103, block; 103, 104; 104, return_statement; 104, 105; 105, True; 106, return_statement; 106, 107; 107, False
def has_change_permission(self, page, lang, method=None): if method != 'POST': return True if self.change_page(): return True if lang: perm = self.user.has_perm( 'pages.can_manage_%s' % lang.replace('-', '_') ) if perm: return True perm_func = getattr(self, 'manage (%s)_page' % lang) if perm_func(page): return True perm_func = getattr(self, 'manage hierarchy_page') if perm_func(page): return True else: for ancestor in page.get_ancestors(): if perm_func(ancestor): return True return False
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:args; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 12; 5, 18; 5, 29; 5, 35; 5, 41; 5, 47; 5, 53; 5, 59; 5, 70; 5, 76; 5, 107; 5, 326; 5, 332; 5, 363; 5, 418; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:params; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, identifier:parameters; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 14, identifier:args; 15, call; 15, 16; 15, 17; 16, identifier:OrderedDict; 17, argument_list; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 23; 20, subscript; 20, 21; 20, 22; 21, identifier:args; 22, string:'help'; 23, call; 23, 24; 23, 25; 24, identifier:HelpArg; 25, argument_list; 25, 26; 26, keyword_argument; 26, 27; 26, 28; 27, identifier:command; 28, identifier:self; 29, expression_statement; 29, 30; 30, assignment; 30, 31; 30, 32; 31, identifier:normalize_name; 32, attribute; 32, 33; 32, 34; 33, identifier:self; 34, identifier:normalize_name; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 38; 37, identifier:get_arg_config; 38, attribute; 38, 39; 38, 40; 39, identifier:self; 40, identifier:get_arg_config; 41, expression_statement; 41, 42; 42, assignment; 42, 43; 42, 44; 43, identifier:get_short_option; 44, attribute; 44, 45; 44, 46; 45, identifier:self; 46, identifier:get_short_option_for_arg; 47, expression_statement; 47, 48; 48, assignment; 48, 49; 48, 50; 49, identifier:get_long_option; 50, attribute; 50, 51; 50, 52; 51, identifier:self; 52, identifier:get_long_option_for_arg; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 56; 55, identifier:get_inverse_option; 56, attribute; 56, 57; 56, 58; 57, identifier:self; 58, identifier:get_inverse_option_for_arg; 59, expression_statement; 59, 60; 60, assignment; 60, 61; 60, 62; 61, identifier:names; 62, set_comprehension; 62, 63; 62, 67; 63, call; 63, 64; 63, 65; 64, identifier:normalize_name; 65, argument_list; 65, 66; 66, identifier:name; 67, for_in_clause; 67, 68; 67, 69; 68, identifier:name; 69, identifier:params; 70, expression_statement; 70, 71; 71, assignment; 71, 72; 71, 73; 72, identifier:used_short_options; 73, call; 73, 74; 73, 75; 74, identifier:set; 75, argument_list; 76, for_statement; 76, 77; 76, 78; 76, 83; 77, identifier:param; 78, call; 78, 79; 78, 82; 79, attribute; 79, 80; 79, 81; 80, identifier:params; 81, identifier:values; 82, argument_list; 83, block; 83, 84; 83, 91; 83, 97; 84, expression_statement; 84, 85; 85, assignment; 85, 86; 85, 87; 86, identifier:annotation; 87, call; 87, 88; 87, 89; 88, identifier:get_arg_config; 89, argument_list; 89, 90; 90, identifier:param; 91, expression_statement; 91, 92; 92, assignment; 92, 93; 92, 94; 93, identifier:short_option; 94, attribute; 94, 95; 94, 96; 95, identifier:annotation; 96, identifier:short_option; 97, if_statement; 97, 98; 97, 99; 98, identifier:short_option; 99, block; 99, 100; 100, expression_statement; 100, 101; 101, call; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, identifier:used_short_options; 104, identifier:add; 105, argument_list; 105, 106; 106, identifier:short_option; 107, for_statement; 107, 108; 107, 111; 107, 116; 108, pattern_list; 108, 109; 108, 110; 109, identifier:name; 110, identifier:param; 111, call; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, identifier:params; 114, identifier:items; 115, argument_list; 116, block; 116, 117; 116, 124; 116, 150; 116, 154; 116, 161; 116, 167; 116, 173; 116, 179; 116, 185; 116, 191; 116, 197; 116, 203; 116, 209; 116, 215; 116, 221; 116, 227; 116, 276; 117, expression_statement; 117, 118; 118, assignment; 118, 119; 118, 120; 119, identifier:name; 120, call; 120, 121; 120, 122; 121, identifier:normalize_name; 122, argument_list; 122, 123; 123, identifier:name; 124, expression_statement; 124, 125; 125, assignment; 125, 126; 125, 127; 126, identifier:skip; 127, parenthesized_expression; 127, 128; 128, boolean_operator:or; 128, 129; 128, 143; 129, boolean_operator:or; 129, 130; 129, 136; 130, call; 130, 131; 130, 134; 131, attribute; 131, 132; 131, 133; 132, identifier:name; 133, identifier:startswith; 134, argument_list; 134, 135; 135, string:'_'; 136, comparison_operator:is; 136, 137; 136, 140; 137, attribute; 137, 138; 137, 139; 138, identifier:param; 139, identifier:kind; 140, attribute; 140, 141; 140, 142; 141, identifier:param; 142, identifier:VAR_KEYWORD; 143, comparison_operator:is; 143, 144; 143, 147; 144, attribute; 144, 145; 144, 146; 145, identifier:param; 146, identifier:kind; 147, attribute; 147, 148; 147, 149; 148, identifier:param; 149, identifier:KEYWORD_ONLY; 150, if_statement; 150, 151; 150, 152; 151, identifier:skip; 152, block; 152, 153; 153, continue_statement; 154, expression_statement; 154, 155; 155, assignment; 155, 156; 155, 157; 156, identifier:annotation; 157, call; 157, 158; 157, 159; 158, identifier:get_arg_config; 159, argument_list; 159, 160; 160, identifier:param; 161, expression_statement; 161, 162; 162, assignment; 162, 163; 162, 164; 163, identifier:container; 164, attribute; 164, 165; 164, 166; 165, identifier:annotation; 166, identifier:container; 167, expression_statement; 167, 168; 168, assignment; 168, 169; 168, 170; 169, identifier:type; 170, attribute; 170, 171; 170, 172; 171, identifier:annotation; 172, identifier:type; 173, expression_statement; 173, 174; 174, assignment; 174, 175; 174, 176; 175, identifier:choices; 176, attribute; 176, 177; 176, 178; 177, identifier:annotation; 178, identifier:choices; 179, expression_statement; 179, 180; 180, assignment; 180, 181; 180, 182; 181, identifier:help; 182, attribute; 182, 183; 182, 184; 183, identifier:annotation; 184, identifier:help; 185, expression_statement; 185, 186; 186, assignment; 186, 187; 186, 188; 187, identifier:inverse_help; 188, attribute; 188, 189; 188, 190; 189, identifier:annotation; 190, identifier:inverse_help; 191, expression_statement; 191, 192; 192, assignment; 192, 193; 192, 194; 193, identifier:short_option; 194, attribute; 194, 195; 194, 196; 195, identifier:annotation; 196, identifier:short_option; 197, expression_statement; 197, 198; 198, assignment; 198, 199; 198, 200; 199, identifier:long_option; 200, attribute; 200, 201; 200, 202; 201, identifier:annotation; 202, identifier:long_option; 203, expression_statement; 203, 204; 204, assignment; 204, 205; 204, 206; 205, identifier:inverse_option; 206, attribute; 206, 207; 206, 208; 207, identifier:annotation; 208, identifier:inverse_option; 209, expression_statement; 209, 210; 210, assignment; 210, 211; 210, 212; 211, identifier:action; 212, attribute; 212, 213; 212, 214; 213, identifier:annotation; 214, identifier:action; 215, expression_statement; 215, 216; 216, assignment; 216, 217; 216, 218; 217, identifier:nargs; 218, attribute; 218, 219; 218, 220; 219, identifier:annotation; 220, identifier:nargs; 221, expression_statement; 221, 222; 222, assignment; 222, 223; 222, 224; 223, identifier:default; 224, attribute; 224, 225; 224, 226; 225, identifier:param; 226, identifier:default; 227, if_statement; 227, 228; 227, 233; 228, comparison_operator:is; 228, 229; 228, 230; 229, identifier:default; 230, attribute; 230, 231; 230, 232; 231, identifier:param; 232, identifier:empty; 233, block; 233, 234; 233, 254; 233, 265; 234, if_statement; 234, 235; 234, 237; 235, not_operator; 235, 236; 236, identifier:short_option; 237, block; 237, 238; 237, 247; 238, expression_statement; 238, 239; 239, assignment; 239, 240; 239, 241; 240, identifier:short_option; 241, call; 241, 242; 241, 243; 242, identifier:get_short_option; 243, argument_list; 243, 244; 243, 245; 243, 246; 244, identifier:name; 245, identifier:names; 246, identifier:used_short_options; 247, expression_statement; 247, 248; 248, call; 248, 249; 248, 252; 249, attribute; 249, 250; 249, 251; 250, identifier:used_short_options; 251, identifier:add; 252, argument_list; 252, 253; 253, identifier:short_option; 254, if_statement; 254, 255; 254, 257; 255, not_operator; 255, 256; 256, identifier:long_option; 257, block; 257, 258; 258, expression_statement; 258, 259; 259, assignment; 259, 260; 259, 261; 260, identifier:long_option; 261, call; 261, 262; 261, 263; 262, identifier:get_long_option; 263, argument_list; 263, 264; 264, identifier:name; 265, if_statement; 265, 266; 265, 268; 266, not_operator; 266, 267; 267, identifier:inverse_option; 268, block; 268, 269; 269, expression_statement; 269, 270; 270, assignment; 270, 271; 270, 272; 271, identifier:inverse_option; 272, call; 272, 273; 272, 274; 273, identifier:get_inverse_option; 274, argument_list; 274, 275; 275, identifier:long_option; 276, expression_statement; 276, 277; 277, assignment; 277, 278; 277, 281; 278, subscript; 278, 279; 278, 280; 279, identifier:args; 280, identifier:name; 281, call; 281, 282; 281, 283; 282, identifier:Arg; 283, argument_list; 283, 284; 283, 287; 283, 290; 283, 293; 283, 296; 283, 299; 283, 302; 283, 305; 283, 308; 283, 311; 283, 314; 283, 317; 283, 320; 283, 323; 284, keyword_argument; 284, 285; 284, 286; 285, identifier:command; 286, identifier:self; 287, keyword_argument; 287, 288; 287, 289; 288, identifier:parameter; 289, identifier:param; 290, keyword_argument; 290, 291; 290, 292; 291, identifier:name; 292, identifier:name; 293, keyword_argument; 293, 294; 293, 295; 294, identifier:container; 295, identifier:container; 296, keyword_argument; 296, 297; 296, 298; 297, identifier:type; 298, identifier:type; 299, keyword_argument; 299, 300; 299, 301; 300, identifier:default; 301, identifier:default; 302, keyword_argument; 302, 303; 302, 304; 303, identifier:choices; 304, identifier:choices; 305, keyword_argument; 305, 306; 305, 307; 306, identifier:help; 307, identifier:help; 308, keyword_argument; 308, 309; 308, 310; 309, identifier:inverse_help; 310, identifier:inverse_help; 311, keyword_argument; 311, 312; 311, 313; 312, identifier:short_option; 313, identifier:short_option; 314, keyword_argument; 314, 315; 314, 316; 315, identifier:long_option; 316, identifier:long_option; 317, keyword_argument; 317, 318; 317, 319; 318, identifier:inverse_option; 319, identifier:inverse_option; 320, keyword_argument; 320, 321; 320, 322; 321, identifier:action; 322, identifier:action; 323, keyword_argument; 323, 324; 323, 325; 324, identifier:nargs; 325, identifier:nargs; 326, expression_statement; 326, 327; 327, assignment; 327, 328; 327, 329; 328, identifier:option_map; 329, call; 329, 330; 329, 331; 330, identifier:OrderedDict; 331, argument_list; 332, for_statement; 332, 333; 332, 334; 332, 339; 333, identifier:arg; 334, call; 334, 335; 334, 338; 335, attribute; 335, 336; 335, 337; 336, identifier:args; 337, identifier:values; 338, argument_list; 339, block; 339, 340; 340, for_statement; 340, 341; 340, 342; 340, 345; 341, identifier:option; 342, attribute; 342, 343; 342, 344; 343, identifier:arg; 344, identifier:options; 345, block; 345, 346; 345, 354; 346, expression_statement; 346, 347; 347, call; 347, 348; 347, 351; 348, attribute; 348, 349; 348, 350; 349, identifier:option_map; 350, identifier:setdefault; 351, argument_list; 351, 352; 351, 353; 352, identifier:option; 353, list:[]; 354, expression_statement; 354, 355; 355, call; 355, 356; 355, 361; 356, attribute; 356, 357; 356, 360; 357, subscript; 357, 358; 357, 359; 358, identifier:option_map; 359, identifier:option; 360, identifier:append; 361, argument_list; 361, 362; 362, identifier:arg; 363, for_statement; 363, 364; 363, 367; 363, 372; 364, pattern_list; 364, 365; 364, 366; 365, identifier:option; 366, identifier:option_args; 367, call; 367, 368; 367, 371; 368, attribute; 368, 369; 368, 370; 369, identifier:option_map; 370, identifier:items; 371, argument_list; 372, block; 372, 373; 373, if_statement; 373, 374; 373, 380; 374, comparison_operator:>; 374, 375; 374, 379; 375, call; 375, 376; 375, 377; 376, identifier:len; 377, argument_list; 377, 378; 378, identifier:option_args; 379, integer:1; 380, block; 380, 381; 380, 397; 380, 402; 380, 413; 381, expression_statement; 381, 382; 382, assignment; 382, 383; 382, 384; 383, identifier:names; 384, call; 384, 385; 384, 388; 385, attribute; 385, 386; 385, 387; 386, string:', '; 387, identifier:join; 388, generator_expression; 388, 389; 388, 394; 389, attribute; 389, 390; 389, 393; 390, attribute; 390, 391; 390, 392; 391, identifier:a; 392, identifier:parameter; 393, identifier:name; 394, for_in_clause; 394, 395; 394, 396; 395, identifier:a; 396, identifier:option_args; 397, expression_statement; 397, 398; 398, assignment; 398, 399; 398, 400; 399, identifier:message; 400, parenthesized_expression; 400, 401; 401, string:'Option {option} of command {self.name} maps to multiple parameters: {names}'; 402, expression_statement; 402, 403; 403, assignment; 403, 404; 403, 405; 404, identifier:message; 405, call; 405, 406; 405, 409; 406, attribute; 406, 407; 406, 408; 407, identifier:message; 408, identifier:format_map; 409, argument_list; 409, 410; 410, call; 410, 411; 410, 412; 411, identifier:locals; 412, argument_list; 413, raise_statement; 413, 414; 414, call; 414, 415; 414, 416; 415, identifier:CommandError; 416, argument_list; 416, 417; 417, identifier:message; 418, return_statement; 418, 419; 419, identifier:args
def args(self): params = self.parameters args = OrderedDict() args['help'] = HelpArg(command=self) normalize_name = self.normalize_name get_arg_config = self.get_arg_config get_short_option = self.get_short_option_for_arg get_long_option = self.get_long_option_for_arg get_inverse_option = self.get_inverse_option_for_arg names = {normalize_name(name) for name in params} used_short_options = set() for param in params.values(): annotation = get_arg_config(param) short_option = annotation.short_option if short_option: used_short_options.add(short_option) for name, param in params.items(): name = normalize_name(name) skip = ( name.startswith('_') or param.kind is param.VAR_KEYWORD or param.kind is param.KEYWORD_ONLY) if skip: continue annotation = get_arg_config(param) container = annotation.container type = annotation.type choices = annotation.choices help = annotation.help inverse_help = annotation.inverse_help short_option = annotation.short_option long_option = annotation.long_option inverse_option = annotation.inverse_option action = annotation.action nargs = annotation.nargs default = param.default if default is not param.empty: if not short_option: short_option = get_short_option(name, names, used_short_options) used_short_options.add(short_option) if not long_option: long_option = get_long_option(name) if not inverse_option: inverse_option = get_inverse_option(long_option) args[name] = Arg( command=self, parameter=param, name=name, container=container, type=type, default=default, choices=choices, help=help, inverse_help=inverse_help, short_option=short_option, long_option=long_option, inverse_option=inverse_option, action=action, nargs=nargs, ) option_map = OrderedDict() for arg in args.values(): for option in arg.options: option_map.setdefault(option, []) option_map[option].append(arg) for option, option_args in option_map.items(): if len(option_args) > 1: names = ', '.join(a.parameter.name for a in option_args) message = ( 'Option {option} of command {self.name} maps to multiple parameters: {names}') message = message.format_map(locals()) raise CommandError(message) return args
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:epcr_threads; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:formattedprimers; 6, default_parameter; 6, 7; 6, 8; 7, identifier:ampliconsize; 8, integer:10000; 9, block; 9, 10; 9, 52; 9, 59; 9, 294; 10, for_statement; 10, 11; 10, 12; 10, 15; 11, identifier:sample; 12, attribute; 12, 13; 12, 14; 13, identifier:self; 14, identifier:metadata; 15, block; 15, 16; 16, if_statement; 16, 17; 16, 24; 17, comparison_operator:!=; 17, 18; 17, 23; 18, attribute; 18, 19; 18, 22; 19, attribute; 19, 20; 19, 21; 20, identifier:sample; 21, identifier:general; 22, identifier:bestassemblyfile; 23, string:'NA'; 24, block; 24, 25; 24, 39; 24, 46; 25, expression_statement; 25, 26; 26, assignment; 26, 27; 26, 28; 27, identifier:threads; 28, call; 28, 29; 28, 30; 29, identifier:Thread; 30, argument_list; 30, 31; 30, 36; 31, keyword_argument; 31, 32; 31, 33; 32, identifier:target; 33, attribute; 33, 34; 33, 35; 34, identifier:self; 35, identifier:epcr; 36, keyword_argument; 36, 37; 36, 38; 37, identifier:args; 38, tuple; 39, expression_statement; 39, 40; 40, call; 40, 41; 40, 44; 41, attribute; 41, 42; 41, 43; 42, identifier:threads; 43, identifier:setDaemon; 44, argument_list; 44, 45; 45, True; 46, expression_statement; 46, 47; 47, call; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, identifier:threads; 50, identifier:start; 51, argument_list; 52, expression_statement; 52, 53; 53, call; 53, 54; 53, 57; 54, attribute; 54, 55; 54, 56; 55, identifier:logging; 56, identifier:info; 57, argument_list; 57, 58; 58, string:'Running ePCR analyses'; 59, for_statement; 59, 60; 59, 61; 59, 64; 60, identifier:sample; 61, attribute; 61, 62; 61, 63; 62, identifier:self; 63, identifier:metadata; 64, block; 64, 65; 65, if_statement; 65, 66; 65, 73; 66, comparison_operator:!=; 66, 67; 66, 72; 67, attribute; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, identifier:sample; 70, identifier:general; 71, identifier:bestassemblyfile; 72, string:'NA'; 73, block; 73, 74; 73, 85; 73, 95; 73, 119; 73, 130; 73, 150; 73, 187; 73, 217; 73, 266; 73, 283; 74, expression_statement; 74, 75; 75, call; 75, 76; 75, 77; 76, identifier:setattr; 77, argument_list; 77, 78; 77, 79; 77, 82; 78, identifier:sample; 79, attribute; 79, 80; 79, 81; 80, identifier:self; 81, identifier:analysistype; 82, call; 82, 83; 82, 84; 83, identifier:GenObject; 84, argument_list; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 94; 87, attribute; 87, 88; 87, 93; 88, subscript; 88, 89; 88, 90; 89, identifier:sample; 90, attribute; 90, 91; 90, 92; 91, identifier:self; 92, identifier:analysistype; 93, identifier:primers; 94, identifier:formattedprimers; 95, expression_statement; 95, 96; 96, assignment; 96, 97; 96, 104; 97, attribute; 97, 98; 97, 103; 98, subscript; 98, 99; 98, 100; 99, identifier:sample; 100, attribute; 100, 101; 100, 102; 101, identifier:self; 102, identifier:analysistype; 103, identifier:reportdir; 104, call; 104, 105; 104, 110; 105, attribute; 105, 106; 105, 109; 106, attribute; 106, 107; 106, 108; 107, identifier:os; 108, identifier:path; 109, identifier:join; 110, argument_list; 110, 111; 110, 116; 111, attribute; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, identifier:sample; 114, identifier:general; 115, identifier:outputdirectory; 116, attribute; 116, 117; 116, 118; 117, identifier:self; 118, identifier:analysistype; 119, expression_statement; 119, 120; 120, call; 120, 121; 120, 122; 121, identifier:make_path; 122, argument_list; 122, 123; 123, attribute; 123, 124; 123, 129; 124, subscript; 124, 125; 124, 126; 125, identifier:sample; 126, attribute; 126, 127; 126, 128; 127, identifier:self; 128, identifier:analysistype; 129, identifier:reportdir; 130, expression_statement; 130, 131; 131, assignment; 131, 132; 131, 133; 132, identifier:outfile; 133, call; 133, 134; 133, 139; 134, attribute; 134, 135; 134, 138; 135, attribute; 135, 136; 135, 137; 136, identifier:os; 137, identifier:path; 138, identifier:join; 139, argument_list; 139, 140; 139, 147; 140, attribute; 140, 141; 140, 146; 141, subscript; 141, 142; 141, 143; 142, identifier:sample; 143, attribute; 143, 144; 143, 145; 144, identifier:self; 145, identifier:analysistype; 146, identifier:reportdir; 147, attribute; 147, 148; 147, 149; 148, identifier:sample; 149, identifier:name; 150, expression_statement; 150, 151; 151, assignment; 151, 152; 151, 157; 152, attribute; 152, 153; 152, 156; 153, attribute; 153, 154; 153, 155; 154, identifier:sample; 155, identifier:commands; 156, identifier:famap; 157, call; 157, 158; 157, 162; 158, attribute; 158, 159; 158, 160; 158, 161; 159, string:'{famap} -b {outfile}.famap {fasta}'; 160, line_continuation:\; 161, identifier:format; 162, argument_list; 162, 163; 162, 177; 162, 180; 163, keyword_argument; 163, 164; 163, 165; 164, identifier:famap; 165, call; 165, 166; 165, 171; 166, attribute; 166, 167; 166, 170; 167, attribute; 167, 168; 167, 169; 168, identifier:os; 169, identifier:path; 170, identifier:join; 171, argument_list; 171, 172; 171, 175; 171, 176; 172, attribute; 172, 173; 172, 174; 173, identifier:self; 174, identifier:homepath; 175, string:'ePCR'; 176, string:'famap'; 177, keyword_argument; 177, 178; 177, 179; 178, identifier:outfile; 179, identifier:outfile; 180, keyword_argument; 180, 181; 180, 182; 181, identifier:fasta; 182, attribute; 182, 183; 182, 186; 183, attribute; 183, 184; 183, 185; 184, identifier:sample; 185, identifier:general; 186, identifier:bestassemblyfile; 187, expression_statement; 187, 188; 188, assignment; 188, 189; 188, 194; 189, attribute; 189, 190; 189, 193; 190, attribute; 190, 191; 190, 192; 191, identifier:sample; 192, identifier:commands; 193, identifier:fahash; 194, call; 194, 195; 194, 199; 195, attribute; 195, 196; 195, 197; 195, 198; 196, string:'{fahash} -b {outfile}.hash {outfile}.famap'; 197, line_continuation:\; 198, identifier:format; 199, argument_list; 199, 200; 199, 214; 200, keyword_argument; 200, 201; 200, 202; 201, identifier:fahash; 202, call; 202, 203; 202, 208; 203, attribute; 203, 204; 203, 207; 204, attribute; 204, 205; 204, 206; 205, identifier:os; 206, identifier:path; 207, identifier:join; 208, argument_list; 208, 209; 208, 212; 208, 213; 209, attribute; 209, 210; 209, 211; 210, identifier:self; 211, identifier:homepath; 212, string:'ePCR'; 213, string:'fahash'; 214, keyword_argument; 214, 215; 214, 216; 215, identifier:outfile; 216, identifier:outfile; 217, expression_statement; 217, 218; 218, assignment; 218, 219; 218, 224; 219, attribute; 219, 220; 219, 223; 220, attribute; 220, 221; 220, 222; 221, identifier:sample; 222, identifier:commands; 223, identifier:epcr; 224, call; 224, 225; 224, 231; 225, attribute; 225, 226; 225, 229; 225, 230; 226, concatenated_string; 226, 227; 226, 228; 227, string:'{rePCR} -S {outfile}.hash -r + -d 1-{ampsize} -n {mismatches} -g 0 -G -q '; 228, string:'-o {outfile}.txt {primers}'; 229, line_continuation:\; 230, identifier:format; 231, argument_list; 231, 232; 231, 246; 231, 249; 231, 252; 231, 257; 232, keyword_argument; 232, 233; 232, 234; 233, identifier:rePCR; 234, call; 234, 235; 234, 240; 235, attribute; 235, 236; 235, 239; 236, attribute; 236, 237; 236, 238; 237, identifier:os; 238, identifier:path; 239, identifier:join; 240, argument_list; 240, 241; 240, 244; 240, 245; 241, attribute; 241, 242; 241, 243; 242, identifier:self; 243, identifier:homepath; 244, string:'ePCR'; 245, string:'re-PCR'; 246, keyword_argument; 246, 247; 246, 248; 247, identifier:outfile; 248, identifier:outfile; 249, keyword_argument; 249, 250; 249, 251; 250, identifier:ampsize; 251, identifier:ampliconsize; 252, keyword_argument; 252, 253; 252, 254; 253, identifier:mismatches; 254, attribute; 254, 255; 254, 256; 255, identifier:self; 256, identifier:mismatches; 257, keyword_argument; 257, 258; 257, 259; 258, identifier:primers; 259, attribute; 259, 260; 259, 265; 260, subscript; 260, 261; 260, 262; 261, identifier:sample; 262, attribute; 262, 263; 262, 264; 263, identifier:self; 264, identifier:analysistype; 265, identifier:primers; 266, expression_statement; 266, 267; 267, assignment; 267, 268; 267, 275; 268, attribute; 268, 269; 268, 274; 269, subscript; 269, 270; 269, 271; 270, identifier:sample; 271, attribute; 271, 272; 271, 273; 272, identifier:self; 273, identifier:analysistype; 274, identifier:resultsfile; 275, call; 275, 276; 275, 279; 276, attribute; 276, 277; 276, 278; 277, string:'{of}.txt'; 278, identifier:format; 279, argument_list; 279, 280; 280, keyword_argument; 280, 281; 280, 282; 281, identifier:of; 282, identifier:outfile; 283, expression_statement; 283, 284; 284, call; 284, 285; 284, 290; 285, attribute; 285, 286; 285, 289; 286, attribute; 286, 287; 286, 288; 287, identifier:self; 288, identifier:epcrqueue; 289, identifier:put; 290, argument_list; 290, 291; 291, tuple; 291, 292; 291, 293; 292, identifier:sample; 293, identifier:outfile; 294, expression_statement; 294, 295; 295, call; 295, 296; 295, 301; 296, attribute; 296, 297; 296, 300; 297, attribute; 297, 298; 297, 299; 298, identifier:self; 299, identifier:epcrqueue; 300, identifier:join; 301, argument_list
def epcr_threads(self, formattedprimers, ampliconsize=10000): for sample in self.metadata: if sample.general.bestassemblyfile != 'NA': threads = Thread(target=self.epcr, args=()) threads.setDaemon(True) threads.start() logging.info('Running ePCR analyses') for sample in self.metadata: if sample.general.bestassemblyfile != 'NA': setattr(sample, self.analysistype, GenObject()) sample[self.analysistype].primers = formattedprimers sample[self.analysistype].reportdir = os.path.join(sample.general.outputdirectory, self.analysistype) make_path(sample[self.analysistype].reportdir) outfile = os.path.join(sample[self.analysistype].reportdir, sample.name) sample.commands.famap = '{famap} -b {outfile}.famap {fasta}'\ .format(famap=os.path.join(self.homepath, 'ePCR', 'famap'), outfile=outfile, fasta=sample.general.bestassemblyfile) sample.commands.fahash = '{fahash} -b {outfile}.hash {outfile}.famap'\ .format(fahash=os.path.join(self.homepath, 'ePCR', 'fahash'), outfile=outfile) sample.commands.epcr = \ '{rePCR} -S {outfile}.hash -r + -d 1-{ampsize} -n {mismatches} -g 0 -G -q ' \ '-o {outfile}.txt {primers}'\ .format(rePCR=os.path.join(self.homepath, 'ePCR', 're-PCR'), outfile=outfile, ampsize=ampliconsize, mismatches=self.mismatches, primers=sample[self.analysistype].primers) sample[self.analysistype].resultsfile = '{of}.txt'.format(of=outfile) self.epcrqueue.put((sample, outfile)) self.epcrqueue.join()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:aggregate; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, for_statement; 6, 7; 6, 8; 6, 11; 7, identifier:report; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:reportset; 11, block; 11, 12; 11, 32; 11, 41; 11, 45; 12, expression_statement; 12, 13; 13, call; 13, 14; 13, 15; 14, identifier:printtime; 15, argument_list; 15, 16; 15, 29; 16, call; 16, 17; 16, 20; 17, attribute; 17, 18; 17, 19; 18, string:'Processing {}'; 19, identifier:format; 20, argument_list; 20, 21; 21, subscript; 21, 22; 21, 28; 22, call; 22, 23; 22, 26; 23, attribute; 23, 24; 23, 25; 24, identifier:report; 25, identifier:split; 26, argument_list; 26, 27; 27, string:'.'; 28, integer:0; 29, attribute; 29, 30; 29, 31; 30, identifier:self; 31, identifier:start; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 35; 34, identifier:header; 35, conditional_expression:if; 35, 36; 35, 37; 35, 40; 36, string:''; 37, comparison_operator:!=; 37, 38; 37, 39; 38, identifier:report; 39, string:'mlst.csv'; 40, string:'Strain,Genus,SequenceType,Matches,1,2,3,4,5,6,7\n'; 41, expression_statement; 41, 42; 42, assignment; 42, 43; 42, 44; 43, identifier:data; 44, string:''; 45, with_statement; 45, 46; 45, 66; 46, with_clause; 46, 47; 47, with_item; 47, 48; 48, as_pattern; 48, 49; 48, 64; 49, call; 49, 50; 49, 51; 50, identifier:open; 51, argument_list; 51, 52; 51, 63; 52, call; 52, 53; 52, 58; 53, attribute; 53, 54; 53, 57; 54, attribute; 54, 55; 54, 56; 55, identifier:os; 56, identifier:path; 57, identifier:join; 58, argument_list; 58, 59; 58, 62; 59, attribute; 59, 60; 59, 61; 60, identifier:self; 61, identifier:reportpath; 62, identifier:report; 63, string:'w'; 64, as_pattern_target; 64, 65; 65, identifier:aggregate; 66, block; 66, 67; 66, 159; 66, 166; 67, for_statement; 67, 68; 67, 69; 67, 74; 68, identifier:sample; 69, attribute; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:self; 72, identifier:runmetadata; 73, identifier:samples; 74, block; 74, 75; 75, try_statement; 75, 76; 75, 155; 76, block; 76, 77; 77, with_statement; 77, 78; 77, 100; 78, with_clause; 78, 79; 79, with_item; 79, 80; 80, as_pattern; 80, 81; 80, 98; 81, call; 81, 82; 81, 83; 82, identifier:open; 83, argument_list; 83, 84; 83, 97; 84, call; 84, 85; 84, 90; 85, attribute; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:os; 88, identifier:path; 89, identifier:join; 90, argument_list; 90, 91; 90, 96; 91, attribute; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:sample; 94, identifier:general; 95, identifier:reportpath; 96, identifier:report; 97, string:'r'; 98, as_pattern_target; 98, 99; 99, identifier:runreport; 100, block; 100, 101; 101, if_statement; 101, 102; 101, 104; 101, 113; 102, not_operator; 102, 103; 103, identifier:header; 104, block; 104, 105; 105, expression_statement; 105, 106; 106, assignment; 106, 107; 106, 108; 107, identifier:header; 108, call; 108, 109; 108, 112; 109, attribute; 109, 110; 109, 111; 110, identifier:runreport; 111, identifier:readline; 112, argument_list; 113, else_clause; 113, 114; 114, block; 114, 115; 115, for_statement; 115, 116; 115, 117; 115, 118; 116, identifier:row; 117, identifier:runreport; 118, block; 118, 119; 118, 132; 119, if_statement; 119, 120; 119, 127; 120, not_operator; 120, 121; 121, call; 121, 122; 121, 125; 122, attribute; 122, 123; 122, 124; 123, identifier:row; 124, identifier:endswith; 125, argument_list; 125, 126; 126, string:'\n'; 127, block; 127, 128; 128, expression_statement; 128, 129; 129, augmented_assignment:+=; 129, 130; 129, 131; 130, identifier:row; 131, string:'\n'; 132, if_statement; 132, 133; 132, 150; 133, comparison_operator:!=; 133, 134; 133, 142; 134, subscript; 134, 135; 134, 141; 135, call; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:row; 138, identifier:split; 139, argument_list; 139, 140; 140, string:','; 141, integer:0; 142, subscript; 142, 143; 142, 149; 143, call; 143, 144; 143, 147; 144, attribute; 144, 145; 144, 146; 145, identifier:header; 146, identifier:split; 147, argument_list; 147, 148; 148, string:','; 149, integer:0; 150, block; 150, 151; 151, expression_statement; 151, 152; 152, augmented_assignment:+=; 152, 153; 152, 154; 153, identifier:data; 154, identifier:row; 155, except_clause; 155, 156; 155, 157; 156, identifier:IOError; 157, block; 157, 158; 158, pass_statement; 159, expression_statement; 159, 160; 160, call; 160, 161; 160, 164; 161, attribute; 161, 162; 161, 163; 162, identifier:aggregate; 163, identifier:write; 164, argument_list; 164, 165; 165, identifier:header; 166, expression_statement; 166, 167; 167, call; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, identifier:aggregate; 170, identifier:write; 171, argument_list; 171, 172; 172, identifier:data
def aggregate(self): for report in self.reportset: printtime('Processing {}'.format(report.split('.')[0]), self.start) header = '' if report != 'mlst.csv' else 'Strain,Genus,SequenceType,Matches,1,2,3,4,5,6,7\n' data = '' with open(os.path.join(self.reportpath, report), 'w') as aggregate: for sample in self.runmetadata.samples: try: with open(os.path.join(sample.general.reportpath, report), 'r') as runreport: if not header: header = runreport.readline() else: for row in runreport: if not row.endswith('\n'): row += '\n' if row.split(',')[0] != header.split(',')[0]: data += row except IOError: pass aggregate.write(header) aggregate.write(data)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_parse_sequences; 3, parameters; 3, 4; 3, 5; 4, identifier:ilines; 5, identifier:expect_qlen; 6, block; 6, 7; 7, while_statement; 7, 8; 7, 9; 8, True; 9, block; 9, 10; 9, 17; 9, 33; 9, 57; 9, 74; 9, 101; 9, 116; 9, 127; 9, 138; 9, 174; 9, 210; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12, identifier:first; 13, call; 13, 14; 13, 15; 14, identifier:next; 15, argument_list; 15, 16; 16, identifier:ilines; 17, if_statement; 17, 18; 17, 31; 18, boolean_operator:and; 18, 19; 18, 25; 19, call; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:first; 22, identifier:startswith; 23, argument_list; 23, 24; 24, string:'_'; 25, call; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:first; 28, identifier:endswith; 29, argument_list; 29, 30; 30, string:'].'; 31, block; 31, 32; 32, break_statement; 33, try_statement; 33, 34; 33, 45; 34, block; 34, 35; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 41; 37, pattern_list; 37, 38; 37, 39; 37, 40; 38, identifier:index; 39, identifier:this_len; 40, identifier:query_len; 41, call; 41, 42; 41, 43; 42, identifier:_parse_seq_preheader; 43, argument_list; 43, 44; 44, identifier:first; 45, except_clause; 45, 46; 45, 47; 46, identifier:ValueError; 47, block; 47, 48; 47, 56; 48, expression_statement; 48, 49; 49, call; 49, 50; 49, 53; 50, attribute; 50, 51; 50, 52; 51, identifier:logging; 52, identifier:warn; 53, argument_list; 53, 54; 53, 55; 54, string:'Unparseable line (SKIPPING):\n%s'; 55, identifier:first; 56, continue_statement; 57, expression_statement; 57, 58; 58, assignment; 58, 59; 58, 67; 59, tuple_pattern; 59, 60; 59, 61; 59, 62; 59, 63; 59, 64; 59, 65; 59, 66; 60, identifier:rec_id; 61, identifier:dbxrefs; 62, identifier:headlen; 63, identifier:taillen; 64, identifier:phylum; 65, identifier:taxchar; 66, identifier:description; 67, call; 67, 68; 67, 69; 68, identifier:_parse_seq_header; 69, argument_list; 69, 70; 70, call; 70, 71; 70, 72; 71, identifier:next; 72, argument_list; 72, 73; 73, identifier:ilines; 74, try_statement; 74, 75; 74, 89; 75, block; 75, 76; 76, expression_statement; 76, 77; 77, assignment; 77, 78; 77, 82; 78, pattern_list; 78, 79; 78, 80; 78, 81; 79, identifier:headseq; 80, identifier:molseq; 81, identifier:tailseq; 82, call; 82, 83; 82, 84; 83, identifier:_parse_seq_body; 84, argument_list; 84, 85; 85, call; 85, 86; 85, 87; 86, identifier:next; 87, argument_list; 87, 88; 88, identifier:ilines; 89, except_clause; 89, 90; 89, 91; 90, identifier:ValueError; 91, block; 91, 92; 91, 100; 92, expression_statement; 92, 93; 93, call; 93, 94; 93, 97; 94, attribute; 94, 95; 94, 96; 95, identifier:logging; 96, identifier:warn; 97, argument_list; 97, 98; 97, 99; 98, string:'Unparseable sequence: %s -- SKIPPING'; 99, identifier:rec_id; 100, continue_statement; 101, if_statement; 101, 102; 101, 105; 102, comparison_operator:!=; 102, 103; 102, 104; 103, identifier:expect_qlen; 104, identifier:query_len; 105, block; 105, 106; 106, expression_statement; 106, 107; 107, call; 107, 108; 107, 111; 108, attribute; 108, 109; 108, 110; 109, identifier:logging; 110, identifier:warn; 111, argument_list; 111, 112; 111, 113; 111, 114; 111, 115; 112, string:"Query length in %s given as %d; expected %d"; 113, identifier:rec_id; 114, identifier:query_len; 115, identifier:expect_qlen; 116, if_statement; 116, 117; 116, 122; 117, boolean_operator:and; 117, 118; 117, 120; 118, not_operator; 118, 119; 119, identifier:headseq; 120, not_operator; 120, 121; 121, identifier:headlen; 122, block; 122, 123; 123, expression_statement; 123, 124; 124, assignment; 124, 125; 124, 126; 125, identifier:headlen; 126, integer:0; 127, if_statement; 127, 128; 127, 133; 128, boolean_operator:and; 128, 129; 128, 131; 129, not_operator; 129, 130; 130, identifier:tailseq; 131, not_operator; 131, 132; 132, identifier:taillen; 133, block; 133, 134; 134, expression_statement; 134, 135; 135, assignment; 135, 136; 135, 137; 136, identifier:taillen; 137, integer:0; 138, if_statement; 138, 139; 138, 140; 139, identifier:headseq; 140, block; 140, 141; 141, if_statement; 141, 142; 141, 145; 141, 153; 142, comparison_operator:is; 142, 143; 142, 144; 143, identifier:headlen; 144, None; 145, block; 145, 146; 146, expression_statement; 146, 147; 147, assignment; 147, 148; 147, 149; 148, identifier:headlen; 149, call; 149, 150; 149, 151; 150, identifier:len; 151, argument_list; 151, 152; 152, identifier:headseq; 153, elif_clause; 153, 154; 153, 160; 154, comparison_operator:!=; 154, 155; 154, 156; 155, identifier:headlen; 156, call; 156, 157; 156, 158; 157, identifier:len; 158, argument_list; 158, 159; 159, identifier:headseq; 160, block; 160, 161; 161, expression_statement; 161, 162; 162, call; 162, 163; 162, 166; 163, attribute; 163, 164; 163, 165; 164, identifier:logging; 165, identifier:warn; 166, argument_list; 166, 167; 166, 168; 166, 169; 166, 170; 167, string:"Conflicting head flank lengths in %s: %d, %d"; 168, identifier:rec_id; 169, identifier:headlen; 170, call; 170, 171; 170, 172; 171, identifier:len; 172, argument_list; 172, 173; 173, identifier:headseq; 174, if_statement; 174, 175; 174, 176; 175, identifier:tailseq; 176, block; 176, 177; 177, if_statement; 177, 178; 177, 181; 177, 189; 178, comparison_operator:is; 178, 179; 178, 180; 179, identifier:taillen; 180, None; 181, block; 181, 182; 182, expression_statement; 182, 183; 183, assignment; 183, 184; 183, 185; 184, identifier:taillen; 185, call; 185, 186; 185, 187; 186, identifier:len; 187, argument_list; 187, 188; 188, identifier:tailseq; 189, elif_clause; 189, 190; 189, 196; 190, comparison_operator:!=; 190, 191; 190, 192; 191, identifier:taillen; 192, call; 192, 193; 192, 194; 193, identifier:len; 194, argument_list; 194, 195; 195, identifier:tailseq; 196, block; 196, 197; 197, expression_statement; 197, 198; 198, call; 198, 199; 198, 202; 199, attribute; 199, 200; 199, 201; 200, identifier:logging; 201, identifier:warn; 202, argument_list; 202, 203; 202, 204; 202, 205; 202, 206; 203, string:"Conflicting tail flank lengths in %s: %d, %d"; 204, identifier:rec_id; 205, identifier:taillen; 206, call; 206, 207; 206, 208; 207, identifier:len; 208, argument_list; 208, 209; 209, identifier:tailseq; 210, expression_statement; 210, 211; 211, yield; 211, 212; 212, dictionary; 212, 213; 212, 216; 212, 219; 212, 222; 212, 225; 212, 228; 212, 231; 212, 234; 212, 237; 212, 240; 212, 243; 212, 246; 213, pair; 213, 214; 213, 215; 214, string:'index'; 215, identifier:index; 216, pair; 216, 217; 216, 218; 217, string:'id'; 218, identifier:rec_id; 219, pair; 219, 220; 219, 221; 220, string:'description'; 221, identifier:description; 222, pair; 222, 223; 222, 224; 223, string:'dbxrefs'; 224, identifier:dbxrefs; 225, pair; 225, 226; 225, 227; 226, string:'phylum'; 227, identifier:phylum; 228, pair; 228, 229; 228, 230; 229, string:'taxchar'; 230, identifier:taxchar; 231, pair; 231, 232; 231, 233; 232, string:'head_len'; 233, identifier:headlen; 234, pair; 234, 235; 234, 236; 235, string:'tail_len'; 236, identifier:taillen; 237, pair; 237, 238; 237, 239; 238, string:'head_seq'; 239, identifier:headseq; 240, pair; 240, 241; 240, 242; 241, string:'tail_seq'; 242, identifier:tailseq; 243, pair; 243, 244; 243, 245; 244, string:'length'; 245, identifier:this_len; 246, pair; 246, 247; 246, 248; 247, string:'seq'; 248, identifier:molseq
def _parse_sequences(ilines, expect_qlen): while True: first = next(ilines) if first.startswith('_') and first.endswith('].'): break try: index, this_len, query_len = _parse_seq_preheader(first) except ValueError: logging.warn('Unparseable line (SKIPPING):\n%s', first) continue (rec_id, dbxrefs, headlen, taillen, phylum, taxchar, description ) = _parse_seq_header(next(ilines)) try: headseq, molseq, tailseq = _parse_seq_body(next(ilines)) except ValueError: logging.warn('Unparseable sequence: %s -- SKIPPING', rec_id) continue if expect_qlen != query_len: logging.warn("Query length in %s given as %d; expected %d", rec_id, query_len, expect_qlen) if not headseq and not headlen: headlen = 0 if not tailseq and not taillen: taillen = 0 if headseq: if headlen is None: headlen = len(headseq) elif headlen != len(headseq): logging.warn("Conflicting head flank lengths in %s: %d, %d", rec_id, headlen, len(headseq)) if tailseq: if taillen is None: taillen = len(tailseq) elif taillen != len(tailseq): logging.warn("Conflicting tail flank lengths in %s: %d, %d", rec_id, taillen, len(tailseq)) yield {'index': index, 'id': rec_id, 'description': description, 'dbxrefs': dbxrefs, 'phylum': phylum, 'taxchar': taxchar, 'head_len': headlen, 'tail_len': taillen, 'head_seq': headseq, 'tail_seq': tailseq, 'length': this_len, 'seq': molseq, }
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:realign_seqs; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:block; 5, default_parameter; 5, 6; 5, 7; 6, identifier:gap_char; 7, string:'.'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:align_indels; 10, False; 11, block; 11, 12; 11, 27; 11, 34; 11, 38; 11, 89; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 14, identifier:all_chars; 15, list_comprehension; 15, 16; 15, 22; 16, call; 16, 17; 16, 18; 17, identifier:list; 18, argument_list; 18, 19; 19, subscript; 19, 20; 19, 21; 20, identifier:sq; 21, string:'seq'; 22, for_in_clause; 22, 23; 22, 24; 23, identifier:sq; 24, subscript; 24, 25; 24, 26; 25, identifier:block; 26, string:'sequences'; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:nrows; 30, call; 30, 31; 30, 32; 31, identifier:len; 32, argument_list; 32, 33; 33, identifier:all_chars; 34, expression_statement; 34, 35; 35, assignment; 35, 36; 35, 37; 36, identifier:i; 37, integer:0; 38, while_statement; 38, 39; 38, 47; 39, comparison_operator:<; 39, 40; 39, 41; 40, identifier:i; 41, call; 41, 42; 41, 43; 42, identifier:len; 43, argument_list; 43, 44; 44, subscript; 44, 45; 44, 46; 45, identifier:all_chars; 46, integer:0; 47, block; 47, 48; 47, 65; 47, 85; 48, expression_statement; 48, 49; 49, assignment; 49, 50; 49, 51; 50, identifier:rows_need_gaps; 51, list_comprehension; 51, 52; 51, 53; 51, 56; 52, identifier:r; 53, for_in_clause; 53, 54; 53, 55; 54, identifier:r; 55, identifier:all_chars; 56, if_clause; 56, 57; 57, not_operator; 57, 58; 58, call; 58, 59; 58, 64; 59, attribute; 59, 60; 59, 63; 60, subscript; 60, 61; 60, 62; 61, identifier:r; 62, identifier:i; 63, identifier:islower; 64, argument_list; 65, if_statement; 65, 66; 65, 72; 66, comparison_operator:!=; 66, 67; 66, 71; 67, call; 67, 68; 67, 69; 68, identifier:len; 69, argument_list; 69, 70; 70, identifier:rows_need_gaps; 71, identifier:nrows; 72, block; 72, 73; 73, for_statement; 73, 74; 73, 75; 73, 76; 74, identifier:row; 75, identifier:rows_need_gaps; 76, block; 76, 77; 77, expression_statement; 77, 78; 78, call; 78, 79; 78, 82; 79, attribute; 79, 80; 79, 81; 80, identifier:row; 81, identifier:insert; 82, argument_list; 82, 83; 82, 84; 83, identifier:i; 84, identifier:gap_char; 85, expression_statement; 85, 86; 86, augmented_assignment:+=; 86, 87; 86, 88; 87, identifier:i; 88, integer:1; 89, return_statement; 89, 90; 90, list_comprehension; 90, 91; 90, 97; 91, call; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, string:''; 94, identifier:join; 95, argument_list; 95, 96; 96, identifier:row; 97, for_in_clause; 97, 98; 97, 99; 98, identifier:row; 99, identifier:all_chars
def realign_seqs(block, gap_char='.', align_indels=False): all_chars = [list(sq['seq']) for sq in block['sequences']] nrows = len(all_chars) i = 0 while i < len(all_chars[0]): rows_need_gaps = [r for r in all_chars if not r[i].islower()] if len(rows_need_gaps) != nrows: for row in rows_need_gaps: row.insert(i, gap_char) i += 1 return [''.join(row) for row in all_chars]
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:collapse_to_consensus; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:seqrecords; 5, default_parameter; 5, 6; 5, 7; 6, identifier:strict; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:do_iron; 10, True; 11, block; 11, 12; 11, 16; 11, 24; 11, 63; 11, 72; 11, 79; 11, 112; 11, 199; 11, 211; 11, 224; 11, 230; 11, 365; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 14, identifier:level; 15, integer:0; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 19; 18, identifier:name; 19, attribute; 19, 20; 19, 23; 20, subscript; 20, 21; 20, 22; 21, identifier:seqrecords; 22, integer:0; 23, identifier:id; 24, if_statement; 24, 25; 24, 30; 25, call; 25, 26; 25, 27; 26, identifier:hasattr; 27, argument_list; 27, 28; 27, 29; 28, identifier:seqrecords; 29, string:'_records'; 30, block; 30, 31; 30, 44; 30, 57; 31, if_statement; 31, 32; 31, 37; 32, call; 32, 33; 32, 34; 33, identifier:hasattr; 34, argument_list; 34, 35; 34, 36; 35, identifier:seqrecords; 36, string:'level'; 37, block; 37, 38; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 41; 40, identifier:level; 41, attribute; 41, 42; 41, 43; 42, identifier:seqrecords; 43, identifier:level; 44, if_statement; 44, 45; 44, 50; 45, call; 45, 46; 45, 47; 46, identifier:hasattr; 47, argument_list; 47, 48; 47, 49; 48, identifier:seqrecords; 49, string:'name'; 50, block; 50, 51; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 54; 53, identifier:name; 54, attribute; 54, 55; 54, 56; 55, identifier:seqrecords; 56, identifier:name; 57, expression_statement; 57, 58; 58, assignment; 58, 59; 58, 60; 59, identifier:seqrecords; 60, attribute; 60, 61; 60, 62; 61, identifier:seqrecords; 62, identifier:_records; 63, expression_statement; 63, 64; 64, assignment; 64, 65; 64, 66; 65, identifier:consensus; 66, call; 66, 67; 66, 70; 67, attribute; 67, 68; 67, 69; 68, identifier:seqrecords; 69, identifier:pop; 70, argument_list; 70, 71; 71, integer:0; 72, expression_statement; 72, 73; 73, assignment; 73, 74; 73, 75; 74, identifier:cons_length; 75, call; 75, 76; 75, 77; 76, identifier:len; 77, argument_list; 77, 78; 78, identifier:consensus; 79, for_statement; 79, 80; 79, 83; 79, 87; 80, pattern_list; 80, 81; 80, 82; 81, identifier:i; 82, identifier:s; 83, call; 83, 84; 83, 85; 84, identifier:enumerate; 85, argument_list; 85, 86; 86, identifier:seqrecords; 87, block; 87, 88; 88, if_statement; 88, 89; 88, 95; 89, comparison_operator:!=; 89, 90; 89, 94; 90, call; 90, 91; 90, 92; 91, identifier:len; 92, argument_list; 92, 93; 93, identifier:s; 94, identifier:cons_length; 95, block; 95, 96; 96, raise_statement; 96, 97; 97, call; 97, 98; 97, 99; 98, identifier:ValueError; 99, argument_list; 99, 100; 99, 101; 100, ERROR; 101, binary_operator:%; 101, 102; 101, 103; 102, identifier:Sequence; 103, tuple; 103, 104; 103, 107; 103, 111; 104, binary_operator:+; 104, 105; 104, 106; 105, identifier:i; 106, integer:2; 107, call; 107, 108; 107, 109; 108, identifier:len; 109, argument_list; 109, 110; 110, identifier:s; 111, identifier:cons_length; 112, if_statement; 112, 113; 112, 121; 112, 182; 113, comparison_operator:in; 113, 114; 113, 115; 114, string:'.'; 115, call; 115, 116; 115, 117; 116, identifier:str; 117, argument_list; 117, 118; 118, attribute; 118, 119; 118, 120; 119, identifier:consensus; 120, identifier:seq; 121, block; 121, 122; 122, if_statement; 122, 123; 122, 131; 122, 165; 123, comparison_operator:in; 123, 124; 123, 125; 124, string:'-'; 125, call; 125, 126; 125, 127; 126, identifier:str; 127, argument_list; 127, 128; 128, attribute; 128, 129; 128, 130; 129, identifier:consensus; 130, identifier:seq; 131, block; 131, 132; 131, 140; 131, 149; 132, if_statement; 132, 133; 132, 134; 133, identifier:strict; 134, block; 134, 135; 135, raise_statement; 135, 136; 136, call; 136, 137; 136, 138; 137, identifier:ValueError; 138, argument_list; 138, 139; 139, string:"Consensus contains '-' gap characters"; 140, expression_statement; 140, 141; 141, call; 141, 142; 141, 145; 142, attribute; 142, 143; 142, 144; 143, identifier:logging; 144, identifier:warn; 145, argument_list; 145, 146; 146, concatenated_string; 146, 147; 146, 148; 147, string:"Consensus sequence contains both '.' and '-' gap "; 148, string:"characters -- is it really the consensus?"; 149, expression_statement; 149, 150; 150, assignment; 150, 151; 150, 152; 151, identifier:aligned_cols; 152, list_comprehension; 152, 153; 152, 157; 153, parenthesized_expression; 153, 154; 154, comparison_operator:not; 154, 155; 154, 156; 155, identifier:c; 156, string:'.-'; 157, for_in_clause; 157, 158; 157, 159; 158, identifier:c; 159, call; 159, 160; 159, 161; 160, identifier:str; 161, argument_list; 161, 162; 162, attribute; 162, 163; 162, 164; 163, identifier:consensus; 164, identifier:seq; 165, else_clause; 165, 166; 166, block; 166, 167; 167, expression_statement; 167, 168; 168, assignment; 168, 169; 168, 170; 169, identifier:aligned_cols; 170, list_comprehension; 170, 171; 170, 174; 171, comparison_operator:!=; 171, 172; 171, 173; 172, identifier:c; 173, string:'.'; 174, for_in_clause; 174, 175; 174, 176; 175, identifier:c; 176, call; 176, 177; 176, 178; 177, identifier:str; 178, argument_list; 178, 179; 179, attribute; 179, 180; 179, 181; 180, identifier:consensus; 181, identifier:seq; 182, else_clause; 182, 183; 183, block; 183, 184; 184, expression_statement; 184, 185; 185, assignment; 185, 186; 185, 187; 186, identifier:aligned_cols; 187, list_comprehension; 187, 188; 187, 191; 188, comparison_operator:!=; 188, 189; 188, 190; 189, identifier:c; 190, string:'-'; 191, for_in_clause; 191, 192; 191, 193; 192, identifier:c; 193, call; 193, 194; 193, 195; 194, identifier:str; 195, argument_list; 195, 196; 196, attribute; 196, 197; 196, 198; 197, identifier:consensus; 198, identifier:seq; 199, expression_statement; 199, 200; 200, assignment; 200, 201; 200, 204; 201, attribute; 201, 202; 201, 203; 202, identifier:consensus; 203, identifier:seq; 204, call; 204, 205; 204, 206; 205, identifier:replace_asterisks; 206, argument_list; 206, 207; 206, 210; 207, attribute; 207, 208; 207, 209; 208, identifier:consensus; 209, identifier:seq; 210, string:'consensus'; 211, expression_statement; 211, 212; 212, assignment; 212, 213; 212, 214; 213, identifier:block; 214, call; 214, 215; 214, 216; 215, identifier:consensus2block; 216, argument_list; 216, 217; 216, 218; 216, 221; 217, identifier:consensus; 218, keyword_argument; 218, 219; 218, 220; 219, identifier:level; 220, identifier:level; 221, keyword_argument; 221, 222; 221, 223; 222, identifier:name; 223, identifier:name; 224, expression_statement; 224, 225; 225, assignment; 225, 226; 225, 227; 226, identifier:qlen; 227, subscript; 227, 228; 227, 229; 228, identifier:block; 229, string:'query_length'; 230, for_statement; 230, 231; 230, 234; 230, 248; 231, pattern_list; 231, 232; 231, 233; 232, identifier:index; 233, identifier:rec; 234, call; 234, 235; 234, 236; 235, identifier:zip; 236, argument_list; 236, 237; 236, 247; 237, call; 237, 238; 237, 239; 238, identifier:xrange; 239, argument_list; 239, 240; 239, 241; 240, integer:2; 241, binary_operator:+; 241, 242; 241, 246; 242, call; 242, 243; 242, 244; 243, identifier:len; 244, argument_list; 244, 245; 245, identifier:seqrecords; 246, integer:2; 247, identifier:seqrecords; 248, block; 248, 249; 248, 253; 248, 257; 248, 326; 248, 337; 248, 351; 249, expression_statement; 249, 250; 250, assignment; 250, 251; 250, 252; 251, identifier:new_mol_seq; 252, list:[]; 253, expression_statement; 253, 254; 254, assignment; 254, 255; 254, 256; 255, identifier:is_beginning; 256, True; 257, for_statement; 257, 258; 257, 261; 257, 272; 258, pattern_list; 258, 259; 258, 260; 259, identifier:aligned_col; 260, identifier:char; 261, call; 261, 262; 261, 263; 262, identifier:zip; 263, argument_list; 263, 264; 263, 265; 264, identifier:aligned_cols; 265, call; 265, 266; 265, 267; 266, identifier:replace_asterisks; 267, argument_list; 267, 268; 267, 271; 268, attribute; 268, 269; 268, 270; 269, identifier:rec; 270, identifier:seq; 271, identifier:index; 272, block; 272, 273; 273, if_statement; 273, 274; 273, 275; 273, 305; 274, identifier:aligned_col; 275, block; 275, 276; 275, 280; 276, expression_statement; 276, 277; 277, assignment; 277, 278; 277, 279; 278, identifier:is_beginning; 279, False; 280, if_statement; 280, 281; 280, 284; 280, 292; 281, comparison_operator:in; 281, 282; 281, 283; 282, identifier:char; 283, string:'-.'; 284, block; 284, 285; 285, expression_statement; 285, 286; 286, call; 286, 287; 286, 290; 287, attribute; 287, 288; 287, 289; 288, identifier:new_mol_seq; 289, identifier:append; 290, argument_list; 290, 291; 291, string:'-'; 292, else_clause; 292, 293; 293, block; 293, 294; 294, expression_statement; 294, 295; 295, call; 295, 296; 295, 299; 296, attribute; 296, 297; 296, 298; 297, identifier:new_mol_seq; 298, identifier:append; 299, argument_list; 299, 300; 300, call; 300, 301; 300, 304; 301, attribute; 301, 302; 301, 303; 302, identifier:char; 303, identifier:upper; 304, argument_list; 305, else_clause; 305, 306; 306, block; 306, 307; 307, if_statement; 307, 308; 307, 314; 308, boolean_operator:and; 308, 309; 308, 312; 309, comparison_operator:not; 309, 310; 309, 311; 310, identifier:char; 311, string:'-.'; 312, not_operator; 312, 313; 313, identifier:is_beginning; 314, block; 314, 315; 315, expression_statement; 315, 316; 316, call; 316, 317; 316, 320; 317, attribute; 317, 318; 317, 319; 318, identifier:new_mol_seq; 319, identifier:append; 320, argument_list; 320, 321; 321, call; 321, 322; 321, 325; 322, attribute; 322, 323; 322, 324; 323, identifier:char; 324, identifier:lower; 325, argument_list; 326, expression_statement; 326, 327; 327, assignment; 327, 328; 327, 331; 328, attribute; 328, 329; 328, 330; 329, identifier:rec; 330, identifier:seq; 331, call; 331, 332; 331, 335; 332, attribute; 332, 333; 332, 334; 333, string:''; 334, identifier:join; 335, argument_list; 335, 336; 336, identifier:new_mol_seq; 337, if_statement; 337, 338; 337, 339; 338, identifier:do_iron; 339, block; 339, 340; 340, expression_statement; 340, 341; 341, assignment; 341, 342; 341, 345; 342, attribute; 342, 343; 342, 344; 343, identifier:rec; 344, identifier:seq; 345, call; 345, 346; 345, 347; 346, identifier:iron; 347, argument_list; 347, 348; 348, attribute; 348, 349; 348, 350; 349, identifier:rec; 350, identifier:seq; 351, expression_statement; 351, 352; 352, call; 352, 353; 352, 358; 353, attribute; 353, 354; 353, 357; 354, subscript; 354, 355; 354, 356; 355, identifier:block; 356, string:'sequences'; 357, identifier:append; 358, argument_list; 358, 359; 359, call; 359, 360; 359, 361; 360, identifier:seqrecord2sequence; 361, argument_list; 361, 362; 361, 363; 361, 364; 362, identifier:rec; 363, identifier:qlen; 364, identifier:index; 365, return_statement; 365, 366; 366, identifier:block
def collapse_to_consensus(seqrecords, strict=False, do_iron=True): level = 0 name = seqrecords[0].id if hasattr(seqrecords, '_records'): if hasattr(seqrecords, 'level'): level = seqrecords.level if hasattr(seqrecords, 'name'): name = seqrecords.name seqrecords = seqrecords._records consensus = seqrecords.pop(0) cons_length = len(consensus) for i, s in enumerate(seqrecords): if len(s) != cons_length: raise ValueError( "Sequence % (i+2, len(s), cons_length)) if '.' in str(consensus.seq): if '-' in str(consensus.seq): if strict: raise ValueError("Consensus contains '-' gap characters") logging.warn("Consensus sequence contains both '.' and '-' gap " "characters -- is it really the consensus?") aligned_cols = [(c not in '.-') for c in str(consensus.seq)] else: aligned_cols = [c != '.' for c in str(consensus.seq)] else: aligned_cols = [c != '-' for c in str(consensus.seq)] consensus.seq = replace_asterisks(consensus.seq, 'consensus') block = consensus2block(consensus, level=level, name=name) qlen = block['query_length'] for index, rec in zip(xrange(2, len(seqrecords)+2), seqrecords): new_mol_seq = [] is_beginning = True for aligned_col, char in zip(aligned_cols, replace_asterisks(rec.seq, index)): if aligned_col: is_beginning = False if char in '-.': new_mol_seq.append('-') else: new_mol_seq.append(char.upper()) else: if char not in '-.' and not is_beginning: new_mol_seq.append(char.lower()) rec.seq = ''.join(new_mol_seq) if do_iron: rec.seq = iron(rec.seq) block['sequences'].append(seqrecord2sequence(rec, qlen, index)) return block
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:iron; 3, parameters; 3, 4; 4, identifier:sequence; 5, block; 5, 6; 5, 15; 5, 19; 5, 389; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:r_indel; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:re; 12, identifier:compile; 13, argument_list; 13, 14; 14, string:r'(-[a-y]|[a-y]-)'; 15, expression_statement; 15, 16; 16, assignment; 16, 17; 16, 18; 17, identifier:orig_sequence; 18, identifier:sequence; 19, while_statement; 19, 20; 19, 26; 20, call; 20, 21; 20, 24; 21, attribute; 21, 22; 21, 23; 22, identifier:r_indel; 23, identifier:search; 24, argument_list; 24, 25; 25, identifier:sequence; 26, block; 26, 27; 26, 31; 26, 35; 26, 39; 26, 43; 26, 47; 26, 326; 26, 336; 26, 348; 26, 357; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:in_insert; 30, False; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 34; 33, identifier:in_gap; 34, False; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 38; 37, identifier:seen_gaps; 38, integer:0; 39, expression_statement; 39, 40; 40, assignment; 40, 41; 40, 42; 41, identifier:inserts; 42, list:[]; 43, expression_statement; 43, 44; 44, assignment; 44, 45; 44, 46; 45, identifier:outchars; 46, list:[]; 47, for_statement; 47, 48; 47, 49; 47, 50; 48, identifier:char; 49, identifier:sequence; 50, block; 50, 51; 51, if_statement; 51, 52; 51, 53; 51, 162; 51, 263; 52, identifier:in_insert; 53, block; 53, 54; 54, if_statement; 54, 55; 54, 60; 54, 68; 54, 110; 55, call; 55, 56; 55, 59; 56, attribute; 56, 57; 56, 58; 57, identifier:char; 58, identifier:islower; 59, argument_list; 60, block; 60, 61; 61, expression_statement; 61, 62; 62, call; 62, 63; 62, 66; 63, attribute; 63, 64; 63, 65; 64, identifier:inserts; 65, identifier:append; 66, argument_list; 66, 67; 67, identifier:char; 68, elif_clause; 68, 69; 68, 74; 69, call; 69, 70; 69, 73; 70, attribute; 70, 71; 70, 72; 71, identifier:char; 72, identifier:isupper; 73, argument_list; 74, block; 74, 75; 74, 79; 74, 86; 74, 90; 74, 99; 74, 103; 75, expression_statement; 75, 76; 76, assignment; 76, 77; 76, 78; 77, identifier:in_insert; 78, False; 79, expression_statement; 79, 80; 80, call; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:outchars; 83, identifier:extend; 84, argument_list; 84, 85; 85, identifier:inserts; 86, expression_statement; 86, 87; 87, assignment; 87, 88; 87, 89; 88, identifier:inserts; 89, list:[]; 90, expression_statement; 90, 91; 91, call; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:outchars; 94, identifier:append; 95, argument_list; 95, 96; 96, binary_operator:*; 96, 97; 96, 98; 97, string:'-'; 98, identifier:seen_gaps; 99, expression_statement; 99, 100; 100, assignment; 100, 101; 100, 102; 101, identifier:seen_gaps; 102, integer:0; 103, expression_statement; 103, 104; 104, call; 104, 105; 104, 108; 105, attribute; 105, 106; 105, 107; 106, identifier:outchars; 107, identifier:append; 108, argument_list; 108, 109; 109, identifier:char; 110, else_clause; 110, 111; 111, block; 111, 112; 111, 116; 112, assert_statement; 112, 113; 113, comparison_operator:==; 113, 114; 113, 115; 114, identifier:char; 115, string:'-'; 116, if_statement; 116, 117; 116, 119; 116, 132; 117, not_operator; 117, 118; 118, identifier:inserts; 119, block; 119, 120; 119, 124; 119, 128; 120, expression_statement; 120, 121; 121, assignment; 121, 122; 121, 123; 122, identifier:in_insert; 123, False; 124, expression_statement; 124, 125; 125, assignment; 125, 126; 125, 127; 126, identifier:in_gap; 127, True; 128, expression_statement; 128, 129; 129, augmented_assignment:+=; 129, 130; 129, 131; 130, identifier:seen_gaps; 131, integer:1; 132, else_clause; 132, 133; 133, block; 133, 134; 133, 150; 134, expression_statement; 134, 135; 135, call; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:outchars; 138, identifier:append; 139, argument_list; 139, 140; 140, call; 140, 141; 140, 149; 141, attribute; 141, 142; 141, 148; 142, call; 142, 143; 142, 146; 143, attribute; 143, 144; 143, 145; 144, identifier:inserts; 145, identifier:pop; 146, argument_list; 146, 147; 147, integer:0; 148, identifier:upper; 149, argument_list; 150, if_statement; 150, 151; 150, 153; 151, not_operator; 151, 152; 152, identifier:inserts; 153, block; 153, 154; 153, 158; 154, expression_statement; 154, 155; 155, assignment; 155, 156; 155, 157; 156, identifier:in_insert; 157, False; 158, expression_statement; 158, 159; 159, assignment; 159, 160; 159, 161; 160, identifier:in_gap; 161, True; 162, elif_clause; 162, 163; 162, 164; 163, identifier:in_gap; 164, block; 164, 165; 165, if_statement; 165, 166; 165, 171; 165, 208; 165, 253; 166, call; 166, 167; 166, 170; 167, attribute; 167, 168; 167, 169; 168, identifier:char; 169, identifier:islower; 170, argument_list; 171, block; 171, 172; 171, 176; 171, 180; 171, 203; 172, expression_statement; 172, 173; 173, assignment; 173, 174; 173, 175; 174, identifier:in_insert; 175, True; 176, expression_statement; 176, 177; 177, assignment; 177, 178; 177, 179; 178, identifier:in_gap; 179, False; 180, if_statement; 180, 181; 180, 182; 181, identifier:inserts; 182, block; 182, 183; 182, 190; 182, 199; 183, expression_statement; 183, 184; 184, call; 184, 185; 184, 188; 185, attribute; 185, 186; 185, 187; 186, identifier:outchars; 187, identifier:extend; 188, argument_list; 188, 189; 189, identifier:inserts; 190, expression_statement; 190, 191; 191, call; 191, 192; 191, 195; 192, attribute; 192, 193; 192, 194; 193, identifier:outchars; 194, identifier:append; 195, argument_list; 195, 196; 196, binary_operator:*; 196, 197; 196, 198; 197, string:'-'; 198, identifier:seen_gaps; 199, expression_statement; 199, 200; 200, assignment; 200, 201; 200, 202; 201, identifier:seen_gaps; 202, integer:0; 203, expression_statement; 203, 204; 204, assignment; 204, 205; 204, 206; 205, identifier:inserts; 206, list:[char]; 206, 207; 207, identifier:char; 208, elif_clause; 208, 209; 208, 214; 209, call; 209, 210; 209, 213; 210, attribute; 210, 211; 210, 212; 211, identifier:char; 212, identifier:isupper; 213, argument_list; 214, block; 214, 215; 214, 219; 214, 233; 214, 242; 214, 246; 215, expression_statement; 215, 216; 216, assignment; 216, 217; 216, 218; 217, identifier:in_gap; 218, False; 219, if_statement; 219, 220; 219, 221; 220, identifier:inserts; 221, block; 221, 222; 221, 229; 222, expression_statement; 222, 223; 223, call; 223, 224; 223, 227; 224, attribute; 224, 225; 224, 226; 225, identifier:outchars; 226, identifier:extend; 227, argument_list; 227, 228; 228, identifier:inserts; 229, expression_statement; 229, 230; 230, assignment; 230, 231; 230, 232; 231, identifier:inserts; 232, list:[]; 233, expression_statement; 233, 234; 234, call; 234, 235; 234, 238; 235, attribute; 235, 236; 235, 237; 236, identifier:outchars; 237, identifier:append; 238, argument_list; 238, 239; 239, binary_operator:*; 239, 240; 239, 241; 240, string:'-'; 241, identifier:seen_gaps; 242, expression_statement; 242, 243; 243, assignment; 243, 244; 243, 245; 244, identifier:seen_gaps; 245, integer:0; 246, expression_statement; 246, 247; 247, call; 247, 248; 247, 251; 248, attribute; 248, 249; 248, 250; 249, identifier:outchars; 250, identifier:append; 251, argument_list; 251, 252; 252, identifier:char; 253, else_clause; 253, 254; 254, block; 254, 255; 254, 259; 255, assert_statement; 255, 256; 256, comparison_operator:==; 256, 257; 256, 258; 257, identifier:char; 258, string:'-'; 259, expression_statement; 259, 260; 260, augmented_assignment:+=; 260, 261; 260, 262; 261, identifier:seen_gaps; 262, integer:1; 263, else_clause; 263, 264; 264, block; 264, 265; 264, 280; 265, assert_statement; 265, 266; 265, 271; 266, boolean_operator:and; 266, 267; 266, 269; 267, not_operator; 267, 268; 268, identifier:inserts; 269, not_operator; 269, 270; 270, identifier:seen_gaps; 271, parenthesized_expression; 271, 272; 272, binary_operator:%; 272, 273; 272, 274; 273, string:"Inserts: %s, gaps: %s, seq: %s, in_ins=%s, in_gap=%s"; 274, tuple; 274, 275; 274, 276; 274, 277; 274, 278; 274, 279; 275, identifier:inserts; 276, identifier:seen_gaps; 277, identifier:sequence; 278, identifier:in_insert; 279, identifier:in_gap; 280, if_statement; 280, 281; 280, 286; 280, 294; 280, 312; 281, call; 281, 282; 281, 285; 282, attribute; 282, 283; 282, 284; 283, identifier:char; 284, identifier:isupper; 285, argument_list; 286, block; 286, 287; 287, expression_statement; 287, 288; 288, call; 288, 289; 288, 292; 289, attribute; 289, 290; 289, 291; 290, identifier:outchars; 291, identifier:append; 292, argument_list; 292, 293; 293, identifier:char; 294, elif_clause; 294, 295; 294, 300; 295, call; 295, 296; 295, 299; 296, attribute; 296, 297; 296, 298; 297, identifier:char; 298, identifier:islower; 299, argument_list; 300, block; 300, 301; 300, 308; 301, expression_statement; 301, 302; 302, call; 302, 303; 302, 306; 303, attribute; 303, 304; 303, 305; 304, identifier:inserts; 305, identifier:append; 306, argument_list; 306, 307; 307, identifier:char; 308, expression_statement; 308, 309; 309, assignment; 309, 310; 309, 311; 310, identifier:in_insert; 311, True; 312, else_clause; 312, 313; 313, block; 313, 314; 313, 318; 313, 322; 314, assert_statement; 314, 315; 315, comparison_operator:==; 315, 316; 315, 317; 316, identifier:char; 317, string:'-'; 318, expression_statement; 318, 319; 319, augmented_assignment:+=; 319, 320; 319, 321; 320, identifier:seen_gaps; 321, integer:1; 322, expression_statement; 322, 323; 323, assignment; 323, 324; 323, 325; 324, identifier:in_gap; 325, True; 326, if_statement; 326, 327; 326, 328; 327, identifier:inserts; 328, block; 328, 329; 329, expression_statement; 329, 330; 330, call; 330, 331; 330, 334; 331, attribute; 331, 332; 331, 333; 332, identifier:outchars; 333, identifier:extend; 334, argument_list; 334, 335; 335, identifier:inserts; 336, if_statement; 336, 337; 336, 338; 337, identifier:seen_gaps; 338, block; 338, 339; 339, expression_statement; 339, 340; 340, call; 340, 341; 340, 344; 341, attribute; 341, 342; 341, 343; 342, identifier:outchars; 343, identifier:append; 344, argument_list; 344, 345; 345, binary_operator:*; 345, 346; 345, 347; 346, string:'-'; 347, identifier:seen_gaps; 348, expression_statement; 348, 349; 349, assignment; 349, 350; 349, 351; 350, identifier:sequence; 351, call; 351, 352; 351, 355; 352, attribute; 352, 353; 352, 354; 353, string:''; 354, identifier:join; 355, argument_list; 355, 356; 356, identifier:outchars; 357, assert_statement; 357, 358; 357, 382; 358, parenthesized_expression; 358, 359; 359, comparison_operator:==; 359, 360; 359, 371; 360, call; 360, 361; 360, 370; 361, attribute; 361, 362; 361, 369; 362, call; 362, 363; 362, 366; 363, attribute; 363, 364; 363, 365; 364, identifier:sequence; 365, identifier:replace; 366, argument_list; 366, 367; 366, 368; 367, string:'-'; 368, string:''; 369, identifier:upper; 370, argument_list; 371, call; 371, 372; 371, 381; 372, attribute; 372, 373; 372, 380; 373, call; 373, 374; 373, 377; 374, attribute; 374, 375; 374, 376; 375, identifier:orig_sequence; 376, identifier:replace; 377, argument_list; 377, 378; 377, 379; 378, string:'-'; 379, string:''; 380, identifier:upper; 381, argument_list; 382, binary_operator:+; 382, 383; 382, 388; 383, binary_operator:+; 383, 384; 383, 387; 384, binary_operator:+; 384, 385; 384, 386; 385, string:'\nOrig: '; 386, identifier:orig_sequence; 387, string:'\nIron: '; 388, identifier:sequence; 389, return_statement; 389, 390; 390, identifier:sequence
def iron(sequence): r_indel = re.compile(r'(-[a-y]|[a-y]-)') orig_sequence = sequence while r_indel.search(sequence): in_insert = False in_gap = False seen_gaps = 0 inserts = [] outchars = [] for char in sequence: if in_insert: if char.islower(): inserts.append(char) elif char.isupper(): in_insert = False outchars.extend(inserts) inserts = [] outchars.append('-' * seen_gaps) seen_gaps = 0 outchars.append(char) else: assert char == '-' if not inserts: in_insert = False in_gap = True seen_gaps += 1 else: outchars.append(inserts.pop(0).upper()) if not inserts: in_insert = False in_gap = True elif in_gap: if char.islower(): in_insert = True in_gap = False if inserts: outchars.extend(inserts) outchars.append('-' * seen_gaps) seen_gaps = 0 inserts = [char] elif char.isupper(): in_gap = False if inserts: outchars.extend(inserts) inserts = [] outchars.append('-' * seen_gaps) seen_gaps = 0 outchars.append(char) else: assert char == '-' seen_gaps += 1 else: assert not inserts and not seen_gaps, ( "Inserts: %s, gaps: %s, seq: %s, in_ins=%s, in_gap=%s" % (inserts, seen_gaps, sequence, in_insert, in_gap)) if char.isupper(): outchars.append(char) elif char.islower(): inserts.append(char) in_insert = True else: assert char == '-' seen_gaps += 1 in_gap = True if inserts: outchars.extend(inserts) if seen_gaps: outchars.append('-' * seen_gaps) sequence = ''.join(outchars) assert (sequence.replace('-', '').upper() == orig_sequence.replace('-', '').upper()), \ '\nOrig: ' + orig_sequence + \ '\nIron: ' + sequence return sequence
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 4; 2, function_name:collect_reponames; 3, parameters; 4, block; 4, 5; 4, 9; 4, 146; 4, 216; 5, expression_statement; 5, 6; 6, assignment; 6, 7; 6, 8; 7, identifier:reponames; 8, list:[]; 9, try_statement; 9, 10; 9, 136; 9, 140; 10, block; 10, 11; 10, 40; 10, 44; 10, 99; 11, with_statement; 11, 12; 11, 23; 12, with_clause; 12, 13; 13, with_item; 13, 14; 14, as_pattern; 14, 15; 14, 21; 15, call; 15, 16; 15, 17; 16, identifier:open; 17, argument_list; 17, 18; 18, attribute; 18, 19; 18, 20; 19, identifier:os; 20, identifier:devnull; 21, as_pattern_target; 21, 22; 22, identifier:devnull; 23, block; 23, 24; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 27; 26, identifier:remote_data; 27, call; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:subprocess; 30, identifier:check_output; 31, argument_list; 31, 32; 31, 37; 32, list:["git","remote","-v","show"]; 32, 33; 32, 34; 32, 35; 32, 36; 33, string:"git"; 34, string:"remote"; 35, string:"-v"; 36, string:"show"; 37, keyword_argument; 37, 38; 37, 39; 38, identifier:stderr; 39, identifier:devnull; 40, expression_statement; 40, 41; 41, assignment; 41, 42; 41, 43; 42, identifier:branches; 43, dictionary; 44, for_statement; 44, 45; 44, 46; 44, 57; 45, identifier:line; 46, call; 46, 47; 46, 55; 47, attribute; 47, 48; 47, 54; 48, call; 48, 49; 48, 52; 49, attribute; 49, 50; 49, 51; 50, identifier:remote_data; 51, identifier:decode; 52, argument_list; 52, 53; 53, string:'utf-8'; 54, identifier:split; 55, argument_list; 55, 56; 56, string:"\n"; 57, block; 57, 58; 57, 68; 57, 77; 58, if_statement; 58, 59; 58, 66; 59, comparison_operator:==; 59, 60; 59, 65; 60, call; 60, 61; 60, 64; 61, attribute; 61, 62; 61, 63; 62, identifier:line; 63, identifier:strip; 64, argument_list; 65, string:""; 66, block; 66, 67; 67, continue_statement; 68, expression_statement; 68, 69; 69, assignment; 69, 70; 69, 71; 70, identifier:remote_match; 71, call; 71, 72; 71, 75; 72, attribute; 72, 73; 72, 74; 73, identifier:re_mote; 74, identifier:match; 75, argument_list; 75, 76; 76, identifier:line; 77, if_statement; 77, 78; 77, 82; 78, not_operator; 78, 79; 79, comparison_operator:is; 79, 80; 79, 81; 80, identifier:remote_match; 81, None; 82, block; 82, 83; 83, expression_statement; 83, 84; 84, assignment; 84, 85; 84, 93; 85, subscript; 85, 86; 85, 87; 86, identifier:branches; 87, call; 87, 88; 87, 91; 88, attribute; 88, 89; 88, 90; 89, identifier:remote_match; 90, identifier:group; 91, argument_list; 91, 92; 92, integer:1; 93, call; 93, 94; 93, 97; 94, attribute; 94, 95; 94, 96; 95, identifier:remote_match; 96, identifier:group; 97, argument_list; 97, 98; 98, integer:5; 99, if_statement; 99, 100; 99, 106; 100, comparison_operator:>; 100, 101; 100, 105; 101, call; 101, 102; 101, 103; 102, identifier:len; 103, argument_list; 103, 104; 104, identifier:branches; 105, integer:0; 106, block; 106, 107; 107, if_statement; 107, 108; 107, 111; 107, 121; 108, comparison_operator:in; 108, 109; 108, 110; 109, string:"origin"; 110, identifier:branches; 111, block; 111, 112; 112, expression_statement; 112, 113; 113, call; 113, 114; 113, 117; 114, attribute; 114, 115; 114, 116; 115, identifier:reponames; 116, identifier:append; 117, argument_list; 117, 118; 118, subscript; 118, 119; 118, 120; 119, identifier:branches; 120, string:"origin"; 121, else_clause; 121, 122; 122, block; 122, 123; 123, expression_statement; 123, 124; 124, call; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:reponames; 127, identifier:append; 128, argument_list; 128, 129; 129, subscript; 129, 130; 129, 135; 130, call; 130, 131; 130, 134; 131, attribute; 131, 132; 131, 133; 132, identifier:branches; 133, identifier:values; 134, argument_list; 135, integer:0; 136, except_clause; 136, 137; 136, 138; 137, identifier:OSError; 138, block; 138, 139; 139, pass_statement; 140, except_clause; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, identifier:subprocess; 143, identifier:CalledProcessError; 144, block; 144, 145; 145, pass_statement; 146, for_statement; 146, 147; 146, 148; 146, 154; 147, identifier:fname; 148, call; 148, 149; 148, 152; 149, attribute; 149, 150; 149, 151; 150, identifier:glob; 151, identifier:iglob; 152, argument_list; 152, 153; 153, string:"*.html"; 154, block; 154, 155; 154, 164; 154, 170; 154, 178; 154, 188; 154, 206; 155, expression_statement; 155, 156; 156, assignment; 156, 157; 156, 158; 157, identifier:fid; 158, call; 158, 159; 158, 160; 159, identifier:open; 160, argument_list; 160, 161; 160, 162; 160, 163; 161, identifier:fname; 162, string:"r"; 163, string:"utf8"; 164, expression_statement; 164, 165; 165, call; 165, 166; 165, 169; 166, attribute; 166, 167; 166, 168; 167, identifier:fid; 168, identifier:readline; 169, argument_list; 170, expression_statement; 170, 171; 171, assignment; 171, 172; 171, 173; 172, identifier:line; 173, call; 173, 174; 173, 177; 174, attribute; 174, 175; 174, 176; 175, identifier:fid; 176, identifier:readline; 177, argument_list; 178, expression_statement; 178, 179; 179, assignment; 179, 180; 179, 181; 180, identifier:match; 181, call; 181, 182; 181, 185; 182, attribute; 182, 183; 182, 184; 183, identifier:re; 184, identifier:match; 185, argument_list; 185, 186; 185, 187; 186, identifier:repo_marker_re; 187, identifier:line; 188, if_statement; 188, 189; 188, 193; 189, not_operator; 189, 190; 190, comparison_operator:is; 190, 191; 190, 192; 191, identifier:match; 192, None; 193, block; 193, 194; 194, expression_statement; 194, 195; 195, call; 195, 196; 195, 199; 196, attribute; 196, 197; 196, 198; 197, identifier:reponames; 198, identifier:append; 199, argument_list; 199, 200; 200, call; 200, 201; 200, 204; 201, attribute; 201, 202; 201, 203; 202, identifier:match; 203, identifier:group; 204, argument_list; 204, 205; 205, integer:1; 206, expression_statement; 206, 207; 207, assignment; 207, 208; 207, 209; 208, identifier:reponames; 209, call; 209, 210; 209, 211; 210, identifier:list; 211, argument_list; 211, 212; 212, call; 212, 213; 212, 214; 213, identifier:set; 214, argument_list; 214, 215; 215, identifier:reponames; 216, return_statement; 216, 217; 217, identifier:reponames
def collect_reponames(): reponames = [] try: with open(os.devnull) as devnull: remote_data = subprocess.check_output(["git","remote","-v","show"],stderr=devnull) branches = {} for line in remote_data.decode('utf-8').split("\n"): if line.strip() == "": continue remote_match = re_mote.match(line) if not remote_match is None: branches[remote_match.group(1)] = remote_match.group(5) if len(branches) > 0: if "origin" in branches: reponames.append(branches["origin"]) else: reponames.append(branches.values()[0]) except OSError: pass except subprocess.CalledProcessError: pass for fname in glob.iglob("*.html"): fid = open(fname,"r","utf8") fid.readline() line = fid.readline() match = re.match(repo_marker_re,line) if not match is None: reponames.append(match.group(1)) reponames = list(set(reponames)) return reponames
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:build_markdown_table; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:headers; 5, identifier:rows; 6, default_parameter; 6, 7; 6, 8; 7, identifier:row_keys; 8, None; 9, block; 9, 10; 9, 18; 9, 34; 9, 49; 9, 65; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12, identifier:row_maxes; 13, call; 13, 14; 13, 15; 14, identifier:_find_row_maxes; 15, argument_list; 15, 16; 15, 17; 16, identifier:headers; 17, identifier:rows; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:row_keys; 21, boolean_operator:or; 21, 22; 21, 23; 22, identifier:row_keys; 23, list_comprehension; 23, 24; 23, 25; 24, identifier:key; 25, for_in_clause; 25, 26; 25, 29; 26, pattern_list; 26, 27; 26, 28; 27, identifier:key; 28, identifier:value; 29, call; 29, 30; 29, 33; 30, attribute; 30, 31; 30, 32; 31, identifier:headers; 32, identifier:items; 33, argument_list; 34, expression_statement; 34, 35; 35, assignment; 35, 36; 35, 37; 36, identifier:table; 37, list:[ _build_row(headers, row_maxes, row_keys), _build_separator(row_maxes, row_keys) ]; 37, 38; 37, 44; 38, call; 38, 39; 38, 40; 39, identifier:_build_row; 40, argument_list; 40, 41; 40, 42; 40, 43; 41, identifier:headers; 42, identifier:row_maxes; 43, identifier:row_keys; 44, call; 44, 45; 44, 46; 45, identifier:_build_separator; 46, argument_list; 46, 47; 46, 48; 47, identifier:row_maxes; 48, identifier:row_keys; 49, for_statement; 49, 50; 49, 51; 49, 52; 50, identifier:row; 51, identifier:rows; 52, block; 52, 53; 53, expression_statement; 53, 54; 54, call; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:table; 57, identifier:append; 58, argument_list; 58, 59; 59, call; 59, 60; 59, 61; 60, identifier:_build_row; 61, argument_list; 61, 62; 61, 63; 61, 64; 62, identifier:row; 63, identifier:row_maxes; 64, identifier:row_keys; 65, return_statement; 65, 66; 66, binary_operator:+; 66, 67; 66, 73; 67, call; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, string:'\n'; 70, identifier:join; 71, argument_list; 71, 72; 72, identifier:table; 73, string:'\n'
def build_markdown_table(headers, rows, row_keys=None): row_maxes = _find_row_maxes(headers, rows) row_keys = row_keys or [key for key, value in headers.items()] table = [ _build_row(headers, row_maxes, row_keys), _build_separator(row_maxes, row_keys) ] for row in rows: table.append(_build_row(row, row_maxes, row_keys)) return '\n'.join(table) + '\n'
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:create_publication_assistant; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, dictionary_splat_pattern; 5, 6; 6, identifier:args; 7, block; 7, 8; 7, 10; 7, 16; 7, 23; 7, 33; 7, 59; 7, 85; 7, 95; 7, 147; 7, 153; 8, expression_statement; 8, 9; 9, string:''' Create an assistant for a dataset that allows to make PID requests for the dataset and all of its files. :param drs_id: Mandatory. The dataset id of the dataset to be published. :param version_number: Mandatory. The version number of the dataset to be published. :param is_replica: Mandatory. Flag to indicate whether the dataset is a replica. .. note:: If the replica flag is set to False, the publication may still be considered a replica by the consuming servlet, namely if the dataset was already published at a different host. For this, please refer to the consumer documentation. :return: A publication assistant which provides all necessary methods to publish a dataset and its files. '''; 10, expression_statement; 10, 11; 11, call; 11, 12; 11, 13; 12, identifier:logdebug; 13, argument_list; 13, 14; 13, 15; 14, identifier:LOGGER; 15, string:'Creating publication assistant..'; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 19; 18, identifier:mandatory_args; 19, list:['drs_id', 'version_number', 'is_replica']; 19, 20; 19, 21; 19, 22; 20, string:'drs_id'; 21, string:'version_number'; 22, string:'is_replica'; 23, expression_statement; 23, 24; 24, call; 24, 25; 24, 30; 25, attribute; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:esgfpid; 28, identifier:utils; 29, identifier:check_presence_of_mandatory_args; 30, argument_list; 30, 31; 30, 32; 31, identifier:args; 32, identifier:mandatory_args; 33, if_statement; 33, 34; 33, 39; 34, comparison_operator:is; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:self; 37, identifier:__thredds_service_path; 38, None; 39, block; 39, 40; 39, 44; 39, 50; 40, expression_statement; 40, 41; 41, assignment; 41, 42; 41, 43; 42, identifier:msg; 43, string:'No thredds_service_path given (but it is mandatory for publication)'; 44, expression_statement; 44, 45; 45, call; 45, 46; 45, 47; 46, identifier:logwarn; 47, argument_list; 47, 48; 47, 49; 48, identifier:LOGGER; 49, identifier:msg; 50, raise_statement; 50, 51; 51, call; 51, 52; 51, 57; 52, attribute; 52, 53; 52, 56; 53, attribute; 53, 54; 53, 55; 54, identifier:esgfpid; 55, identifier:exceptions; 56, identifier:ArgumentError; 57, argument_list; 57, 58; 58, identifier:msg; 59, if_statement; 59, 60; 59, 65; 60, comparison_operator:is; 60, 61; 60, 64; 61, attribute; 61, 62; 61, 63; 62, identifier:self; 63, identifier:__data_node; 64, None; 65, block; 65, 66; 65, 70; 65, 76; 66, expression_statement; 66, 67; 67, assignment; 67, 68; 67, 69; 68, identifier:msg; 69, string:'No data_node given (but it is mandatory for publication)'; 70, expression_statement; 70, 71; 71, call; 71, 72; 71, 73; 72, identifier:logwarn; 73, argument_list; 73, 74; 73, 75; 74, identifier:LOGGER; 75, identifier:msg; 76, raise_statement; 76, 77; 77, call; 77, 78; 77, 83; 78, attribute; 78, 79; 78, 82; 79, attribute; 79, 80; 79, 81; 80, identifier:esgfpid; 81, identifier:exceptions; 82, identifier:ArgumentError; 83, argument_list; 83, 84; 84, identifier:msg; 85, if_statement; 85, 86; 85, 93; 86, call; 86, 87; 86, 92; 87, attribute; 87, 88; 87, 91; 88, attribute; 88, 89; 88, 90; 89, identifier:self; 90, identifier:__coupler; 91, identifier:is_solr_switched_off; 92, argument_list; 93, block; 93, 94; 94, pass_statement; 95, expression_statement; 95, 96; 96, assignment; 96, 97; 96, 98; 97, identifier:assistant; 98, call; 98, 99; 98, 106; 99, attribute; 99, 100; 99, 105; 100, attribute; 100, 101; 100, 104; 101, attribute; 101, 102; 101, 103; 102, identifier:esgfpid; 103, identifier:assistant; 104, identifier:publish; 105, identifier:DatasetPublicationAssistant; 106, argument_list; 106, 107; 106, 112; 106, 117; 106, 122; 106, 127; 106, 132; 106, 137; 106, 142; 107, keyword_argument; 107, 108; 107, 109; 108, identifier:drs_id; 109, subscript; 109, 110; 109, 111; 110, identifier:args; 111, string:'drs_id'; 112, keyword_argument; 112, 113; 112, 114; 113, identifier:version_number; 114, subscript; 114, 115; 114, 116; 115, identifier:args; 116, string:'version_number'; 117, keyword_argument; 117, 118; 117, 119; 118, identifier:thredds_service_path; 119, attribute; 119, 120; 119, 121; 120, identifier:self; 121, identifier:__thredds_service_path; 122, keyword_argument; 122, 123; 122, 124; 123, identifier:data_node; 124, attribute; 124, 125; 124, 126; 125, identifier:self; 126, identifier:__data_node; 127, keyword_argument; 127, 128; 127, 129; 128, identifier:prefix; 129, attribute; 129, 130; 129, 131; 130, identifier:self; 131, identifier:prefix; 132, keyword_argument; 132, 133; 132, 134; 133, identifier:coupler; 134, attribute; 134, 135; 134, 136; 135, identifier:self; 136, identifier:__coupler; 137, keyword_argument; 137, 138; 137, 139; 138, identifier:is_replica; 139, subscript; 139, 140; 139, 141; 140, identifier:args; 141, string:'is_replica'; 142, keyword_argument; 142, 143; 142, 144; 143, identifier:consumer_solr_url; 144, attribute; 144, 145; 144, 146; 145, identifier:self; 146, identifier:__consumer_solr_url; 147, expression_statement; 147, 148; 148, call; 148, 149; 148, 150; 149, identifier:logdebug; 150, argument_list; 150, 151; 150, 152; 151, identifier:LOGGER; 152, string:'Creating publication assistant.. done'; 153, return_statement; 153, 154; 154, identifier:assistant
def create_publication_assistant(self, **args): ''' Create an assistant for a dataset that allows to make PID requests for the dataset and all of its files. :param drs_id: Mandatory. The dataset id of the dataset to be published. :param version_number: Mandatory. The version number of the dataset to be published. :param is_replica: Mandatory. Flag to indicate whether the dataset is a replica. .. note:: If the replica flag is set to False, the publication may still be considered a replica by the consuming servlet, namely if the dataset was already published at a different host. For this, please refer to the consumer documentation. :return: A publication assistant which provides all necessary methods to publish a dataset and its files. ''' logdebug(LOGGER, 'Creating publication assistant..') mandatory_args = ['drs_id', 'version_number', 'is_replica'] esgfpid.utils.check_presence_of_mandatory_args(args, mandatory_args) if self.__thredds_service_path is None: msg = 'No thredds_service_path given (but it is mandatory for publication)' logwarn(LOGGER, msg) raise esgfpid.exceptions.ArgumentError(msg) if self.__data_node is None: msg = 'No data_node given (but it is mandatory for publication)' logwarn(LOGGER, msg) raise esgfpid.exceptions.ArgumentError(msg) if self.__coupler.is_solr_switched_off(): pass assistant = esgfpid.assistant.publish.DatasetPublicationAssistant( drs_id=args['drs_id'], version_number=args['version_number'], thredds_service_path=self.__thredds_service_path, data_node=self.__data_node, prefix=self.prefix, coupler=self.__coupler, is_replica=args['is_replica'], consumer_solr_url=self.__consumer_solr_url ) logdebug(LOGGER, 'Creating publication assistant.. done') return assistant
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:replace_source; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:source; 6, identifier:name; 7, identifier:modules; 8, identifier:prefix; 9, block; 9, 10; 9, 14; 9, 102; 9, 115; 9, 126; 9, 135; 9, 139; 9, 196; 9, 207; 9, 219; 9, 232; 9, 242; 9, 250; 9, 272; 9, 276; 9, 289; 9, 302; 9, 314; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12, identifier:needs_windll; 13, False; 14, function_definition; 14, 15; 14, 16; 14, 20; 15, function_name:_func_replacer; 16, parameters; 16, 17; 16, 18; 16, 19; 17, identifier:match; 18, identifier:modules; 19, identifier:windll; 20, block; 20, 21; 20, 30; 20, 39; 20, 50; 20, 100; 21, expression_statement; 21, 22; 22, assignment; 22, 23; 22, 24; 23, identifier:matched; 24, call; 24, 25; 24, 28; 25, attribute; 25, 26; 25, 27; 26, identifier:match; 27, identifier:group; 28, argument_list; 28, 29; 29, integer:0; 30, if_statement; 30, 31; 30, 36; 31, comparison_operator:in; 31, 32; 31, 33; 32, identifier:matched; 33, attribute; 33, 34; 33, 35; 34, identifier:self; 35, identifier:BLACKLIST; 36, block; 36, 37; 37, return_statement; 37, 38; 38, identifier:matched; 39, expression_statement; 39, 40; 40, assignment; 40, 41; 40, 42; 41, identifier:module; 42, call; 42, 43; 42, 48; 43, attribute; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:self; 46, identifier:database; 47, identifier:query_func_module; 48, argument_list; 48, 49; 49, identifier:matched; 50, if_statement; 50, 51; 50, 52; 51, identifier:module; 52, block; 52, 53; 52, 80; 52, 92; 53, try_statement; 53, 54; 53, 66; 54, block; 54, 55; 55, expression_statement; 55, 56; 56, augmented_assignment:+=; 56, 57; 56, 62; 57, subscript; 57, 58; 57, 59; 58, identifier:modules; 59, subscript; 59, 60; 59, 61; 60, identifier:module; 61, integer:0; 62, list:[module[1]]; 62, 63; 63, subscript; 63, 64; 63, 65; 64, identifier:module; 65, integer:1; 66, except_clause; 66, 67; 66, 68; 67, identifier:KeyError; 68, block; 68, 69; 69, expression_statement; 69, 70; 70, assignment; 70, 71; 70, 76; 71, subscript; 71, 72; 71, 73; 72, identifier:modules; 73, subscript; 73, 74; 73, 75; 74, identifier:module; 75, integer:0; 76, list:[module[1]]; 76, 77; 77, subscript; 77, 78; 77, 79; 78, identifier:module; 79, integer:1; 80, if_statement; 80, 81; 80, 82; 81, identifier:windll; 82, block; 82, 83; 83, return_statement; 83, 84; 84, call; 84, 85; 84, 88; 85, attribute; 85, 86; 85, 87; 86, string:'{}->{}.{}'; 87, identifier:format; 88, argument_list; 88, 89; 88, 90; 89, identifier:windll; 90, list_splat; 90, 91; 91, identifier:module; 92, return_statement; 92, 93; 93, call; 93, 94; 93, 97; 94, attribute; 94, 95; 94, 96; 95, string:'{}->{}'; 96, identifier:format; 97, argument_list; 97, 98; 98, list_splat; 98, 99; 99, identifier:module; 100, return_statement; 100, 101; 101, identifier:matched; 102, expression_statement; 102, 103; 103, assignment; 103, 104; 103, 105; 104, identifier:replacer; 105, call; 105, 106; 105, 107; 106, identifier:partial; 107, argument_list; 107, 108; 107, 109; 107, 112; 108, identifier:_func_replacer; 109, keyword_argument; 109, 110; 109, 111; 110, identifier:modules; 111, identifier:modules; 112, keyword_argument; 112, 113; 112, 114; 113, identifier:windll; 114, string:'windll'; 115, expression_statement; 115, 116; 116, assignment; 116, 117; 116, 118; 117, identifier:replaced; 118, call; 118, 119; 118, 122; 119, attribute; 119, 120; 119, 121; 120, identifier:re; 121, identifier:sub; 122, argument_list; 122, 123; 122, 124; 122, 125; 123, string:r'[_\w][_\w\d]*(?=\s*\()'; 124, identifier:replacer; 125, identifier:source; 126, if_statement; 126, 127; 126, 130; 127, comparison_operator:!=; 127, 128; 127, 129; 128, identifier:source; 129, identifier:replaced; 130, block; 130, 131; 131, expression_statement; 131, 132; 132, assignment; 132, 133; 132, 134; 133, identifier:needs_windll; 134, True; 135, expression_statement; 135, 136; 136, assignment; 136, 137; 136, 138; 137, identifier:str_table; 138, dictionary; 139, function_definition; 139, 140; 139, 141; 139, 143; 140, function_name:_string_replacer; 141, parameters; 141, 142; 142, identifier:match; 143, block; 143, 144; 143, 158; 143, 188; 144, expression_statement; 144, 145; 145, assignment; 145, 146; 145, 147; 146, identifier:matched; 147, subscript; 147, 148; 147, 153; 148, call; 148, 149; 148, 152; 149, attribute; 149, 150; 149, 151; 150, identifier:match; 151, identifier:group; 152, argument_list; 153, slice; 153, 154; 153, 155; 153, 156; 154, integer:1; 155, colon; 156, unary_operator:-; 156, 157; 157, integer:1; 158, try_statement; 158, 159; 158, 166; 159, block; 159, 160; 160, expression_statement; 160, 161; 161, assignment; 161, 162; 161, 163; 162, identifier:number; 163, subscript; 163, 164; 163, 165; 164, identifier:str_table; 165, identifier:matched; 166, except_clause; 166, 167; 166, 168; 167, identifier:KeyError; 168, block; 168, 169; 168, 178; 169, expression_statement; 169, 170; 170, assignment; 170, 171; 170, 172; 171, identifier:number; 172, binary_operator:+; 172, 173; 172, 177; 173, call; 173, 174; 173, 175; 174, identifier:len; 175, argument_list; 175, 176; 176, identifier:str_table; 177, integer:1; 178, expression_statement; 178, 179; 179, call; 179, 180; 179, 183; 180, attribute; 180, 181; 180, 182; 181, identifier:str_table; 182, identifier:update; 183, argument_list; 183, 184; 184, dictionary; 184, 185; 185, pair; 185, 186; 185, 187; 186, identifier:matched; 187, identifier:number; 188, return_statement; 188, 189; 189, call; 189, 190; 189, 193; 190, attribute; 190, 191; 190, 192; 191, string:'{}{}'; 192, identifier:format; 193, argument_list; 193, 194; 193, 195; 194, identifier:prefix; 195, identifier:number; 196, expression_statement; 196, 197; 197, assignment; 197, 198; 197, 199; 198, identifier:replaced; 199, call; 199, 200; 199, 203; 200, attribute; 200, 201; 200, 202; 201, identifier:re; 202, identifier:sub; 203, argument_list; 203, 204; 203, 205; 203, 206; 204, string:r'".+?"'; 205, identifier:_string_replacer; 206, identifier:replaced; 207, expression_statement; 207, 208; 208, assignment; 208, 209; 208, 212; 209, pattern_list; 209, 210; 209, 211; 210, identifier:strings; 211, identifier:relocs; 212, call; 212, 213; 212, 216; 213, attribute; 213, 214; 213, 215; 214, identifier:self; 215, identifier:build_strings; 216, argument_list; 216, 217; 216, 218; 217, identifier:str_table; 218, identifier:prefix; 219, expression_statement; 219, 220; 220, assignment; 220, 221; 220, 222; 221, identifier:strings; 222, call; 222, 223; 222, 231; 223, attribute; 223, 224; 223, 230; 224, call; 224, 225; 224, 228; 225, attribute; 225, 226; 225, 227; 226, string:''; 227, identifier:join; 228, argument_list; 228, 229; 229, identifier:strings; 230, identifier:strip; 231, argument_list; 232, expression_statement; 232, 233; 233, assignment; 233, 234; 233, 235; 234, identifier:windll32; 235, call; 235, 236; 235, 237; 236, identifier:reloc_var; 237, argument_list; 237, 238; 237, 239; 237, 240; 237, 241; 238, string:'windll'; 239, string:'reloc_delta'; 240, True; 241, string:'windll_t'; 242, if_statement; 242, 243; 242, 244; 243, identifier:needs_windll; 244, block; 244, 245; 245, expression_statement; 245, 246; 246, augmented_assignment:+=; 246, 247; 246, 248; 247, identifier:relocs; 248, list:[windll32]; 248, 249; 249, identifier:windll32; 250, if_statement; 250, 251; 250, 252; 251, identifier:strings; 252, block; 252, 253; 252, 259; 253, expression_statement; 253, 254; 254, assignment; 254, 255; 254, 256; 255, identifier:strings; 256, binary_operator:+; 256, 257; 256, 258; 257, string:'\n'; 258, identifier:strings; 259, if_statement; 259, 260; 259, 262; 260, not_operator; 260, 261; 261, identifier:needs_windll; 262, block; 262, 263; 262, 268; 263, expression_statement; 263, 264; 264, augmented_assignment:+=; 264, 265; 264, 266; 265, identifier:relocs; 266, list:[windll32]; 266, 267; 267, identifier:windll32; 268, expression_statement; 268, 269; 269, assignment; 269, 270; 269, 271; 270, identifier:needs_windll; 271, True; 272, expression_statement; 272, 273; 273, assignment; 273, 274; 273, 275; 274, identifier:windll64; 275, string:''; 276, if_statement; 276, 277; 276, 278; 277, identifier:needs_windll; 278, block; 278, 279; 279, expression_statement; 279, 280; 280, assignment; 280, 281; 280, 282; 281, identifier:windll64; 282, call; 282, 283; 282, 286; 283, attribute; 283, 284; 283, 285; 284, string:'{0} *{1} = &_{1};\n'; 285, identifier:format; 286, argument_list; 286, 287; 286, 288; 287, string:'windll_t'; 288, string:'windll'; 289, expression_statement; 289, 290; 290, assignment; 290, 291; 290, 292; 291, identifier:relocs; 292, call; 292, 293; 292, 294; 293, identifier:reloc_both; 294, argument_list; 294, 295; 294, 301; 295, call; 295, 296; 295, 299; 296, attribute; 296, 297; 296, 298; 297, string:''; 298, identifier:join; 299, argument_list; 299, 300; 300, identifier:relocs; 301, identifier:windll64; 302, if_statement; 302, 303; 302, 307; 303, comparison_operator:in; 303, 304; 303, 305; 304, identifier:name; 305, list:['main']; 305, 306; 306, string:'main'; 307, block; 307, 308; 308, expression_statement; 308, 309; 309, assignment; 309, 310; 309, 311; 310, identifier:replaced; 311, binary_operator:+; 311, 312; 311, 313; 312, string:'\ninit();'; 313, identifier:replaced; 314, return_statement; 314, 315; 315, binary_operator:+; 315, 316; 315, 319; 316, binary_operator:+; 316, 317; 316, 318; 317, identifier:strings; 318, identifier:relocs; 319, identifier:replaced
def replace_source(self, source, name, modules, prefix): needs_windll = False def _func_replacer(match, modules, windll): matched = match.group(0) if matched in self.BLACKLIST: return matched module = self.database.query_func_module(matched) if module: try: modules[module[0]] += [module[1]] except KeyError: modules[module[0]] = [module[1]] if windll: return '{}->{}.{}'.format(windll, *module) return '{}->{}'.format(*module) return matched replacer = partial( _func_replacer, modules=modules, windll='windll') replaced = re.sub(r'[_\w][_\w\d]*(?=\s*\()', replacer, source) if source != replaced: needs_windll = True str_table = {} def _string_replacer(match): matched = match.group()[1:-1] try: number = str_table[matched] except KeyError: number = len(str_table) + 1 str_table.update({matched: number}) return '{}{}'.format(prefix, number) replaced = re.sub(r'".+?"', _string_replacer, replaced) strings, relocs = self.build_strings(str_table, prefix) strings = ''.join(strings).strip() windll32 = reloc_var('windll', 'reloc_delta', True, 'windll_t') if needs_windll: relocs += [windll32] if strings: strings = '\n' + strings if not needs_windll: relocs += [windll32] needs_windll = True windll64 = '' if needs_windll: windll64 = '{0} *{1} = &_{1};\n'.format('windll_t', 'windll') relocs = reloc_both(''.join(relocs), windll64) if name in ['main']: replaced = '\ninit();' + replaced return strings + relocs + replaced
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:sort_item; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:iterable; 5, identifier:number; 6, default_parameter; 6, 7; 6, 8; 7, identifier:reverse; 8, False; 9, block; 9, 10; 10, return_statement; 10, 11; 11, call; 11, 12; 11, 13; 12, identifier:sorted; 13, argument_list; 13, 14; 13, 15; 13, 21; 14, identifier:iterable; 15, keyword_argument; 15, 16; 15, 17; 16, identifier:key; 17, call; 17, 18; 17, 19; 18, identifier:itemgetter; 19, argument_list; 19, 20; 20, identifier:number; 21, keyword_argument; 21, 22; 21, 23; 22, identifier:reverse; 23, identifier:reverse
def sort_item(iterable, number, reverse=False): return sorted(iterable, key=itemgetter(number), reverse=reverse)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_equivalent_positions; 3, parameters; 3, 4; 4, identifier:block; 5, block; 5, 6; 5, 16; 5, 26; 5, 40; 5, 46; 5, 52; 5, 83; 5, 98; 5, 102; 5, 106; 5, 128; 5, 148; 5, 265; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:consensus; 9, subscript; 9, 10; 9, 15; 10, subscript; 10, 11; 10, 14; 11, subscript; 11, 12; 11, 13; 12, identifier:block; 13, string:'sequences'; 14, integer:0; 15, string:'seq'; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 19; 18, identifier:rest; 19, subscript; 19, 20; 19, 23; 20, subscript; 20, 21; 20, 22; 21, identifier:block; 22, string:'sequences'; 23, slice; 23, 24; 23, 25; 24, integer:1; 25, colon; 26, if_statement; 26, 27; 26, 34; 27, boolean_operator:or; 27, 28; 27, 31; 28, comparison_operator:in; 28, 29; 28, 30; 29, string:'-'; 30, identifier:consensus; 31, comparison_operator:in; 31, 32; 31, 33; 32, string:'.'; 33, identifier:consensus; 34, block; 34, 35; 35, raise_statement; 35, 36; 36, call; 36, 37; 36, 38; 37, identifier:ValueError; 38, argument_list; 38, 39; 39, string:"First sequence (consensus?) contains gaps"; 40, expression_statement; 40, 41; 41, assignment; 41, 42; 41, 43; 42, identifier:seen; 43, call; 43, 44; 43, 45; 44, identifier:set; 45, argument_list; 46, expression_statement; 46, 47; 47, assignment; 47, 48; 47, 49; 48, identifier:dupes; 49, call; 49, 50; 49, 51; 50, identifier:set; 51, argument_list; 52, for_statement; 52, 53; 52, 54; 52, 55; 53, identifier:rec; 54, identifier:rest; 55, block; 55, 56; 56, if_statement; 56, 57; 56, 62; 56, 72; 57, comparison_operator:in; 57, 58; 57, 61; 58, subscript; 58, 59; 58, 60; 59, identifier:rec; 60, string:'id'; 61, identifier:seen; 62, block; 62, 63; 63, expression_statement; 63, 64; 64, call; 64, 65; 64, 68; 65, attribute; 65, 66; 65, 67; 66, identifier:dupes; 67, identifier:add; 68, argument_list; 68, 69; 69, subscript; 69, 70; 69, 71; 70, identifier:rec; 71, string:'id'; 72, else_clause; 72, 73; 73, block; 73, 74; 74, expression_statement; 74, 75; 75, call; 75, 76; 75, 79; 76, attribute; 76, 77; 76, 78; 77, identifier:seen; 78, identifier:add; 79, argument_list; 79, 80; 80, subscript; 80, 81; 80, 82; 81, identifier:rec; 82, string:'id'; 83, if_statement; 83, 84; 83, 85; 84, identifier:dupes; 85, block; 85, 86; 86, raise_statement; 86, 87; 87, call; 87, 88; 87, 89; 88, identifier:ValueError; 89, argument_list; 89, 90; 90, binary_operator:+; 90, 91; 90, 92; 91, string:"Duplicate sequences:\n"; 92, call; 92, 93; 92, 96; 93, attribute; 93, 94; 93, 95; 94, string:'\n'; 95, identifier:join; 96, argument_list; 96, 97; 97, identifier:dupes; 98, expression_statement; 98, 99; 99, assignment; 99, 100; 99, 101; 100, identifier:curr_shift; 101, dictionary; 102, expression_statement; 102, 103; 103, assignment; 103, 104; 103, 105; 104, identifier:curr_resn; 105, dictionary; 106, for_statement; 106, 107; 106, 108; 106, 109; 107, identifier:rec; 108, identifier:rest; 109, block; 109, 110; 109, 118; 110, expression_statement; 110, 111; 111, assignment; 111, 112; 111, 117; 112, subscript; 112, 113; 112, 114; 113, identifier:curr_shift; 114, subscript; 114, 115; 114, 116; 115, identifier:rec; 116, string:'id'; 117, integer:0; 118, expression_statement; 118, 119; 119, assignment; 119, 120; 119, 125; 120, subscript; 120, 121; 120, 122; 121, identifier:curr_resn; 122, subscript; 122, 123; 122, 124; 123, identifier:rec; 124, string:'id'; 125, subscript; 125, 126; 125, 127; 126, identifier:rec; 127, string:'head_len'; 128, expression_statement; 128, 129; 129, assignment; 129, 130; 129, 131; 130, identifier:equivalencies; 131, call; 131, 132; 131, 133; 132, identifier:dict; 133, generator_expression; 133, 134; 133, 139; 134, tuple; 134, 135; 134, 138; 135, binary_operator:+; 135, 136; 135, 137; 136, identifier:i; 137, integer:1; 138, dictionary; 139, for_in_clause; 139, 140; 139, 141; 140, identifier:i; 141, call; 141, 142; 141, 143; 142, identifier:xrange; 143, argument_list; 143, 144; 144, call; 144, 145; 144, 146; 145, identifier:len; 146, argument_list; 146, 147; 147, identifier:consensus; 148, for_statement; 148, 149; 148, 152; 148, 156; 149, pattern_list; 149, 150; 149, 151; 150, identifier:i; 151, identifier:char; 152, call; 152, 153; 152, 154; 153, identifier:enumerate; 154, argument_list; 154, 155; 155, identifier:consensus; 156, block; 156, 157; 156, 163; 157, assert_statement; 157, 158; 158, call; 158, 159; 158, 162; 159, attribute; 159, 160; 159, 161; 160, identifier:char; 161, identifier:isupper; 162, argument_list; 163, for_statement; 163, 164; 163, 165; 163, 166; 164, identifier:rec; 165, identifier:rest; 166, block; 166, 167; 166, 173; 166, 181; 166, 253; 167, expression_statement; 167, 168; 168, assignment; 168, 169; 168, 170; 169, identifier:rid; 170, subscript; 170, 171; 170, 172; 171, identifier:rec; 172, string:'id'; 173, expression_statement; 173, 174; 174, assignment; 174, 175; 174, 176; 175, identifier:strposn; 176, binary_operator:+; 176, 177; 176, 178; 177, identifier:i; 178, subscript; 178, 179; 178, 180; 179, identifier:curr_shift; 180, identifier:rid; 181, if_statement; 181, 182; 181, 191; 181, 198; 181, 242; 182, call; 182, 183; 182, 190; 183, attribute; 183, 184; 183, 189; 184, subscript; 184, 185; 184, 188; 185, subscript; 185, 186; 185, 187; 186, identifier:rec; 187, string:'seq'; 188, identifier:strposn; 189, identifier:isupper; 190, argument_list; 191, block; 191, 192; 192, expression_statement; 192, 193; 193, augmented_assignment:+=; 193, 194; 193, 197; 194, subscript; 194, 195; 194, 196; 195, identifier:curr_resn; 196, identifier:rid; 197, integer:1; 198, elif_clause; 198, 199; 198, 208; 199, call; 199, 200; 199, 207; 200, attribute; 200, 201; 200, 206; 201, subscript; 201, 202; 201, 205; 202, subscript; 202, 203; 202, 204; 203, identifier:rec; 204, string:'seq'; 205, identifier:strposn; 206, identifier:islower; 207, argument_list; 208, block; 208, 209; 208, 236; 209, while_statement; 209, 210; 209, 219; 210, call; 210, 211; 210, 218; 211, attribute; 211, 212; 211, 217; 212, subscript; 212, 213; 212, 216; 213, subscript; 213, 214; 213, 215; 214, identifier:rec; 215, string:'seq'; 216, identifier:strposn; 217, identifier:islower; 218, argument_list; 219, block; 219, 220; 219, 226; 219, 232; 220, expression_statement; 220, 221; 221, augmented_assignment:+=; 221, 222; 221, 225; 222, subscript; 222, 223; 222, 224; 223, identifier:curr_shift; 224, identifier:rid; 225, integer:1; 226, expression_statement; 226, 227; 227, augmented_assignment:+=; 227, 228; 227, 231; 228, subscript; 228, 229; 228, 230; 229, identifier:curr_resn; 230, identifier:rid; 231, integer:1; 232, expression_statement; 232, 233; 233, augmented_assignment:+=; 233, 234; 233, 235; 234, identifier:strposn; 235, integer:1; 236, expression_statement; 236, 237; 237, augmented_assignment:+=; 237, 238; 237, 241; 238, subscript; 238, 239; 238, 240; 239, identifier:curr_resn; 240, identifier:rid; 241, integer:1; 242, else_clause; 242, 243; 243, block; 243, 244; 243, 252; 244, assert_statement; 244, 245; 245, comparison_operator:in; 245, 246; 245, 251; 246, subscript; 246, 247; 246, 250; 247, subscript; 247, 248; 247, 249; 248, identifier:rec; 249, string:'seq'; 250, identifier:strposn; 251, string:'.-'; 252, continue_statement; 253, expression_statement; 253, 254; 254, assignment; 254, 255; 254, 262; 255, subscript; 255, 256; 255, 261; 256, subscript; 256, 257; 256, 258; 257, identifier:equivalencies; 258, binary_operator:+; 258, 259; 258, 260; 259, identifier:i; 260, integer:1; 261, identifier:rid; 262, subscript; 262, 263; 262, 264; 263, identifier:curr_resn; 264, identifier:rid; 265, return_statement; 265, 266; 266, identifier:equivalencies
def get_equivalent_positions(block): consensus = block['sequences'][0]['seq'] rest = block['sequences'][1:] if '-' in consensus or '.' in consensus: raise ValueError("First sequence (consensus?) contains gaps") seen = set() dupes = set() for rec in rest: if rec['id'] in seen: dupes.add(rec['id']) else: seen.add(rec['id']) if dupes: raise ValueError("Duplicate sequences:\n" + '\n'.join(dupes)) curr_shift = {} curr_resn = {} for rec in rest: curr_shift[rec['id']] = 0 curr_resn[rec['id']] = rec['head_len'] equivalencies = dict((i+1, {}) for i in xrange(len(consensus))) for i, char in enumerate(consensus): assert char.isupper() for rec in rest: rid = rec['id'] strposn = i + curr_shift[rid] if rec['seq'][strposn].isupper(): curr_resn[rid] += 1 elif rec['seq'][strposn].islower(): while rec['seq'][strposn].islower(): curr_shift[rid] += 1 curr_resn[rid] += 1 strposn += 1 curr_resn[rid] += 1 else: assert rec['seq'][strposn] in '.-' continue equivalencies[i+1][rid] = curr_resn[rid] return equivalencies
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:remove_path_segments; 3, parameters; 3, 4; 3, 5; 4, identifier:segments; 5, identifier:removes; 6, block; 6, 7; 6, 20; 6, 33; 6, 142; 7, if_statement; 7, 8; 7, 12; 8, comparison_operator:==; 8, 9; 8, 10; 9, identifier:segments; 10, list:['']; 10, 11; 11, string:''; 12, block; 12, 13; 13, expression_statement; 13, 14; 14, call; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:segments; 17, identifier:append; 18, argument_list; 18, 19; 19, string:''; 20, if_statement; 20, 21; 20, 25; 21, comparison_operator:==; 21, 22; 21, 23; 22, identifier:removes; 23, list:['']; 23, 24; 24, string:''; 25, block; 25, 26; 26, expression_statement; 26, 27; 27, call; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:removes; 30, identifier:append; 31, argument_list; 31, 32; 32, string:''; 33, if_statement; 33, 34; 33, 37; 33, 42; 33, 57; 34, comparison_operator:==; 34, 35; 34, 36; 35, identifier:segments; 36, identifier:removes; 37, block; 37, 38; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 41; 40, identifier:ret; 41, list:[]; 42, elif_clause; 42, 43; 42, 52; 43, comparison_operator:>; 43, 44; 43, 48; 44, call; 44, 45; 44, 46; 45, identifier:len; 46, argument_list; 46, 47; 47, identifier:removes; 48, call; 48, 49; 48, 50; 49, identifier:len; 50, argument_list; 50, 51; 51, identifier:segments; 52, block; 52, 53; 53, expression_statement; 53, 54; 54, assignment; 54, 55; 54, 56; 55, identifier:ret; 56, identifier:segments; 57, else_clause; 57, 58; 58, block; 58, 59; 58, 66; 58, 87; 59, expression_statement; 59, 60; 60, assignment; 60, 61; 60, 62; 61, identifier:removes2; 62, call; 62, 63; 62, 64; 63, identifier:list; 64, argument_list; 64, 65; 65, identifier:removes; 66, if_statement; 66, 67; 66, 79; 67, boolean_operator:and; 67, 68; 67, 74; 68, comparison_operator:>; 68, 69; 68, 73; 69, call; 69, 70; 69, 71; 70, identifier:len; 71, argument_list; 71, 72; 72, identifier:removes; 73, integer:1; 74, comparison_operator:==; 74, 75; 74, 78; 75, subscript; 75, 76; 75, 77; 76, identifier:removes; 77, integer:0; 78, string:''; 79, block; 79, 80; 80, expression_statement; 80, 81; 81, call; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:removes2; 84, identifier:pop; 85, argument_list; 85, 86; 86, integer:0; 87, if_statement; 87, 88; 87, 103; 87, 136; 88, boolean_operator:and; 88, 89; 88, 90; 89, identifier:removes2; 90, comparison_operator:==; 90, 91; 90, 92; 91, identifier:removes2; 92, subscript; 92, 93; 92, 94; 93, identifier:segments; 94, slice; 94, 95; 94, 102; 95, binary_operator:*; 95, 96; 95, 98; 96, unary_operator:-; 96, 97; 97, integer:1; 98, call; 98, 99; 98, 100; 99, identifier:len; 100, argument_list; 100, 101; 101, identifier:removes2; 102, colon; 103, block; 103, 104; 103, 120; 104, expression_statement; 104, 105; 105, assignment; 105, 106; 105, 107; 106, identifier:ret; 107, subscript; 107, 108; 107, 109; 108, identifier:segments; 109, slice; 109, 110; 109, 111; 110, colon; 111, binary_operator:-; 111, 112; 111, 116; 112, call; 112, 113; 112, 114; 113, identifier:len; 114, argument_list; 114, 115; 115, identifier:segments; 116, call; 116, 117; 116, 118; 117, identifier:len; 118, argument_list; 118, 119; 119, identifier:removes2; 120, if_statement; 120, 121; 120, 128; 121, boolean_operator:and; 121, 122; 121, 127; 122, comparison_operator:!=; 122, 123; 122, 126; 123, subscript; 123, 124; 123, 125; 124, identifier:removes; 125, integer:0; 126, string:''; 127, identifier:ret; 128, block; 128, 129; 129, expression_statement; 129, 130; 130, call; 130, 131; 130, 134; 131, attribute; 131, 132; 131, 133; 132, identifier:ret; 133, identifier:append; 134, argument_list; 134, 135; 135, string:''; 136, else_clause; 136, 137; 137, block; 137, 138; 138, expression_statement; 138, 139; 139, assignment; 139, 140; 139, 141; 140, identifier:ret; 141, identifier:segments; 142, return_statement; 142, 143; 143, identifier:ret
def remove_path_segments(segments, removes): if segments == ['']: segments.append('') if removes == ['']: removes.append('') if segments == removes: ret = [] elif len(removes) > len(segments): ret = segments else: removes2 = list(removes) if len(removes) > 1 and removes[0] == '': removes2.pop(0) if removes2 and removes2 == segments[-1 * len(removes2):]: ret = segments[:len(segments) - len(removes2)] if removes[0] != '' and ret: ret.append('') else: ret = segments return ret
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 17; 2, function_name:error; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 4, identifier:cls; 5, identifier:template; 6, default_parameter; 6, 7; 6, 8; 7, identifier:default_params; 8, dictionary; 9, default_parameter; 9, 10; 9, 11; 10, identifier:cause; 11, None; 12, default_parameter; 12, 13; 12, 14; 13, identifier:stack_depth; 14, integer:0; 15, dictionary_splat_pattern; 15, 16; 16, identifier:more_params; 17, block; 17, 18; 17, 44; 17, 66; 17, 78; 17, 82; 17, 162; 17, 173; 17, 191; 17, 214; 18, if_statement; 18, 19; 18, 24; 19, not_operator; 19, 20; 20, call; 20, 21; 20, 22; 21, identifier:is_text; 22, argument_list; 22, 23; 23, identifier:template; 24, block; 24, 25; 24, 37; 25, expression_statement; 25, 26; 26, call; 26, 27; 26, 32; 27, attribute; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:sys; 30, identifier:stderr; 31, identifier:write; 32, argument_list; 32, 33; 33, call; 33, 34; 33, 35; 34, identifier:str; 35, argument_list; 35, 36; 36, string:"Log.error was expecting a unicode template"; 37, expression_statement; 37, 38; 38, call; 38, 39; 38, 42; 39, attribute; 39, 40; 39, 41; 40, identifier:Log; 41, identifier:error; 42, argument_list; 42, 43; 43, string:"Log.error was expecting a unicode template"; 44, if_statement; 44, 45; 44, 57; 45, boolean_operator:and; 45, 46; 45, 47; 46, identifier:default_params; 47, call; 47, 48; 47, 49; 48, identifier:isinstance; 49, argument_list; 49, 50; 49, 56; 50, subscript; 50, 51; 50, 55; 51, call; 51, 52; 51, 53; 52, identifier:listwrap; 53, argument_list; 53, 54; 54, identifier:default_params; 55, integer:0; 56, identifier:BaseException; 57, block; 57, 58; 57, 62; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 61; 60, identifier:cause; 61, identifier:default_params; 62, expression_statement; 62, 63; 63, assignment; 63, 64; 63, 65; 64, identifier:default_params; 65, dictionary; 66, expression_statement; 66, 67; 67, assignment; 67, 68; 67, 69; 68, identifier:params; 69, call; 69, 70; 69, 71; 70, identifier:Data; 71, argument_list; 71, 72; 72, call; 72, 73; 72, 74; 73, identifier:dict; 74, argument_list; 74, 75; 74, 76; 75, identifier:default_params; 76, dictionary_splat; 76, 77; 77, identifier:more_params; 78, expression_statement; 78, 79; 79, assignment; 79, 80; 79, 81; 80, identifier:add_to_trace; 81, False; 82, if_statement; 82, 83; 82, 86; 82, 91; 82, 130; 82, 149; 83, comparison_operator:==; 83, 84; 83, 85; 84, identifier:cause; 85, None; 86, block; 86, 87; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 90; 89, identifier:causes; 90, None; 91, elif_clause; 91, 92; 91, 96; 92, call; 92, 93; 92, 94; 93, identifier:is_list; 94, argument_list; 94, 95; 95, identifier:cause; 96, block; 96, 97; 96, 101; 96, 123; 97, expression_statement; 97, 98; 98, assignment; 98, 99; 98, 100; 99, identifier:causes; 100, list:[]; 101, for_statement; 101, 102; 101, 103; 101, 107; 102, identifier:c; 103, call; 103, 104; 103, 105; 104, identifier:listwrap; 105, argument_list; 105, 106; 106, identifier:cause; 107, block; 107, 108; 108, expression_statement; 108, 109; 109, call; 109, 110; 109, 113; 110, attribute; 110, 111; 110, 112; 111, identifier:causes; 112, identifier:append; 113, argument_list; 113, 114; 114, call; 114, 115; 114, 118; 115, attribute; 115, 116; 115, 117; 116, identifier:Except; 117, identifier:wrap; 118, argument_list; 118, 119; 118, 120; 119, identifier:c; 120, keyword_argument; 120, 121; 120, 122; 121, identifier:stack_depth; 122, integer:1; 123, expression_statement; 123, 124; 124, assignment; 124, 125; 124, 126; 125, identifier:causes; 126, call; 126, 127; 126, 128; 127, identifier:FlatList; 128, argument_list; 128, 129; 129, identifier:causes; 130, elif_clause; 130, 131; 130, 136; 131, call; 131, 132; 131, 133; 132, identifier:isinstance; 133, argument_list; 133, 134; 133, 135; 134, identifier:cause; 135, identifier:BaseException; 136, block; 136, 137; 137, expression_statement; 137, 138; 138, assignment; 138, 139; 138, 140; 139, identifier:causes; 140, call; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, identifier:Except; 143, identifier:wrap; 144, argument_list; 144, 145; 144, 146; 145, identifier:cause; 146, keyword_argument; 146, 147; 146, 148; 147, identifier:stack_depth; 148, integer:1; 149, else_clause; 149, 150; 150, block; 150, 151; 150, 155; 151, expression_statement; 151, 152; 152, assignment; 152, 153; 152, 154; 153, identifier:causes; 154, None; 155, expression_statement; 155, 156; 156, call; 156, 157; 156, 160; 157, attribute; 157, 158; 157, 159; 158, identifier:Log; 159, identifier:error; 160, argument_list; 160, 161; 161, string:"can only accept Exception, or list of exceptions"; 162, expression_statement; 162, 163; 163, assignment; 163, 164; 163, 165; 164, identifier:trace; 165, call; 165, 166; 165, 169; 166, attribute; 166, 167; 166, 168; 167, identifier:exceptions; 168, identifier:extract_stack; 169, argument_list; 169, 170; 170, binary_operator:+; 170, 171; 170, 172; 171, identifier:stack_depth; 172, integer:1; 173, if_statement; 173, 174; 173, 175; 174, identifier:add_to_trace; 175, block; 175, 176; 176, expression_statement; 176, 177; 177, call; 177, 178; 177, 185; 178, attribute; 178, 179; 178, 184; 179, attribute; 179, 180; 179, 183; 180, subscript; 180, 181; 180, 182; 181, identifier:cause; 182, integer:0; 183, identifier:trace; 184, identifier:extend; 185, argument_list; 185, 186; 186, subscript; 186, 187; 186, 188; 187, identifier:trace; 188, slice; 188, 189; 188, 190; 189, integer:1; 190, colon; 191, expression_statement; 191, 192; 192, assignment; 192, 193; 192, 194; 193, identifier:e; 194, call; 194, 195; 194, 196; 195, identifier:Except; 196, argument_list; 196, 197; 196, 202; 196, 205; 196, 208; 196, 211; 197, keyword_argument; 197, 198; 197, 199; 198, identifier:context; 199, attribute; 199, 200; 199, 201; 200, identifier:exceptions; 201, identifier:ERROR; 202, keyword_argument; 202, 203; 202, 204; 203, identifier:template; 204, identifier:template; 205, keyword_argument; 205, 206; 205, 207; 206, identifier:params; 207, identifier:params; 208, keyword_argument; 208, 209; 208, 210; 209, identifier:cause; 210, identifier:causes; 211, keyword_argument; 211, 212; 211, 213; 212, identifier:trace; 213, identifier:trace; 214, expression_statement; 214, 215; 215, call; 215, 216; 215, 217; 216, identifier:raise_from_none; 217, argument_list; 217, 218; 218, identifier:e
def error( cls, template, default_params={}, cause=None, stack_depth=0, **more_params ): if not is_text(template): sys.stderr.write(str("Log.error was expecting a unicode template")) Log.error("Log.error was expecting a unicode template") if default_params and isinstance(listwrap(default_params)[0], BaseException): cause = default_params default_params = {} params = Data(dict(default_params, **more_params)) add_to_trace = False if cause == None: causes = None elif is_list(cause): causes = [] for c in listwrap(cause): causes.append(Except.wrap(c, stack_depth=1)) causes = FlatList(causes) elif isinstance(cause, BaseException): causes = Except.wrap(cause, stack_depth=1) else: causes = None Log.error("can only accept Exception, or list of exceptions") trace = exceptions.extract_stack(stack_depth + 1) if add_to_trace: cause[0].trace.extend(trace[1:]) e = Except(context=exceptions.ERROR, template=template, params=params, cause=causes, trace=trace) raise_from_none(e)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:summary_reporter; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 13; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:logging; 10, identifier:info; 11, argument_list; 11, 12; 12, string:'Creating MOB-recon summary report'; 13, with_statement; 13, 14; 13, 34; 14, with_clause; 14, 15; 15, with_item; 15, 16; 16, as_pattern; 16, 17; 16, 32; 17, call; 17, 18; 17, 19; 18, identifier:open; 19, argument_list; 19, 20; 19, 31; 20, call; 20, 21; 20, 26; 21, attribute; 21, 22; 21, 25; 22, attribute; 22, 23; 22, 24; 23, identifier:os; 24, identifier:path; 25, identifier:join; 26, argument_list; 26, 27; 26, 30; 27, attribute; 27, 28; 27, 29; 28, identifier:self; 29, identifier:reportpath; 30, string:'mob_recon_summary.csv'; 31, string:'w'; 32, as_pattern_target; 32, 33; 33, identifier:summary; 34, block; 34, 35; 34, 41; 34, 188; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 38; 37, identifier:data; 38, concatenated_string; 38, 39; 38, 40; 39, string:'Strain,Location,Contig,Incompatibility,IncompatibilityAccession,RelaxaseType,'; 40, string:'MashNearestNeighbor,MashNeighborDistance\n'; 41, for_statement; 41, 42; 41, 43; 41, 46; 42, identifier:sample; 43, attribute; 43, 44; 43, 45; 44, identifier:self; 45, identifier:metadata; 46, block; 46, 47; 46, 59; 47, expression_statement; 47, 48; 48, assignment; 48, 49; 48, 56; 49, attribute; 49, 50; 49, 55; 50, subscript; 50, 51; 50, 52; 51, identifier:sample; 52, attribute; 52, 53; 52, 54; 53, identifier:self; 54, identifier:analysistype; 55, identifier:pipelineresults; 56, call; 56, 57; 56, 58; 57, identifier:dict; 58, argument_list; 59, for_statement; 59, 60; 59, 63; 59, 74; 60, pattern_list; 60, 61; 60, 62; 61, identifier:primarykey; 62, identifier:results; 63, call; 63, 64; 63, 73; 64, attribute; 64, 65; 64, 72; 65, attribute; 65, 66; 65, 71; 66, subscript; 66, 67; 66, 68; 67, identifier:sample; 68, attribute; 68, 69; 68, 70; 69, identifier:self; 70, identifier:analysistype; 71, identifier:report_dict; 72, identifier:items; 73, argument_list; 74, block; 74, 75; 75, if_statement; 75, 76; 75, 81; 76, comparison_operator:!=; 76, 77; 76, 80; 77, subscript; 77, 78; 77, 79; 78, identifier:results; 79, string:'cluster_id'; 80, string:'chromosome'; 81, block; 81, 82; 81, 142; 81, 146; 82, expression_statement; 82, 83; 83, augmented_assignment:+=; 83, 84; 83, 85; 84, identifier:data; 85, call; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, string:','; 88, identifier:join; 89, generator_expression; 89, 90; 89, 108; 90, conditional_expression:if; 90, 91; 90, 101; 90, 107; 91, call; 91, 92; 91, 98; 92, attribute; 92, 93; 92, 97; 93, call; 93, 94; 93, 95; 94, identifier:str; 95, argument_list; 95, 96; 96, identifier:result; 97, identifier:replace; 98, argument_list; 98, 99; 98, 100; 99, string:','; 100, string:';'; 101, comparison_operator:!=; 101, 102; 101, 106; 102, call; 102, 103; 102, 104; 103, identifier:str; 104, argument_list; 104, 105; 105, identifier:result; 106, string:'nan'; 107, string:'ND'; 108, for_in_clause; 108, 109; 108, 110; 109, identifier:result; 110, list:[ sample.name, results['cluster_id'], results['contig_id'].split('|')[1], results['rep_type'], results['rep_type_accession'], results['relaxase_type'], results['mash_nearest_neighbor'], results['mash_neighbor_distance']]; 110, 111; 110, 114; 110, 117; 110, 127; 110, 130; 110, 133; 110, 136; 110, 139; 111, attribute; 111, 112; 111, 113; 112, identifier:sample; 113, identifier:name; 114, subscript; 114, 115; 114, 116; 115, identifier:results; 116, string:'cluster_id'; 117, subscript; 117, 118; 117, 126; 118, call; 118, 119; 118, 124; 119, attribute; 119, 120; 119, 123; 120, subscript; 120, 121; 120, 122; 121, identifier:results; 122, string:'contig_id'; 123, identifier:split; 124, argument_list; 124, 125; 125, string:'|'; 126, integer:1; 127, subscript; 127, 128; 127, 129; 128, identifier:results; 129, string:'rep_type'; 130, subscript; 130, 131; 130, 132; 131, identifier:results; 132, string:'rep_type_accession'; 133, subscript; 133, 134; 133, 135; 134, identifier:results; 135, string:'relaxase_type'; 136, subscript; 136, 137; 136, 138; 137, identifier:results; 138, string:'mash_nearest_neighbor'; 139, subscript; 139, 140; 139, 141; 140, identifier:results; 141, string:'mash_neighbor_distance'; 142, expression_statement; 142, 143; 143, augmented_assignment:+=; 143, 144; 143, 145; 144, identifier:data; 145, string:'\n'; 146, expression_statement; 146, 147; 147, assignment; 147, 148; 147, 159; 148, subscript; 148, 149; 148, 156; 149, attribute; 149, 150; 149, 155; 150, subscript; 150, 151; 150, 152; 151, identifier:sample; 152, attribute; 152, 153; 152, 154; 153, identifier:self; 154, identifier:analysistype; 155, identifier:pipelineresults; 156, subscript; 156, 157; 156, 158; 157, identifier:results; 158, string:'cluster_id'; 159, call; 159, 160; 159, 163; 160, attribute; 160, 161; 160, 162; 161, string:';'; 162, identifier:join; 163, generator_expression; 163, 164; 163, 182; 164, conditional_expression:if; 164, 165; 164, 175; 164, 181; 165, call; 165, 166; 165, 172; 166, attribute; 166, 167; 166, 171; 167, call; 167, 168; 167, 169; 168, identifier:str; 169, argument_list; 169, 170; 170, identifier:result; 171, identifier:replace; 172, argument_list; 172, 173; 172, 174; 173, string:','; 174, string:';'; 175, comparison_operator:!=; 175, 176; 175, 180; 176, call; 176, 177; 176, 178; 177, identifier:str; 178, argument_list; 178, 179; 179, identifier:result; 180, string:'nan'; 181, string:'ND'; 182, for_in_clause; 182, 183; 182, 184; 183, identifier:result; 184, list:[ results['rep_type']]; 184, 185; 185, subscript; 185, 186; 185, 187; 186, identifier:results; 187, string:'rep_type'; 188, expression_statement; 188, 189; 189, call; 189, 190; 189, 193; 190, attribute; 190, 191; 190, 192; 191, identifier:summary; 192, identifier:write; 193, argument_list; 193, 194; 194, identifier:data
def summary_reporter(self): logging.info('Creating MOB-recon summary report') with open(os.path.join(self.reportpath, 'mob_recon_summary.csv'), 'w') as summary: data = 'Strain,Location,Contig,Incompatibility,IncompatibilityAccession,RelaxaseType,' \ 'MashNearestNeighbor,MashNeighborDistance\n' for sample in self.metadata: sample[self.analysistype].pipelineresults = dict() for primarykey, results in sample[self.analysistype].report_dict.items(): if results['cluster_id'] != 'chromosome': data += ','.join(str(result).replace(',', ';') if str(result) != 'nan' else 'ND' for result in [ sample.name, results['cluster_id'], results['contig_id'].split('|')[1], results['rep_type'], results['rep_type_accession'], results['relaxase_type'], results['mash_nearest_neighbor'], results['mash_neighbor_distance']] ) data += '\n' sample[self.analysistype].pipelineresults[results['cluster_id']] = \ ';'.join(str(result).replace(',', ';') if str(result) != 'nan' else 'ND' for result in [ results['rep_type']] ) summary.write(data)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:amrsummary; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 13; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:logging; 10, identifier:info; 11, argument_list; 11, 12; 12, string:'Creating AMR summary table from ResFinder and MOB-recon outputs'; 13, with_statement; 13, 14; 13, 34; 14, with_clause; 14, 15; 15, with_item; 15, 16; 16, as_pattern; 16, 17; 16, 32; 17, call; 17, 18; 17, 19; 18, identifier:open; 19, argument_list; 19, 20; 19, 31; 20, call; 20, 21; 20, 26; 21, attribute; 21, 22; 21, 25; 22, attribute; 22, 23; 22, 24; 23, identifier:os; 24, identifier:path; 25, identifier:join; 26, argument_list; 26, 27; 26, 30; 27, attribute; 27, 28; 27, 29; 28, identifier:self; 29, identifier:reportpath; 30, string:'amr_summary.csv'; 31, string:'w'; 32, as_pattern_target; 32, 33; 33, identifier:amr; 34, block; 34, 35; 34, 39; 34, 306; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 38; 37, identifier:data; 38, string:'Strain,Gene,Allele,Resistance,PercentIdentity,Contig,Location,PlasmidIncompatibilitySets\n'; 39, for_statement; 39, 40; 39, 41; 39, 44; 40, identifier:sample; 41, attribute; 41, 42; 41, 43; 42, identifier:self; 43, identifier:metadata; 44, block; 44, 45; 44, 51; 44, 135; 45, expression_statement; 45, 46; 46, assignment; 46, 47; 46, 48; 47, identifier:inc_dict; 48, call; 48, 49; 48, 50; 49, identifier:dict; 50, argument_list; 51, for_statement; 51, 52; 51, 55; 51, 66; 52, pattern_list; 52, 53; 52, 54; 53, identifier:primarykey; 54, identifier:results; 55, call; 55, 56; 55, 65; 56, attribute; 56, 57; 56, 64; 57, attribute; 57, 58; 57, 63; 58, subscript; 58, 59; 58, 60; 59, identifier:sample; 60, attribute; 60, 61; 60, 62; 61, identifier:self; 62, identifier:analysistype; 63, identifier:report_dict; 64, identifier:items; 65, argument_list; 66, block; 66, 67; 67, try_statement; 67, 68; 67, 131; 68, block; 68, 69; 68, 75; 68, 100; 69, expression_statement; 69, 70; 70, assignment; 70, 71; 70, 72; 71, identifier:inc; 72, subscript; 72, 73; 72, 74; 73, identifier:results; 74, string:'cluster_id'; 75, expression_statement; 75, 76; 76, assignment; 76, 77; 76, 78; 77, identifier:rep; 78, conditional_expression:if; 78, 79; 78, 91; 78, 99; 79, call; 79, 80; 79, 88; 80, attribute; 80, 81; 80, 87; 81, call; 81, 82; 81, 83; 82, identifier:str; 83, argument_list; 83, 84; 84, subscript; 84, 85; 84, 86; 85, identifier:results; 86, string:'rep_type'; 87, identifier:replace; 88, argument_list; 88, 89; 88, 90; 89, string:','; 90, string:';'; 91, comparison_operator:!=; 91, 92; 91, 98; 92, call; 92, 93; 92, 94; 93, identifier:str; 94, argument_list; 94, 95; 95, subscript; 95, 96; 95, 97; 96, identifier:results; 97, string:'rep_type'; 98, string:'nan'; 99, string:'ND'; 100, try_statement; 100, 101; 100, 111; 101, block; 101, 102; 102, expression_statement; 102, 103; 103, call; 103, 104; 103, 109; 104, attribute; 104, 105; 104, 108; 105, subscript; 105, 106; 105, 107; 106, identifier:inc_dict; 107, identifier:inc; 108, identifier:add; 109, argument_list; 109, 110; 110, identifier:rep; 111, except_clause; 111, 112; 111, 113; 112, identifier:KeyError; 113, block; 113, 114; 113, 122; 114, expression_statement; 114, 115; 115, assignment; 115, 116; 115, 119; 116, subscript; 116, 117; 116, 118; 117, identifier:inc_dict; 118, identifier:inc; 119, call; 119, 120; 119, 121; 120, identifier:set; 121, argument_list; 122, expression_statement; 122, 123; 123, call; 123, 124; 123, 129; 124, attribute; 124, 125; 124, 128; 125, subscript; 125, 126; 125, 127; 126, identifier:inc_dict; 127, identifier:inc; 128, identifier:add; 129, argument_list; 129, 130; 130, identifier:rep; 131, except_clause; 131, 132; 131, 133; 132, identifier:KeyError; 133, block; 133, 134; 134, pass_statement; 135, for_statement; 135, 136; 135, 139; 135, 150; 136, pattern_list; 136, 137; 136, 138; 137, identifier:primarykey; 138, identifier:results; 139, call; 139, 140; 139, 149; 140, attribute; 140, 141; 140, 148; 141, attribute; 141, 142; 141, 147; 142, subscript; 142, 143; 142, 144; 143, identifier:sample; 144, attribute; 144, 145; 144, 146; 145, identifier:self; 146, identifier:analysistype; 147, identifier:report_dict; 148, identifier:items; 149, argument_list; 150, block; 150, 151; 151, try_statement; 151, 152; 151, 302; 152, block; 152, 153; 152, 166; 152, 192; 153, expression_statement; 153, 154; 154, assignment; 154, 155; 154, 156; 155, identifier:contig; 156, subscript; 156, 157; 156, 165; 157, call; 157, 158; 157, 163; 158, attribute; 158, 159; 158, 162; 159, subscript; 159, 160; 159, 161; 160, identifier:results; 161, string:'contig_id'; 162, identifier:split; 163, argument_list; 163, 164; 164, string:'|'; 165, integer:1; 166, if_statement; 166, 167; 166, 180; 167, call; 167, 168; 167, 178; 168, attribute; 168, 169; 168, 177; 169, subscript; 169, 170; 169, 176; 170, call; 170, 171; 170, 174; 171, attribute; 171, 172; 171, 173; 172, identifier:contig; 173, identifier:split; 174, argument_list; 174, 175; 175, string:'_'; 176, integer:1; 177, identifier:startswith; 178, argument_list; 178, 179; 179, string:'length'; 180, block; 180, 181; 181, expression_statement; 181, 182; 182, assignment; 182, 183; 182, 184; 183, identifier:contig; 184, subscript; 184, 185; 184, 191; 185, call; 185, 186; 185, 189; 186, attribute; 186, 187; 186, 188; 187, identifier:contig; 188, identifier:split; 189, argument_list; 189, 190; 190, string:'_'; 191, integer:0; 192, for_statement; 192, 193; 192, 194; 192, 199; 193, identifier:amr_result; 194, attribute; 194, 195; 194, 198; 195, attribute; 195, 196; 195, 197; 196, identifier:sample; 197, identifier:resfinder_assembled; 198, identifier:sampledata; 199, block; 199, 200; 200, if_statement; 200, 201; 200, 210; 201, comparison_operator:==; 201, 202; 201, 203; 202, identifier:contig; 203, call; 203, 204; 203, 205; 204, identifier:str; 205, argument_list; 205, 206; 206, subscript; 206, 207; 206, 208; 207, identifier:amr_result; 208, unary_operator:-; 208, 209; 209, integer:1; 210, block; 210, 211; 210, 224; 211, expression_statement; 211, 212; 212, augmented_assignment:+=; 212, 213; 212, 214; 213, identifier:data; 214, call; 214, 215; 214, 218; 215, attribute; 215, 216; 215, 217; 216, string:'{sn},'; 217, identifier:format; 218, argument_list; 218, 219; 219, keyword_argument; 219, 220; 219, 221; 220, identifier:sn; 221, attribute; 221, 222; 221, 223; 222, identifier:sample; 223, identifier:name; 224, expression_statement; 224, 225; 225, augmented_assignment:+=; 225, 226; 225, 227; 226, identifier:data; 227, call; 227, 228; 227, 232; 228, attribute; 228, 229; 228, 230; 228, 231; 229, string:'{amr},{mob}\n'; 230, line_continuation:\; 231, identifier:format; 232, argument_list; 232, 233; 232, 260; 233, keyword_argument; 233, 234; 233, 235; 234, identifier:amr; 235, call; 235, 236; 235, 239; 236, attribute; 236, 237; 236, 238; 237, string:','; 238, identifier:join; 239, generator_expression; 239, 240; 239, 252; 240, conditional_expression:if; 240, 241; 240, 245; 240, 251; 241, call; 241, 242; 241, 243; 242, identifier:str; 243, argument_list; 243, 244; 244, identifier:res; 245, comparison_operator:!=; 245, 246; 245, 250; 246, call; 246, 247; 246, 248; 247, identifier:str; 248, argument_list; 248, 249; 249, identifier:res; 250, string:'nan'; 251, string:'ND'; 252, for_in_clause; 252, 253; 252, 254; 253, identifier:res; 254, subscript; 254, 255; 254, 256; 255, identifier:amr_result; 256, slice; 256, 257; 256, 258; 256, 259; 257, integer:0; 258, colon; 259, integer:4; 260, keyword_argument; 260, 261; 260, 262; 261, identifier:mob; 262, call; 262, 263; 262, 266; 263, attribute; 263, 264; 263, 265; 264, string:','; 265, identifier:join; 266, generator_expression; 266, 267; 266, 279; 267, conditional_expression:if; 267, 268; 267, 272; 267, 278; 268, call; 268, 269; 268, 270; 269, identifier:str; 270, argument_list; 270, 271; 271, identifier:res; 272, comparison_operator:!=; 272, 273; 272, 277; 273, call; 273, 274; 273, 275; 274, identifier:str; 275, argument_list; 275, 276; 276, identifier:res; 277, string:'nan'; 278, string:'ND'; 279, for_in_clause; 279, 280; 279, 281; 280, identifier:res; 281, list:[contig, results['cluster_id'], ';'.join(sorted(inc_dict[str(results['cluster_id'])])) ]; 281, 282; 281, 283; 281, 286; 282, identifier:contig; 283, subscript; 283, 284; 283, 285; 284, identifier:results; 285, string:'cluster_id'; 286, call; 286, 287; 286, 290; 287, attribute; 287, 288; 287, 289; 288, string:';'; 289, identifier:join; 290, argument_list; 290, 291; 291, call; 291, 292; 291, 293; 292, identifier:sorted; 293, argument_list; 293, 294; 294, subscript; 294, 295; 294, 296; 295, identifier:inc_dict; 296, call; 296, 297; 296, 298; 297, identifier:str; 298, argument_list; 298, 299; 299, subscript; 299, 300; 299, 301; 300, identifier:results; 301, string:'cluster_id'; 302, except_clause; 302, 303; 302, 304; 303, identifier:KeyError; 304, block; 304, 305; 305, pass_statement; 306, expression_statement; 306, 307; 307, call; 307, 308; 307, 311; 308, attribute; 308, 309; 308, 310; 309, identifier:amr; 310, identifier:write; 311, argument_list; 311, 312; 312, identifier:data
def amrsummary(self): logging.info('Creating AMR summary table from ResFinder and MOB-recon outputs') with open(os.path.join(self.reportpath, 'amr_summary.csv'), 'w') as amr: data = 'Strain,Gene,Allele,Resistance,PercentIdentity,Contig,Location,PlasmidIncompatibilitySets\n' for sample in self.metadata: inc_dict = dict() for primarykey, results in sample[self.analysistype].report_dict.items(): try: inc = results['cluster_id'] rep = str(results['rep_type']).replace(',', ';') if str(results['rep_type']) != 'nan' else 'ND' try: inc_dict[inc].add(rep) except KeyError: inc_dict[inc] = set() inc_dict[inc].add(rep) except KeyError: pass for primarykey, results in sample[self.analysistype].report_dict.items(): try: contig = results['contig_id'].split('|')[1] if contig.split('_')[1].startswith('length'): contig = contig.split('_')[0] for amr_result in sample.resfinder_assembled.sampledata: if contig == str(amr_result[-1]): data += '{sn},'.format(sn=sample.name) data += '{amr},{mob}\n'\ .format(amr=','.join(str(res) if str(res) != 'nan' else 'ND' for res in amr_result[0:4]), mob=','.join(str(res) if str(res) != 'nan' else 'ND' for res in [contig, results['cluster_id'], ';'.join(sorted(inc_dict[str(results['cluster_id'])])) ] ) ) except KeyError: pass amr.write(data)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:geneseekrsummary; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 13; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:logging; 10, identifier:info; 11, argument_list; 11, 12; 12, string:'Creating predicted plasmid-borne gene summary table'; 13, with_statement; 13, 14; 13, 34; 14, with_clause; 14, 15; 15, with_item; 15, 16; 16, as_pattern; 16, 17; 16, 32; 17, call; 17, 18; 17, 19; 18, identifier:open; 19, argument_list; 19, 20; 19, 31; 20, call; 20, 21; 20, 26; 21, attribute; 21, 22; 21, 25; 22, attribute; 22, 23; 22, 24; 23, identifier:os; 24, identifier:path; 25, identifier:join; 26, argument_list; 26, 27; 26, 30; 27, attribute; 27, 28; 27, 29; 28, identifier:self; 29, identifier:reportpath; 30, string:'plasmid_borne_summary.csv'; 31, string:'w'; 32, as_pattern_target; 32, 33; 33, identifier:pbs; 34, block; 34, 35; 34, 39; 34, 314; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 38; 37, identifier:data; 38, string:'Strain,Gene,PercentIdentity,Contig,Location,PlasmidIncompatibilitySets\n'; 39, for_statement; 39, 40; 39, 41; 39, 44; 40, identifier:sample; 41, attribute; 41, 42; 41, 43; 42, identifier:self; 43, identifier:metadata; 44, block; 44, 45; 44, 49; 44, 55; 44, 139; 44, 297; 45, expression_statement; 45, 46; 46, assignment; 46, 47; 46, 48; 47, identifier:result_bool; 48, False; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 52; 51, identifier:inc_dict; 52, call; 52, 53; 52, 54; 53, identifier:dict; 54, argument_list; 55, for_statement; 55, 56; 55, 59; 55, 70; 56, pattern_list; 56, 57; 56, 58; 57, identifier:primarykey; 58, identifier:results; 59, call; 59, 60; 59, 69; 60, attribute; 60, 61; 60, 68; 61, attribute; 61, 62; 61, 67; 62, subscript; 62, 63; 62, 64; 63, identifier:sample; 64, attribute; 64, 65; 64, 66; 65, identifier:self; 66, identifier:analysistype; 67, identifier:report_dict; 68, identifier:items; 69, argument_list; 70, block; 70, 71; 71, try_statement; 71, 72; 71, 135; 72, block; 72, 73; 72, 79; 72, 104; 73, expression_statement; 73, 74; 74, assignment; 74, 75; 74, 76; 75, identifier:inc; 76, subscript; 76, 77; 76, 78; 77, identifier:results; 78, string:'cluster_id'; 79, expression_statement; 79, 80; 80, assignment; 80, 81; 80, 82; 81, identifier:rep; 82, conditional_expression:if; 82, 83; 82, 95; 82, 103; 83, call; 83, 84; 83, 92; 84, attribute; 84, 85; 84, 91; 85, call; 85, 86; 85, 87; 86, identifier:str; 87, argument_list; 87, 88; 88, subscript; 88, 89; 88, 90; 89, identifier:results; 90, string:'rep_type'; 91, identifier:replace; 92, argument_list; 92, 93; 92, 94; 93, string:','; 94, string:';'; 95, comparison_operator:!=; 95, 96; 95, 102; 96, call; 96, 97; 96, 98; 97, identifier:str; 98, argument_list; 98, 99; 99, subscript; 99, 100; 99, 101; 100, identifier:results; 101, string:'rep_type'; 102, string:'nan'; 103, string:'ND'; 104, try_statement; 104, 105; 104, 115; 105, block; 105, 106; 106, expression_statement; 106, 107; 107, call; 107, 108; 107, 113; 108, attribute; 108, 109; 108, 112; 109, subscript; 109, 110; 109, 111; 110, identifier:inc_dict; 111, identifier:inc; 112, identifier:add; 113, argument_list; 113, 114; 114, identifier:rep; 115, except_clause; 115, 116; 115, 117; 116, identifier:KeyError; 117, block; 117, 118; 117, 126; 118, expression_statement; 118, 119; 119, assignment; 119, 120; 119, 123; 120, subscript; 120, 121; 120, 122; 121, identifier:inc_dict; 122, identifier:inc; 123, call; 123, 124; 123, 125; 124, identifier:set; 125, argument_list; 126, expression_statement; 126, 127; 127, call; 127, 128; 127, 133; 128, attribute; 128, 129; 128, 132; 129, subscript; 129, 130; 129, 131; 130, identifier:inc_dict; 131, identifier:inc; 132, identifier:add; 133, argument_list; 133, 134; 134, identifier:rep; 135, except_clause; 135, 136; 135, 137; 136, identifier:KeyError; 137, block; 137, 138; 138, pass_statement; 139, for_statement; 139, 140; 139, 143; 139, 154; 140, pattern_list; 140, 141; 140, 142; 141, identifier:primarykey; 142, identifier:results; 143, call; 143, 144; 143, 153; 144, attribute; 144, 145; 144, 152; 145, attribute; 145, 146; 145, 151; 146, subscript; 146, 147; 146, 148; 147, identifier:sample; 148, attribute; 148, 149; 148, 150; 149, identifier:self; 150, identifier:analysistype; 151, identifier:report_dict; 152, identifier:items; 153, argument_list; 154, block; 154, 155; 155, try_statement; 155, 156; 155, 293; 156, block; 156, 157; 156, 170; 156, 196; 157, expression_statement; 157, 158; 158, assignment; 158, 159; 158, 160; 159, identifier:contig; 160, subscript; 160, 161; 160, 169; 161, call; 161, 162; 161, 167; 162, attribute; 162, 163; 162, 166; 163, subscript; 163, 164; 163, 165; 164, identifier:results; 165, string:'contig_id'; 166, identifier:split; 167, argument_list; 167, 168; 168, string:'|'; 169, integer:1; 170, if_statement; 170, 171; 170, 184; 171, call; 171, 172; 171, 182; 172, attribute; 172, 173; 172, 181; 173, subscript; 173, 174; 173, 180; 174, call; 174, 175; 174, 178; 175, attribute; 175, 176; 175, 177; 176, identifier:contig; 177, identifier:split; 178, argument_list; 178, 179; 179, string:'_'; 180, integer:1; 181, identifier:startswith; 182, argument_list; 182, 183; 183, string:'length'; 184, block; 184, 185; 185, expression_statement; 185, 186; 186, assignment; 186, 187; 186, 188; 187, identifier:contig; 188, subscript; 188, 189; 188, 195; 189, call; 189, 190; 189, 193; 190, attribute; 190, 191; 190, 192; 191, identifier:contig; 192, identifier:split; 193, argument_list; 193, 194; 194, string:'_'; 195, integer:0; 196, for_statement; 196, 197; 196, 200; 196, 209; 197, pattern_list; 197, 198; 197, 199; 198, identifier:gene; 199, identifier:result_dict; 200, call; 200, 201; 200, 208; 201, attribute; 201, 202; 201, 207; 202, attribute; 202, 203; 202, 206; 203, attribute; 203, 204; 203, 205; 204, identifier:sample; 205, identifier:geneseekr_results; 206, identifier:sampledata; 207, identifier:items; 208, argument_list; 209, block; 209, 210; 210, if_statement; 210, 211; 210, 216; 211, comparison_operator:==; 211, 212; 211, 213; 212, identifier:contig; 213, subscript; 213, 214; 213, 215; 214, identifier:result_dict; 215, string:'query_id'; 216, block; 216, 217; 216, 223; 217, expression_statement; 217, 218; 218, assignment; 218, 219; 218, 220; 219, identifier:percent_identity; 220, subscript; 220, 221; 220, 222; 221, identifier:result_dict; 222, string:'PercentIdentity'; 223, if_statement; 223, 224; 223, 234; 224, comparison_operator:>=; 224, 225; 224, 231; 225, call; 225, 226; 225, 227; 226, identifier:float; 227, argument_list; 227, 228; 228, subscript; 228, 229; 228, 230; 229, identifier:result_dict; 230, string:'PercentIdentity'; 231, attribute; 231, 232; 231, 233; 232, identifier:self; 233, identifier:cutoff; 234, block; 234, 235; 234, 239; 234, 252; 235, expression_statement; 235, 236; 236, assignment; 236, 237; 236, 238; 237, identifier:result_bool; 238, True; 239, expression_statement; 239, 240; 240, augmented_assignment:+=; 240, 241; 240, 242; 241, identifier:data; 242, call; 242, 243; 242, 246; 243, attribute; 243, 244; 243, 245; 244, string:'{sn},'; 245, identifier:format; 246, argument_list; 246, 247; 247, keyword_argument; 247, 248; 247, 249; 248, identifier:sn; 249, attribute; 249, 250; 249, 251; 250, identifier:sample; 251, identifier:name; 252, expression_statement; 252, 253; 253, augmented_assignment:+=; 253, 254; 253, 255; 254, identifier:data; 255, call; 255, 256; 255, 260; 256, attribute; 256, 257; 256, 258; 256, 259; 257, string:'{gene},{pi},{contig},{cid},{inc}\n'; 258, line_continuation:\; 259, identifier:format; 260, argument_list; 260, 261; 260, 264; 260, 267; 260, 270; 260, 275; 261, keyword_argument; 261, 262; 261, 263; 262, identifier:gene; 263, identifier:gene; 264, keyword_argument; 264, 265; 264, 266; 265, identifier:pi; 266, identifier:percent_identity; 267, keyword_argument; 267, 268; 267, 269; 268, identifier:contig; 269, identifier:contig; 270, keyword_argument; 270, 271; 270, 272; 271, identifier:cid; 272, subscript; 272, 273; 272, 274; 273, identifier:results; 274, string:'cluster_id'; 275, keyword_argument; 275, 276; 275, 277; 276, identifier:inc; 277, call; 277, 278; 277, 281; 278, attribute; 278, 279; 278, 280; 279, string:';'; 280, identifier:join; 281, argument_list; 281, 282; 282, call; 282, 283; 282, 284; 283, identifier:sorted; 284, argument_list; 284, 285; 285, subscript; 285, 286; 285, 287; 286, identifier:inc_dict; 287, call; 287, 288; 287, 289; 288, identifier:str; 289, argument_list; 289, 290; 290, subscript; 290, 291; 290, 292; 291, identifier:results; 292, string:'cluster_id'; 293, except_clause; 293, 294; 293, 295; 294, identifier:KeyError; 295, block; 295, 296; 296, pass_statement; 297, if_statement; 297, 298; 297, 300; 298, not_operator; 298, 299; 299, identifier:result_bool; 300, block; 300, 301; 301, expression_statement; 301, 302; 302, augmented_assignment:+=; 302, 303; 302, 304; 303, identifier:data; 304, call; 304, 305; 304, 308; 305, attribute; 305, 306; 305, 307; 306, string:'{sn}\n'; 307, identifier:format; 308, argument_list; 308, 309; 309, keyword_argument; 309, 310; 309, 311; 310, identifier:sn; 311, attribute; 311, 312; 311, 313; 312, identifier:sample; 313, identifier:name; 314, expression_statement; 314, 315; 315, call; 315, 316; 315, 319; 316, attribute; 316, 317; 316, 318; 317, identifier:pbs; 318, identifier:write; 319, argument_list; 319, 320; 320, identifier:data
def geneseekrsummary(self): logging.info('Creating predicted plasmid-borne gene summary table') with open(os.path.join(self.reportpath, 'plasmid_borne_summary.csv'), 'w') as pbs: data = 'Strain,Gene,PercentIdentity,Contig,Location,PlasmidIncompatibilitySets\n' for sample in self.metadata: result_bool = False inc_dict = dict() for primarykey, results in sample[self.analysistype].report_dict.items(): try: inc = results['cluster_id'] rep = str(results['rep_type']).replace(',', ';') if str(results['rep_type']) != 'nan' else 'ND' try: inc_dict[inc].add(rep) except KeyError: inc_dict[inc] = set() inc_dict[inc].add(rep) except KeyError: pass for primarykey, results in sample[self.analysistype].report_dict.items(): try: contig = results['contig_id'].split('|')[1] if contig.split('_')[1].startswith('length'): contig = contig.split('_')[0] for gene, result_dict in sample.geneseekr_results.sampledata.items(): if contig == result_dict['query_id']: percent_identity = result_dict['PercentIdentity'] if float(result_dict['PercentIdentity']) >= self.cutoff: result_bool = True data += '{sn},'.format(sn=sample.name) data += '{gene},{pi},{contig},{cid},{inc}\n'\ .format(gene=gene, pi=percent_identity, contig=contig, cid=results['cluster_id'], inc=';'.join(sorted(inc_dict[str(results['cluster_id'])]))) except KeyError: pass if not result_bool: data += '{sn}\n'.format(sn=sample.name) pbs.write(data)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:filterunique; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, for_statement; 6, 7; 6, 8; 6, 11; 7, identifier:sample; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:metadata; 11, block; 11, 12; 11, 24; 11, 30; 11, 36; 11, 278; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 21; 14, attribute; 14, 15; 14, 20; 15, subscript; 15, 16; 15, 17; 16, identifier:sample; 17, attribute; 17, 18; 17, 19; 18, identifier:self; 19, identifier:analysistype; 20, identifier:blastresults; 21, call; 21, 22; 21, 23; 22, identifier:list; 23, argument_list; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 27; 26, identifier:resultdict; 27, call; 27, 28; 27, 29; 28, identifier:dict; 29, argument_list; 30, expression_statement; 30, 31; 31, assignment; 31, 32; 31, 33; 32, identifier:rowdict; 33, call; 33, 34; 33, 35; 34, identifier:dict; 35, argument_list; 36, try_statement; 36, 37; 36, 274; 37, block; 37, 38; 38, for_statement; 38, 39; 38, 40; 38, 47; 39, identifier:contig; 40, attribute; 40, 41; 40, 46; 41, subscript; 41, 42; 41, 43; 42, identifier:sample; 43, attribute; 43, 44; 43, 45; 44, identifier:self; 45, identifier:analysistype; 46, identifier:queryranges; 47, block; 47, 48; 48, for_statement; 48, 49; 48, 50; 48, 59; 49, identifier:location; 50, subscript; 50, 51; 50, 58; 51, attribute; 51, 52; 51, 57; 52, subscript; 52, 53; 52, 54; 53, identifier:sample; 54, attribute; 54, 55; 54, 56; 55, identifier:self; 56, identifier:analysistype; 57, identifier:queryranges; 58, identifier:contig; 59, block; 59, 60; 60, for_statement; 60, 61; 60, 62; 60, 71; 61, identifier:row; 62, subscript; 62, 63; 62, 70; 63, attribute; 63, 64; 63, 69; 64, subscript; 64, 65; 64, 66; 65, identifier:sample; 66, attribute; 66, 67; 66, 68; 67, identifier:self; 68, identifier:analysistype; 69, identifier:results; 70, identifier:contig; 71, block; 71, 72; 71, 78; 71, 84; 71, 90; 71, 96; 71, 112; 71, 123; 72, expression_statement; 72, 73; 73, assignment; 73, 74; 73, 75; 74, identifier:contig; 75, subscript; 75, 76; 75, 77; 76, identifier:row; 77, string:'query_id'; 78, expression_statement; 78, 79; 79, assignment; 79, 80; 79, 81; 80, identifier:high; 81, subscript; 81, 82; 81, 83; 82, identifier:row; 83, string:'high'; 84, expression_statement; 84, 85; 85, assignment; 85, 86; 85, 87; 86, identifier:low; 87, subscript; 87, 88; 87, 89; 88, identifier:row; 89, string:'low'; 90, expression_statement; 90, 91; 91, assignment; 91, 92; 91, 93; 92, identifier:percentidentity; 93, subscript; 93, 94; 93, 95; 94, identifier:row; 95, string:'percentidentity'; 96, expression_statement; 96, 97; 97, assignment; 97, 98; 97, 99; 98, identifier:locstr; 99, call; 99, 100; 99, 103; 100, attribute; 100, 101; 100, 102; 101, string:','; 102, identifier:join; 103, argument_list; 103, 104; 104, list_comprehension; 104, 105; 104, 109; 105, call; 105, 106; 105, 107; 106, identifier:str; 107, argument_list; 107, 108; 108, identifier:x; 109, for_in_clause; 109, 110; 109, 111; 110, identifier:x; 111, identifier:location; 112, expression_statement; 112, 113; 113, assignment; 113, 114; 113, 115; 114, identifier:loc; 115, call; 115, 116; 115, 117; 116, identifier:set; 117, argument_list; 117, 118; 118, call; 118, 119; 118, 120; 119, identifier:range; 120, argument_list; 120, 121; 120, 122; 121, identifier:low; 122, identifier:high; 123, if_statement; 123, 124; 123, 141; 124, call; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:loc; 127, identifier:intersection; 128, argument_list; 128, 129; 129, call; 129, 130; 129, 131; 130, identifier:set; 131, argument_list; 131, 132; 132, call; 132, 133; 132, 134; 133, identifier:range; 134, argument_list; 134, 135; 134, 138; 135, subscript; 135, 136; 135, 137; 136, identifier:location; 137, integer:0; 138, subscript; 138, 139; 138, 140; 139, identifier:location; 140, integer:1; 141, block; 141, 142; 142, try_statement; 142, 143; 142, 166; 143, block; 143, 144; 143, 155; 144, expression_statement; 144, 145; 145, call; 145, 146; 145, 153; 146, attribute; 146, 147; 146, 152; 147, subscript; 147, 148; 147, 151; 148, subscript; 148, 149; 148, 150; 149, identifier:resultdict; 150, identifier:contig; 151, identifier:locstr; 152, identifier:append; 153, argument_list; 153, 154; 154, identifier:percentidentity; 155, expression_statement; 155, 156; 156, call; 156, 157; 156, 164; 157, attribute; 157, 158; 157, 163; 158, subscript; 158, 159; 158, 162; 159, subscript; 159, 160; 159, 161; 160, identifier:rowdict; 161, identifier:contig; 162, identifier:locstr; 163, identifier:append; 164, argument_list; 164, 165; 165, identifier:row; 166, except_clause; 166, 167; 166, 168; 167, identifier:KeyError; 168, block; 168, 169; 169, try_statement; 169, 170; 169, 213; 170, block; 170, 171; 170, 181; 170, 192; 170, 202; 171, expression_statement; 171, 172; 172, assignment; 172, 173; 172, 178; 173, subscript; 173, 174; 173, 177; 174, subscript; 174, 175; 174, 176; 175, identifier:resultdict; 176, identifier:contig; 177, identifier:locstr; 178, call; 178, 179; 178, 180; 179, identifier:list; 180, argument_list; 181, expression_statement; 181, 182; 182, call; 182, 183; 182, 190; 183, attribute; 183, 184; 183, 189; 184, subscript; 184, 185; 184, 188; 185, subscript; 185, 186; 185, 187; 186, identifier:resultdict; 187, identifier:contig; 188, identifier:locstr; 189, identifier:append; 190, argument_list; 190, 191; 191, identifier:percentidentity; 192, expression_statement; 192, 193; 193, assignment; 193, 194; 193, 199; 194, subscript; 194, 195; 194, 198; 195, subscript; 195, 196; 195, 197; 196, identifier:rowdict; 197, identifier:contig; 198, identifier:locstr; 199, call; 199, 200; 199, 201; 200, identifier:list; 201, argument_list; 202, expression_statement; 202, 203; 203, call; 203, 204; 203, 211; 204, attribute; 204, 205; 204, 210; 205, subscript; 205, 206; 205, 209; 206, subscript; 206, 207; 206, 208; 207, identifier:rowdict; 208, identifier:contig; 209, identifier:locstr; 210, identifier:append; 211, argument_list; 211, 212; 212, identifier:row; 213, except_clause; 213, 214; 213, 215; 214, identifier:KeyError; 215, block; 215, 216; 215, 224; 215, 234; 215, 245; 215, 253; 215, 263; 216, expression_statement; 216, 217; 217, assignment; 217, 218; 217, 221; 218, subscript; 218, 219; 218, 220; 219, identifier:resultdict; 220, identifier:contig; 221, call; 221, 222; 221, 223; 222, identifier:dict; 223, argument_list; 224, expression_statement; 224, 225; 225, assignment; 225, 226; 225, 231; 226, subscript; 226, 227; 226, 230; 227, subscript; 227, 228; 227, 229; 228, identifier:resultdict; 229, identifier:contig; 230, identifier:locstr; 231, call; 231, 232; 231, 233; 232, identifier:list; 233, argument_list; 234, expression_statement; 234, 235; 235, call; 235, 236; 235, 243; 236, attribute; 236, 237; 236, 242; 237, subscript; 237, 238; 237, 241; 238, subscript; 238, 239; 238, 240; 239, identifier:resultdict; 240, identifier:contig; 241, identifier:locstr; 242, identifier:append; 243, argument_list; 243, 244; 244, identifier:percentidentity; 245, expression_statement; 245, 246; 246, assignment; 246, 247; 246, 250; 247, subscript; 247, 248; 247, 249; 248, identifier:rowdict; 249, identifier:contig; 250, call; 250, 251; 250, 252; 251, identifier:dict; 252, argument_list; 253, expression_statement; 253, 254; 254, assignment; 254, 255; 254, 260; 255, subscript; 255, 256; 255, 259; 256, subscript; 256, 257; 256, 258; 257, identifier:rowdict; 258, identifier:contig; 259, identifier:locstr; 260, call; 260, 261; 260, 262; 261, identifier:list; 262, argument_list; 263, expression_statement; 263, 264; 264, call; 264, 265; 264, 272; 265, attribute; 265, 266; 265, 271; 266, subscript; 266, 267; 266, 270; 267, subscript; 267, 268; 267, 269; 268, identifier:rowdict; 269, identifier:contig; 270, identifier:locstr; 271, identifier:append; 272, argument_list; 272, 273; 273, identifier:row; 274, except_clause; 274, 275; 274, 276; 275, identifier:KeyError; 276, block; 276, 277; 277, pass_statement; 278, for_statement; 278, 279; 278, 280; 278, 281; 279, identifier:contig; 280, identifier:resultdict; 281, block; 281, 282; 281, 288; 282, expression_statement; 282, 283; 283, assignment; 283, 284; 283, 285; 284, identifier:genes; 285, call; 285, 286; 285, 287; 286, identifier:list; 287, argument_list; 288, for_statement; 288, 289; 288, 290; 288, 293; 289, identifier:location; 290, subscript; 290, 291; 290, 292; 291, identifier:resultdict; 292, identifier:contig; 293, block; 293, 294; 293, 298; 294, expression_statement; 294, 295; 295, assignment; 295, 296; 295, 297; 296, identifier:multiple; 297, False; 298, for_statement; 298, 299; 298, 300; 298, 305; 299, identifier:row; 300, subscript; 300, 301; 300, 304; 301, subscript; 301, 302; 301, 303; 302, identifier:rowdict; 303, identifier:contig; 304, identifier:location; 305, block; 305, 306; 306, if_statement; 306, 307; 306, 329; 307, boolean_operator:and; 307, 308; 307, 323; 307, 324; 308, boolean_operator:and; 308, 309; 308, 321; 309, comparison_operator:==; 309, 310; 309, 313; 310, subscript; 310, 311; 310, 312; 311, identifier:row; 312, string:'percentidentity'; 313, call; 313, 314; 313, 315; 314, identifier:max; 315, argument_list; 315, 316; 316, subscript; 316, 317; 316, 320; 317, subscript; 317, 318; 317, 319; 318, identifier:resultdict; 319, identifier:contig; 320, identifier:location; 321, not_operator; 321, 322; 322, identifier:multiple; 323, line_continuation:\; 324, comparison_operator:not; 324, 325; 324, 328; 325, subscript; 325, 326; 325, 327; 326, identifier:row; 327, string:'subject_id'; 328, identifier:genes; 329, block; 329, 330; 329, 343; 329, 352; 330, expression_statement; 330, 331; 331, call; 331, 332; 331, 341; 332, attribute; 332, 333; 332, 340; 333, attribute; 333, 334; 333, 339; 334, subscript; 334, 335; 334, 336; 335, identifier:sample; 336, attribute; 336, 337; 336, 338; 337, identifier:self; 338, identifier:analysistype; 339, identifier:blastresults; 340, identifier:append; 341, argument_list; 341, 342; 342, identifier:row; 343, expression_statement; 343, 344; 344, call; 344, 345; 344, 348; 345, attribute; 345, 346; 345, 347; 346, identifier:genes; 347, identifier:append; 348, argument_list; 348, 349; 349, subscript; 349, 350; 349, 351; 350, identifier:row; 351, string:'subject_id'; 352, expression_statement; 352, 353; 353, assignment; 353, 354; 353, 355; 354, identifier:multiple; 355, True
def filterunique(self): for sample in self.metadata: sample[self.analysistype].blastresults = list() resultdict = dict() rowdict = dict() try: for contig in sample[self.analysistype].queryranges: for location in sample[self.analysistype].queryranges[contig]: for row in sample[self.analysistype].results[contig]: contig = row['query_id'] high = row['high'] low = row['low'] percentidentity = row['percentidentity'] locstr = ','.join([str(x) for x in location]) loc = set(range(low, high)) if loc.intersection(set(range(location[0], location[1]))): try: resultdict[contig][locstr].append(percentidentity) rowdict[contig][locstr].append(row) except KeyError: try: resultdict[contig][locstr] = list() resultdict[contig][locstr].append(percentidentity) rowdict[contig][locstr] = list() rowdict[contig][locstr].append(row) except KeyError: resultdict[contig] = dict() resultdict[contig][locstr] = list() resultdict[contig][locstr].append(percentidentity) rowdict[contig] = dict() rowdict[contig][locstr] = list() rowdict[contig][locstr].append(row) except KeyError: pass for contig in resultdict: genes = list() for location in resultdict[contig]: multiple = False for row in rowdict[contig][location]: if row['percentidentity'] == max(resultdict[contig][location]) and not multiple \ and row['subject_id'] not in genes: sample[self.analysistype].blastresults.append(row) genes.append(row['subject_id']) multiple = True
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:makedbthreads; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 38; 5, 77; 5, 164; 6, for_statement; 6, 7; 6, 8; 6, 11; 7, identifier:sample; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:metadata; 11, block; 11, 12; 12, if_statement; 12, 13; 12, 22; 13, comparison_operator:!=; 13, 14; 13, 21; 14, attribute; 14, 15; 14, 20; 15, subscript; 15, 16; 15, 17; 16, identifier:sample; 17, attribute; 17, 18; 17, 19; 18, identifier:self; 19, identifier:analysistype; 20, identifier:combinedtargets; 21, string:'NA'; 22, block; 22, 23; 23, expression_statement; 23, 24; 24, call; 24, 25; 24, 30; 25, attribute; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:self; 28, identifier:targetfolders; 29, identifier:add; 30, argument_list; 30, 31; 31, attribute; 31, 32; 31, 37; 32, subscript; 32, 33; 32, 34; 33, identifier:sample; 34, attribute; 34, 35; 34, 36; 35, identifier:self; 36, identifier:analysistype; 37, identifier:targetpath; 38, for_statement; 38, 39; 38, 40; 38, 49; 39, identifier:i; 40, call; 40, 41; 40, 42; 41, identifier:range; 42, argument_list; 42, 43; 43, call; 43, 44; 43, 45; 44, identifier:len; 45, argument_list; 45, 46; 46, attribute; 46, 47; 46, 48; 47, identifier:self; 48, identifier:targetfolders; 49, block; 49, 50; 49, 64; 49, 71; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 53; 52, identifier:threads; 53, call; 53, 54; 53, 55; 54, identifier:Thread; 55, argument_list; 55, 56; 55, 61; 56, keyword_argument; 56, 57; 56, 58; 57, identifier:target; 58, attribute; 58, 59; 58, 60; 59, identifier:self; 60, identifier:makeblastdb; 61, keyword_argument; 61, 62; 61, 63; 62, identifier:args; 63, tuple; 64, expression_statement; 64, 65; 65, call; 65, 66; 65, 69; 66, attribute; 66, 67; 66, 68; 67, identifier:threads; 68, identifier:setDaemon; 69, argument_list; 69, 70; 70, True; 71, expression_statement; 71, 72; 72, call; 72, 73; 72, 76; 73, attribute; 73, 74; 73, 75; 74, identifier:threads; 75, identifier:start; 76, argument_list; 77, for_statement; 77, 78; 77, 79; 77, 82; 78, identifier:targetdir; 79, attribute; 79, 80; 79, 81; 80, identifier:self; 81, identifier:targetfolders; 82, block; 82, 83; 82, 100; 82, 130; 83, expression_statement; 83, 84; 84, assignment; 84, 85; 84, 88; 85, attribute; 85, 86; 85, 87; 86, identifier:self; 87, identifier:targetfiles; 88, call; 88, 89; 88, 90; 89, identifier:glob; 90, argument_list; 90, 91; 91, call; 91, 92; 91, 97; 92, attribute; 92, 93; 92, 96; 93, attribute; 93, 94; 93, 95; 94, identifier:os; 95, identifier:path; 96, identifier:join; 97, argument_list; 97, 98; 97, 99; 98, identifier:targetdir; 99, string:'*.fasta'; 100, try_statement; 100, 101; 100, 110; 101, block; 101, 102; 102, expression_statement; 102, 103; 103, assignment; 103, 104; 103, 105; 104, identifier:_; 105, subscript; 105, 106; 105, 109; 106, attribute; 106, 107; 106, 108; 107, identifier:self; 108, identifier:targetfiles; 109, integer:0; 110, except_clause; 110, 111; 110, 112; 111, identifier:IndexError; 112, block; 112, 113; 113, expression_statement; 113, 114; 114, assignment; 114, 115; 114, 118; 115, attribute; 115, 116; 115, 117; 116, identifier:self; 117, identifier:targetfiles; 118, call; 118, 119; 118, 120; 119, identifier:glob; 120, argument_list; 120, 121; 121, call; 121, 122; 121, 127; 122, attribute; 122, 123; 122, 126; 123, attribute; 123, 124; 123, 125; 124, identifier:os; 125, identifier:path; 126, identifier:join; 127, argument_list; 127, 128; 127, 129; 128, identifier:targetdir; 129, string:'*.fasta'; 130, for_statement; 130, 131; 130, 132; 130, 135; 131, identifier:targetfile; 132, attribute; 132, 133; 132, 134; 133, identifier:self; 134, identifier:targetfiles; 135, block; 135, 136; 135, 155; 136, expression_statement; 136, 137; 137, assignment; 137, 138; 137, 143; 138, subscript; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:self; 141, identifier:records; 142, identifier:targetfile; 143, call; 143, 144; 143, 147; 144, attribute; 144, 145; 144, 146; 145, identifier:SeqIO; 146, identifier:to_dict; 147, argument_list; 147, 148; 148, call; 148, 149; 148, 152; 149, attribute; 149, 150; 149, 151; 150, identifier:SeqIO; 151, identifier:parse; 152, argument_list; 152, 153; 152, 154; 153, identifier:targetfile; 154, string:'fasta'; 155, expression_statement; 155, 156; 156, call; 156, 157; 156, 162; 157, attribute; 157, 158; 157, 161; 158, attribute; 158, 159; 158, 160; 159, identifier:self; 160, identifier:dqueue; 161, identifier:put; 162, argument_list; 162, 163; 163, identifier:targetfile; 164, expression_statement; 164, 165; 165, call; 165, 166; 165, 171; 166, attribute; 166, 167; 166, 170; 167, attribute; 167, 168; 167, 169; 168, identifier:self; 169, identifier:dqueue; 170, identifier:join; 171, argument_list
def makedbthreads(self): for sample in self.metadata: if sample[self.analysistype].combinedtargets != 'NA': self.targetfolders.add(sample[self.analysistype].targetpath) for i in range(len(self.targetfolders)): threads = Thread(target=self.makeblastdb, args=()) threads.setDaemon(True) threads.start() for targetdir in self.targetfolders: self.targetfiles = glob(os.path.join(targetdir, '*.fasta')) try: _ = self.targetfiles[0] except IndexError: self.targetfiles = glob(os.path.join(targetdir, '*.fasta')) for targetfile in self.targetfiles: self.records[targetfile] = SeqIO.to_dict(SeqIO.parse(targetfile, 'fasta')) self.dqueue.put(targetfile) self.dqueue.join()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:cowbat; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 13; 5, 49; 5, 85; 5, 116; 5, 152; 5, 188; 5, 229; 5, 265; 5, 307; 5, 349; 5, 391; 5, 433; 5, 469; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:logging; 10, identifier:info; 11, argument_list; 11, 12; 12, string:'Beginning COWBAT database downloads'; 13, if_statement; 13, 14; 13, 37; 14, boolean_operator:or; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:self; 17, identifier:overwrite; 18, not_operator; 18, 19; 19, call; 19, 20; 19, 25; 20, attribute; 20, 21; 20, 24; 21, attribute; 21, 22; 21, 23; 22, identifier:os; 23, identifier:path; 24, identifier:isdir; 25, argument_list; 25, 26; 26, call; 26, 27; 26, 32; 27, attribute; 27, 28; 27, 31; 28, attribute; 28, 29; 28, 30; 29, identifier:os; 30, identifier:path; 31, identifier:join; 32, argument_list; 32, 33; 32, 36; 33, attribute; 33, 34; 33, 35; 34, identifier:self; 35, identifier:databasepath; 36, string:'genesippr'; 37, block; 37, 38; 38, expression_statement; 38, 39; 39, call; 39, 40; 39, 43; 40, attribute; 40, 41; 40, 42; 41, identifier:self; 42, identifier:sipprverse_targets; 43, argument_list; 43, 44; 44, keyword_argument; 44, 45; 44, 46; 45, identifier:databasepath; 46, attribute; 46, 47; 46, 48; 47, identifier:self; 48, identifier:databasepath; 49, if_statement; 49, 50; 49, 73; 50, boolean_operator:or; 50, 51; 50, 54; 51, attribute; 51, 52; 51, 53; 52, identifier:self; 53, identifier:overwrite; 54, not_operator; 54, 55; 55, call; 55, 56; 55, 61; 56, attribute; 56, 57; 56, 60; 57, attribute; 57, 58; 57, 59; 58, identifier:os; 59, identifier:path; 60, identifier:isdir; 61, argument_list; 61, 62; 62, call; 62, 63; 62, 68; 63, attribute; 63, 64; 63, 67; 64, attribute; 64, 65; 64, 66; 65, identifier:os; 66, identifier:path; 67, identifier:join; 68, argument_list; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, identifier:self; 71, identifier:databasepath; 72, string:'coregenome'; 73, block; 73, 74; 74, expression_statement; 74, 75; 75, call; 75, 76; 75, 79; 76, attribute; 76, 77; 76, 78; 77, identifier:self; 78, identifier:cowbat_targets; 79, argument_list; 79, 80; 80, keyword_argument; 80, 81; 80, 82; 81, identifier:databasepath; 82, attribute; 82, 83; 82, 84; 83, identifier:self; 84, identifier:databasepath; 85, if_statement; 85, 86; 85, 109; 86, boolean_operator:or; 86, 87; 86, 90; 87, attribute; 87, 88; 87, 89; 88, identifier:self; 89, identifier:overwrite; 90, not_operator; 90, 91; 91, call; 91, 92; 91, 97; 92, attribute; 92, 93; 92, 96; 93, attribute; 93, 94; 93, 95; 94, identifier:os; 95, identifier:path; 96, identifier:isdir; 97, argument_list; 97, 98; 98, call; 98, 99; 98, 104; 99, attribute; 99, 100; 99, 103; 100, attribute; 100, 101; 100, 102; 101, identifier:os; 102, identifier:path; 103, identifier:join; 104, argument_list; 104, 105; 104, 108; 105, attribute; 105, 106; 105, 107; 106, identifier:self; 107, identifier:databasepath; 108, string:'ConFindr'; 109, block; 109, 110; 110, expression_statement; 110, 111; 111, call; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, identifier:self; 114, identifier:confindr_targets; 115, argument_list; 116, if_statement; 116, 117; 116, 140; 117, boolean_operator:or; 117, 118; 117, 121; 118, attribute; 118, 119; 118, 120; 119, identifier:self; 120, identifier:overwrite; 121, not_operator; 121, 122; 122, call; 122, 123; 122, 128; 123, attribute; 123, 124; 123, 127; 124, attribute; 124, 125; 124, 126; 125, identifier:os; 126, identifier:path; 127, identifier:isdir; 128, argument_list; 128, 129; 129, call; 129, 130; 129, 135; 130, attribute; 130, 131; 130, 134; 131, attribute; 131, 132; 131, 133; 132, identifier:os; 133, identifier:path; 134, identifier:join; 135, argument_list; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:self; 138, identifier:databasepath; 139, string:'mash'; 140, block; 140, 141; 141, expression_statement; 141, 142; 142, call; 142, 143; 142, 146; 143, attribute; 143, 144; 143, 145; 144, identifier:self; 145, identifier:mash; 146, argument_list; 146, 147; 147, keyword_argument; 147, 148; 147, 149; 148, identifier:databasepath; 149, attribute; 149, 150; 149, 151; 150, identifier:self; 151, identifier:databasepath; 152, if_statement; 152, 153; 152, 176; 153, boolean_operator:or; 153, 154; 153, 157; 154, attribute; 154, 155; 154, 156; 155, identifier:self; 156, identifier:overwrite; 157, not_operator; 157, 158; 158, call; 158, 159; 158, 164; 159, attribute; 159, 160; 159, 163; 160, attribute; 160, 161; 160, 162; 161, identifier:os; 162, identifier:path; 163, identifier:isdir; 164, argument_list; 164, 165; 165, call; 165, 166; 165, 171; 166, attribute; 166, 167; 166, 170; 167, attribute; 167, 168; 167, 169; 168, identifier:os; 169, identifier:path; 170, identifier:join; 171, argument_list; 171, 172; 171, 175; 172, attribute; 172, 173; 172, 174; 173, identifier:self; 174, identifier:databasepath; 175, string:'MLST'; 176, block; 176, 177; 177, expression_statement; 177, 178; 178, call; 178, 179; 178, 182; 179, attribute; 179, 180; 179, 181; 180, identifier:self; 181, identifier:mlst; 182, argument_list; 182, 183; 183, keyword_argument; 183, 184; 183, 185; 184, identifier:databasepath; 185, attribute; 185, 186; 185, 187; 186, identifier:self; 187, identifier:databasepath; 188, if_statement; 188, 189; 188, 212; 189, boolean_operator:or; 189, 190; 189, 193; 190, attribute; 190, 191; 190, 192; 191, identifier:self; 192, identifier:overwrite; 193, not_operator; 193, 194; 194, call; 194, 195; 194, 200; 195, attribute; 195, 196; 195, 199; 196, attribute; 196, 197; 196, 198; 197, identifier:os; 198, identifier:path; 199, identifier:isdir; 200, argument_list; 200, 201; 201, call; 201, 202; 201, 207; 202, attribute; 202, 203; 202, 206; 203, attribute; 203, 204; 203, 205; 204, identifier:os; 205, identifier:path; 206, identifier:join; 207, argument_list; 207, 208; 207, 211; 208, attribute; 208, 209; 208, 210; 209, identifier:self; 210, identifier:databasepath; 211, string:'rMLST'; 212, block; 212, 213; 213, expression_statement; 213, 214; 214, call; 214, 215; 214, 218; 215, attribute; 215, 216; 215, 217; 216, identifier:self; 217, identifier:rmlst; 218, argument_list; 218, 219; 218, 224; 219, keyword_argument; 219, 220; 219, 221; 220, identifier:databasepath; 221, attribute; 221, 222; 221, 223; 222, identifier:self; 223, identifier:databasepath; 224, keyword_argument; 224, 225; 224, 226; 225, identifier:credentials; 226, attribute; 226, 227; 226, 228; 227, identifier:self; 228, identifier:credentials; 229, if_statement; 229, 230; 229, 253; 230, boolean_operator:or; 230, 231; 230, 234; 231, attribute; 231, 232; 231, 233; 232, identifier:self; 233, identifier:overwrite; 234, not_operator; 234, 235; 235, call; 235, 236; 235, 241; 236, attribute; 236, 237; 236, 240; 237, attribute; 237, 238; 237, 239; 238, identifier:os; 239, identifier:path; 240, identifier:isdir; 241, argument_list; 241, 242; 242, call; 242, 243; 242, 248; 243, attribute; 243, 244; 243, 247; 244, attribute; 244, 245; 244, 246; 245, identifier:os; 246, identifier:path; 247, identifier:join; 248, argument_list; 248, 249; 248, 252; 249, attribute; 249, 250; 249, 251; 250, identifier:self; 251, identifier:databasepath; 252, string:'univec'; 253, block; 253, 254; 254, expression_statement; 254, 255; 255, call; 255, 256; 255, 259; 256, attribute; 256, 257; 256, 258; 257, identifier:self; 258, identifier:univec; 259, argument_list; 259, 260; 260, keyword_argument; 260, 261; 260, 262; 261, identifier:databasepath; 262, attribute; 262, 263; 262, 264; 263, identifier:self; 264, identifier:databasepath; 265, if_statement; 265, 266; 265, 289; 266, boolean_operator:or; 266, 267; 266, 270; 267, attribute; 267, 268; 267, 269; 268, identifier:self; 269, identifier:overwrite; 270, not_operator; 270, 271; 271, call; 271, 272; 271, 277; 272, attribute; 272, 273; 272, 276; 273, attribute; 273, 274; 273, 275; 274, identifier:os; 275, identifier:path; 276, identifier:isdir; 277, argument_list; 277, 278; 278, call; 278, 279; 278, 284; 279, attribute; 279, 280; 279, 283; 280, attribute; 280, 281; 280, 282; 281, identifier:os; 282, identifier:path; 283, identifier:join; 284, argument_list; 284, 285; 284, 288; 285, attribute; 285, 286; 285, 287; 286, identifier:self; 287, identifier:databasepath; 288, string:'resfinder'; 289, block; 289, 290; 290, expression_statement; 290, 291; 291, call; 291, 292; 291, 295; 292, attribute; 292, 293; 292, 294; 293, identifier:self; 294, identifier:cge_db_downloader; 295, argument_list; 295, 296; 295, 301; 295, 304; 296, keyword_argument; 296, 297; 296, 298; 297, identifier:databasepath; 298, attribute; 298, 299; 298, 300; 299, identifier:self; 300, identifier:databasepath; 301, keyword_argument; 301, 302; 301, 303; 302, identifier:analysistype; 303, string:'resfinder'; 304, keyword_argument; 304, 305; 304, 306; 305, identifier:dbname; 306, string:'resfinder_db'; 307, if_statement; 307, 308; 307, 331; 308, boolean_operator:or; 308, 309; 308, 312; 309, attribute; 309, 310; 309, 311; 310, identifier:self; 311, identifier:overwrite; 312, not_operator; 312, 313; 313, call; 313, 314; 313, 319; 314, attribute; 314, 315; 314, 318; 315, attribute; 315, 316; 315, 317; 316, identifier:os; 317, identifier:path; 318, identifier:isdir; 319, argument_list; 319, 320; 320, call; 320, 321; 320, 326; 321, attribute; 321, 322; 321, 325; 322, attribute; 322, 323; 322, 324; 323, identifier:os; 324, identifier:path; 325, identifier:join; 326, argument_list; 326, 327; 326, 330; 327, attribute; 327, 328; 327, 329; 328, identifier:self; 329, identifier:databasepath; 330, string:'virulence'; 331, block; 331, 332; 332, expression_statement; 332, 333; 333, call; 333, 334; 333, 337; 334, attribute; 334, 335; 334, 336; 335, identifier:self; 336, identifier:cge_db_downloader; 337, argument_list; 337, 338; 337, 343; 337, 346; 338, keyword_argument; 338, 339; 338, 340; 339, identifier:databasepath; 340, attribute; 340, 341; 340, 342; 341, identifier:self; 342, identifier:databasepath; 343, keyword_argument; 343, 344; 343, 345; 344, identifier:analysistype; 345, string:'virulence'; 346, keyword_argument; 346, 347; 346, 348; 347, identifier:dbname; 348, string:'virulencefinder_db'; 349, if_statement; 349, 350; 349, 373; 350, boolean_operator:or; 350, 351; 350, 354; 351, attribute; 351, 352; 351, 353; 352, identifier:self; 353, identifier:overwrite; 354, not_operator; 354, 355; 355, call; 355, 356; 355, 361; 356, attribute; 356, 357; 356, 360; 357, attribute; 357, 358; 357, 359; 358, identifier:os; 359, identifier:path; 360, identifier:isdir; 361, argument_list; 361, 362; 362, call; 362, 363; 362, 368; 363, attribute; 363, 364; 363, 367; 364, attribute; 364, 365; 364, 366; 365, identifier:os; 366, identifier:path; 367, identifier:join; 368, argument_list; 368, 369; 368, 372; 369, attribute; 369, 370; 369, 371; 370, identifier:self; 371, identifier:databasepath; 372, string:'serosippr'; 373, block; 373, 374; 374, expression_statement; 374, 375; 375, call; 375, 376; 375, 379; 376, attribute; 376, 377; 376, 378; 377, identifier:self; 378, identifier:cge_db_downloader; 379, argument_list; 379, 380; 379, 385; 379, 388; 380, keyword_argument; 380, 381; 380, 382; 381, identifier:databasepath; 382, attribute; 382, 383; 382, 384; 383, identifier:self; 384, identifier:databasepath; 385, keyword_argument; 385, 386; 385, 387; 386, identifier:analysistype; 387, string:'serosippr'; 388, keyword_argument; 388, 389; 388, 390; 389, identifier:dbname; 390, string:'serotypefinder_db'; 391, if_statement; 391, 392; 391, 415; 392, boolean_operator:or; 392, 393; 392, 396; 393, attribute; 393, 394; 393, 395; 394, identifier:self; 395, identifier:overwrite; 396, not_operator; 396, 397; 397, call; 397, 398; 397, 403; 398, attribute; 398, 399; 398, 402; 399, attribute; 399, 400; 399, 401; 400, identifier:os; 401, identifier:path; 402, identifier:isdir; 403, argument_list; 403, 404; 404, call; 404, 405; 404, 410; 405, attribute; 405, 406; 405, 409; 406, attribute; 406, 407; 406, 408; 407, identifier:os; 408, identifier:path; 409, identifier:join; 410, argument_list; 410, 411; 410, 414; 411, attribute; 411, 412; 411, 413; 412, identifier:self; 413, identifier:databasepath; 414, string:'pointfinder'; 415, block; 415, 416; 416, expression_statement; 416, 417; 417, call; 417, 418; 417, 421; 418, attribute; 418, 419; 418, 420; 419, identifier:self; 420, identifier:cge_db_downloader; 421, argument_list; 421, 422; 421, 427; 421, 430; 422, keyword_argument; 422, 423; 422, 424; 423, identifier:databasepath; 424, attribute; 424, 425; 424, 426; 425, identifier:self; 426, identifier:databasepath; 427, keyword_argument; 427, 428; 427, 429; 428, identifier:analysistype; 429, string:'pointfinder'; 430, keyword_argument; 430, 431; 430, 432; 431, identifier:dbname; 432, string:'pointfinder_db'; 433, if_statement; 433, 434; 433, 457; 434, boolean_operator:or; 434, 435; 434, 438; 435, attribute; 435, 436; 435, 437; 436, identifier:self; 437, identifier:overwrite; 438, not_operator; 438, 439; 439, call; 439, 440; 439, 445; 440, attribute; 440, 441; 440, 444; 441, attribute; 441, 442; 441, 443; 442, identifier:os; 443, identifier:path; 444, identifier:isdir; 445, argument_list; 445, 446; 446, call; 446, 447; 446, 452; 447, attribute; 447, 448; 447, 451; 448, attribute; 448, 449; 448, 450; 449, identifier:os; 450, identifier:path; 451, identifier:join; 452, argument_list; 452, 453; 452, 456; 453, attribute; 453, 454; 453, 455; 454, identifier:self; 455, identifier:databasepath; 456, string:'clark'; 457, block; 457, 458; 458, expression_statement; 458, 459; 459, call; 459, 460; 459, 463; 460, attribute; 460, 461; 460, 462; 461, identifier:self; 462, identifier:clark; 463, argument_list; 463, 464; 464, keyword_argument; 464, 465; 464, 466; 465, identifier:databasepath; 466, attribute; 466, 467; 466, 468; 467, identifier:self; 468, identifier:databasepath; 469, if_statement; 469, 470; 469, 493; 470, boolean_operator:or; 470, 471; 470, 474; 471, attribute; 471, 472; 471, 473; 472, identifier:self; 473, identifier:overwrite; 474, not_operator; 474, 475; 475, call; 475, 476; 475, 481; 476, attribute; 476, 477; 476, 480; 477, attribute; 477, 478; 477, 479; 478, identifier:os; 479, identifier:path; 480, identifier:isdir; 481, argument_list; 481, 482; 482, call; 482, 483; 482, 488; 483, attribute; 483, 484; 483, 487; 484, attribute; 484, 485; 484, 486; 485, identifier:os; 486, identifier:path; 487, identifier:join; 488, argument_list; 488, 489; 488, 492; 489, attribute; 489, 490; 489, 491; 490, identifier:self; 491, identifier:databasepath; 492, string:'mob_suite'; 493, block; 493, 494; 494, expression_statement; 494, 495; 495, call; 495, 496; 495, 499; 496, attribute; 496, 497; 496, 498; 497, identifier:self; 498, identifier:mob_suite_targets; 499, argument_list
def cowbat(self): logging.info('Beginning COWBAT database downloads') if self.overwrite or not os.path.isdir(os.path.join(self.databasepath, 'genesippr')): self.sipprverse_targets(databasepath=self.databasepath) if self.overwrite or not os.path.isdir(os.path.join(self.databasepath, 'coregenome')): self.cowbat_targets(databasepath=self.databasepath) if self.overwrite or not os.path.isdir(os.path.join(self.databasepath, 'ConFindr')): self.confindr_targets() if self.overwrite or not os.path.isdir(os.path.join(self.databasepath, 'mash')): self.mash(databasepath=self.databasepath) if self.overwrite or not os.path.isdir(os.path.join(self.databasepath, 'MLST')): self.mlst(databasepath=self.databasepath) if self.overwrite or not os.path.isdir(os.path.join(self.databasepath, 'rMLST')): self.rmlst(databasepath=self.databasepath, credentials=self.credentials) if self.overwrite or not os.path.isdir(os.path.join(self.databasepath, 'univec')): self.univec(databasepath=self.databasepath) if self.overwrite or not os.path.isdir(os.path.join(self.databasepath, 'resfinder')): self.cge_db_downloader(databasepath=self.databasepath, analysistype='resfinder', dbname='resfinder_db') if self.overwrite or not os.path.isdir(os.path.join(self.databasepath, 'virulence')): self.cge_db_downloader(databasepath=self.databasepath, analysistype='virulence', dbname='virulencefinder_db') if self.overwrite or not os.path.isdir(os.path.join(self.databasepath, 'serosippr')): self.cge_db_downloader(databasepath=self.databasepath, analysistype='serosippr', dbname='serotypefinder_db') if self.overwrite or not os.path.isdir(os.path.join(self.databasepath, 'pointfinder')): self.cge_db_downloader(databasepath=self.databasepath, analysistype='pointfinder', dbname='pointfinder_db') if self.overwrite or not os.path.isdir(os.path.join(self.databasepath, 'clark')): self.clark(databasepath=self.databasepath) if self.overwrite or not os.path.isdir(os.path.join(self.databasepath, 'mob_suite')): self.mob_suite_targets()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:setCalibration; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:dbBoostArray; 6, identifier:frequencies; 7, identifier:frange; 8, block; 8, 9; 9, if_statement; 9, 10; 9, 17; 9, 189; 10, boolean_operator:and; 10, 11; 10, 14; 11, comparison_operator:is; 11, 12; 11, 13; 12, identifier:dbBoostArray; 13, None; 14, comparison_operator:is; 14, 15; 14, 16; 15, identifier:frequencies; 16, None; 17, block; 17, 18; 17, 27; 17, 44; 17, 60; 17, 76; 17, 84; 17, 144; 17, 150; 17, 171; 17, 177; 17, 183; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:logger; 21, call; 21, 22; 21, 25; 22, attribute; 22, 23; 22, 24; 23, identifier:logging; 24, identifier:getLogger; 25, argument_list; 25, 26; 26, string:'main'; 27, if_statement; 27, 28; 27, 35; 28, comparison_operator:!=; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, identifier:dbBoostArray; 31, identifier:shape; 32, attribute; 32, 33; 32, 34; 33, identifier:frequencies; 34, identifier:shape; 35, block; 35, 36; 35, 43; 36, expression_statement; 36, 37; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:logger; 40, identifier:error; 41, argument_list; 41, 42; 42, string:"ERROR: calibration array and frequency array must have same dimensions"; 43, return_statement; 44, if_statement; 44, 45; 44, 48; 45, comparison_operator:is; 45, 46; 45, 47; 46, identifier:frange; 47, None; 48, block; 48, 49; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 52; 51, identifier:frange; 52, tuple; 52, 53; 52, 56; 53, subscript; 53, 54; 53, 55; 54, identifier:frequencies; 55, integer:0; 56, subscript; 56, 57; 56, 58; 57, identifier:frequencies; 58, unary_operator:-; 58, 59; 59, integer:1; 60, expression_statement; 60, 61; 61, call; 61, 62; 61, 65; 62, attribute; 62, 63; 62, 64; 63, identifier:logger; 64, identifier:debug; 65, argument_list; 65, 66; 66, call; 66, 67; 66, 70; 67, attribute; 67, 68; 67, 69; 68, string:'setting calibration with samplerate {}'; 69, identifier:format; 70, argument_list; 70, 71; 71, call; 71, 72; 71, 75; 72, attribute; 72, 73; 72, 74; 73, identifier:self; 74, identifier:samplerate; 75, argument_list; 76, expression_statement; 76, 77; 77, assignment; 77, 78; 77, 79; 78, identifier:fs; 79, call; 79, 80; 79, 83; 80, attribute; 80, 81; 80, 82; 81, identifier:self; 82, identifier:samplerate; 83, argument_list; 84, if_statement; 84, 85; 84, 90; 84, 108; 85, comparison_operator:in; 85, 86; 85, 87; 86, identifier:fs; 87, attribute; 87, 88; 87, 89; 88, identifier:StimulusModel; 89, identifier:kernelCache; 90, block; 90, 91; 90, 98; 91, expression_statement; 91, 92; 92, call; 92, 93; 92, 96; 93, attribute; 93, 94; 93, 95; 94, identifier:logger; 95, identifier:debug; 96, argument_list; 96, 97; 97, string:'---->using cached filter'; 98, expression_statement; 98, 99; 99, assignment; 99, 100; 99, 103; 100, attribute; 100, 101; 100, 102; 101, identifier:self; 102, identifier:impulseResponse; 103, subscript; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:StimulusModel; 106, identifier:kernelCache; 107, identifier:fs; 108, else_clause; 108, 109; 109, block; 109, 110; 109, 122; 109, 134; 110, expression_statement; 110, 111; 111, call; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, identifier:logger; 114, identifier:debug; 115, argument_list; 115, 116; 116, call; 116, 117; 116, 120; 117, attribute; 117, 118; 117, 119; 118, string:'---->calculating new filter for fs {}'; 119, identifier:format; 120, argument_list; 120, 121; 121, identifier:fs; 122, expression_statement; 122, 123; 123, assignment; 123, 124; 123, 127; 124, attribute; 124, 125; 124, 126; 125, identifier:self; 126, identifier:impulseResponse; 127, call; 127, 128; 127, 129; 128, identifier:impulse_response; 129, argument_list; 129, 130; 129, 131; 129, 132; 129, 133; 130, identifier:fs; 131, identifier:dbBoostArray; 132, identifier:frequencies; 133, identifier:frange; 134, expression_statement; 134, 135; 135, assignment; 135, 136; 135, 141; 136, subscript; 136, 137; 136, 140; 137, attribute; 137, 138; 137, 139; 138, identifier:StimulusModel; 139, identifier:kernelCache; 140, identifier:fs; 141, attribute; 141, 142; 141, 143; 142, identifier:self; 143, identifier:impulseResponse; 144, expression_statement; 144, 145; 145, assignment; 145, 146; 145, 149; 146, attribute; 146, 147; 146, 148; 147, identifier:self; 148, identifier:_calibration_fs; 149, identifier:fs; 150, if_statement; 150, 151; 150, 156; 151, comparison_operator:not; 151, 152; 151, 153; 152, identifier:DEFAULT_SAMPLERATE; 153, attribute; 153, 154; 153, 155; 154, identifier:StimulusModel; 155, identifier:kernelCache; 156, block; 156, 157; 157, expression_statement; 157, 158; 158, assignment; 158, 159; 158, 164; 159, subscript; 159, 160; 159, 163; 160, attribute; 160, 161; 160, 162; 161, identifier:StimulusModel; 162, identifier:kernelCache; 163, identifier:DEFAULT_SAMPLERATE; 164, call; 164, 165; 164, 166; 165, identifier:impulse_response; 166, argument_list; 166, 167; 166, 168; 166, 169; 166, 170; 167, identifier:DEFAULT_SAMPLERATE; 168, identifier:dbBoostArray; 169, identifier:frequencies; 170, identifier:frange; 171, expression_statement; 171, 172; 172, assignment; 172, 173; 172, 176; 173, attribute; 173, 174; 173, 175; 174, identifier:self; 175, identifier:_attenuationVector; 176, identifier:dbBoostArray; 177, expression_statement; 177, 178; 178, assignment; 178, 179; 178, 182; 179, attribute; 179, 180; 179, 181; 180, identifier:self; 181, identifier:_calFrequencies; 182, identifier:frequencies; 183, expression_statement; 183, 184; 184, assignment; 184, 185; 184, 188; 185, attribute; 185, 186; 185, 187; 186, identifier:self; 187, identifier:_calFrange; 188, identifier:frange; 189, else_clause; 189, 190; 190, block; 190, 191; 191, expression_statement; 191, 192; 192, assignment; 192, 193; 192, 196; 193, attribute; 193, 194; 193, 195; 194, identifier:self; 195, identifier:impulseResponse; 196, None
def setCalibration(self, dbBoostArray, frequencies, frange): if dbBoostArray is not None and frequencies is not None: logger = logging.getLogger('main') if dbBoostArray.shape != frequencies.shape: logger.error("ERROR: calibration array and frequency array must have same dimensions") return if frange is None: frange = (frequencies[0], frequencies[-1]) logger.debug('setting calibration with samplerate {}'.format(self.samplerate())) fs = self.samplerate() if fs in StimulusModel.kernelCache: logger.debug('---->using cached filter') self.impulseResponse = StimulusModel.kernelCache[fs] else: logger.debug('---->calculating new filter for fs {}'.format(fs)) self.impulseResponse = impulse_response(fs, dbBoostArray, frequencies, frange) StimulusModel.kernelCache[fs] = self.impulseResponse self._calibration_fs = fs if DEFAULT_SAMPLERATE not in StimulusModel.kernelCache: StimulusModel.kernelCache[DEFAULT_SAMPLERATE] = impulse_response(DEFAULT_SAMPLERATE, dbBoostArray, frequencies, frange) self._attenuationVector = dbBoostArray self._calFrequencies = frequencies self._calFrange = frange else: self.impulseResponse = None
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:expandFunction; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:func; 6, default_parameter; 6, 7; 6, 8; 7, identifier:args; 8, list:[]; 9, block; 9, 10; 9, 20; 9, 28; 9, 32; 9, 45; 9, 66; 9, 70; 9, 117; 9, 121; 9, 187; 9, 216; 10, expression_statement; 10, 11; 11, assignment; 11, 12; 11, 13; 12, identifier:params; 13, call; 13, 14; 13, 19; 14, attribute; 14, 15; 14, 18; 15, attribute; 15, 16; 15, 17; 16, identifier:self; 17, identifier:_autoParams; 18, identifier:allData; 19, argument_list; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:steps; 23, call; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:self; 26, identifier:autoParamRanges; 27, argument_list; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:ntraces; 31, integer:1; 32, for_statement; 32, 33; 32, 34; 32, 35; 33, identifier:p; 34, identifier:steps; 35, block; 35, 36; 36, expression_statement; 36, 37; 37, assignment; 37, 38; 37, 39; 38, identifier:ntraces; 39, binary_operator:*; 39, 40; 39, 41; 40, identifier:ntraces; 41, call; 41, 42; 41, 43; 42, identifier:len; 43, argument_list; 43, 44; 44, identifier:p; 45, expression_statement; 45, 46; 46, assignment; 46, 47; 46, 48; 47, identifier:varylist; 48, list_comprehension; 48, 49; 48, 60; 49, list_comprehension; 49, 50; 49, 51; 50, None; 51, for_in_clause; 51, 52; 51, 53; 52, identifier:x; 53, call; 53, 54; 53, 55; 54, identifier:range; 55, argument_list; 55, 56; 56, call; 56, 57; 56, 58; 57, identifier:len; 58, argument_list; 58, 59; 59, identifier:params; 60, for_in_clause; 60, 61; 60, 62; 61, identifier:y; 62, call; 62, 63; 62, 64; 63, identifier:range; 64, argument_list; 64, 65; 65, identifier:ntraces; 66, expression_statement; 66, 67; 67, assignment; 67, 68; 67, 69; 68, identifier:x; 69, integer:1; 70, for_statement; 70, 71; 70, 74; 70, 78; 71, pattern_list; 71, 72; 71, 73; 72, identifier:iset; 73, identifier:step_set; 74, call; 74, 75; 74, 76; 75, identifier:enumerate; 76, argument_list; 76, 77; 77, identifier:steps; 78, block; 78, 79; 78, 108; 79, for_statement; 79, 80; 79, 81; 79, 85; 80, identifier:itrace; 81, call; 81, 82; 81, 83; 82, identifier:range; 83, argument_list; 83, 84; 84, identifier:ntraces; 85, block; 85, 86; 85, 98; 86, expression_statement; 86, 87; 87, assignment; 87, 88; 87, 89; 88, identifier:idx; 89, binary_operator:%; 89, 90; 89, 94; 90, parenthesized_expression; 90, 91; 91, binary_operator:/; 91, 92; 91, 93; 92, identifier:itrace; 93, identifier:x; 94, call; 94, 95; 94, 96; 95, identifier:len; 96, argument_list; 96, 97; 97, identifier:step_set; 98, expression_statement; 98, 99; 99, assignment; 99, 100; 99, 105; 100, subscript; 100, 101; 100, 104; 101, subscript; 101, 102; 101, 103; 102, identifier:varylist; 103, identifier:itrace; 104, identifier:iset; 105, subscript; 105, 106; 105, 107; 106, identifier:step_set; 107, identifier:idx; 108, expression_statement; 108, 109; 109, assignment; 109, 110; 109, 111; 110, identifier:x; 111, binary_operator:*; 111, 112; 111, 113; 112, identifier:x; 113, call; 113, 114; 113, 115; 114, identifier:len; 115, argument_list; 115, 116; 116, identifier:step_set; 117, expression_statement; 117, 118; 118, assignment; 118, 119; 118, 120; 119, identifier:stim_list; 120, list:[]; 121, for_statement; 121, 122; 121, 123; 121, 127; 122, identifier:itrace; 123, call; 123, 124; 123, 125; 124, identifier:range; 125, argument_list; 125, 126; 126, identifier:ntraces; 127, block; 127, 128; 127, 176; 128, for_statement; 128, 129; 128, 132; 128, 136; 129, pattern_list; 129, 130; 129, 131; 130, identifier:ip; 131, identifier:param; 132, call; 132, 133; 132, 134; 133, identifier:enumerate; 134, argument_list; 134, 135; 135, identifier:params; 136, block; 136, 137; 137, for_statement; 137, 138; 137, 139; 137, 142; 138, identifier:component; 139, subscript; 139, 140; 139, 141; 140, identifier:param; 141, string:'selection'; 142, block; 142, 143; 142, 152; 142, 162; 143, expression_statement; 143, 144; 144, assignment; 144, 145; 144, 146; 145, identifier:index; 146, call; 146, 147; 146, 150; 147, attribute; 147, 148; 147, 149; 148, identifier:self; 149, identifier:indexByComponent; 150, argument_list; 150, 151; 151, identifier:component; 152, expression_statement; 152, 153; 153, assignment; 153, 154; 153, 155; 154, identifier:component; 155, call; 155, 156; 155, 159; 156, attribute; 156, 157; 156, 158; 157, identifier:self; 158, identifier:component; 159, argument_list; 159, 160; 160, list_splat; 160, 161; 161, identifier:index; 162, expression_statement; 162, 163; 163, call; 163, 164; 163, 167; 164, attribute; 164, 165; 164, 166; 165, identifier:component; 166, identifier:set; 167, argument_list; 167, 168; 167, 171; 168, subscript; 168, 169; 168, 170; 169, identifier:param; 170, string:'parameter'; 171, subscript; 171, 172; 171, 175; 172, subscript; 172, 173; 172, 174; 173, identifier:varylist; 174, identifier:itrace; 175, identifier:ip; 176, expression_statement; 176, 177; 177, call; 177, 178; 177, 181; 178, attribute; 178, 179; 178, 180; 179, identifier:stim_list; 180, identifier:append; 181, argument_list; 181, 182; 182, call; 182, 183; 182, 184; 183, identifier:func; 184, argument_list; 184, 185; 185, list_splat; 185, 186; 186, identifier:args; 187, for_statement; 187, 188; 187, 191; 187, 195; 188, pattern_list; 188, 189; 188, 190; 189, identifier:ip; 190, identifier:param; 191, call; 191, 192; 191, 193; 192, identifier:enumerate; 193, argument_list; 193, 194; 194, identifier:params; 195, block; 195, 196; 196, for_statement; 196, 197; 196, 198; 196, 201; 197, identifier:component; 198, subscript; 198, 199; 198, 200; 199, identifier:param; 200, string:'selection'; 201, block; 201, 202; 202, expression_statement; 202, 203; 203, call; 203, 204; 203, 207; 204, attribute; 204, 205; 204, 206; 205, identifier:component; 206, identifier:set; 207, argument_list; 207, 208; 207, 211; 208, subscript; 208, 209; 208, 210; 209, identifier:param; 210, string:'parameter'; 211, subscript; 211, 212; 211, 215; 212, subscript; 212, 213; 212, 214; 213, identifier:varylist; 214, integer:0; 215, identifier:ip; 216, return_statement; 216, 217; 217, identifier:stim_list
def expandFunction(self, func, args=[]): params = self._autoParams.allData() steps = self.autoParamRanges() ntraces = 1 for p in steps: ntraces = ntraces*len(p) varylist = [[None for x in range(len(params))] for y in range(ntraces)] x = 1 for iset, step_set in enumerate(steps): for itrace in range(ntraces): idx = (itrace / x) % len(step_set) varylist[itrace][iset] = step_set[idx] x = x*len(step_set) stim_list = [] for itrace in range(ntraces): for ip, param in enumerate(params): for component in param['selection']: index = self.indexByComponent(component) component = self.component(*index) component.set(param['parameter'], varylist[itrace][ip]) stim_list.append(func(*args)) for ip, param in enumerate(params): for component in param['selection']: component.set(param['parameter'], varylist[0][ip]) return stim_list
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:signal; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:force_fs; 7, False; 8, block; 8, 9; 8, 16; 8, 33; 8, 37; 8, 57; 8, 61; 8, 122; 8, 135; 8, 145; 8, 161; 8, 182; 8, 194; 8, 252; 8, 259; 8, 263; 8, 271; 8, 283; 8, 430; 9, assert_statement; 9, 10; 9, 15; 10, comparison_operator:not; 10, 11; 10, 12; 11, None; 12, attribute; 12, 13; 12, 14; 13, identifier:self; 14, identifier:voltage_limits; 15, string:'Max voltage level not set'; 16, if_statement; 16, 17; 16, 18; 16, 23; 17, identifier:force_fs; 18, block; 18, 19; 19, expression_statement; 19, 20; 20, assignment; 20, 21; 20, 22; 21, identifier:samplerate; 22, identifier:force_fs; 23, else_clause; 23, 24; 24, block; 24, 25; 25, expression_statement; 25, 26; 26, assignment; 26, 27; 26, 28; 27, identifier:samplerate; 28, call; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, identifier:self; 31, identifier:samplerate; 32, argument_list; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 36; 35, identifier:track_signals; 36, list:[]; 37, expression_statement; 37, 38; 38, assignment; 38, 39; 38, 40; 39, identifier:max_db; 40, call; 40, 41; 40, 42; 41, identifier:max; 42, argument_list; 42, 43; 43, list_comprehension; 43, 44; 43, 49; 43, 54; 44, call; 44, 45; 44, 48; 45, attribute; 45, 46; 45, 47; 46, identifier:comp; 47, identifier:intensity; 48, argument_list; 49, for_in_clause; 49, 50; 49, 51; 50, identifier:t; 51, attribute; 51, 52; 51, 53; 52, identifier:self; 53, identifier:_segments; 54, for_in_clause; 54, 55; 54, 56; 55, identifier:comp; 56, identifier:t; 57, expression_statement; 57, 58; 58, assignment; 58, 59; 58, 60; 59, identifier:atten; 60, integer:0; 61, for_statement; 61, 62; 61, 63; 61, 66; 62, identifier:track; 63, attribute; 63, 64; 63, 65; 64, identifier:self; 65, identifier:_segments; 66, block; 66, 67; 66, 71; 66, 102; 67, expression_statement; 67, 68; 68, assignment; 68, 69; 68, 70; 69, identifier:track_list; 70, list:[]; 71, for_statement; 71, 72; 71, 73; 71, 74; 72, identifier:component; 73, identifier:track; 74, block; 74, 75; 75, expression_statement; 75, 76; 76, call; 76, 77; 76, 80; 77, attribute; 77, 78; 77, 79; 78, identifier:track_list; 79, identifier:append; 80, argument_list; 80, 81; 81, call; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:component; 84, identifier:signal; 85, argument_list; 85, 86; 85, 89; 85, 92; 85, 97; 86, keyword_argument; 86, 87; 86, 88; 87, identifier:fs; 88, identifier:samplerate; 89, keyword_argument; 89, 90; 89, 91; 90, identifier:atten; 91, integer:0; 92, keyword_argument; 92, 93; 92, 94; 93, identifier:caldb; 94, attribute; 94, 95; 94, 96; 95, identifier:self; 96, identifier:caldb; 97, keyword_argument; 97, 98; 97, 99; 98, identifier:calv; 99, attribute; 99, 100; 99, 101; 100, identifier:self; 101, identifier:calv; 102, if_statement; 102, 103; 102, 109; 103, comparison_operator:>; 103, 104; 103, 108; 104, call; 104, 105; 104, 106; 105, identifier:len; 106, argument_list; 106, 107; 107, identifier:track_list; 108, integer:0; 109, block; 109, 110; 110, expression_statement; 110, 111; 111, call; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, identifier:track_signals; 114, identifier:append; 115, argument_list; 115, 116; 116, call; 116, 117; 116, 120; 117, attribute; 117, 118; 117, 119; 118, identifier:np; 119, identifier:hstack; 120, argument_list; 120, 121; 121, identifier:track_list; 122, expression_statement; 122, 123; 123, assignment; 123, 124; 123, 125; 124, identifier:full_len; 125, call; 125, 126; 125, 127; 126, identifier:len; 127, argument_list; 127, 128; 128, call; 128, 129; 128, 130; 129, identifier:max; 130, argument_list; 130, 131; 130, 132; 131, identifier:track_signals; 132, keyword_argument; 132, 133; 132, 134; 133, identifier:key; 134, identifier:len; 135, expression_statement; 135, 136; 136, assignment; 136, 137; 136, 138; 137, identifier:total_signal; 138, call; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:np; 141, identifier:zeros; 142, argument_list; 142, 143; 143, tuple; 143, 144; 144, identifier:full_len; 145, for_statement; 145, 146; 145, 147; 145, 148; 146, identifier:track; 147, identifier:track_signals; 148, block; 148, 149; 149, expression_statement; 149, 150; 150, augmented_assignment:+=; 150, 151; 150, 160; 151, subscript; 151, 152; 151, 153; 152, identifier:total_signal; 153, slice; 153, 154; 153, 155; 153, 156; 154, integer:0; 155, colon; 156, call; 156, 157; 156, 158; 157, identifier:len; 158, argument_list; 158, 159; 159, identifier:track; 160, identifier:track; 161, expression_statement; 161, 162; 162, assignment; 162, 163; 162, 164; 163, identifier:component_names; 164, call; 164, 165; 164, 166; 165, identifier:list; 166, argument_list; 166, 167; 167, call; 167, 168; 167, 169; 168, identifier:set; 169, argument_list; 169, 170; 170, list_comprehension; 170, 171; 170, 174; 170, 179; 171, attribute; 171, 172; 171, 173; 172, identifier:comp; 173, identifier:name; 174, for_in_clause; 174, 175; 174, 176; 175, identifier:track; 176, attribute; 176, 177; 176, 178; 177, identifier:self; 178, identifier:_segments; 179, for_in_clause; 179, 180; 179, 181; 180, identifier:comp; 181, identifier:track; 182, if_statement; 182, 183; 182, 186; 183, comparison_operator:in; 183, 184; 183, 185; 184, string:'silence'; 185, identifier:component_names; 186, block; 186, 187; 187, expression_statement; 187, 188; 188, call; 188, 189; 188, 192; 189, attribute; 189, 190; 189, 191; 190, identifier:component_names; 191, identifier:remove; 192, argument_list; 192, 193; 193, string:'silence'; 194, if_statement; 194, 195; 194, 215; 194, 238; 195, boolean_operator:or; 195, 196; 195, 202; 196, comparison_operator:>; 196, 197; 196, 201; 197, call; 197, 198; 197, 199; 198, identifier:len; 199, argument_list; 199, 200; 200, identifier:component_names; 201, integer:1; 202, parenthesized_expression; 202, 203; 203, boolean_operator:and; 203, 204; 203, 210; 204, comparison_operator:==; 204, 205; 204, 209; 205, call; 205, 206; 205, 207; 206, identifier:len; 207, argument_list; 207, 208; 208, identifier:component_names; 209, integer:1; 210, comparison_operator:!=; 210, 211; 210, 214; 211, subscript; 211, 212; 211, 213; 212, identifier:component_names; 213, integer:0; 214, string:"Square Wave"; 215, block; 215, 216; 215, 226; 215, 234; 216, expression_statement; 216, 217; 217, assignment; 217, 218; 217, 219; 218, identifier:total_signal; 219, call; 219, 220; 219, 221; 220, identifier:convolve_filter; 221, argument_list; 221, 222; 221, 223; 222, identifier:total_signal; 223, attribute; 223, 224; 223, 225; 224, identifier:self; 225, identifier:impulseResponse; 226, expression_statement; 226, 227; 227, assignment; 227, 228; 227, 229; 228, identifier:maxv; 229, subscript; 229, 230; 229, 233; 230, attribute; 230, 231; 230, 232; 231, identifier:self; 232, identifier:voltage_limits; 233, integer:0; 234, expression_statement; 234, 235; 235, assignment; 235, 236; 235, 237; 236, identifier:to_speaker; 237, True; 238, else_clause; 238, 239; 239, block; 239, 240; 239, 248; 240, expression_statement; 240, 241; 241, assignment; 241, 242; 241, 243; 242, identifier:maxv; 243, subscript; 243, 244; 243, 247; 244, attribute; 244, 245; 244, 246; 245, identifier:self; 246, identifier:voltage_limits; 247, integer:1; 248, expression_statement; 248, 249; 249, assignment; 249, 250; 249, 251; 250, identifier:to_speaker; 251, False; 252, expression_statement; 252, 253; 253, assignment; 253, 254; 253, 258; 254, subscript; 254, 255; 254, 256; 255, identifier:total_signal; 256, unary_operator:-; 256, 257; 257, integer:1; 258, integer:0; 259, expression_statement; 259, 260; 260, assignment; 260, 261; 260, 262; 261, identifier:undesired_attenuation; 262, integer:0; 263, expression_statement; 263, 264; 264, assignment; 264, 265; 264, 266; 265, identifier:minv; 266, subscript; 266, 267; 266, 270; 267, attribute; 267, 268; 267, 269; 268, identifier:self; 269, identifier:voltage_limits; 270, integer:2; 271, expression_statement; 271, 272; 272, assignment; 272, 273; 272, 274; 273, identifier:sig_max; 274, call; 274, 275; 274, 278; 275, attribute; 275, 276; 275, 277; 276, identifier:np; 277, identifier:max; 278, argument_list; 278, 279; 279, call; 279, 280; 279, 281; 280, identifier:abs; 281, argument_list; 281, 282; 282, identifier:total_signal; 283, if_statement; 283, 284; 283, 287; 283, 356; 284, comparison_operator:>; 284, 285; 284, 286; 285, identifier:sig_max; 286, identifier:maxv; 287, block; 287, 288; 287, 297; 287, 310; 288, expression_statement; 288, 289; 289, assignment; 289, 290; 289, 291; 290, identifier:total_signal; 291, binary_operator:*; 291, 292; 291, 296; 292, parenthesized_expression; 292, 293; 293, binary_operator:/; 293, 294; 293, 295; 294, identifier:total_signal; 295, identifier:sig_max; 296, identifier:maxv; 297, expression_statement; 297, 298; 298, assignment; 298, 299; 298, 300; 299, identifier:attenuated; 300, binary_operator:*; 300, 301; 300, 302; 301, integer:20; 302, call; 302, 303; 302, 306; 303, attribute; 303, 304; 303, 305; 304, identifier:np; 305, identifier:log10; 306, argument_list; 306, 307; 307, binary_operator:/; 307, 308; 307, 309; 308, identifier:sig_max; 309, identifier:maxv; 310, if_statement; 310, 311; 310, 314; 310, 321; 311, comparison_operator:<=; 311, 312; 311, 313; 312, identifier:attenuated; 313, identifier:atten; 314, block; 314, 315; 315, expression_statement; 315, 316; 316, assignment; 316, 317; 316, 318; 317, identifier:atten; 318, binary_operator:-; 318, 319; 318, 320; 319, identifier:atten; 320, identifier:attenuated; 321, else_clause; 321, 322; 322, block; 322, 323; 322, 329; 322, 333; 322, 342; 323, expression_statement; 323, 324; 324, assignment; 324, 325; 324, 326; 325, identifier:undesired_attenuation; 326, binary_operator:-; 326, 327; 326, 328; 327, identifier:attenuated; 328, identifier:atten; 329, expression_statement; 329, 330; 330, assignment; 330, 331; 330, 332; 331, identifier:atten; 332, integer:0; 333, expression_statement; 333, 334; 334, assignment; 334, 335; 334, 336; 335, identifier:logger; 336, call; 336, 337; 336, 340; 337, attribute; 337, 338; 337, 339; 338, identifier:logging; 339, identifier:getLogger; 340, argument_list; 340, 341; 341, string:'main'; 342, expression_statement; 342, 343; 343, call; 343, 344; 343, 347; 344, attribute; 344, 345; 344, 346; 345, identifier:logger; 346, identifier:warning; 347, argument_list; 347, 348; 348, call; 348, 349; 348, 352; 349, attribute; 349, 350; 349, 351; 350, string:"STIMULUS AMPLTIUDE {:.2f}V EXCEEDS MAXIMUM({}V), RESCALING. \ UNDESIRED ATTENUATION {:.2f}dB"; 351, identifier:format; 352, argument_list; 352, 353; 352, 354; 352, 355; 353, identifier:sig_max; 354, identifier:maxv; 355, identifier:undesired_attenuation; 356, elif_clause; 356, 357; 356, 366; 357, boolean_operator:and; 357, 358; 357, 365; 358, boolean_operator:and; 358, 359; 358, 362; 359, comparison_operator:<; 359, 360; 359, 361; 360, identifier:sig_max; 361, identifier:minv; 362, comparison_operator:!=; 362, 363; 362, 364; 363, identifier:sig_max; 364, integer:0; 365, identifier:to_speaker; 366, block; 366, 367; 366, 385; 366, 394; 366, 412; 366, 426; 367, expression_statement; 367, 368; 368, assignment; 368, 369; 368, 370; 369, identifier:before_rms; 370, call; 370, 371; 370, 374; 371, attribute; 371, 372; 371, 373; 372, identifier:np; 373, identifier:sqrt; 374, argument_list; 374, 375; 375, call; 375, 376; 375, 379; 376, attribute; 376, 377; 376, 378; 377, identifier:np; 378, identifier:mean; 379, argument_list; 379, 380; 380, call; 380, 381; 380, 382; 381, identifier:pow; 382, argument_list; 382, 383; 382, 384; 383, identifier:total_signal; 384, integer:2; 385, expression_statement; 385, 386; 386, assignment; 386, 387; 386, 388; 387, identifier:total_signal; 388, binary_operator:*; 388, 389; 388, 393; 389, parenthesized_expression; 389, 390; 390, binary_operator:/; 390, 391; 390, 392; 391, identifier:total_signal; 392, identifier:sig_max; 393, identifier:minv; 394, expression_statement; 394, 395; 395, assignment; 395, 396; 395, 397; 396, identifier:after_rms; 397, call; 397, 398; 397, 401; 398, attribute; 398, 399; 398, 400; 399, identifier:np; 400, identifier:sqrt; 401, argument_list; 401, 402; 402, call; 402, 403; 402, 406; 403, attribute; 403, 404; 403, 405; 404, identifier:np; 405, identifier:mean; 406, argument_list; 406, 407; 407, call; 407, 408; 407, 409; 408, identifier:pow; 409, argument_list; 409, 410; 409, 411; 410, identifier:total_signal; 411, integer:2; 412, expression_statement; 412, 413; 413, assignment; 413, 414; 413, 415; 414, identifier:attenuated; 415, binary_operator:*; 415, 416; 415, 418; 416, unary_operator:-; 416, 417; 417, integer:20; 418, call; 418, 419; 418, 422; 419, attribute; 419, 420; 419, 421; 420, identifier:np; 421, identifier:log10; 422, argument_list; 422, 423; 423, binary_operator:/; 423, 424; 423, 425; 424, identifier:before_rms; 425, identifier:after_rms; 426, expression_statement; 426, 427; 427, augmented_assignment:+=; 427, 428; 427, 429; 428, identifier:atten; 429, identifier:attenuated; 430, return_statement; 430, 431; 431, expression_list; 431, 432; 431, 433; 431, 434; 432, identifier:total_signal; 433, identifier:atten; 434, identifier:undesired_attenuation
def signal(self, force_fs=False): assert None not in self.voltage_limits, 'Max voltage level not set' if force_fs: samplerate = force_fs else: samplerate = self.samplerate() track_signals = [] max_db = max([comp.intensity() for t in self._segments for comp in t]) atten = 0 for track in self._segments: track_list = [] for component in track: track_list.append(component.signal(fs=samplerate, atten=0, caldb=self.caldb, calv=self.calv)) if len(track_list) > 0: track_signals.append(np.hstack(track_list)) full_len = len(max(track_signals, key=len)) total_signal = np.zeros((full_len,)) for track in track_signals: total_signal[0:len(track)] += track component_names = list(set([comp.name for track in self._segments for comp in track])) if 'silence' in component_names: component_names.remove('silence') if len(component_names) > 1 or (len(component_names) == 1 and component_names[0] != "Square Wave"): total_signal = convolve_filter(total_signal, self.impulseResponse) maxv = self.voltage_limits[0] to_speaker = True else: maxv = self.voltage_limits[1] to_speaker = False total_signal[-1] = 0 undesired_attenuation = 0 minv = self.voltage_limits[2] sig_max = np.max(abs(total_signal)) if sig_max > maxv: total_signal = (total_signal/sig_max)*maxv attenuated = 20 * np.log10(sig_max/maxv) if attenuated <= atten: atten = atten - attenuated else: undesired_attenuation = attenuated - atten atten = 0 logger = logging.getLogger('main') logger.warning("STIMULUS AMPLTIUDE {:.2f}V EXCEEDS MAXIMUM({}V), RESCALING. \ UNDESIRED ATTENUATION {:.2f}dB".format(sig_max, maxv, undesired_attenuation)) elif sig_max < minv and sig_max !=0 and to_speaker: before_rms = np.sqrt(np.mean(pow(total_signal,2))) total_signal = (total_signal/sig_max)*minv after_rms = np.sqrt(np.mean(pow(total_signal,2))) attenuated = -20 * np.log10(before_rms/after_rms) atten += attenuated return total_signal, atten, undesired_attenuation
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:verify; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:windowSize; 7, None; 8, block; 8, 9; 8, 20; 8, 30; 8, 35; 8, 46; 8, 78; 8, 91; 8, 96; 8, 111; 8, 120; 9, if_statement; 9, 10; 9, 17; 10, comparison_operator:is; 10, 11; 10, 16; 11, call; 11, 12; 11, 15; 12, attribute; 12, 13; 12, 14; 13, identifier:self; 14, identifier:samplerate; 15, argument_list; 16, None; 17, block; 17, 18; 18, return_statement; 18, 19; 19, string:"Multiple recording files with conflicting samplerates"; 20, expression_statement; 20, 21; 21, assignment; 21, 22; 21, 23; 22, identifier:msg; 23, call; 23, 24; 23, 29; 24, attribute; 24, 25; 24, 28; 25, attribute; 25, 26; 25, 27; 26, identifier:self; 27, identifier:_autoParams; 28, identifier:verify; 29, argument_list; 30, if_statement; 30, 31; 30, 32; 31, identifier:msg; 32, block; 32, 33; 33, return_statement; 33, 34; 34, identifier:msg; 35, if_statement; 35, 36; 35, 43; 36, comparison_operator:==; 36, 37; 36, 42; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:self; 40, identifier:traceCount; 41, argument_list; 42, integer:0; 43, block; 43, 44; 44, return_statement; 44, 45; 45, string:"Test is empty"; 46, if_statement; 46, 47; 46, 50; 47, comparison_operator:is; 47, 48; 47, 49; 48, identifier:windowSize; 49, None; 50, block; 50, 51; 50, 62; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 54; 53, identifier:durations; 54, call; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:self; 57, identifier:expandFunction; 58, argument_list; 58, 59; 59, attribute; 59, 60; 59, 61; 60, identifier:self; 61, identifier:duration; 62, if_statement; 62, 63; 62, 75; 63, boolean_operator:or; 63, 64; 63, 69; 64, comparison_operator:>; 64, 65; 64, 68; 65, subscript; 65, 66; 65, 67; 66, identifier:durations; 67, integer:0; 68, identifier:windowSize; 69, comparison_operator:>; 69, 70; 69, 74; 70, subscript; 70, 71; 70, 72; 71, identifier:durations; 72, unary_operator:-; 72, 73; 73, integer:1; 74, identifier:windowSize; 75, block; 75, 76; 76, return_statement; 76, 77; 77, string:"Stimulus duration exceeds window duration"; 78, expression_statement; 78, 79; 79, assignment; 79, 80; 79, 81; 80, identifier:msg; 81, call; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:self; 84, identifier:verifyExpanded; 85, argument_list; 85, 86; 86, call; 86, 87; 86, 90; 87, attribute; 87, 88; 87, 89; 88, identifier:self; 89, identifier:samplerate; 90, argument_list; 91, if_statement; 91, 92; 91, 93; 92, identifier:msg; 93, block; 93, 94; 94, return_statement; 94, 95; 95, identifier:msg; 96, if_statement; 96, 97; 96, 108; 97, boolean_operator:or; 97, 98; 97, 103; 98, comparison_operator:is; 98, 99; 98, 102; 99, attribute; 99, 100; 99, 101; 100, identifier:self; 101, identifier:caldb; 102, None; 103, comparison_operator:is; 103, 104; 103, 107; 104, attribute; 104, 105; 104, 106; 105, identifier:self; 106, identifier:calv; 107, None; 108, block; 108, 109; 109, return_statement; 109, 110; 110, string:"Test reference voltage not set"; 111, if_statement; 111, 112; 111, 117; 112, comparison_operator:in; 112, 113; 112, 114; 113, None; 114, attribute; 114, 115; 114, 116; 115, identifier:self; 116, identifier:voltage_limits; 117, block; 117, 118; 118, return_statement; 118, 119; 119, string:"Device voltage limits not set"; 120, return_statement; 120, 121; 121, integer:0
def verify(self, windowSize=None): if self.samplerate() is None: return "Multiple recording files with conflicting samplerates" msg = self._autoParams.verify() if msg: return msg if self.traceCount() == 0: return "Test is empty" if windowSize is not None: durations = self.expandFunction(self.duration) if durations[0] > windowSize or durations[-1] > windowSize: return "Stimulus duration exceeds window duration" msg = self.verifyExpanded(self.samplerate()) if msg: return msg if self.caldb is None or self.calv is None: return "Test reference voltage not set" if None in self.voltage_limits: return "Device voltage limits not set" return 0
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:getLogicalLines; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:fp; 5, default_parameter; 5, 6; 5, 7; 6, identifier:allowQP; 7, True; 8, default_parameter; 8, 9; 8, 10; 9, identifier:findBegin; 10, False; 11, block; 11, 12; 12, if_statement; 12, 13; 12, 15; 12, 69; 13, not_operator; 13, 14; 14, identifier:allowQP; 15, block; 15, 16; 15, 26; 15, 30; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 19; 18, identifier:val; 19, call; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:fp; 22, identifier:read; 23, argument_list; 23, 24; 24, unary_operator:-; 24, 25; 25, integer:1; 26, expression_statement; 26, 27; 27, assignment; 27, 28; 27, 29; 28, identifier:lineNumber; 29, integer:1; 30, for_statement; 30, 31; 30, 32; 30, 38; 31, identifier:match; 32, call; 32, 33; 32, 36; 33, attribute; 33, 34; 33, 35; 34, identifier:logical_lines_re; 35, identifier:finditer; 36, argument_list; 36, 37; 37, identifier:val; 38, block; 38, 39; 38, 55; 38, 65; 39, expression_statement; 39, 40; 40, assignment; 40, 41; 40, 44; 41, pattern_list; 41, 42; 41, 43; 42, identifier:line; 43, identifier:n; 44, call; 44, 45; 44, 48; 45, attribute; 45, 46; 45, 47; 46, identifier:wrap_re; 47, identifier:subn; 48, argument_list; 48, 49; 48, 50; 49, string:''; 50, call; 50, 51; 50, 54; 51, attribute; 51, 52; 51, 53; 52, identifier:match; 53, identifier:group; 54, argument_list; 55, if_statement; 55, 56; 55, 59; 56, comparison_operator:!=; 56, 57; 56, 58; 57, identifier:line; 58, string:''; 59, block; 59, 60; 60, expression_statement; 60, 61; 61, yield; 61, 62; 62, expression_list; 62, 63; 62, 64; 63, identifier:line; 64, identifier:lineNumber; 65, expression_statement; 65, 66; 66, augmented_assignment:+=; 66, 67; 66, 68; 67, identifier:lineNumber; 68, identifier:n; 69, else_clause; 69, 70; 70, block; 70, 71; 70, 75; 70, 81; 70, 87; 70, 91; 70, 95; 70, 293; 71, expression_statement; 71, 72; 72, assignment; 72, 73; 72, 74; 73, identifier:quotedPrintable; 74, False; 75, expression_statement; 75, 76; 76, assignment; 76, 77; 76, 78; 77, identifier:newbuffer; 78, attribute; 78, 79; 78, 80; 79, identifier:six; 80, identifier:StringIO; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 84; 83, identifier:logicalLine; 84, call; 84, 85; 84, 86; 85, identifier:newbuffer; 86, argument_list; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 90; 89, identifier:lineNumber; 90, integer:0; 91, expression_statement; 91, 92; 92, assignment; 92, 93; 92, 94; 93, identifier:lineStartNumber; 94, integer:0; 95, while_statement; 95, 96; 95, 97; 96, True; 97, block; 97, 98; 97, 106; 97, 127; 97, 169; 97, 260; 97, 268; 98, expression_statement; 98, 99; 99, assignment; 99, 100; 99, 101; 100, identifier:line; 101, call; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, identifier:fp; 104, identifier:readline; 105, argument_list; 106, if_statement; 106, 107; 106, 110; 106, 112; 107, comparison_operator:==; 107, 108; 107, 109; 108, identifier:line; 109, string:''; 110, block; 110, 111; 111, break_statement; 112, else_clause; 112, 113; 113, block; 113, 114; 113, 123; 114, expression_statement; 114, 115; 115, assignment; 115, 116; 115, 117; 116, identifier:line; 117, call; 117, 118; 117, 121; 118, attribute; 118, 119; 118, 120; 119, identifier:line; 120, identifier:rstrip; 121, argument_list; 121, 122; 122, identifier:CRLF; 123, expression_statement; 123, 124; 124, augmented_assignment:+=; 124, 125; 124, 126; 125, identifier:lineNumber; 126, integer:1; 127, if_statement; 127, 128; 127, 135; 128, comparison_operator:==; 128, 129; 128, 134; 129, call; 129, 130; 129, 133; 130, attribute; 130, 131; 130, 132; 131, identifier:line; 132, identifier:rstrip; 133, argument_list; 134, string:''; 135, block; 135, 136; 135, 154; 135, 158; 135, 164; 135, 168; 136, if_statement; 136, 137; 136, 144; 137, comparison_operator:>; 137, 138; 137, 143; 138, call; 138, 139; 138, 142; 139, attribute; 139, 140; 139, 141; 140, identifier:logicalLine; 141, identifier:tell; 142, argument_list; 143, integer:0; 144, block; 144, 145; 145, expression_statement; 145, 146; 146, yield; 146, 147; 147, expression_list; 147, 148; 147, 153; 148, call; 148, 149; 148, 152; 149, attribute; 149, 150; 149, 151; 150, identifier:logicalLine; 151, identifier:getvalue; 152, argument_list; 153, identifier:lineStartNumber; 154, expression_statement; 154, 155; 155, assignment; 155, 156; 155, 157; 156, identifier:lineStartNumber; 157, identifier:lineNumber; 158, expression_statement; 158, 159; 159, assignment; 159, 160; 159, 161; 160, identifier:logicalLine; 161, call; 161, 162; 161, 163; 162, identifier:newbuffer; 163, argument_list; 164, expression_statement; 164, 165; 165, assignment; 165, 166; 165, 167; 166, identifier:quotedPrintable; 167, False; 168, continue_statement; 169, if_statement; 169, 170; 169, 173; 169, 192; 169, 210; 169, 245; 170, boolean_operator:and; 170, 171; 170, 172; 171, identifier:quotedPrintable; 172, identifier:allowQP; 173, block; 173, 174; 173, 181; 173, 188; 174, expression_statement; 174, 175; 175, call; 175, 176; 175, 179; 176, attribute; 176, 177; 176, 178; 177, identifier:logicalLine; 178, identifier:write; 179, argument_list; 179, 180; 180, string:'\n'; 181, expression_statement; 181, 182; 182, call; 182, 183; 182, 186; 183, attribute; 183, 184; 183, 185; 184, identifier:logicalLine; 185, identifier:write; 186, argument_list; 186, 187; 187, identifier:line; 188, expression_statement; 188, 189; 189, assignment; 189, 190; 189, 191; 190, identifier:quotedPrintable; 191, False; 192, elif_clause; 192, 193; 192, 198; 193, comparison_operator:in; 193, 194; 193, 197; 194, subscript; 194, 195; 194, 196; 195, identifier:line; 196, integer:0; 197, identifier:SPACEORTAB; 198, block; 198, 199; 199, expression_statement; 199, 200; 200, call; 200, 201; 200, 204; 201, attribute; 201, 202; 201, 203; 202, identifier:logicalLine; 203, identifier:write; 204, argument_list; 204, 205; 205, subscript; 205, 206; 205, 207; 206, identifier:line; 207, slice; 207, 208; 207, 209; 208, integer:1; 209, colon; 210, elif_clause; 210, 211; 210, 218; 211, comparison_operator:>; 211, 212; 211, 217; 212, call; 212, 213; 212, 216; 213, attribute; 213, 214; 213, 215; 214, identifier:logicalLine; 215, identifier:tell; 216, argument_list; 217, integer:0; 218, block; 218, 219; 218, 228; 218, 232; 218, 238; 219, expression_statement; 219, 220; 220, yield; 220, 221; 221, expression_list; 221, 222; 221, 227; 222, call; 222, 223; 222, 226; 223, attribute; 223, 224; 223, 225; 224, identifier:logicalLine; 225, identifier:getvalue; 226, argument_list; 227, identifier:lineStartNumber; 228, expression_statement; 228, 229; 229, assignment; 229, 230; 229, 231; 230, identifier:lineStartNumber; 231, identifier:lineNumber; 232, expression_statement; 232, 233; 233, assignment; 233, 234; 233, 235; 234, identifier:logicalLine; 235, call; 235, 236; 235, 237; 236, identifier:newbuffer; 237, argument_list; 238, expression_statement; 238, 239; 239, call; 239, 240; 239, 243; 240, attribute; 240, 241; 240, 242; 241, identifier:logicalLine; 242, identifier:write; 243, argument_list; 243, 244; 244, identifier:line; 245, else_clause; 245, 246; 246, block; 246, 247; 246, 253; 247, expression_statement; 247, 248; 248, assignment; 248, 249; 248, 250; 249, identifier:logicalLine; 250, call; 250, 251; 250, 252; 251, identifier:newbuffer; 252, argument_list; 253, expression_statement; 253, 254; 254, call; 254, 255; 254, 258; 255, attribute; 255, 256; 255, 257; 256, identifier:logicalLine; 257, identifier:write; 258, argument_list; 258, 259; 259, identifier:line; 260, expression_statement; 260, 261; 261, assignment; 261, 262; 261, 263; 262, identifier:val; 263, call; 263, 264; 263, 267; 264, attribute; 264, 265; 264, 266; 265, identifier:logicalLine; 266, identifier:getvalue; 267, argument_list; 268, if_statement; 268, 269; 268, 288; 269, boolean_operator:and; 269, 270; 269, 276; 270, comparison_operator:==; 270, 271; 270, 275; 271, subscript; 271, 272; 271, 273; 272, identifier:val; 273, unary_operator:-; 273, 274; 274, integer:1; 275, string:'='; 276, comparison_operator:>=; 276, 277; 276, 287; 277, call; 277, 278; 277, 285; 278, attribute; 278, 279; 278, 284; 279, call; 279, 280; 279, 283; 280, attribute; 280, 281; 280, 282; 281, identifier:val; 282, identifier:lower; 283, argument_list; 284, identifier:find; 285, argument_list; 285, 286; 286, string:'quoted-printable'; 287, integer:0; 288, block; 288, 289; 289, expression_statement; 289, 290; 290, assignment; 290, 291; 290, 292; 291, identifier:quotedPrintable; 292, True; 293, if_statement; 293, 294; 293, 301; 294, comparison_operator:>; 294, 295; 294, 300; 295, call; 295, 296; 295, 299; 296, attribute; 296, 297; 296, 298; 297, identifier:logicalLine; 298, identifier:tell; 299, argument_list; 300, integer:0; 301, block; 301, 302; 302, expression_statement; 302, 303; 303, yield; 303, 304; 304, expression_list; 304, 305; 304, 310; 305, call; 305, 306; 305, 309; 306, attribute; 306, 307; 306, 308; 307, identifier:logicalLine; 308, identifier:getvalue; 309, argument_list; 310, identifier:lineStartNumber
def getLogicalLines(fp, allowQP=True, findBegin=False): if not allowQP: val = fp.read(-1) lineNumber = 1 for match in logical_lines_re.finditer(val): line, n = wrap_re.subn('', match.group()) if line != '': yield line, lineNumber lineNumber += n else: quotedPrintable = False newbuffer = six.StringIO logicalLine = newbuffer() lineNumber = 0 lineStartNumber = 0 while True: line = fp.readline() if line == '': break else: line = line.rstrip(CRLF) lineNumber += 1 if line.rstrip() == '': if logicalLine.tell() > 0: yield logicalLine.getvalue(), lineStartNumber lineStartNumber = lineNumber logicalLine = newbuffer() quotedPrintable = False continue if quotedPrintable and allowQP: logicalLine.write('\n') logicalLine.write(line) quotedPrintable = False elif line[0] in SPACEORTAB: logicalLine.write(line[1:]) elif logicalLine.tell() > 0: yield logicalLine.getvalue(), lineStartNumber lineStartNumber = lineNumber logicalLine = newbuffer() logicalLine.write(line) else: logicalLine = newbuffer() logicalLine.write(line) val = logicalLine.getvalue() if val[-1]=='=' and val.lower().find('quoted-printable') >= 0: quotedPrintable=True if logicalLine.tell() > 0: yield logicalLine.getvalue(), lineStartNumber
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:_bind_model; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 51; 5, 69; 5, 79; 5, 85; 5, 89; 5, 178; 6, if_statement; 6, 7; 6, 16; 7, comparison_operator:!=; 7, 8; 7, 15; 8, attribute; 8, 9; 8, 14; 9, subscript; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifier:groups; 13, integer:0; 14, identifier:level; 15, integer:0; 16, block; 16, 17; 16, 35; 17, expression_statement; 17, 18; 18, call; 18, 19; 18, 24; 19, attribute; 19, 20; 19, 23; 20, attribute; 20, 21; 20, 22; 21, identifier:self; 22, identifier:log; 23, identifier:info; 24, argument_list; 24, 25; 25, call; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, string:"Got invalid first group: {0}"; 28, identifier:format; 29, argument_list; 29, 30; 30, subscript; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:self; 33, identifier:groups; 34, integer:0; 35, raise_statement; 35, 36; 36, call; 36, 37; 36, 38; 37, identifier:ValueError; 38, argument_list; 38, 39; 39, call; 39, 40; 39, 43; 40, attribute; 40, 41; 40, 42; 41, string:"Invalid group tree: first group must have level of 0 (got {0})"; 42, identifier:format; 43, argument_list; 43, 44; 44, attribute; 44, 45; 44, 50; 45, subscript; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:self; 48, identifier:groups; 49, integer:0; 50, identifier:level; 51, class_definition; 51, 52; 51, 53; 51, 55; 52, identifier:Stack; 53, argument_list; 53, 54; 54, identifier:list; 55, block; 55, 56; 56, function_definition; 56, 57; 56, 58; 56, 61; 57, function_name:push; 58, parameters; 58, 59; 58, 60; 59, identifier:self; 60, identifier:el; 61, block; 61, 62; 62, expression_statement; 62, 63; 63, call; 63, 64; 63, 67; 64, attribute; 64, 65; 64, 66; 65, identifier:self; 66, identifier:append; 67, argument_list; 67, 68; 68, identifier:el; 69, expression_statement; 69, 70; 70, assignment; 70, 71; 70, 72; 71, identifier:parent_stack; 72, call; 72, 73; 72, 74; 73, identifier:Stack; 74, argument_list; 74, 75; 75, list:[self.root]; 75, 76; 76, attribute; 76, 77; 76, 78; 77, identifier:self; 78, identifier:root; 79, expression_statement; 79, 80; 80, assignment; 80, 81; 80, 82; 81, identifier:current_parent; 82, attribute; 82, 83; 82, 84; 83, identifier:self; 84, identifier:root; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 88; 87, identifier:prev_group; 88, None; 89, for_statement; 89, 90; 89, 91; 89, 94; 90, identifier:g; 91, attribute; 91, 92; 91, 93; 92, identifier:self; 93, identifier:groups; 94, block; 94, 95; 94, 101; 94, 159; 94, 165; 94, 174; 95, expression_statement; 95, 96; 96, assignment; 96, 97; 96, 100; 97, attribute; 97, 98; 97, 99; 98, identifier:g; 99, identifier:db; 100, identifier:self; 101, if_statement; 101, 102; 101, 105; 102, comparison_operator:is; 102, 103; 102, 104; 103, identifier:prev_group; 104, None; 105, block; 105, 106; 106, if_statement; 106, 107; 106, 114; 106, 126; 107, comparison_operator:>; 107, 108; 107, 111; 108, attribute; 108, 109; 108, 110; 109, identifier:g; 110, identifier:level; 111, attribute; 111, 112; 111, 113; 112, identifier:prev_group; 113, identifier:level; 114, block; 114, 115; 114, 119; 115, expression_statement; 115, 116; 116, assignment; 116, 117; 116, 118; 117, identifier:current_parent; 118, identifier:prev_group; 119, expression_statement; 119, 120; 120, call; 120, 121; 120, 124; 121, attribute; 121, 122; 121, 123; 122, identifier:parent_stack; 123, identifier:push; 124, argument_list; 124, 125; 125, identifier:current_parent; 126, elif_clause; 126, 127; 126, 134; 127, comparison_operator:<; 127, 128; 127, 131; 128, attribute; 128, 129; 128, 130; 129, identifier:g; 130, identifier:level; 131, attribute; 131, 132; 131, 133; 132, identifier:prev_group; 133, identifier:level; 134, block; 134, 135; 134, 152; 135, while_statement; 135, 136; 135, 143; 136, comparison_operator:<=; 136, 137; 136, 140; 137, attribute; 137, 138; 137, 139; 138, identifier:g; 139, identifier:level; 140, attribute; 140, 141; 140, 142; 141, identifier:current_parent; 142, identifier:level; 143, block; 143, 144; 144, expression_statement; 144, 145; 145, assignment; 145, 146; 145, 147; 146, identifier:current_parent; 147, call; 147, 148; 147, 151; 148, attribute; 148, 149; 148, 150; 149, identifier:parent_stack; 150, identifier:pop; 151, argument_list; 152, expression_statement; 152, 153; 153, call; 153, 154; 153, 157; 154, attribute; 154, 155; 154, 156; 155, identifier:parent_stack; 156, identifier:push; 157, argument_list; 157, 158; 158, identifier:current_parent; 159, expression_statement; 159, 160; 160, assignment; 160, 161; 160, 164; 161, attribute; 161, 162; 161, 163; 162, identifier:g; 163, identifier:parent; 164, identifier:current_parent; 165, expression_statement; 165, 166; 166, call; 166, 167; 166, 172; 167, attribute; 167, 168; 167, 171; 168, attribute; 168, 169; 168, 170; 169, identifier:current_parent; 170, identifier:children; 171, identifier:append; 172, argument_list; 172, 173; 173, identifier:g; 174, expression_statement; 174, 175; 175, assignment; 175, 176; 175, 177; 176, identifier:prev_group; 177, identifier:g; 178, for_statement; 178, 179; 178, 180; 178, 183; 179, identifier:entry; 180, attribute; 180, 181; 180, 182; 181, identifier:self; 182, identifier:entries; 183, block; 183, 184; 184, for_statement; 184, 185; 184, 186; 184, 189; 184, 215; 185, identifier:group; 186, attribute; 186, 187; 186, 188; 187, identifier:self; 188, identifier:groups; 189, block; 189, 190; 190, if_statement; 190, 191; 190, 198; 191, comparison_operator:==; 191, 192; 191, 195; 192, attribute; 192, 193; 192, 194; 193, identifier:entry; 194, identifier:group_id; 195, attribute; 195, 196; 195, 197; 196, identifier:group; 197, identifier:id; 198, block; 198, 199; 198, 208; 198, 214; 199, expression_statement; 199, 200; 200, call; 200, 201; 200, 206; 201, attribute; 201, 202; 201, 205; 202, attribute; 202, 203; 202, 204; 203, identifier:group; 204, identifier:entries; 205, identifier:append; 206, argument_list; 206, 207; 207, identifier:entry; 208, expression_statement; 208, 209; 209, assignment; 209, 210; 209, 213; 210, attribute; 210, 211; 210, 212; 211, identifier:entry; 212, identifier:group; 213, identifier:group; 214, break_statement; 215, else_clause; 215, 216; 216, block; 216, 217; 217, raise_statement; 217, 218; 218, call; 218, 219; 218, 220; 219, identifier:NotImplementedError; 220, argument_list; 220, 221; 221, string:"Orphaned entries not (yet) supported."
def _bind_model(self): if self.groups[0].level != 0: self.log.info("Got invalid first group: {0}".format(self.groups[0])) raise ValueError("Invalid group tree: first group must have level of 0 (got {0})".format(self.groups[0].level)) class Stack(list): def push(self, el): self.append(el) parent_stack = Stack([self.root]) current_parent = self.root prev_group = None for g in self.groups: g.db = self if prev_group is not None: if g.level > prev_group.level: current_parent = prev_group parent_stack.push(current_parent) elif g.level < prev_group.level: while g.level <= current_parent.level: current_parent = parent_stack.pop() parent_stack.push(current_parent) g.parent = current_parent current_parent.children.append(g) prev_group = g for entry in self.entries: for group in self.groups: if entry.group_id == group.id: group.entries.append(entry) entry.group = group break else: raise NotImplementedError("Orphaned entries not (yet) supported.")
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:bowtie; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 42; 5, 460; 6, for_statement; 6, 7; 6, 8; 6, 14; 7, identifier:i; 8, call; 8, 9; 8, 10; 9, identifier:range; 10, argument_list; 10, 11; 11, attribute; 11, 12; 11, 13; 12, identifier:self; 13, identifier:cpus; 14, block; 14, 15; 14, 29; 14, 36; 15, expression_statement; 15, 16; 16, assignment; 16, 17; 16, 18; 17, identifier:threads; 18, call; 18, 19; 18, 20; 19, identifier:Thread; 20, argument_list; 20, 21; 20, 26; 21, keyword_argument; 21, 22; 21, 23; 22, identifier:target; 23, attribute; 23, 24; 23, 25; 24, identifier:self; 25, identifier:align; 26, keyword_argument; 26, 27; 26, 28; 27, identifier:args; 28, tuple; 29, expression_statement; 29, 30; 30, call; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:threads; 33, identifier:setDaemon; 34, argument_list; 34, 35; 35, True; 36, expression_statement; 36, 37; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:threads; 40, identifier:start; 41, argument_list; 42, with_statement; 42, 43; 42, 54; 43, with_clause; 43, 44; 44, with_item; 44, 45; 45, as_pattern; 45, 46; 45, 52; 46, call; 46, 47; 46, 48; 47, identifier:progressbar; 48, argument_list; 48, 49; 49, attribute; 49, 50; 49, 51; 50, identifier:self; 51, identifier:metadata; 52, as_pattern_target; 52, 53; 53, identifier:bar; 54, block; 54, 55; 55, for_statement; 55, 56; 55, 57; 55, 58; 56, identifier:sample; 57, identifier:bar; 58, block; 58, 59; 58, 67; 58, 73; 59, expression_statement; 59, 60; 60, assignment; 60, 61; 60, 64; 61, attribute; 61, 62; 61, 63; 62, identifier:sample; 63, identifier:mapping; 64, call; 64, 65; 64, 66; 65, identifier:GenObject; 66, argument_list; 67, expression_statement; 67, 68; 68, assignment; 68, 69; 68, 70; 69, identifier:sagen; 70, attribute; 70, 71; 70, 72; 71, identifier:sample; 72, identifier:general; 73, if_statement; 73, 74; 73, 79; 73, 434; 74, comparison_operator:!=; 74, 75; 74, 78; 75, attribute; 75, 76; 75, 77; 76, identifier:sagen; 77, identifier:bestassemblyfile; 78, string:"NA"; 79, block; 79, 80; 79, 96; 79, 103; 79, 126; 79, 141; 79, 147; 79, 165; 79, 181; 79, 193; 79, 212; 79, 229; 79, 248; 79, 371; 79, 392; 79, 403; 79, 414; 80, expression_statement; 80, 81; 81, assignment; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:sagen; 84, identifier:QualimapResults; 85, call; 85, 86; 85, 91; 86, attribute; 86, 87; 86, 90; 87, attribute; 87, 88; 87, 89; 88, identifier:os; 89, identifier:path; 90, identifier:join; 91, argument_list; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, identifier:sagen; 94, identifier:outputdirectory; 95, string:'qualimap_results'; 96, expression_statement; 96, 97; 97, call; 97, 98; 97, 99; 98, identifier:make_path; 99, argument_list; 99, 100; 100, attribute; 100, 101; 100, 102; 101, identifier:sagen; 102, identifier:QualimapResults; 103, expression_statement; 103, 104; 104, assignment; 104, 105; 104, 108; 105, attribute; 105, 106; 105, 107; 106, identifier:sagen; 107, identifier:sortedbam; 108, call; 108, 109; 108, 114; 109, attribute; 109, 110; 109, 113; 110, attribute; 110, 111; 110, 112; 111, identifier:os; 112, identifier:path; 113, identifier:join; 114, argument_list; 114, 115; 114, 118; 115, attribute; 115, 116; 115, 117; 116, identifier:sagen; 117, identifier:QualimapResults; 118, call; 118, 119; 118, 122; 119, attribute; 119, 120; 119, 121; 120, string:'{}_sorted.bam'; 121, identifier:format; 122, argument_list; 122, 123; 123, attribute; 123, 124; 123, 125; 124, identifier:sample; 125, identifier:name; 126, expression_statement; 126, 127; 127, assignment; 127, 128; 127, 129; 128, identifier:filenoext; 129, subscript; 129, 130; 129, 140; 130, call; 130, 131; 130, 136; 131, attribute; 131, 132; 131, 135; 132, attribute; 132, 133; 132, 134; 133, identifier:os; 134, identifier:path; 135, identifier:splitext; 136, argument_list; 136, 137; 137, attribute; 137, 138; 137, 139; 138, identifier:sagen; 139, identifier:filteredfile; 140, integer:0; 141, expression_statement; 141, 142; 142, assignment; 142, 143; 142, 146; 143, attribute; 143, 144; 143, 145; 144, identifier:sagen; 145, identifier:filenoext; 146, identifier:filenoext; 147, expression_statement; 147, 148; 148, assignment; 148, 149; 148, 152; 149, attribute; 149, 150; 149, 151; 150, identifier:sagen; 151, identifier:bowtie2results; 152, call; 152, 153; 152, 158; 153, attribute; 153, 154; 153, 157; 154, attribute; 154, 155; 154, 156; 155, identifier:os; 156, identifier:path; 157, identifier:join; 158, argument_list; 158, 159; 158, 162; 159, attribute; 159, 160; 159, 161; 160, identifier:sagen; 161, identifier:QualimapResults; 162, attribute; 162, 163; 162, 164; 163, identifier:sample; 164, identifier:name; 165, expression_statement; 165, 166; 166, assignment; 166, 167; 166, 168; 167, identifier:bowtie2build; 168, call; 168, 169; 168, 170; 169, identifier:Bowtie2BuildCommandLine; 170, argument_list; 170, 171; 170, 176; 171, keyword_argument; 171, 172; 171, 173; 172, identifier:reference; 173, attribute; 173, 174; 173, 175; 174, identifier:sagen; 175, identifier:bestassemblyfile; 176, keyword_argument; 176, 177; 176, 178; 177, identifier:bt2; 178, attribute; 178, 179; 178, 180; 179, identifier:sagen; 180, identifier:bowtie2results; 181, expression_statement; 181, 182; 182, assignment; 182, 183; 182, 188; 183, attribute; 183, 184; 183, 187; 184, attribute; 184, 185; 184, 186; 185, identifier:sample; 186, identifier:mapping; 187, identifier:BamFile; 188, binary_operator:+; 188, 189; 188, 192; 189, attribute; 189, 190; 189, 191; 190, identifier:sagen; 191, identifier:bowtie2results; 192, string:"_sorted.bam"; 193, expression_statement; 193, 194; 194, assignment; 194, 195; 194, 196; 195, identifier:samsort; 196, call; 196, 197; 196, 198; 197, identifier:SamtoolsSortCommandline; 198, argument_list; 198, 199; 198, 206; 198, 209; 199, keyword_argument; 199, 200; 199, 201; 200, identifier:input; 201, attribute; 201, 202; 201, 205; 202, attribute; 202, 203; 202, 204; 203, identifier:sample; 204, identifier:mapping; 205, identifier:BamFile; 206, keyword_argument; 206, 207; 206, 208; 207, identifier:o; 208, True; 209, keyword_argument; 209, 210; 209, 211; 210, identifier:out_prefix; 211, string:"-"; 212, expression_statement; 212, 213; 213, assignment; 213, 214; 213, 215; 214, identifier:samtools; 215, list:[SamtoolsViewCommandline(b=True, S=True, input_file="-"), samsort]; 215, 216; 215, 228; 216, call; 216, 217; 216, 218; 217, identifier:SamtoolsViewCommandline; 218, argument_list; 218, 219; 218, 222; 218, 225; 219, keyword_argument; 219, 220; 219, 221; 220, identifier:b; 221, True; 222, keyword_argument; 222, 223; 222, 224; 223, identifier:S; 224, True; 225, keyword_argument; 225, 226; 225, 227; 226, identifier:input_file; 227, string:"-"; 228, identifier:samsort; 229, expression_statement; 229, 230; 230, assignment; 230, 231; 230, 232; 231, identifier:indict; 232, dictionary; 232, 233; 232, 236; 232, 239; 232, 242; 232, 245; 233, pair; 233, 234; 233, 235; 234, string:'D'; 235, integer:5; 236, pair; 236, 237; 236, 238; 237, string:'R'; 238, integer:1; 239, pair; 239, 240; 239, 241; 240, string:'num_mismatches'; 241, integer:0; 242, pair; 242, 243; 242, 244; 243, string:'seed_length'; 244, integer:22; 245, pair; 245, 246; 245, 247; 246, string:'i_func'; 247, string:"S,0,2.50"; 248, try_statement; 248, 249; 248, 313; 249, block; 249, 250; 249, 258; 250, expression_statement; 250, 251; 251, assignment; 251, 252; 251, 253; 252, identifier:_; 253, attribute; 253, 254; 253, 257; 254, attribute; 254, 255; 254, 256; 255, identifier:sample; 256, identifier:general; 257, identifier:mergedreads; 258, if_statement; 258, 259; 258, 269; 258, 295; 259, comparison_operator:==; 259, 260; 259, 268; 260, call; 260, 261; 260, 262; 261, identifier:len; 262, argument_list; 262, 263; 263, attribute; 263, 264; 263, 267; 264, attribute; 264, 265; 264, 266; 265, identifier:sample; 266, identifier:general; 267, identifier:trimmedcorrectedfastqfiles; 268, integer:2; 269, block; 269, 270; 270, expression_statement; 270, 271; 271, call; 271, 272; 271, 275; 272, attribute; 272, 273; 272, 274; 273, identifier:indict; 274, identifier:update; 275, argument_list; 275, 276; 276, dictionary; 276, 277; 276, 286; 277, pair; 277, 278; 277, 279; 278, string:'m1'; 279, subscript; 279, 280; 279, 285; 280, attribute; 280, 281; 280, 284; 281, attribute; 281, 282; 281, 283; 282, identifier:sample; 283, identifier:general; 284, identifier:trimmedcorrectedfastqfiles; 285, integer:0; 286, pair; 286, 287; 286, 288; 287, string:'m2'; 288, subscript; 288, 289; 288, 294; 289, attribute; 289, 290; 289, 293; 290, attribute; 290, 291; 290, 292; 291, identifier:sample; 292, identifier:general; 293, identifier:trimmedcorrectedfastqfiles; 294, integer:1; 295, else_clause; 295, 296; 296, block; 296, 297; 297, expression_statement; 297, 298; 298, call; 298, 299; 298, 302; 299, attribute; 299, 300; 299, 301; 300, identifier:indict; 301, identifier:update; 302, argument_list; 302, 303; 303, dictionary; 303, 304; 304, pair; 304, 305; 304, 306; 305, string:'U'; 306, subscript; 306, 307; 306, 312; 307, attribute; 307, 308; 307, 311; 308, attribute; 308, 309; 308, 310; 309, identifier:sample; 310, identifier:general; 311, identifier:trimmedcorrectedfastqfiles; 312, integer:0; 313, except_clause; 313, 314; 313, 315; 314, identifier:AttributeError; 315, block; 315, 316; 316, if_statement; 316, 317; 316, 327; 316, 353; 317, comparison_operator:==; 317, 318; 317, 326; 318, call; 318, 319; 318, 320; 319, identifier:len; 320, argument_list; 320, 321; 321, attribute; 321, 322; 321, 325; 322, attribute; 322, 323; 322, 324; 323, identifier:sample; 324, identifier:general; 325, identifier:assemblyfastq; 326, integer:2; 327, block; 327, 328; 328, expression_statement; 328, 329; 329, call; 329, 330; 329, 333; 330, attribute; 330, 331; 330, 332; 331, identifier:indict; 332, identifier:update; 333, argument_list; 333, 334; 334, dictionary; 334, 335; 334, 344; 335, pair; 335, 336; 335, 337; 336, string:'m1'; 337, subscript; 337, 338; 337, 343; 338, attribute; 338, 339; 338, 342; 339, attribute; 339, 340; 339, 341; 340, identifier:sample; 341, identifier:general; 342, identifier:assemblyfastq; 343, integer:0; 344, pair; 344, 345; 344, 346; 345, string:'m2'; 346, subscript; 346, 347; 346, 352; 347, attribute; 347, 348; 347, 351; 348, attribute; 348, 349; 348, 350; 349, identifier:sample; 350, identifier:general; 351, identifier:assemblyfastq; 352, integer:1; 353, else_clause; 353, 354; 354, block; 354, 355; 355, expression_statement; 355, 356; 356, call; 356, 357; 356, 360; 357, attribute; 357, 358; 357, 359; 358, identifier:indict; 359, identifier:update; 360, argument_list; 360, 361; 361, dictionary; 361, 362; 362, pair; 362, 363; 362, 364; 363, string:'U'; 364, subscript; 364, 365; 364, 370; 365, attribute; 365, 366; 365, 369; 366, attribute; 366, 367; 366, 368; 367, identifier:sample; 368, identifier:general; 369, identifier:assemblyfastq; 370, integer:0; 371, expression_statement; 371, 372; 372, assignment; 372, 373; 372, 374; 373, identifier:bowtie2align; 374, call; 374, 375; 374, 376; 375, identifier:Bowtie2CommandLine; 376, argument_list; 376, 377; 376, 382; 376, 387; 376, 390; 377, keyword_argument; 377, 378; 377, 379; 378, identifier:bt2; 379, attribute; 379, 380; 379, 381; 380, identifier:sagen; 381, identifier:bowtie2results; 382, keyword_argument; 382, 383; 382, 384; 383, identifier:threads; 384, attribute; 384, 385; 384, 386; 385, identifier:self; 386, identifier:threads; 387, keyword_argument; 387, 388; 387, 389; 388, identifier:samtools; 389, identifier:samtools; 390, dictionary_splat; 390, 391; 391, identifier:indict; 392, expression_statement; 392, 393; 393, assignment; 393, 394; 393, 399; 394, attribute; 394, 395; 394, 398; 395, attribute; 395, 396; 395, 397; 396, identifier:sample; 397, identifier:commands; 398, identifier:bowtie2align; 399, call; 399, 400; 399, 401; 400, identifier:str; 401, argument_list; 401, 402; 402, identifier:bowtie2align; 403, expression_statement; 403, 404; 404, assignment; 404, 405; 404, 410; 405, attribute; 405, 406; 405, 409; 406, attribute; 406, 407; 406, 408; 407, identifier:sample; 408, identifier:commands; 409, identifier:bowtie2build; 410, call; 410, 411; 410, 412; 411, identifier:str; 412, argument_list; 412, 413; 413, identifier:bowtie2build; 414, expression_statement; 414, 415; 415, call; 415, 416; 415, 421; 416, attribute; 416, 417; 416, 420; 417, attribute; 417, 418; 417, 419; 418, identifier:self; 419, identifier:bowqueue; 420, identifier:put; 421, argument_list; 421, 422; 422, tuple; 422, 423; 422, 424; 422, 429; 423, identifier:sample; 424, attribute; 424, 425; 424, 428; 425, attribute; 425, 426; 425, 427; 426, identifier:sample; 427, identifier:commands; 428, identifier:bowtie2build; 429, attribute; 429, 430; 429, 433; 430, attribute; 430, 431; 430, 432; 431, identifier:sample; 432, identifier:commands; 433, identifier:bowtie2align; 434, else_clause; 434, 435; 435, block; 435, 436; 435, 444; 435, 452; 436, expression_statement; 436, 437; 437, assignment; 437, 438; 437, 443; 438, attribute; 438, 439; 438, 442; 439, attribute; 439, 440; 439, 441; 440, identifier:sample; 441, identifier:commands; 442, identifier:samtools; 443, string:"NA"; 444, expression_statement; 444, 445; 445, assignment; 445, 446; 445, 451; 446, attribute; 446, 447; 446, 450; 447, attribute; 447, 448; 447, 449; 448, identifier:sample; 449, identifier:mapping; 450, identifier:MeanInsertSize; 451, string:'NA'; 452, expression_statement; 452, 453; 453, assignment; 453, 454; 453, 459; 454, attribute; 454, 455; 454, 458; 455, attribute; 455, 456; 455, 457; 456, identifier:sample; 457, identifier:mapping; 458, identifier:MeanCoveragedata; 459, string:'NA'; 460, expression_statement; 460, 461; 461, call; 461, 462; 461, 467; 462, attribute; 462, 463; 462, 466; 463, attribute; 463, 464; 463, 465; 464, identifier:self; 465, identifier:bowqueue; 466, identifier:join; 467, argument_list
def bowtie(self): for i in range(self.cpus): threads = Thread(target=self.align, args=()) threads.setDaemon(True) threads.start() with progressbar(self.metadata) as bar: for sample in bar: sample.mapping = GenObject() sagen = sample.general if sagen.bestassemblyfile != "NA": sagen.QualimapResults = os.path.join(sagen.outputdirectory, 'qualimap_results') make_path(sagen.QualimapResults) sagen.sortedbam = os.path.join(sagen.QualimapResults, '{}_sorted.bam'.format(sample.name)) filenoext = os.path.splitext(sagen.filteredfile)[0] sagen.filenoext = filenoext sagen.bowtie2results = os.path.join(sagen.QualimapResults, sample.name) bowtie2build = Bowtie2BuildCommandLine(reference=sagen.bestassemblyfile, bt2=sagen.bowtie2results) sample.mapping.BamFile = sagen.bowtie2results + "_sorted.bam" samsort = SamtoolsSortCommandline(input=sample.mapping.BamFile, o=True, out_prefix="-") samtools = [SamtoolsViewCommandline(b=True, S=True, input_file="-"), samsort] indict = {'D': 5, 'R': 1, 'num_mismatches': 0, 'seed_length': 22, 'i_func': "S,0,2.50"} try: _ = sample.general.mergedreads if len(sample.general.trimmedcorrectedfastqfiles) == 2: indict.update({'m1': sample.general.trimmedcorrectedfastqfiles[0], 'm2': sample.general.trimmedcorrectedfastqfiles[1]}) else: indict.update({'U': sample.general.trimmedcorrectedfastqfiles[0]}) except AttributeError: if len(sample.general.assemblyfastq) == 2: indict.update({'m1': sample.general.assemblyfastq[0], 'm2': sample.general.assemblyfastq[1]}) else: indict.update({'U': sample.general.assemblyfastq[0]}) bowtie2align = Bowtie2CommandLine(bt2=sagen.bowtie2results, threads=self.threads, samtools=samtools, **indict) sample.commands.bowtie2align = str(bowtie2align) sample.commands.bowtie2build = str(bowtie2build) self.bowqueue.put((sample, sample.commands.bowtie2build, sample.commands.bowtie2align)) else: sample.commands.samtools = "NA" sample.mapping.MeanInsertSize = 'NA' sample.mapping.MeanCoveragedata = 'NA' self.bowqueue.join()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:validate_pages_json_data; 3, parameters; 3, 4; 3, 5; 4, identifier:d; 5, identifier:preferred_lang; 6, block; 6, 7; 6, 14; 6, 18; 6, 36; 6, 52; 6, 61; 6, 83; 6, 89; 6, 370; 7, import_from_statement; 7, 8; 7, 12; 8, relative_import; 8, 9; 8, 10; 9, import_prefix; 10, dotted_name; 10, 11; 11, identifier:models; 12, dotted_name; 12, 13; 13, identifier:Page; 14, expression_statement; 14, 15; 15, assignment; 15, 16; 15, 17; 16, identifier:errors; 17, list:[]; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:seen_complete_slugs; 21, call; 21, 22; 21, 23; 22, identifier:dict; 23, generator_expression; 23, 24; 23, 31; 24, tuple; 24, 25; 24, 28; 25, subscript; 25, 26; 25, 27; 26, identifier:lang; 27, integer:0; 28, call; 28, 29; 28, 30; 29, identifier:set; 30, argument_list; 31, for_in_clause; 31, 32; 31, 33; 32, identifier:lang; 33, attribute; 33, 34; 33, 35; 34, identifier:settings; 35, identifier:PAGE_LANGUAGES; 36, expression_statement; 36, 37; 37, assignment; 37, 38; 37, 39; 38, identifier:valid_templates; 39, call; 39, 40; 39, 41; 40, identifier:set; 41, generator_expression; 41, 42; 41, 45; 42, subscript; 42, 43; 42, 44; 43, identifier:t; 44, integer:0; 45, for_in_clause; 45, 46; 45, 47; 46, identifier:t; 47, call; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, identifier:settings; 50, identifier:get_page_templates; 51, argument_list; 52, expression_statement; 52, 53; 53, call; 53, 54; 53, 57; 54, attribute; 54, 55; 54, 56; 55, identifier:valid_templates; 56, identifier:add; 57, argument_list; 57, 58; 58, attribute; 58, 59; 58, 60; 59, identifier:settings; 60, identifier:PAGE_DEFAULT_TEMPLATE; 61, if_statement; 61, 62; 61, 67; 62, comparison_operator:!=; 62, 63; 62, 66; 63, subscript; 63, 64; 63, 65; 64, identifier:d; 65, identifier:JSON_PAGE_EXPORT_NAME; 66, identifier:JSON_PAGE_EXPORT_VERSION; 67, block; 67, 68; 68, return_statement; 68, 69; 69, expression_list; 69, 70; 69, 82; 70, list:[_('Unsupported file version: %s') % repr( d[JSON_PAGE_EXPORT_NAME])]; 70, 71; 71, binary_operator:%; 71, 72; 71, 76; 72, call; 72, 73; 72, 74; 73, identifier:_; 74, argument_list; 74, 75; 75, string:'Unsupported file version: %s'; 76, call; 76, 77; 76, 78; 77, identifier:repr; 78, argument_list; 78, 79; 79, subscript; 79, 80; 79, 81; 80, identifier:d; 81, identifier:JSON_PAGE_EXPORT_NAME; 82, list:[]; 83, expression_statement; 83, 84; 84, assignment; 84, 85; 84, 86; 85, identifier:pages; 86, subscript; 86, 87; 86, 88; 87, identifier:d; 88, string:'pages'; 89, for_statement; 89, 90; 89, 91; 89, 92; 90, identifier:p; 91, identifier:pages; 92, block; 92, 93; 92, 105; 92, 109; 92, 213; 92, 239; 92, 258; 92, 282; 92, 295; 92, 308; 92, 333; 92, 346; 93, expression_statement; 93, 94; 94, assignment; 94, 95; 94, 96; 95, identifier:slug; 96, call; 96, 97; 96, 102; 97, attribute; 97, 98; 97, 101; 98, subscript; 98, 99; 98, 100; 99, identifier:p; 100, string:'complete_slug'; 101, identifier:get; 102, argument_list; 102, 103; 102, 104; 103, identifier:preferred_lang; 104, None; 105, expression_statement; 105, 106; 106, assignment; 106, 107; 106, 108; 107, identifier:seen_parent; 108, False; 109, for_statement; 109, 110; 109, 113; 109, 120; 110, pattern_list; 110, 111; 110, 112; 111, identifier:lang; 112, identifier:s; 113, call; 113, 114; 113, 119; 114, attribute; 114, 115; 114, 118; 115, subscript; 115, 116; 115, 117; 116, identifier:p; 117, string:'complete_slug'; 118, identifier:items; 119, argument_list; 120, block; 120, 121; 120, 127; 120, 136; 120, 145; 120, 205; 121, if_statement; 121, 122; 121, 125; 122, comparison_operator:not; 122, 123; 122, 124; 123, identifier:lang; 124, identifier:seen_complete_slugs; 125, block; 125, 126; 126, continue_statement; 127, expression_statement; 127, 128; 128, call; 128, 129; 128, 134; 129, attribute; 129, 130; 129, 133; 130, subscript; 130, 131; 130, 132; 131, identifier:seen_complete_slugs; 132, identifier:lang; 133, identifier:add; 134, argument_list; 134, 135; 135, identifier:s; 136, if_statement; 136, 137; 136, 140; 137, comparison_operator:not; 137, 138; 137, 139; 138, string:'/'; 139, identifier:s; 140, block; 140, 141; 141, expression_statement; 141, 142; 142, assignment; 142, 143; 142, 144; 143, identifier:seen_parent; 144, True; 145, if_statement; 145, 146; 145, 148; 146, not_operator; 146, 147; 147, identifier:seen_parent; 148, block; 148, 149; 148, 161; 149, expression_statement; 149, 150; 150, assignment; 150, 151; 150, 154; 151, pattern_list; 151, 152; 151, 153; 152, identifier:parent_slug; 153, identifier:ignore; 154, call; 154, 155; 154, 158; 155, attribute; 155, 156; 155, 157; 156, identifier:s; 157, identifier:rsplit; 158, argument_list; 158, 159; 158, 160; 159, string:'/'; 160, integer:1; 161, if_statement; 161, 162; 161, 167; 161, 172; 162, comparison_operator:in; 162, 163; 162, 164; 163, identifier:parent_slug; 164, subscript; 164, 165; 164, 166; 165, identifier:seen_complete_slugs; 166, identifier:lang; 167, block; 167, 168; 168, expression_statement; 168, 169; 169, assignment; 169, 170; 169, 171; 170, identifier:seen_parent; 171, True; 172, else_clause; 172, 173; 173, block; 173, 174; 173, 189; 174, expression_statement; 174, 175; 175, assignment; 175, 176; 175, 177; 176, identifier:parent; 177, call; 177, 178; 177, 183; 178, attribute; 178, 179; 178, 182; 179, attribute; 179, 180; 179, 181; 180, identifier:Page; 181, identifier:objects; 182, identifier:from_path; 183, argument_list; 183, 184; 183, 185; 183, 186; 184, identifier:parent_slug; 185, identifier:lang; 186, keyword_argument; 186, 187; 186, 188; 187, identifier:exclude_drafts; 188, False; 189, if_statement; 189, 190; 189, 200; 190, boolean_operator:and; 190, 191; 190, 192; 191, identifier:parent; 192, comparison_operator:==; 192, 193; 192, 199; 193, call; 193, 194; 193, 197; 194, attribute; 194, 195; 194, 196; 195, identifier:parent; 196, identifier:get_complete_slug; 197, argument_list; 197, 198; 198, identifier:lang; 199, identifier:parent_slug; 200, block; 200, 201; 201, expression_statement; 201, 202; 202, assignment; 202, 203; 202, 204; 203, identifier:seen_parent; 204, True; 205, if_statement; 205, 206; 205, 208; 206, not_operator; 206, 207; 207, identifier:slug; 208, block; 208, 209; 209, expression_statement; 209, 210; 210, assignment; 210, 211; 210, 212; 211, identifier:slug; 212, identifier:s; 213, if_statement; 213, 214; 213, 216; 214, not_operator; 214, 215; 215, identifier:slug; 216, block; 216, 217; 216, 238; 217, expression_statement; 217, 218; 218, call; 218, 219; 218, 222; 219, attribute; 219, 220; 219, 221; 220, identifier:errors; 221, identifier:append; 222, argument_list; 222, 223; 223, binary_operator:%; 223, 224; 223, 228; 224, call; 224, 225; 224, 226; 225, identifier:_; 226, argument_list; 226, 227; 227, string:"%s has no common language with this site"; 228, tuple; 228, 229; 229, subscript; 229, 230; 229, 237; 230, call; 230, 231; 230, 236; 231, attribute; 231, 232; 231, 235; 232, subscript; 232, 233; 232, 234; 233, identifier:p; 234, string:'complete_slug'; 235, identifier:values; 236, argument_list; 237, integer:0; 238, continue_statement; 239, if_statement; 239, 240; 239, 242; 240, not_operator; 240, 241; 241, identifier:seen_parent; 242, block; 242, 243; 243, expression_statement; 243, 244; 244, call; 244, 245; 244, 248; 245, attribute; 245, 246; 245, 247; 246, identifier:errors; 247, identifier:append; 248, argument_list; 248, 249; 249, binary_operator:%; 249, 250; 249, 256; 250, call; 250, 251; 250, 252; 251, identifier:_; 252, argument_list; 252, 253; 253, concatenated_string; 253, 254; 253, 255; 254, string:"%s did not include its parent page and a matching"; 255, string:" one was not found on this site"; 256, tuple; 256, 257; 257, identifier:slug; 258, if_statement; 258, 259; 258, 264; 259, comparison_operator:not; 259, 260; 259, 263; 260, subscript; 260, 261; 260, 262; 261, identifier:p; 262, string:'template'; 263, identifier:valid_templates; 264, block; 264, 265; 264, 281; 265, expression_statement; 265, 266; 266, call; 266, 267; 266, 270; 267, attribute; 267, 268; 267, 269; 268, identifier:errors; 269, identifier:append; 270, argument_list; 270, 271; 271, binary_operator:%; 271, 272; 271, 276; 272, call; 272, 273; 272, 274; 273, identifier:_; 274, argument_list; 274, 275; 275, string:"%s uses a template not found on this site: %s"; 276, tuple; 276, 277; 276, 278; 277, identifier:slug; 278, subscript; 278, 279; 278, 280; 279, identifier:p; 280, string:'template'; 281, continue_statement; 282, expression_statement; 282, 283; 283, assignment; 283, 284; 283, 285; 284, identifier:import_fields; 285, call; 285, 286; 285, 287; 286, identifier:set; 287, argument_list; 287, 288; 288, call; 288, 289; 288, 294; 289, attribute; 289, 290; 289, 293; 290, subscript; 290, 291; 290, 292; 291, identifier:p; 292, string:'content'; 293, identifier:keys; 294, argument_list; 295, expression_statement; 295, 296; 296, augmented_assignment:|=; 296, 297; 296, 298; 297, identifier:import_fields; 298, call; 298, 299; 298, 300; 299, identifier:set; 300, argument_list; 300, 301; 301, tuple; 301, 302; 301, 303; 301, 304; 301, 305; 301, 306; 301, 307; 302, string:'meta_title'; 303, string:'meta_description'; 304, string:'meta_keywords'; 305, string:'meta_author'; 306, string:'fb_page_type'; 307, string:'fb_image'; 308, expression_statement; 308, 309; 309, assignment; 309, 310; 309, 311; 310, identifier:template_fields; 311, call; 311, 312; 311, 313; 312, identifier:set; 313, generator_expression; 313, 314; 313, 317; 313, 325; 314, attribute; 314, 315; 314, 316; 315, identifier:p; 316, identifier:name; 317, for_in_clause; 317, 318; 317, 319; 318, identifier:p; 319, call; 319, 320; 319, 321; 320, identifier:get_placeholders; 321, argument_list; 321, 322; 322, subscript; 322, 323; 322, 324; 323, identifier:p; 324, string:'template'; 325, if_clause; 325, 326; 326, comparison_operator:not; 326, 327; 326, 330; 327, attribute; 327, 328; 327, 329; 328, identifier:p; 329, identifier:name; 330, tuple; 330, 331; 330, 332; 331, string:'title'; 332, string:'slug'; 333, expression_statement; 333, 334; 334, augmented_assignment:|=; 334, 335; 334, 336; 335, identifier:template_fields; 336, call; 336, 337; 336, 338; 337, identifier:set; 338, argument_list; 338, 339; 339, tuple; 339, 340; 339, 341; 339, 342; 339, 343; 339, 344; 339, 345; 340, string:'meta_title'; 341, string:'meta_description'; 342, string:'meta_keywords'; 343, string:'meta_author'; 344, string:'fb_page_type'; 345, string:'fb_image'; 346, if_statement; 346, 347; 346, 350; 347, comparison_operator:!=; 347, 348; 347, 349; 348, identifier:template_fields; 349, identifier:import_fields; 350, block; 350, 351; 350, 369; 351, expression_statement; 351, 352; 352, call; 352, 353; 352, 356; 353, attribute; 353, 354; 353, 355; 354, identifier:errors; 355, identifier:append; 356, argument_list; 356, 357; 357, binary_operator:%; 357, 358; 357, 364; 358, call; 358, 359; 358, 360; 359, identifier:_; 360, argument_list; 360, 361; 361, concatenated_string; 361, 362; 361, 363; 362, string:"%s template contents are different than our "; 363, string:"template: %s"; 364, tuple; 364, 365; 364, 366; 365, identifier:slug; 366, subscript; 366, 367; 366, 368; 367, identifier:p; 368, string:'template'; 369, continue_statement; 370, return_statement; 370, 371; 371, identifier:errors
def validate_pages_json_data(d, preferred_lang): from .models import Page errors = [] seen_complete_slugs = dict( (lang[0], set()) for lang in settings.PAGE_LANGUAGES) valid_templates = set(t[0] for t in settings.get_page_templates()) valid_templates.add(settings.PAGE_DEFAULT_TEMPLATE) if d[JSON_PAGE_EXPORT_NAME] != JSON_PAGE_EXPORT_VERSION: return [_('Unsupported file version: %s') % repr( d[JSON_PAGE_EXPORT_NAME])], [] pages = d['pages'] for p in pages: slug = p['complete_slug'].get(preferred_lang, None) seen_parent = False for lang, s in p['complete_slug'].items(): if lang not in seen_complete_slugs: continue seen_complete_slugs[lang].add(s) if '/' not in s: seen_parent = True if not seen_parent: parent_slug, ignore = s.rsplit('/', 1) if parent_slug in seen_complete_slugs[lang]: seen_parent = True else: parent = Page.objects.from_path(parent_slug, lang, exclude_drafts=False) if parent and parent.get_complete_slug(lang) == parent_slug: seen_parent = True if not slug: slug = s if not slug: errors.append(_("%s has no common language with this site") % (p['complete_slug'].values()[0],)) continue if not seen_parent: errors.append(_("%s did not include its parent page and a matching" " one was not found on this site") % (slug,)) if p['template'] not in valid_templates: errors.append(_("%s uses a template not found on this site: %s") % (slug, p['template'])) continue import_fields = set(p['content'].keys()) import_fields |= set(('meta_title', 'meta_description', 'meta_keywords', 'meta_author', 'fb_page_type', 'fb_image')) template_fields = set(p.name for p in get_placeholders(p['template']) if p.name not in ('title', 'slug')) template_fields |= set(('meta_title', 'meta_description', 'meta_keywords', 'meta_author', 'fb_page_type', 'fb_image')) if template_fields != import_fields: errors.append(_("%s template contents are different than our " "template: %s") % (slug, p['template'])) continue return errors
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:import_po_files; 3, parameters; 3, 4; 3, 7; 4, default_parameter; 4, 5; 4, 6; 5, identifier:path; 6, string:'poexport'; 7, default_parameter; 7, 8; 7, 9; 8, identifier:stdout; 9, None; 10, block; 10, 11; 10, 14; 10, 22; 10, 28; 10, 32; 10, 36; 10, 58; 10, 72; 10, 85; 10, 255; 10, 265; 11, import_statement; 11, 12; 12, dotted_name; 12, 13; 13, identifier:polib; 14, import_from_statement; 14, 15; 14, 18; 14, 20; 15, dotted_name; 15, 16; 15, 17; 16, identifier:basic_cms; 17, identifier:models; 18, dotted_name; 18, 19; 19, identifier:Page; 20, dotted_name; 20, 21; 21, identifier:Content; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 25; 24, identifier:source_language; 25, attribute; 25, 26; 25, 27; 26, identifier:settings; 27, identifier:PAGE_DEFAULT_LANGUAGE; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:source_list; 31, list:[]; 32, expression_statement; 32, 33; 33, assignment; 33, 34; 33, 35; 34, identifier:pages_to_invalidate; 35, list:[]; 36, for_statement; 36, 37; 36, 38; 36, 45; 37, identifier:page; 38, call; 38, 39; 38, 44; 39, attribute; 39, 40; 39, 43; 40, attribute; 40, 41; 40, 42; 41, identifier:Page; 42, identifier:objects; 43, identifier:published; 44, argument_list; 45, block; 45, 46; 46, expression_statement; 46, 47; 47, call; 47, 48; 47, 51; 48, attribute; 48, 49; 48, 50; 49, identifier:source_list; 50, identifier:extend; 51, argument_list; 51, 52; 52, call; 52, 53; 52, 56; 53, attribute; 53, 54; 53, 55; 54, identifier:page; 55, identifier:content_by_language; 56, argument_list; 56, 57; 57, identifier:source_language; 58, if_statement; 58, 59; 58, 62; 59, comparison_operator:is; 59, 60; 59, 61; 60, identifier:stdout; 61, None; 62, block; 62, 63; 62, 66; 63, import_statement; 63, 64; 64, dotted_name; 64, 65; 65, identifier:sys; 66, expression_statement; 66, 67; 67, assignment; 67, 68; 67, 69; 68, identifier:stdout; 69, attribute; 69, 70; 69, 71; 70, identifier:sys; 71, identifier:stdout; 72, if_statement; 72, 73; 72, 80; 73, not_operator; 73, 74; 74, call; 74, 75; 74, 78; 75, attribute; 75, 76; 75, 77; 76, identifier:path; 77, identifier:endswith; 78, argument_list; 78, 79; 79, string:'/'; 80, block; 80, 81; 81, expression_statement; 81, 82; 82, augmented_assignment:+=; 82, 83; 82, 84; 83, identifier:path; 84, string:'/'; 85, for_statement; 85, 86; 85, 87; 85, 90; 86, identifier:lang; 87, attribute; 87, 88; 87, 89; 88, identifier:settings; 89, identifier:PAGE_LANGUAGES; 90, block; 90, 91; 91, if_statement; 91, 92; 91, 99; 92, comparison_operator:!=; 92, 93; 92, 96; 93, subscript; 93, 94; 93, 95; 94, identifier:lang; 95, integer:0; 96, attribute; 96, 97; 96, 98; 97, identifier:settings; 98, identifier:PAGE_DEFAULT_LANGUAGE; 99, block; 99, 100; 99, 111; 99, 121; 99, 130; 100, expression_statement; 100, 101; 101, call; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, identifier:stdout; 104, identifier:write; 105, argument_list; 105, 106; 106, binary_operator:%; 106, 107; 106, 108; 107, string:"Update language %s.\n"; 108, subscript; 108, 109; 108, 110; 109, identifier:lang; 110, integer:0; 111, expression_statement; 111, 112; 112, assignment; 112, 113; 112, 114; 113, identifier:po_path; 114, binary_operator:+; 114, 115; 114, 120; 115, binary_operator:+; 115, 116; 115, 117; 116, identifier:path; 117, subscript; 117, 118; 117, 119; 118, identifier:lang; 119, integer:0; 120, string:'.po'; 121, expression_statement; 121, 122; 122, assignment; 122, 123; 122, 124; 123, identifier:po; 124, call; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:polib; 127, identifier:pofile; 128, argument_list; 128, 129; 129, identifier:po_path; 130, for_statement; 130, 131; 130, 132; 130, 133; 131, identifier:entry; 132, identifier:po; 133, block; 133, 134; 133, 152; 133, 165; 133, 181; 133, 194; 133, 209; 134, expression_statement; 134, 135; 135, assignment; 135, 136; 135, 137; 136, identifier:meta_data; 137, call; 137, 138; 137, 150; 138, attribute; 138, 139; 138, 149; 139, subscript; 139, 140; 139, 148; 140, call; 140, 141; 140, 146; 141, attribute; 141, 142; 141, 145; 142, attribute; 142, 143; 142, 144; 143, identifier:entry; 144, identifier:tcomment; 145, identifier:split; 146, argument_list; 146, 147; 147, identifier:do_not_msg; 148, integer:1; 149, identifier:split; 150, argument_list; 150, 151; 151, string:"\n"; 152, expression_statement; 152, 153; 153, assignment; 153, 154; 153, 155; 154, identifier:placeholder_name; 155, subscript; 155, 156; 155, 164; 156, call; 156, 157; 156, 162; 157, attribute; 157, 158; 157, 161; 158, subscript; 158, 159; 158, 160; 159, identifier:meta_data; 160, integer:1; 161, identifier:split; 162, argument_list; 162, 163; 163, string:'='; 164, integer:1; 165, expression_statement; 165, 166; 166, assignment; 166, 167; 166, 168; 167, identifier:page_id; 168, call; 168, 169; 168, 170; 169, identifier:int; 170, argument_list; 170, 171; 171, subscript; 171, 172; 171, 180; 172, call; 172, 173; 172, 178; 173, attribute; 173, 174; 173, 177; 174, subscript; 174, 175; 174, 176; 175, identifier:meta_data; 176, integer:2; 177, identifier:split; 178, argument_list; 178, 179; 179, string:'='; 180, integer:1; 181, expression_statement; 181, 182; 182, assignment; 182, 183; 182, 184; 183, identifier:page; 184, call; 184, 185; 184, 190; 185, attribute; 185, 186; 185, 189; 186, attribute; 186, 187; 186, 188; 187, identifier:Page; 188, identifier:objects; 189, identifier:get; 190, argument_list; 190, 191; 191, keyword_argument; 191, 192; 191, 193; 192, identifier:id; 193, identifier:page_id; 194, expression_statement; 194, 195; 195, assignment; 195, 196; 195, 197; 196, identifier:current_content; 197, call; 197, 198; 197, 203; 198, attribute; 198, 199; 198, 202; 199, attribute; 199, 200; 199, 201; 200, identifier:Content; 201, identifier:objects; 202, identifier:get_content; 203, argument_list; 203, 204; 203, 205; 203, 208; 204, identifier:page; 205, subscript; 205, 206; 205, 207; 206, identifier:lang; 207, integer:0; 208, identifier:placeholder_name; 209, if_statement; 209, 210; 209, 215; 210, comparison_operator:!=; 210, 211; 210, 212; 211, identifier:current_content; 212, attribute; 212, 213; 212, 214; 213, identifier:entry; 214, identifier:msgstr; 215, block; 215, 216; 215, 227; 215, 243; 216, expression_statement; 216, 217; 217, call; 217, 218; 217, 221; 218, attribute; 218, 219; 218, 220; 219, identifier:stdout; 220, identifier:write; 221, argument_list; 221, 222; 222, binary_operator:%; 222, 223; 222, 224; 223, string:"Update page %d placeholder %s.\n"; 224, tuple; 224, 225; 224, 226; 225, identifier:page_id; 226, identifier:placeholder_name; 227, expression_statement; 227, 228; 228, call; 228, 229; 228, 234; 229, attribute; 229, 230; 229, 233; 230, attribute; 230, 231; 230, 232; 231, identifier:Content; 232, identifier:objects; 233, identifier:create_content_if_changed; 234, argument_list; 234, 235; 234, 236; 234, 239; 234, 240; 235, identifier:page; 236, subscript; 236, 237; 236, 238; 237, identifier:lang; 238, integer:0; 239, identifier:placeholder_name; 240, attribute; 240, 241; 240, 242; 241, identifier:entry; 242, identifier:msgstr; 243, if_statement; 243, 244; 243, 247; 244, comparison_operator:not; 244, 245; 244, 246; 245, identifier:page; 246, identifier:pages_to_invalidate; 247, block; 247, 248; 248, expression_statement; 248, 249; 249, call; 249, 250; 249, 253; 250, attribute; 250, 251; 250, 252; 251, identifier:pages_to_invalidate; 252, identifier:append; 253, argument_list; 253, 254; 254, identifier:page; 255, for_statement; 255, 256; 255, 257; 255, 258; 256, identifier:page; 257, identifier:pages_to_invalidate; 258, block; 258, 259; 259, expression_statement; 259, 260; 260, call; 260, 261; 260, 264; 261, attribute; 261, 262; 261, 263; 262, identifier:page; 263, identifier:invalidate; 264, argument_list; 265, expression_statement; 265, 266; 266, call; 266, 267; 266, 270; 267, attribute; 267, 268; 267, 269; 268, identifier:stdout; 269, identifier:write; 270, argument_list; 270, 271; 271, binary_operator:%; 271, 272; 271, 273; 272, string:"Import finished from %s.\n"; 273, identifier:path
def import_po_files(path='poexport', stdout=None): import polib from basic_cms.models import Page, Content source_language = settings.PAGE_DEFAULT_LANGUAGE source_list = [] pages_to_invalidate = [] for page in Page.objects.published(): source_list.extend(page.content_by_language(source_language)) if stdout is None: import sys stdout = sys.stdout if not path.endswith('/'): path += '/' for lang in settings.PAGE_LANGUAGES: if lang[0] != settings.PAGE_DEFAULT_LANGUAGE: stdout.write("Update language %s.\n" % lang[0]) po_path = path + lang[0] + '.po' po = polib.pofile(po_path) for entry in po: meta_data = entry.tcomment.split(do_not_msg)[1].split("\n") placeholder_name = meta_data[1].split('=')[1] page_id = int(meta_data[2].split('=')[1]) page = Page.objects.get(id=page_id) current_content = Content.objects.get_content(page, lang[0], placeholder_name) if current_content != entry.msgstr: stdout.write("Update page %d placeholder %s.\n" % (page_id, placeholder_name)) Content.objects.create_content_if_changed( page, lang[0], placeholder_name, entry.msgstr) if page not in pages_to_invalidate: pages_to_invalidate.append(page) for page in pages_to_invalidate: page.invalidate() stdout.write("Import finished from %s.\n" % path)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_scene_suggestions; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:current; 6, block; 6, 7; 6, 11; 6, 29; 6, 45; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:l; 10, list:[]; 11, if_statement; 11, 12; 11, 21; 12, call; 12, 13; 12, 14; 13, identifier:isinstance; 14, argument_list; 14, 15; 14, 16; 15, identifier:current; 16, attribute; 16, 17; 16, 20; 17, attribute; 17, 18; 17, 19; 18, identifier:djadapter; 19, identifier:models; 20, identifier:Asset; 21, block; 21, 22; 22, expression_statement; 22, 23; 23, call; 23, 24; 23, 27; 24, attribute; 24, 25; 24, 26; 25, identifier:l; 26, identifier:append; 27, argument_list; 27, 28; 28, identifier:current; 29, expression_statement; 29, 30; 30, call; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:l; 33, identifier:extend; 34, argument_list; 34, 35; 35, call; 35, 36; 35, 37; 36, identifier:list; 37, argument_list; 37, 38; 38, call; 38, 39; 38, 44; 39, attribute; 39, 40; 39, 43; 40, attribute; 40, 41; 40, 42; 41, identifier:current; 42, identifier:assets; 43, identifier:all; 44, argument_list; 45, return_statement; 45, 46; 46, identifier:l
def get_scene_suggestions(self, current): l = [] if isinstance(current, djadapter.models.Asset): l.append(current) l.extend(list(current.assets.all())) return l
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:assert_variable_type; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:variable; 5, identifier:expected_type; 6, default_parameter; 6, 7; 6, 8; 7, identifier:raise_exception; 8, True; 9, block; 9, 10; 9, 23; 9, 45; 9, 63; 9, 125; 10, if_statement; 10, 11; 10, 17; 11, not_operator; 11, 12; 12, call; 12, 13; 12, 14; 13, identifier:isinstance; 14, argument_list; 14, 15; 14, 16; 15, identifier:expected_type; 16, identifier:list; 17, block; 17, 18; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:expected_type; 21, list:[expected_type]; 21, 22; 22, identifier:expected_type; 23, for_statement; 23, 24; 23, 25; 23, 26; 24, identifier:t; 25, identifier:expected_type; 26, block; 26, 27; 27, if_statement; 27, 28; 27, 34; 28, not_operator; 28, 29; 29, call; 29, 30; 29, 31; 30, identifier:isinstance; 31, argument_list; 31, 32; 31, 33; 32, identifier:t; 33, identifier:type; 34, block; 34, 35; 35, raise_statement; 35, 36; 36, call; 36, 37; 36, 38; 37, identifier:ValueError; 38, argument_list; 38, 39; 39, binary_operator:%; 39, 40; 39, 41; 40, string:'expected_type argument "%s" is not a type'; 41, call; 41, 42; 41, 43; 42, identifier:str; 43, argument_list; 43, 44; 44, identifier:t; 45, if_statement; 45, 46; 45, 52; 46, not_operator; 46, 47; 47, call; 47, 48; 47, 49; 48, identifier:isinstance; 49, argument_list; 49, 50; 49, 51; 50, identifier:raise_exception; 51, identifier:bool; 52, block; 52, 53; 53, raise_statement; 53, 54; 54, call; 54, 55; 54, 56; 55, identifier:ValueError; 56, argument_list; 56, 57; 57, binary_operator:%; 57, 58; 57, 59; 58, string:'raise_exception argument "%s" is not a bool'; 59, call; 59, 60; 59, 61; 60, identifier:str; 61, argument_list; 61, 62; 62, identifier:raise_exception; 63, if_statement; 63, 64; 63, 80; 64, not_operator; 64, 65; 65, call; 65, 66; 65, 67; 66, identifier:len; 67, argument_list; 67, 68; 68, list_comprehension; 68, 69; 68, 71; 68, 74; 69, parenthesized_expression; 69, 70; 70, identifier:t; 71, for_in_clause; 71, 72; 71, 73; 72, identifier:t; 73, identifier:expected_type; 74, if_clause; 74, 75; 75, call; 75, 76; 75, 77; 76, identifier:isinstance; 77, argument_list; 77, 78; 77, 79; 78, identifier:variable; 79, identifier:t; 80, block; 80, 81; 80, 111; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 84; 83, identifier:error_message; 84, binary_operator:%; 84, 85; 84, 86; 85, string:'"%s" is not an instance of type %s. It is of type %s'; 86, tuple; 86, 87; 86, 91; 86, 104; 87, call; 87, 88; 87, 89; 88, identifier:str; 89, argument_list; 89, 90; 90, identifier:variable; 91, call; 91, 92; 91, 95; 92, attribute; 92, 93; 92, 94; 93, string:' or '; 94, identifier:join; 95, argument_list; 95, 96; 96, list_comprehension; 96, 97; 96, 101; 97, call; 97, 98; 97, 99; 98, identifier:str; 99, argument_list; 99, 100; 100, identifier:t; 101, for_in_clause; 101, 102; 101, 103; 102, identifier:t; 103, identifier:expected_type; 104, call; 104, 105; 104, 106; 105, identifier:str; 106, argument_list; 106, 107; 107, call; 107, 108; 107, 109; 108, identifier:type; 109, argument_list; 109, 110; 110, identifier:variable; 111, if_statement; 111, 112; 111, 113; 111, 119; 112, identifier:raise_exception; 113, block; 113, 114; 114, raise_statement; 114, 115; 115, call; 115, 116; 115, 117; 116, identifier:ValueError; 117, argument_list; 117, 118; 118, identifier:error_message; 119, else_clause; 119, 120; 120, block; 120, 121; 121, return_statement; 121, 122; 122, expression_list; 122, 123; 122, 124; 123, False; 124, identifier:error_message; 125, return_statement; 125, 126; 126, expression_list; 126, 127; 126, 128; 127, True; 128, None
def assert_variable_type(variable, expected_type, raise_exception=True): if not isinstance(expected_type, list): expected_type = [expected_type] for t in expected_type: if not isinstance(t, type): raise ValueError('expected_type argument "%s" is not a type' %str(t)) if not isinstance(raise_exception, bool): raise ValueError('raise_exception argument "%s" is not a bool' %str(raise_exception)) if not len([(t) for t in expected_type if isinstance(variable, t)]): error_message = '"%s" is not an instance of type %s. It is of type %s' %(str(variable),' or '.join([str(t) for t in expected_type]), str(type(variable))) if raise_exception: raise ValueError(error_message) else: return False, error_message return True, None
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:run; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 6, while_statement; 6, 7; 6, 15; 7, not_operator; 7, 8; 8, call; 8, 9; 8, 14; 9, attribute; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:self; 12, identifier:stopped; 13, identifier:isSet; 14, argument_list; 15, block; 15, 16; 16, try_statement; 16, 17; 16, 158; 17, block; 17, 18; 17, 31; 17, 53; 17, 71; 17, 82; 17, 108; 17, 120; 17, 131; 18, expression_statement; 18, 19; 19, assignment; 19, 20; 19, 21; 20, identifier:timeout; 21, boolean_operator:or; 21, 22; 21, 30; 22, boolean_operator:and; 22, 23; 22, 29; 23, parenthesized_expression; 23, 24; 24, comparison_operator:!=; 24, 25; 24, 28; 25, attribute; 25, 26; 25, 27; 26, identifier:self; 27, identifier:_state; 28, string:'idle'; 29, float:0.2; 30, None; 31, expression_statement; 31, 32; 32, assignment; 32, 33; 32, 37; 33, pattern_list; 33, 34; 33, 35; 33, 36; 34, identifier:rdlist; 35, identifier:_; 36, identifier:_; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:select; 40, identifier:select; 41, argument_list; 41, 42; 41, 50; 41, 51; 41, 52; 42, list:[self._socket.fileno()]; 42, 43; 43, call; 43, 44; 43, 49; 44, attribute; 44, 45; 44, 48; 45, attribute; 45, 46; 45, 47; 46, identifier:self; 47, identifier:_socket; 48, identifier:fileno; 49, argument_list; 50, list:[]; 51, list:[]; 52, identifier:timeout; 53, if_statement; 53, 54; 53, 56; 54, not_operator; 54, 55; 55, identifier:rdlist; 56, block; 56, 57; 56, 70; 57, if_statement; 57, 58; 57, 63; 58, comparison_operator:!=; 58, 59; 58, 62; 59, attribute; 59, 60; 59, 61; 60, identifier:self; 61, identifier:_state; 62, string:'idle'; 63, block; 63, 64; 64, expression_statement; 64, 65; 65, assignment; 65, 66; 65, 69; 66, attribute; 66, 67; 66, 68; 67, identifier:self; 68, identifier:_state; 69, string:'idle'; 70, continue_statement; 71, expression_statement; 71, 72; 72, assignment; 72, 73; 72, 74; 73, identifier:data; 74, call; 74, 75; 74, 80; 75, attribute; 75, 76; 75, 79; 76, attribute; 76, 77; 76, 78; 77, identifier:self; 78, identifier:_socket; 79, identifier:recv; 80, argument_list; 80, 81; 81, integer:1024; 82, if_statement; 82, 83; 82, 85; 83, not_operator; 83, 84; 84, identifier:data; 85, block; 85, 86; 85, 107; 86, try_statement; 86, 87; 86, 101; 87, block; 87, 88; 88, expression_statement; 88, 89; 89, call; 89, 90; 89, 93; 90, attribute; 90, 91; 90, 92; 91, identifier:os; 92, identifier:fstat; 93, argument_list; 93, 94; 94, call; 94, 95; 94, 100; 95, attribute; 95, 96; 95, 99; 96, attribute; 96, 97; 96, 98; 97, identifier:recv; 98, identifier:_socket; 99, identifier:fileno; 100, argument_list; 101, except_clause; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, identifier:socket; 104, identifier:error; 105, block; 105, 106; 106, break_statement; 107, continue_statement; 108, expression_statement; 108, 109; 109, assignment; 109, 110; 109, 111; 110, identifier:code; 111, call; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, identifier:utils; 114, identifier:mangleIR; 115, argument_list; 115, 116; 115, 117; 116, identifier:data; 117, keyword_argument; 117, 118; 117, 119; 118, identifier:ignore_errors; 119, True; 120, expression_statement; 120, 121; 121, assignment; 121, 122; 121, 123; 122, identifier:codeName; 123, call; 123, 124; 123, 129; 124, attribute; 124, 125; 124, 128; 125, attribute; 125, 126; 125, 127; 126, identifier:self; 127, identifier:codeMap; 128, identifier:get; 129, argument_list; 129, 130; 130, identifier:code; 131, if_statement; 131, 132; 131, 140; 132, boolean_operator:and; 132, 133; 132, 134; 133, identifier:codeName; 134, parenthesized_expression; 134, 135; 135, comparison_operator:!=; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:self; 138, identifier:_state; 139, identifier:codeName; 140, block; 140, 141; 140, 147; 141, expression_statement; 141, 142; 142, assignment; 142, 143; 142, 146; 143, attribute; 143, 144; 143, 145; 144, identifier:self; 145, identifier:_state; 146, identifier:codeName; 147, for_statement; 147, 148; 147, 149; 147, 152; 148, identifier:callback; 149, attribute; 149, 150; 149, 151; 150, identifier:self; 151, identifier:_callbacks; 152, block; 152, 153; 153, expression_statement; 153, 154; 154, call; 154, 155; 154, 156; 155, identifier:callback; 156, argument_list; 156, 157; 157, identifier:codeName; 158, except_clause; 158, 159; 159, block; 159, 160; 160, expression_statement; 160, 161; 161, call; 161, 162; 161, 165; 162, attribute; 162, 163; 162, 164; 163, identifier:time; 164, identifier:sleep; 165, argument_list; 165, 166; 166, float:0.1
def run(self): while not self.stopped.isSet(): try: timeout = (self._state != 'idle') and 0.2 or None rdlist, _, _ = select.select([self._socket.fileno()], [], [], timeout) if not rdlist: if self._state != 'idle': self._state = 'idle' continue data = self._socket.recv(1024) if not data: try: os.fstat(recv._socket.fileno()) except socket.error: break continue code = utils.mangleIR(data, ignore_errors=True) codeName = self.codeMap.get(code) if codeName and (self._state != codeName): self._state = codeName for callback in self._callbacks: callback(codeName) except: time.sleep(0.1)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_inc; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:native; 7, False; 8, block; 8, 9; 8, 67; 8, 167; 8, 256; 8, 267; 9, if_statement; 9, 10; 9, 15; 10, comparison_operator:==; 10, 11; 10, 14; 11, attribute; 11, 12; 11, 13; 12, identifier:self; 13, identifier:sdk_version; 14, string:'v7.0A'; 15, block; 15, 16; 15, 30; 15, 54; 15, 65; 16, expression_statement; 16, 17; 17, assignment; 17, 18; 17, 19; 18, identifier:include; 19, call; 19, 20; 19, 25; 20, attribute; 20, 21; 20, 24; 21, attribute; 21, 22; 21, 23; 22, identifier:os; 23, identifier:path; 24, identifier:join; 25, argument_list; 25, 26; 25, 29; 26, attribute; 26, 27; 26, 28; 27, identifier:self; 28, identifier:sdk_dir; 29, string:'include'; 30, if_statement; 30, 31; 30, 39; 31, call; 31, 32; 31, 37; 32, attribute; 32, 33; 32, 36; 33, attribute; 33, 34; 33, 35; 34, identifier:os; 35, identifier:path; 36, identifier:isdir; 37, argument_list; 37, 38; 38, identifier:include; 39, block; 39, 40; 39, 51; 40, expression_statement; 40, 41; 41, call; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:logging; 44, identifier:info; 45, argument_list; 45, 46; 45, 50; 46, call; 46, 47; 46, 48; 47, identifier:_; 48, argument_list; 48, 49; 49, string:'using include: %s'; 50, identifier:include; 51, return_statement; 51, 52; 52, list:[include]; 52, 53; 53, identifier:include; 54, expression_statement; 54, 55; 55, call; 55, 56; 55, 59; 56, attribute; 56, 57; 56, 58; 57, identifier:logging; 58, identifier:debug; 59, argument_list; 59, 60; 59, 64; 60, call; 60, 61; 60, 62; 61, identifier:_; 62, argument_list; 62, 63; 63, string:'include not found: %s'; 64, identifier:include; 65, return_statement; 65, 66; 66, list:[]; 67, if_statement; 67, 68; 67, 73; 68, comparison_operator:==; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, identifier:self; 71, identifier:sdk_version; 72, string:'v8.1'; 73, block; 73, 74; 73, 78; 73, 105; 73, 165; 74, expression_statement; 74, 75; 75, assignment; 75, 76; 75, 77; 76, identifier:dirs; 77, list:[]; 78, if_statement; 78, 79; 78, 80; 78, 96; 79, identifier:native; 80, block; 80, 81; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 84; 83, identifier:parts; 84, list:['km', os.path.join('km', 'crt'), 'shared']; 84, 85; 84, 86; 84, 95; 85, string:'km'; 86, call; 86, 87; 86, 92; 87, attribute; 87, 88; 87, 91; 88, attribute; 88, 89; 88, 90; 89, identifier:os; 90, identifier:path; 91, identifier:join; 92, argument_list; 92, 93; 92, 94; 93, string:'km'; 94, string:'crt'; 95, string:'shared'; 96, else_clause; 96, 97; 97, block; 97, 98; 98, expression_statement; 98, 99; 99, assignment; 99, 100; 99, 101; 100, identifier:parts; 101, list:['um', 'winrt', 'shared']; 101, 102; 101, 103; 101, 104; 102, string:'um'; 103, string:'winrt'; 104, string:'shared'; 105, for_statement; 105, 106; 105, 107; 105, 108; 106, identifier:part; 107, identifier:parts; 108, block; 108, 109; 108, 124; 109, expression_statement; 109, 110; 110, assignment; 110, 111; 110, 112; 111, identifier:include; 112, call; 112, 113; 112, 118; 113, attribute; 113, 114; 113, 117; 114, attribute; 114, 115; 114, 116; 115, identifier:os; 116, identifier:path; 117, identifier:join; 118, argument_list; 118, 119; 118, 122; 118, 123; 119, attribute; 119, 120; 119, 121; 120, identifier:self; 121, identifier:sdk_dir; 122, string:'include'; 123, identifier:part; 124, if_statement; 124, 125; 124, 133; 124, 152; 125, call; 125, 126; 125, 131; 126, attribute; 126, 127; 126, 130; 127, attribute; 127, 128; 127, 129; 128, identifier:os; 129, identifier:path; 130, identifier:isdir; 131, argument_list; 131, 132; 132, identifier:include; 133, block; 133, 134; 133, 145; 134, expression_statement; 134, 135; 135, call; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:logging; 138, identifier:info; 139, argument_list; 139, 140; 139, 144; 140, call; 140, 141; 140, 142; 141, identifier:_; 142, argument_list; 142, 143; 143, string:'using include: %s'; 144, identifier:include; 145, expression_statement; 145, 146; 146, call; 146, 147; 146, 150; 147, attribute; 147, 148; 147, 149; 148, identifier:dirs; 149, identifier:append; 150, argument_list; 150, 151; 151, identifier:include; 152, else_clause; 152, 153; 153, block; 153, 154; 154, expression_statement; 154, 155; 155, call; 155, 156; 155, 159; 156, attribute; 156, 157; 156, 158; 157, identifier:logging; 158, identifier:debug; 159, argument_list; 159, 160; 159, 164; 160, call; 160, 161; 160, 162; 161, identifier:_; 162, argument_list; 162, 163; 163, string:'inc not found: %s'; 164, identifier:include; 165, return_statement; 165, 166; 166, identifier:dirs; 167, if_statement; 167, 168; 167, 173; 168, comparison_operator:==; 168, 169; 168, 172; 169, attribute; 169, 170; 169, 171; 170, identifier:self; 171, identifier:sdk_version; 172, string:'v10.0'; 173, block; 173, 174; 173, 178; 173, 190; 173, 254; 174, expression_statement; 174, 175; 175, assignment; 175, 176; 175, 177; 176, identifier:dirs; 177, list:[]; 178, expression_statement; 178, 179; 179, assignment; 179, 180; 179, 181; 180, identifier:extra; 181, call; 181, 182; 181, 187; 182, attribute; 182, 183; 182, 186; 183, attribute; 183, 184; 183, 185; 184, identifier:os; 185, identifier:path; 186, identifier:join; 187, argument_list; 187, 188; 187, 189; 188, string:'include'; 189, string:'10.0.10240.0'; 190, for_statement; 190, 191; 190, 192; 190, 197; 191, identifier:mode; 192, list:['um', 'ucrt', 'shared', 'winrt']; 192, 193; 192, 194; 192, 195; 192, 196; 193, string:'um'; 194, string:'ucrt'; 195, string:'shared'; 196, string:'winrt'; 197, block; 197, 198; 197, 213; 198, expression_statement; 198, 199; 199, assignment; 199, 200; 199, 201; 200, identifier:include; 201, call; 201, 202; 201, 207; 202, attribute; 202, 203; 202, 206; 203, attribute; 203, 204; 203, 205; 204, identifier:os; 205, identifier:path; 206, identifier:join; 207, argument_list; 207, 208; 207, 211; 207, 212; 208, attribute; 208, 209; 208, 210; 209, identifier:self; 210, identifier:sdk_dir; 211, identifier:extra; 212, identifier:mode; 213, if_statement; 213, 214; 213, 222; 213, 241; 214, call; 214, 215; 214, 220; 215, attribute; 215, 216; 215, 219; 216, attribute; 216, 217; 216, 218; 217, identifier:os; 218, identifier:path; 219, identifier:isdir; 220, argument_list; 220, 221; 221, identifier:include; 222, block; 222, 223; 222, 234; 223, expression_statement; 223, 224; 224, call; 224, 225; 224, 228; 225, attribute; 225, 226; 225, 227; 226, identifier:logging; 227, identifier:info; 228, argument_list; 228, 229; 228, 233; 229, call; 229, 230; 229, 231; 230, identifier:_; 231, argument_list; 231, 232; 232, string:'using include: %s'; 233, identifier:include; 234, expression_statement; 234, 235; 235, call; 235, 236; 235, 239; 236, attribute; 236, 237; 236, 238; 237, identifier:dirs; 238, identifier:append; 239, argument_list; 239, 240; 240, identifier:include; 241, else_clause; 241, 242; 242, block; 242, 243; 243, expression_statement; 243, 244; 244, call; 244, 245; 244, 248; 245, attribute; 245, 246; 245, 247; 246, identifier:logging; 247, identifier:debug; 248, argument_list; 248, 249; 248, 253; 249, call; 249, 250; 249, 251; 250, identifier:_; 251, argument_list; 251, 252; 252, string:'inc not found: %s'; 253, identifier:include; 254, return_statement; 254, 255; 255, identifier:dirs; 256, expression_statement; 256, 257; 257, assignment; 257, 258; 257, 259; 258, identifier:message; 259, call; 259, 260; 259, 263; 260, attribute; 260, 261; 260, 262; 261, string:'unknown sdk version: {}'; 262, identifier:format; 263, argument_list; 263, 264; 264, attribute; 264, 265; 264, 266; 265, identifier:self; 266, identifier:sdk_version; 267, raise_statement; 267, 268; 268, call; 268, 269; 268, 270; 269, identifier:RuntimeError; 270, argument_list; 270, 271; 271, identifier:message
def get_inc(self, native=False): if self.sdk_version == 'v7.0A': include = os.path.join(self.sdk_dir, 'include') if os.path.isdir(include): logging.info(_('using include: %s'), include) return [include] logging.debug(_('include not found: %s'), include) return [] if self.sdk_version == 'v8.1': dirs = [] if native: parts = ['km', os.path.join('km', 'crt'), 'shared'] else: parts = ['um', 'winrt', 'shared'] for part in parts: include = os.path.join(self.sdk_dir, 'include', part) if os.path.isdir(include): logging.info(_('using include: %s'), include) dirs.append(include) else: logging.debug(_('inc not found: %s'), include) return dirs if self.sdk_version == 'v10.0': dirs = [] extra = os.path.join('include', '10.0.10240.0') for mode in ['um', 'ucrt', 'shared', 'winrt']: include = os.path.join(self.sdk_dir, extra, mode) if os.path.isdir(include): logging.info(_('using include: %s'), include) dirs.append(include) else: logging.debug(_('inc not found: %s'), include) return dirs message = 'unknown sdk version: {}'.format(self.sdk_version) raise RuntimeError(message)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:get_lib; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:arch; 7, string:'x86'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:native; 10, False; 11, block; 11, 12; 11, 80; 11, 169; 11, 257; 11, 268; 12, if_statement; 12, 13; 12, 18; 13, comparison_operator:==; 13, 14; 13, 17; 14, attribute; 14, 15; 14, 16; 15, identifier:self; 16, identifier:sdk_version; 17, string:'v7.0A'; 18, block; 18, 19; 18, 28; 18, 43; 18, 67; 18, 78; 19, if_statement; 19, 20; 19, 23; 20, comparison_operator:==; 20, 21; 20, 22; 21, identifier:arch; 22, string:'x86'; 23, block; 23, 24; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 27; 26, identifier:arch; 27, string:''; 28, expression_statement; 28, 29; 29, assignment; 29, 30; 29, 31; 30, identifier:lib; 31, call; 31, 32; 31, 37; 32, attribute; 32, 33; 32, 36; 33, attribute; 33, 34; 33, 35; 34, identifier:os; 35, identifier:path; 36, identifier:join; 37, argument_list; 37, 38; 37, 41; 37, 42; 38, attribute; 38, 39; 38, 40; 39, identifier:self; 40, identifier:sdk_dir; 41, string:'lib'; 42, identifier:arch; 43, if_statement; 43, 44; 43, 52; 44, call; 44, 45; 44, 50; 45, attribute; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:os; 48, identifier:path; 49, identifier:isdir; 50, argument_list; 50, 51; 51, identifier:lib; 52, block; 52, 53; 52, 64; 53, expression_statement; 53, 54; 54, call; 54, 55; 54, 58; 55, attribute; 55, 56; 55, 57; 56, identifier:logging; 57, identifier:info; 58, argument_list; 58, 59; 58, 63; 59, call; 59, 60; 59, 61; 60, identifier:_; 61, argument_list; 61, 62; 62, string:'using lib: %s'; 63, identifier:lib; 64, return_statement; 64, 65; 65, list:[lib]; 65, 66; 66, identifier:lib; 67, expression_statement; 67, 68; 68, call; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, identifier:logging; 71, identifier:debug; 72, argument_list; 72, 73; 72, 77; 73, call; 73, 74; 73, 75; 74, identifier:_; 75, argument_list; 75, 76; 76, string:'lib not found: %s'; 77, identifier:lib; 78, return_statement; 78, 79; 79, list:[]; 80, if_statement; 80, 81; 80, 86; 81, comparison_operator:==; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:self; 84, identifier:sdk_version; 85, string:'v8.1'; 86, block; 86, 87; 86, 116; 86, 132; 86, 156; 86, 167; 87, if_statement; 87, 88; 87, 89; 87, 102; 88, identifier:native; 89, block; 89, 90; 90, expression_statement; 90, 91; 91, assignment; 91, 92; 91, 93; 92, identifier:extra; 93, call; 93, 94; 93, 99; 94, attribute; 94, 95; 94, 98; 95, attribute; 95, 96; 95, 97; 96, identifier:os; 97, identifier:path; 98, identifier:join; 99, argument_list; 99, 100; 99, 101; 100, string:'winv6.3'; 101, string:'km'; 102, else_clause; 102, 103; 103, block; 103, 104; 104, expression_statement; 104, 105; 105, assignment; 105, 106; 105, 107; 106, identifier:extra; 107, call; 107, 108; 107, 113; 108, attribute; 108, 109; 108, 112; 109, attribute; 109, 110; 109, 111; 110, identifier:os; 111, identifier:path; 112, identifier:join; 113, argument_list; 113, 114; 113, 115; 114, string:'winv6.3'; 115, string:'um'; 116, expression_statement; 116, 117; 117, assignment; 117, 118; 117, 119; 118, identifier:lib; 119, call; 119, 120; 119, 125; 120, attribute; 120, 121; 120, 124; 121, attribute; 121, 122; 121, 123; 122, identifier:os; 123, identifier:path; 124, identifier:join; 125, argument_list; 125, 126; 125, 129; 125, 130; 125, 131; 126, attribute; 126, 127; 126, 128; 127, identifier:self; 128, identifier:sdk_dir; 129, string:'lib'; 130, identifier:extra; 131, identifier:arch; 132, if_statement; 132, 133; 132, 141; 133, call; 133, 134; 133, 139; 134, attribute; 134, 135; 134, 138; 135, attribute; 135, 136; 135, 137; 136, identifier:os; 137, identifier:path; 138, identifier:isdir; 139, argument_list; 139, 140; 140, identifier:lib; 141, block; 141, 142; 141, 153; 142, expression_statement; 142, 143; 143, call; 143, 144; 143, 147; 144, attribute; 144, 145; 144, 146; 145, identifier:logging; 146, identifier:info; 147, argument_list; 147, 148; 147, 152; 148, call; 148, 149; 148, 150; 149, identifier:_; 150, argument_list; 150, 151; 151, string:'using lib: %s'; 152, identifier:lib; 153, return_statement; 153, 154; 154, list:[lib]; 154, 155; 155, identifier:lib; 156, expression_statement; 156, 157; 157, call; 157, 158; 157, 161; 158, attribute; 158, 159; 158, 160; 159, identifier:logging; 160, identifier:debug; 161, argument_list; 161, 162; 161, 166; 162, call; 162, 163; 162, 164; 163, identifier:_; 164, argument_list; 164, 165; 165, string:'lib not found: %s'; 166, identifier:lib; 167, return_statement; 167, 168; 168, list:[]; 169, if_statement; 169, 170; 169, 175; 170, comparison_operator:==; 170, 171; 170, 174; 171, attribute; 171, 172; 171, 173; 172, identifier:self; 173, identifier:sdk_version; 174, string:'v10.0'; 175, block; 175, 176; 175, 180; 175, 192; 175, 255; 176, expression_statement; 176, 177; 177, assignment; 177, 178; 177, 179; 178, identifier:dirs; 179, list:[]; 180, expression_statement; 180, 181; 181, assignment; 181, 182; 181, 183; 182, identifier:extra; 183, call; 183, 184; 183, 189; 184, attribute; 184, 185; 184, 188; 185, attribute; 185, 186; 185, 187; 186, identifier:os; 187, identifier:path; 188, identifier:join; 189, argument_list; 189, 190; 189, 191; 190, string:'lib'; 191, string:'10.0.10240.0'; 192, for_statement; 192, 193; 192, 194; 192, 197; 193, identifier:mode; 194, list:['um', 'ucrt']; 194, 195; 194, 196; 195, string:'um'; 196, string:'ucrt'; 197, block; 197, 198; 197, 214; 198, expression_statement; 198, 199; 199, assignment; 199, 200; 199, 201; 200, identifier:lib; 201, call; 201, 202; 201, 207; 202, attribute; 202, 203; 202, 206; 203, attribute; 203, 204; 203, 205; 204, identifier:os; 205, identifier:path; 206, identifier:join; 207, argument_list; 207, 208; 207, 211; 207, 212; 207, 213; 208, attribute; 208, 209; 208, 210; 209, identifier:self; 210, identifier:sdk_dir; 211, identifier:extra; 212, identifier:mode; 213, identifier:arch; 214, if_statement; 214, 215; 214, 223; 214, 242; 215, call; 215, 216; 215, 221; 216, attribute; 216, 217; 216, 220; 217, attribute; 217, 218; 217, 219; 218, identifier:os; 219, identifier:path; 220, identifier:isdir; 221, argument_list; 221, 222; 222, identifier:lib; 223, block; 223, 224; 223, 235; 224, expression_statement; 224, 225; 225, call; 225, 226; 225, 229; 226, attribute; 226, 227; 226, 228; 227, identifier:logging; 228, identifier:info; 229, argument_list; 229, 230; 229, 234; 230, call; 230, 231; 230, 232; 231, identifier:_; 232, argument_list; 232, 233; 233, string:'using lib: %s'; 234, identifier:lib; 235, expression_statement; 235, 236; 236, call; 236, 237; 236, 240; 237, attribute; 237, 238; 237, 239; 238, identifier:dirs; 239, identifier:append; 240, argument_list; 240, 241; 241, identifier:lib; 242, else_clause; 242, 243; 243, block; 243, 244; 244, expression_statement; 244, 245; 245, call; 245, 246; 245, 249; 246, attribute; 246, 247; 246, 248; 247, identifier:logging; 248, identifier:debug; 249, argument_list; 249, 250; 249, 254; 250, call; 250, 251; 250, 252; 251, identifier:_; 252, argument_list; 252, 253; 253, string:'lib not found: %s'; 254, identifier:lib; 255, return_statement; 255, 256; 256, identifier:dirs; 257, expression_statement; 257, 258; 258, assignment; 258, 259; 258, 260; 259, identifier:message; 260, call; 260, 261; 260, 264; 261, attribute; 261, 262; 261, 263; 262, string:'unknown sdk version: {}'; 263, identifier:format; 264, argument_list; 264, 265; 265, attribute; 265, 266; 265, 267; 266, identifier:self; 267, identifier:sdk_version; 268, raise_statement; 268, 269; 269, call; 269, 270; 269, 271; 270, identifier:RuntimeError; 271, argument_list; 271, 272; 272, identifier:message
def get_lib(self, arch='x86', native=False): if self.sdk_version == 'v7.0A': if arch == 'x86': arch = '' lib = os.path.join(self.sdk_dir, 'lib', arch) if os.path.isdir(lib): logging.info(_('using lib: %s'), lib) return [lib] logging.debug(_('lib not found: %s'), lib) return [] if self.sdk_version == 'v8.1': if native: extra = os.path.join('winv6.3', 'km') else: extra = os.path.join('winv6.3', 'um') lib = os.path.join(self.sdk_dir, 'lib', extra, arch) if os.path.isdir(lib): logging.info(_('using lib: %s'), lib) return [lib] logging.debug(_('lib not found: %s'), lib) return [] if self.sdk_version == 'v10.0': dirs = [] extra = os.path.join('lib', '10.0.10240.0') for mode in ['um', 'ucrt']: lib = os.path.join(self.sdk_dir, extra, mode, arch) if os.path.isdir(lib): logging.info(_('using lib: %s'), lib) dirs.append(lib) else: logging.debug(_('lib not found: %s'), lib) return dirs message = 'unknown sdk version: {}'.format(self.sdk_version) raise RuntimeError(message)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:interrogate; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:platformIdentifier; 6, identifier:configuration; 7, identifier:libraries; 8, default_parameter; 8, 9; 8, 10; 9, identifier:libOverrides; 10, dictionary; 11, block; 11, 12; 11, 27; 11, 33; 11, 331; 11, 348; 11, 359; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 14, identifier:libModules; 15, call; 15, 16; 15, 17; 16, identifier:list; 17, argument_list; 17, 18; 18, list_comprehension; 18, 19; 18, 20; 18, 23; 19, identifier:lib; 20, for_in_clause; 20, 21; 20, 22; 21, identifier:lib; 22, identifier:libraries; 23, if_clause; 23, 24; 24, comparison_operator:not; 24, 25; 24, 26; 25, identifier:lib; 26, identifier:libOverrides; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:details; 30, call; 30, 31; 30, 32; 31, identifier:ThirdPartyLibraryDetails; 32, argument_list; 33, if_statement; 33, 34; 33, 40; 34, comparison_operator:>; 34, 35; 34, 39; 35, call; 35, 36; 35, 37; 36, identifier:len; 37, argument_list; 37, 38; 38, identifier:libModules; 39, integer:0; 40, block; 40, 41; 40, 51; 40, 65; 40, 75; 40, 91; 40, 113; 40, 199; 40, 210; 40, 214; 40, 249; 40, 255; 40, 269; 40, 275; 40, 306; 41, expression_statement; 41, 42; 42, assignment; 42, 43; 42, 44; 43, identifier:modules; 44, call; 44, 45; 44, 48; 45, attribute; 45, 46; 45, 47; 46, identifier:self; 47, identifier:_getThirdPartyLibs; 48, argument_list; 48, 49; 48, 50; 49, identifier:platformIdentifier; 50, identifier:configuration; 51, expression_statement; 51, 52; 52, assignment; 52, 53; 52, 54; 53, identifier:modules; 54, list_comprehension; 54, 55; 54, 56; 54, 59; 55, identifier:m; 56, for_in_clause; 56, 57; 56, 58; 57, identifier:m; 58, identifier:modules; 59, if_clause; 59, 60; 60, comparison_operator:in; 60, 61; 60, 64; 61, subscript; 61, 62; 61, 63; 62, identifier:m; 63, string:'Name'; 64, identifier:libModules; 65, expression_statement; 65, 66; 66, assignment; 66, 67; 66, 68; 67, identifier:names; 68, list_comprehension; 68, 69; 68, 72; 69, subscript; 69, 70; 69, 71; 70, identifier:m; 71, string:'Name'; 72, for_in_clause; 72, 73; 72, 74; 73, identifier:m; 74, identifier:modules; 75, expression_statement; 75, 76; 76, assignment; 76, 77; 76, 78; 77, identifier:unsupported; 78, list_comprehension; 78, 79; 78, 84; 78, 87; 79, binary_operator:+; 79, 80; 79, 83; 80, binary_operator:+; 80, 81; 80, 82; 81, string:'"'; 82, identifier:m; 83, string:'"'; 84, for_in_clause; 84, 85; 84, 86; 85, identifier:m; 86, identifier:libModules; 87, if_clause; 87, 88; 88, comparison_operator:not; 88, 89; 88, 90; 89, identifier:m; 90, identifier:names; 91, if_statement; 91, 92; 91, 98; 92, comparison_operator:>; 92, 93; 92, 97; 93, call; 93, 94; 93, 95; 94, identifier:len; 95, argument_list; 95, 96; 96, identifier:unsupported; 97, integer:0; 98, block; 98, 99; 99, expression_statement; 99, 100; 100, call; 100, 101; 100, 104; 101, attribute; 101, 102; 101, 103; 102, identifier:Utility; 103, identifier:printStderr; 104, argument_list; 104, 105; 105, binary_operator:+; 105, 106; 105, 107; 106, string:'Warning: unsupported libraries '; 107, call; 107, 108; 107, 111; 108, attribute; 108, 109; 108, 110; 109, string:','; 110, identifier:join; 111, argument_list; 111, 112; 112, identifier:unsupported; 113, for_statement; 113, 114; 113, 115; 113, 116; 114, identifier:module; 115, identifier:modules; 116, block; 116, 117; 117, if_statement; 117, 118; 117, 135; 118, boolean_operator:and; 118, 119; 118, 127; 119, comparison_operator:>; 119, 120; 119, 126; 120, call; 120, 121; 120, 122; 121, identifier:len; 122, argument_list; 122, 123; 123, subscript; 123, 124; 123, 125; 124, identifier:module; 125, string:'PublicAdditionalLibraries'; 126, integer:0; 127, comparison_operator:>; 127, 128; 127, 134; 128, call; 128, 129; 128, 130; 129, identifier:len; 130, argument_list; 130, 131; 131, subscript; 131, 132; 131, 133; 132, identifier:module; 133, string:'PublicLibraryPaths'; 134, integer:0; 135, block; 135, 136; 135, 150; 135, 169; 135, 193; 136, expression_statement; 136, 137; 137, assignment; 137, 138; 137, 139; 138, identifier:libPath; 139, subscript; 139, 140; 139, 149; 140, parenthesized_expression; 140, 141; 141, call; 141, 142; 141, 145; 142, attribute; 142, 143; 142, 144; 143, identifier:self; 144, identifier:_absolutePaths; 145, argument_list; 145, 146; 146, subscript; 146, 147; 146, 148; 147, identifier:module; 148, string:'PublicLibraryPaths'; 149, integer:0; 150, expression_statement; 150, 151; 151, assignment; 151, 152; 151, 153; 152, identifier:libs; 153, call; 153, 154; 153, 155; 154, identifier:list; 155, argument_list; 155, 156; 156, list_comprehension; 156, 157; 156, 164; 157, call; 157, 158; 157, 161; 158, attribute; 158, 159; 158, 160; 159, identifier:lib; 160, identifier:replace; 161, argument_list; 161, 162; 161, 163; 162, string:'\\'; 163, string:'/'; 164, for_in_clause; 164, 165; 164, 166; 165, identifier:lib; 166, subscript; 166, 167; 166, 168; 167, identifier:module; 168, string:'PublicAdditionalLibraries'; 169, expression_statement; 169, 170; 170, assignment; 170, 171; 170, 172; 171, identifier:libs; 172, call; 172, 173; 172, 174; 173, identifier:list; 174, argument_list; 174, 175; 175, list_comprehension; 175, 176; 175, 190; 176, conditional_expression:if; 176, 177; 176, 186; 176, 189; 177, call; 177, 178; 177, 183; 178, attribute; 178, 179; 178, 182; 179, attribute; 179, 180; 179, 181; 180, identifier:os; 181, identifier:path; 182, identifier:join; 183, argument_list; 183, 184; 183, 185; 184, identifier:libPath; 185, identifier:lib; 186, comparison_operator:not; 186, 187; 186, 188; 187, string:'/'; 188, identifier:lib; 189, identifier:lib; 190, for_in_clause; 190, 191; 190, 192; 191, identifier:lib; 192, identifier:libs; 193, expression_statement; 193, 194; 194, assignment; 194, 195; 194, 198; 195, subscript; 195, 196; 195, 197; 196, identifier:module; 197, string:'PublicAdditionalLibraries'; 198, identifier:libs; 199, expression_statement; 199, 200; 200, assignment; 200, 201; 200, 202; 201, identifier:fields; 202, list:[ 'Directory', 'PublicAdditionalLibraries', 'PublicLibraryPaths', 'PublicSystemIncludePaths', 'PublicIncludePaths', 'PrivateIncludePaths', 'PublicDefinitions' ]; 202, 203; 202, 204; 202, 205; 202, 206; 202, 207; 202, 208; 202, 209; 203, string:'Directory'; 204, string:'PublicAdditionalLibraries'; 205, string:'PublicLibraryPaths'; 206, string:'PublicSystemIncludePaths'; 207, string:'PublicIncludePaths'; 208, string:'PrivateIncludePaths'; 209, string:'PublicDefinitions'; 210, expression_statement; 210, 211; 211, assignment; 211, 212; 211, 213; 212, identifier:flattened; 213, dictionary; 214, for_statement; 214, 215; 214, 216; 214, 217; 215, identifier:field; 216, identifier:fields; 217, block; 217, 218; 217, 236; 218, expression_statement; 218, 219; 219, assignment; 219, 220; 219, 221; 220, identifier:transform; 221, conditional_expression:if; 221, 222; 221, 232; 221, 235; 222, parenthesized_expression; 222, 223; 223, lambda; 223, 224; 223, 226; 224, lambda_parameters; 224, 225; 225, identifier:l; 226, call; 226, 227; 226, 230; 227, attribute; 227, 228; 227, 229; 228, identifier:self; 229, identifier:_absolutePaths; 230, argument_list; 230, 231; 231, identifier:l; 232, comparison_operator:!=; 232, 233; 232, 234; 233, identifier:field; 234, string:'Definitions'; 235, None; 236, expression_statement; 236, 237; 237, assignment; 237, 238; 237, 241; 238, subscript; 238, 239; 238, 240; 239, identifier:flattened; 240, identifier:field; 241, call; 241, 242; 241, 245; 242, attribute; 242, 243; 242, 244; 243, identifier:self; 244, identifier:_flatten; 245, argument_list; 245, 246; 245, 247; 245, 248; 246, identifier:field; 247, identifier:modules; 248, identifier:transform; 249, expression_statement; 249, 250; 250, assignment; 250, 251; 250, 252; 251, identifier:libraryDirectories; 252, subscript; 252, 253; 252, 254; 253, identifier:flattened; 254, string:'PublicLibraryPaths'; 255, expression_statement; 255, 256; 256, assignment; 256, 257; 256, 258; 257, identifier:headerDirectories; 258, binary_operator:+; 258, 259; 258, 266; 259, binary_operator:+; 259, 260; 259, 263; 260, subscript; 260, 261; 260, 262; 261, identifier:flattened; 262, string:'PublicSystemIncludePaths'; 263, subscript; 263, 264; 263, 265; 264, identifier:flattened; 265, string:'PublicIncludePaths'; 266, subscript; 266, 267; 266, 268; 267, identifier:flattened; 268, string:'PrivateIncludePaths'; 269, expression_statement; 269, 270; 270, assignment; 270, 271; 270, 272; 271, identifier:modulePaths; 272, subscript; 272, 273; 272, 274; 273, identifier:flattened; 274, string:'Directory'; 275, expression_statement; 275, 276; 276, assignment; 276, 277; 276, 278; 277, identifier:prefixDirectories; 278, call; 278, 279; 278, 280; 279, identifier:list; 280, argument_list; 280, 281; 281, call; 281, 282; 281, 283; 282, identifier:set; 283, argument_list; 283, 284; 284, binary_operator:+; 284, 285; 284, 292; 285, binary_operator:+; 285, 286; 285, 291; 286, binary_operator:+; 286, 287; 286, 290; 287, subscript; 287, 288; 287, 289; 288, identifier:flattened; 289, string:'Directory'; 290, identifier:headerDirectories; 291, identifier:libraryDirectories; 292, list_comprehension; 292, 293; 292, 301; 293, call; 293, 294; 293, 299; 294, attribute; 294, 295; 294, 298; 295, attribute; 295, 296; 295, 297; 296, identifier:os; 297, identifier:path; 298, identifier:dirname; 299, argument_list; 299, 300; 300, identifier:p; 301, for_in_clause; 301, 302; 301, 303; 302, identifier:p; 303, binary_operator:+; 303, 304; 303, 305; 304, identifier:headerDirectories; 305, identifier:libraryDirectories; 306, expression_statement; 306, 307; 307, assignment; 307, 308; 307, 309; 308, identifier:details; 309, call; 309, 310; 309, 311; 310, identifier:ThirdPartyLibraryDetails; 311, argument_list; 311, 312; 311, 315; 311, 318; 311, 321; 311, 326; 312, keyword_argument; 312, 313; 312, 314; 313, identifier:prefixDirs; 314, identifier:prefixDirectories; 315, keyword_argument; 315, 316; 315, 317; 316, identifier:includeDirs; 317, identifier:headerDirectories; 318, keyword_argument; 318, 319; 318, 320; 319, identifier:linkDirs; 320, identifier:libraryDirectories; 321, keyword_argument; 321, 322; 321, 323; 322, identifier:definitions; 323, subscript; 323, 324; 323, 325; 324, identifier:flattened; 325, string:'PublicDefinitions'; 326, keyword_argument; 326, 327; 326, 328; 327, identifier:libs; 328, subscript; 328, 329; 328, 330; 329, identifier:flattened; 330, string:'PublicAdditionalLibraries'; 331, expression_statement; 331, 332; 332, assignment; 332, 333; 332, 334; 333, identifier:overridesToApply; 334, call; 334, 335; 334, 336; 335, identifier:list; 336, argument_list; 336, 337; 337, list_comprehension; 337, 338; 337, 341; 337, 344; 338, subscript; 338, 339; 338, 340; 339, identifier:libOverrides; 340, identifier:lib; 341, for_in_clause; 341, 342; 341, 343; 342, identifier:lib; 343, identifier:libraries; 344, if_clause; 344, 345; 345, comparison_operator:in; 345, 346; 345, 347; 346, identifier:lib; 347, identifier:libOverrides; 348, for_statement; 348, 349; 348, 350; 348, 351; 349, identifier:override; 350, identifier:overridesToApply; 351, block; 351, 352; 352, expression_statement; 352, 353; 353, call; 353, 354; 353, 357; 354, attribute; 354, 355; 354, 356; 355, identifier:details; 356, identifier:merge; 357, argument_list; 357, 358; 358, identifier:override; 359, return_statement; 359, 360; 360, identifier:details
def interrogate(self, platformIdentifier, configuration, libraries, libOverrides = {}): libModules = list([lib for lib in libraries if lib not in libOverrides]) details = ThirdPartyLibraryDetails() if len(libModules) > 0: modules = self._getThirdPartyLibs(platformIdentifier, configuration) modules = [m for m in modules if m['Name'] in libModules] names = [m['Name'] for m in modules] unsupported = ['"' + m + '"' for m in libModules if m not in names] if len(unsupported) > 0: Utility.printStderr('Warning: unsupported libraries ' + ','.join(unsupported)) for module in modules: if len(module['PublicAdditionalLibraries']) > 0 and len(module['PublicLibraryPaths']) > 0: libPath = (self._absolutePaths(module['PublicLibraryPaths']))[0] libs = list([lib.replace('\\', '/') for lib in module['PublicAdditionalLibraries']]) libs = list([os.path.join(libPath, lib) if '/' not in lib else lib for lib in libs]) module['PublicAdditionalLibraries'] = libs fields = [ 'Directory', 'PublicAdditionalLibraries', 'PublicLibraryPaths', 'PublicSystemIncludePaths', 'PublicIncludePaths', 'PrivateIncludePaths', 'PublicDefinitions' ] flattened = {} for field in fields: transform = (lambda l: self._absolutePaths(l)) if field != 'Definitions' else None flattened[field] = self._flatten(field, modules, transform) libraryDirectories = flattened['PublicLibraryPaths'] headerDirectories = flattened['PublicSystemIncludePaths'] + flattened['PublicIncludePaths'] + flattened['PrivateIncludePaths'] modulePaths = flattened['Directory'] prefixDirectories = list(set(flattened['Directory'] + headerDirectories + libraryDirectories + [os.path.dirname(p) for p in headerDirectories + libraryDirectories])) details = ThirdPartyLibraryDetails( prefixDirs = prefixDirectories, includeDirs = headerDirectories, linkDirs = libraryDirectories, definitions = flattened['PublicDefinitions'], libs = flattened['PublicAdditionalLibraries'] ) overridesToApply = list([libOverrides[lib] for lib in libraries if lib in libOverrides]) for override in overridesToApply: details.merge(override) return details
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_getThirdPartyLibs; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:platformIdentifier; 6, identifier:configuration; 7, block; 7, 8; 7, 20; 7, 27; 7, 35; 7, 47; 7, 63; 7, 69; 7, 92; 7, 105; 7, 154; 7, 168; 7, 182; 7, 198; 7, 215; 7, 227; 7, 238; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:cachedList; 11, call; 11, 12; 11, 15; 12, attribute; 12, 13; 12, 14; 13, identifier:CachedDataManager; 14, identifier:getCachedDataKey; 15, argument_list; 15, 16; 15, 19; 16, attribute; 16, 17; 16, 18; 17, identifier:self; 18, identifier:engineVersionHash; 19, string:'ThirdPartyLibraries'; 20, if_statement; 20, 21; 20, 24; 21, comparison_operator:!=; 21, 22; 21, 23; 22, identifier:cachedList; 23, None; 24, block; 24, 25; 25, return_statement; 25, 26; 26, identifier:cachedList; 27, expression_statement; 27, 28; 28, assignment; 28, 29; 28, 30; 29, identifier:tempDir; 30, call; 30, 31; 30, 34; 31, attribute; 31, 32; 31, 33; 32, identifier:tempfile; 33, identifier:mkdtemp; 34, argument_list; 35, expression_statement; 35, 36; 36, assignment; 36, 37; 36, 38; 37, identifier:jsonFile; 38, call; 38, 39; 38, 44; 39, attribute; 39, 40; 39, 43; 40, attribute; 40, 41; 40, 42; 41, identifier:os; 42, identifier:path; 43, identifier:join; 44, argument_list; 44, 45; 44, 46; 45, identifier:tempDir; 46, string:'ubt_output.json'; 47, expression_statement; 47, 48; 48, assignment; 48, 49; 48, 50; 49, identifier:sentinelFile; 50, call; 50, 51; 50, 56; 51, attribute; 51, 52; 51, 55; 52, attribute; 52, 53; 52, 54; 53, identifier:os; 54, identifier:path; 55, identifier:join; 56, argument_list; 56, 57; 56, 60; 56, 61; 56, 62; 57, attribute; 57, 58; 57, 59; 58, identifier:self; 59, identifier:engineRoot; 60, string:'Engine'; 61, string:'Build'; 62, string:'InstalledBuild.txt'; 63, expression_statement; 63, 64; 64, assignment; 64, 65; 64, 66; 65, identifier:sentinelBackup; 66, binary_operator:+; 66, 67; 66, 68; 67, identifier:sentinelFile; 68, string:'.bak'; 69, expression_statement; 69, 70; 70, assignment; 70, 71; 70, 72; 71, identifier:renameSentinel; 72, boolean_operator:and; 72, 73; 72, 81; 73, call; 73, 74; 73, 79; 74, attribute; 74, 75; 74, 78; 75, attribute; 75, 76; 75, 77; 76, identifier:os; 77, identifier:path; 78, identifier:exists; 79, argument_list; 79, 80; 80, identifier:sentinelFile; 81, comparison_operator:==; 81, 82; 81, 91; 82, call; 82, 83; 82, 88; 83, attribute; 83, 84; 83, 87; 84, attribute; 84, 85; 84, 86; 85, identifier:os; 86, identifier:environ; 87, identifier:get; 88, argument_list; 88, 89; 88, 90; 89, string:'UE4CLI_SENTINEL_RENAME'; 90, string:'0'; 91, string:'1'; 92, if_statement; 92, 93; 92, 96; 93, comparison_operator:==; 93, 94; 93, 95; 94, identifier:renameSentinel; 95, True; 96, block; 96, 97; 97, expression_statement; 97, 98; 98, call; 98, 99; 98, 102; 99, attribute; 99, 100; 99, 101; 100, identifier:shutil; 101, identifier:move; 102, argument_list; 102, 103; 102, 104; 103, identifier:sentinelFile; 104, identifier:sentinelBackup; 105, try_statement; 105, 106; 105, 139; 106, block; 106, 107; 106, 129; 107, expression_statement; 107, 108; 108, assignment; 108, 109; 108, 110; 109, identifier:args; 110, conditional_expression:if; 110, 111; 110, 116; 110, 123; 111, list:['-Mode=JsonExport', '-OutputFile=' +jsonFile ]; 111, 112; 111, 113; 112, string:'-Mode=JsonExport'; 113, binary_operator:+; 113, 114; 113, 115; 114, string:'-OutputFile='; 115, identifier:jsonFile; 116, comparison_operator:>=; 116, 117; 116, 122; 117, subscript; 117, 118; 117, 121; 118, attribute; 118, 119; 118, 120; 119, identifier:self; 120, identifier:engineVersion; 121, string:'MinorVersion'; 122, integer:22; 123, list:['-gather', '-jsonexport=' + jsonFile, '-SkipBuild']; 123, 124; 123, 125; 123, 128; 124, string:'-gather'; 125, binary_operator:+; 125, 126; 125, 127; 126, string:'-jsonexport='; 127, identifier:jsonFile; 128, string:'-SkipBuild'; 129, expression_statement; 129, 130; 130, call; 130, 131; 130, 134; 131, attribute; 131, 132; 131, 133; 132, identifier:self; 133, identifier:runUBTFunc; 134, argument_list; 134, 135; 134, 136; 134, 137; 134, 138; 135, string:'UE4Editor'; 136, identifier:platformIdentifier; 137, identifier:configuration; 138, identifier:args; 139, finally_clause; 139, 140; 140, block; 140, 141; 141, if_statement; 141, 142; 141, 145; 142, comparison_operator:==; 142, 143; 142, 144; 143, identifier:renameSentinel; 144, True; 145, block; 145, 146; 146, expression_statement; 146, 147; 147, call; 147, 148; 147, 151; 148, attribute; 148, 149; 148, 150; 149, identifier:shutil; 150, identifier:move; 151, argument_list; 151, 152; 151, 153; 152, identifier:sentinelBackup; 153, identifier:sentinelFile; 154, expression_statement; 154, 155; 155, assignment; 155, 156; 155, 157; 156, identifier:result; 157, call; 157, 158; 157, 161; 158, attribute; 158, 159; 158, 160; 159, identifier:json; 160, identifier:loads; 161, argument_list; 161, 162; 162, call; 162, 163; 162, 166; 163, attribute; 163, 164; 163, 165; 164, identifier:Utility; 165, identifier:readFile; 166, argument_list; 166, 167; 167, identifier:jsonFile; 168, expression_statement; 168, 169; 169, assignment; 169, 170; 169, 171; 170, identifier:modules; 171, list_comprehension; 171, 172; 171, 177; 172, subscript; 172, 173; 172, 176; 173, subscript; 173, 174; 173, 175; 174, identifier:result; 175, string:'Modules'; 176, identifier:key; 177, for_in_clause; 177, 178; 177, 179; 178, identifier:key; 179, subscript; 179, 180; 179, 181; 180, identifier:result; 181, string:'Modules'; 182, expression_statement; 182, 183; 183, assignment; 183, 184; 183, 185; 184, identifier:thirdPartyRoot; 185, call; 185, 186; 185, 191; 186, attribute; 186, 187; 186, 190; 187, attribute; 187, 188; 187, 189; 188, identifier:os; 189, identifier:path; 190, identifier:join; 191, argument_list; 191, 192; 191, 195; 191, 196; 191, 197; 192, attribute; 192, 193; 192, 194; 193, identifier:self; 194, identifier:engineRoot; 195, string:'Engine'; 196, string:'Source'; 197, string:'ThirdParty'; 198, expression_statement; 198, 199; 199, assignment; 199, 200; 199, 201; 200, identifier:thirdparty; 201, call; 201, 202; 201, 203; 202, identifier:list; 203, argument_list; 203, 204; 204, list_comprehension; 204, 205; 204, 206; 204, 209; 205, identifier:m; 206, for_in_clause; 206, 207; 206, 208; 207, identifier:m; 208, identifier:modules; 209, if_clause; 209, 210; 210, comparison_operator:in; 210, 211; 210, 212; 211, identifier:thirdPartyRoot; 212, subscript; 212, 213; 212, 214; 213, identifier:m; 214, string:'Directory'; 215, try_statement; 215, 216; 215, 224; 216, block; 216, 217; 217, expression_statement; 217, 218; 218, call; 218, 219; 218, 222; 219, attribute; 219, 220; 219, 221; 220, identifier:shutil; 221, identifier:rmtree; 222, argument_list; 222, 223; 223, identifier:tempDir; 224, except_clause; 224, 225; 225, block; 225, 226; 226, pass_statement; 227, expression_statement; 227, 228; 228, call; 228, 229; 228, 232; 229, attribute; 229, 230; 229, 231; 230, identifier:CachedDataManager; 231, identifier:setCachedDataKey; 232, argument_list; 232, 233; 232, 236; 232, 237; 233, attribute; 233, 234; 233, 235; 234, identifier:self; 235, identifier:engineVersionHash; 236, string:'ThirdPartyLibraries'; 237, identifier:thirdparty; 238, return_statement; 238, 239; 239, identifier:thirdparty
def _getThirdPartyLibs(self, platformIdentifier, configuration): cachedList = CachedDataManager.getCachedDataKey(self.engineVersionHash, 'ThirdPartyLibraries') if cachedList != None: return cachedList tempDir = tempfile.mkdtemp() jsonFile = os.path.join(tempDir, 'ubt_output.json') sentinelFile = os.path.join(self.engineRoot, 'Engine', 'Build', 'InstalledBuild.txt') sentinelBackup = sentinelFile + '.bak' renameSentinel = os.path.exists(sentinelFile) and os.environ.get('UE4CLI_SENTINEL_RENAME', '0') == '1' if renameSentinel == True: shutil.move(sentinelFile, sentinelBackup) try: args = ['-Mode=JsonExport', '-OutputFile=' +jsonFile ] if self.engineVersion['MinorVersion'] >= 22 else ['-gather', '-jsonexport=' + jsonFile, '-SkipBuild'] self.runUBTFunc('UE4Editor', platformIdentifier, configuration, args) finally: if renameSentinel == True: shutil.move(sentinelBackup, sentinelFile) result = json.loads(Utility.readFile(jsonFile)) modules = [result['Modules'][key] for key in result['Modules']] thirdPartyRoot = os.path.join(self.engineRoot, 'Engine', 'Source', 'ThirdParty') thirdparty = list([m for m in modules if thirdPartyRoot in m['Directory']]) try: shutil.rmtree(tempDir) except: pass CachedDataManager.setCachedDataKey(self.engineVersionHash, 'ThirdPartyLibraries', thirdparty) return thirdparty
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 57; 2, function_name:add_vt; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 3, 21; 3, 24; 3, 27; 3, 30; 3, 33; 3, 36; 3, 39; 3, 42; 3, 45; 3, 48; 3, 51; 3, 54; 4, identifier:self; 5, identifier:vt_id; 6, default_parameter; 6, 7; 6, 8; 7, identifier:name; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:vt_params; 11, None; 12, default_parameter; 12, 13; 12, 14; 13, identifier:vt_refs; 14, None; 15, default_parameter; 15, 16; 15, 17; 16, identifier:custom; 17, None; 18, default_parameter; 18, 19; 18, 20; 19, identifier:vt_creation_time; 20, None; 21, default_parameter; 21, 22; 21, 23; 22, identifier:vt_modification_time; 23, None; 24, default_parameter; 24, 25; 24, 26; 25, identifier:vt_dependencies; 26, None; 27, default_parameter; 27, 28; 27, 29; 28, identifier:summary; 29, None; 30, default_parameter; 30, 31; 30, 32; 31, identifier:impact; 32, None; 33, default_parameter; 33, 34; 33, 35; 34, identifier:affected; 35, None; 36, default_parameter; 36, 37; 36, 38; 37, identifier:insight; 38, None; 39, default_parameter; 39, 40; 39, 41; 40, identifier:solution; 41, None; 42, default_parameter; 42, 43; 42, 44; 43, identifier:solution_t; 44, None; 45, default_parameter; 45, 46; 45, 47; 46, identifier:detection; 47, None; 48, default_parameter; 48, 49; 48, 50; 49, identifier:qod_t; 50, None; 51, default_parameter; 51, 52; 51, 53; 52, identifier:qod_v; 53, None; 54, default_parameter; 54, 55; 54, 56; 55, identifier:severities; 56, None; 57, block; 57, 58; 57, 65; 57, 80; 57, 90; 57, 99; 57, 110; 57, 125; 57, 140; 57, 155; 57, 170; 57, 185; 57, 200; 57, 215; 57, 230; 57, 245; 57, 260; 57, 290; 57, 305; 57, 335; 57, 350; 58, if_statement; 58, 59; 58, 61; 59, not_operator; 59, 60; 60, identifier:vt_id; 61, block; 61, 62; 62, return_statement; 62, 63; 63, unary_operator:-; 63, 64; 64, integer:2; 65, if_statement; 65, 66; 65, 76; 66, comparison_operator:is; 66, 67; 66, 75; 67, call; 67, 68; 67, 73; 68, attribute; 68, 69; 68, 72; 69, attribute; 69, 70; 69, 71; 70, identifier:self; 71, identifier:vt_id_pattern; 72, identifier:fullmatch; 73, argument_list; 73, 74; 74, identifier:vt_id; 75, None; 76, block; 76, 77; 77, return_statement; 77, 78; 78, unary_operator:-; 78, 79; 79, integer:2; 80, if_statement; 80, 81; 80, 86; 81, comparison_operator:in; 81, 82; 81, 83; 82, identifier:vt_id; 83, attribute; 83, 84; 83, 85; 84, identifier:self; 85, identifier:vts; 86, block; 86, 87; 87, return_statement; 87, 88; 88, unary_operator:-; 88, 89; 89, integer:1; 90, if_statement; 90, 91; 90, 94; 91, comparison_operator:is; 91, 92; 91, 93; 92, identifier:name; 93, None; 94, block; 94, 95; 95, expression_statement; 95, 96; 96, assignment; 96, 97; 96, 98; 97, identifier:name; 98, string:''; 99, expression_statement; 99, 100; 100, assignment; 100, 101; 100, 106; 101, subscript; 101, 102; 101, 105; 102, attribute; 102, 103; 102, 104; 103, identifier:self; 104, identifier:vts; 105, identifier:vt_id; 106, dictionary; 106, 107; 107, pair; 107, 108; 107, 109; 108, string:'name'; 109, identifier:name; 110, if_statement; 110, 111; 110, 114; 111, comparison_operator:is; 111, 112; 111, 113; 112, identifier:custom; 113, None; 114, block; 114, 115; 115, expression_statement; 115, 116; 116, assignment; 116, 117; 116, 124; 117, subscript; 117, 118; 117, 123; 118, subscript; 118, 119; 118, 122; 119, attribute; 119, 120; 119, 121; 120, identifier:self; 121, identifier:vts; 122, identifier:vt_id; 123, string:"custom"; 124, identifier:custom; 125, if_statement; 125, 126; 125, 129; 126, comparison_operator:is; 126, 127; 126, 128; 127, identifier:vt_params; 128, None; 129, block; 129, 130; 130, expression_statement; 130, 131; 131, assignment; 131, 132; 131, 139; 132, subscript; 132, 133; 132, 138; 133, subscript; 133, 134; 133, 137; 134, attribute; 134, 135; 134, 136; 135, identifier:self; 136, identifier:vts; 137, identifier:vt_id; 138, string:"vt_params"; 139, identifier:vt_params; 140, if_statement; 140, 141; 140, 144; 141, comparison_operator:is; 141, 142; 141, 143; 142, identifier:vt_refs; 143, None; 144, block; 144, 145; 145, expression_statement; 145, 146; 146, assignment; 146, 147; 146, 154; 147, subscript; 147, 148; 147, 153; 148, subscript; 148, 149; 148, 152; 149, attribute; 149, 150; 149, 151; 150, identifier:self; 151, identifier:vts; 152, identifier:vt_id; 153, string:"vt_refs"; 154, identifier:vt_refs; 155, if_statement; 155, 156; 155, 159; 156, comparison_operator:is; 156, 157; 156, 158; 157, identifier:vt_dependencies; 158, None; 159, block; 159, 160; 160, expression_statement; 160, 161; 161, assignment; 161, 162; 161, 169; 162, subscript; 162, 163; 162, 168; 163, subscript; 163, 164; 163, 167; 164, attribute; 164, 165; 164, 166; 165, identifier:self; 166, identifier:vts; 167, identifier:vt_id; 168, string:"vt_dependencies"; 169, identifier:vt_dependencies; 170, if_statement; 170, 171; 170, 174; 171, comparison_operator:is; 171, 172; 171, 173; 172, identifier:vt_creation_time; 173, None; 174, block; 174, 175; 175, expression_statement; 175, 176; 176, assignment; 176, 177; 176, 184; 177, subscript; 177, 178; 177, 183; 178, subscript; 178, 179; 178, 182; 179, attribute; 179, 180; 179, 181; 180, identifier:self; 181, identifier:vts; 182, identifier:vt_id; 183, string:"creation_time"; 184, identifier:vt_creation_time; 185, if_statement; 185, 186; 185, 189; 186, comparison_operator:is; 186, 187; 186, 188; 187, identifier:vt_modification_time; 188, None; 189, block; 189, 190; 190, expression_statement; 190, 191; 191, assignment; 191, 192; 191, 199; 192, subscript; 192, 193; 192, 198; 193, subscript; 193, 194; 193, 197; 194, attribute; 194, 195; 194, 196; 195, identifier:self; 196, identifier:vts; 197, identifier:vt_id; 198, string:"modification_time"; 199, identifier:vt_modification_time; 200, if_statement; 200, 201; 200, 204; 201, comparison_operator:is; 201, 202; 201, 203; 202, identifier:summary; 203, None; 204, block; 204, 205; 205, expression_statement; 205, 206; 206, assignment; 206, 207; 206, 214; 207, subscript; 207, 208; 207, 213; 208, subscript; 208, 209; 208, 212; 209, attribute; 209, 210; 209, 211; 210, identifier:self; 211, identifier:vts; 212, identifier:vt_id; 213, string:"summary"; 214, identifier:summary; 215, if_statement; 215, 216; 215, 219; 216, comparison_operator:is; 216, 217; 216, 218; 217, identifier:impact; 218, None; 219, block; 219, 220; 220, expression_statement; 220, 221; 221, assignment; 221, 222; 221, 229; 222, subscript; 222, 223; 222, 228; 223, subscript; 223, 224; 223, 227; 224, attribute; 224, 225; 224, 226; 225, identifier:self; 226, identifier:vts; 227, identifier:vt_id; 228, string:"impact"; 229, identifier:impact; 230, if_statement; 230, 231; 230, 234; 231, comparison_operator:is; 231, 232; 231, 233; 232, identifier:affected; 233, None; 234, block; 234, 235; 235, expression_statement; 235, 236; 236, assignment; 236, 237; 236, 244; 237, subscript; 237, 238; 237, 243; 238, subscript; 238, 239; 238, 242; 239, attribute; 239, 240; 239, 241; 240, identifier:self; 241, identifier:vts; 242, identifier:vt_id; 243, string:"affected"; 244, identifier:affected; 245, if_statement; 245, 246; 245, 249; 246, comparison_operator:is; 246, 247; 246, 248; 247, identifier:insight; 248, None; 249, block; 249, 250; 250, expression_statement; 250, 251; 251, assignment; 251, 252; 251, 259; 252, subscript; 252, 253; 252, 258; 253, subscript; 253, 254; 253, 257; 254, attribute; 254, 255; 254, 256; 255, identifier:self; 256, identifier:vts; 257, identifier:vt_id; 258, string:"insight"; 259, identifier:insight; 260, if_statement; 260, 261; 260, 264; 261, comparison_operator:is; 261, 262; 261, 263; 262, identifier:solution; 263, None; 264, block; 264, 265; 264, 275; 265, expression_statement; 265, 266; 266, assignment; 266, 267; 266, 274; 267, subscript; 267, 268; 267, 273; 268, subscript; 268, 269; 268, 272; 269, attribute; 269, 270; 269, 271; 270, identifier:self; 271, identifier:vts; 272, identifier:vt_id; 273, string:"solution"; 274, identifier:solution; 275, if_statement; 275, 276; 275, 279; 276, comparison_operator:is; 276, 277; 276, 278; 277, identifier:solution_t; 278, None; 279, block; 279, 280; 280, expression_statement; 280, 281; 281, assignment; 281, 282; 281, 289; 282, subscript; 282, 283; 282, 288; 283, subscript; 283, 284; 283, 287; 284, attribute; 284, 285; 284, 286; 285, identifier:self; 286, identifier:vts; 287, identifier:vt_id; 288, string:"solution_type"; 289, identifier:solution_t; 290, if_statement; 290, 291; 290, 294; 291, comparison_operator:is; 291, 292; 291, 293; 292, identifier:detection; 293, None; 294, block; 294, 295; 295, expression_statement; 295, 296; 296, assignment; 296, 297; 296, 304; 297, subscript; 297, 298; 297, 303; 298, subscript; 298, 299; 298, 302; 299, attribute; 299, 300; 299, 301; 300, identifier:self; 301, identifier:vts; 302, identifier:vt_id; 303, string:"detection"; 304, identifier:detection; 305, if_statement; 305, 306; 305, 309; 305, 320; 306, comparison_operator:is; 306, 307; 306, 308; 307, identifier:qod_t; 308, None; 309, block; 309, 310; 310, expression_statement; 310, 311; 311, assignment; 311, 312; 311, 319; 312, subscript; 312, 313; 312, 318; 313, subscript; 313, 314; 313, 317; 314, attribute; 314, 315; 314, 316; 315, identifier:self; 316, identifier:vts; 317, identifier:vt_id; 318, string:"qod_type"; 319, identifier:qod_t; 320, elif_clause; 320, 321; 320, 324; 321, comparison_operator:is; 321, 322; 321, 323; 322, identifier:qod_v; 323, None; 324, block; 324, 325; 325, expression_statement; 325, 326; 326, assignment; 326, 327; 326, 334; 327, subscript; 327, 328; 327, 333; 328, subscript; 328, 329; 328, 332; 329, attribute; 329, 330; 329, 331; 330, identifier:self; 331, identifier:vts; 332, identifier:vt_id; 333, string:"qod"; 334, identifier:qod_v; 335, if_statement; 335, 336; 335, 339; 336, comparison_operator:is; 336, 337; 336, 338; 337, identifier:severities; 338, None; 339, block; 339, 340; 340, expression_statement; 340, 341; 341, assignment; 341, 342; 341, 349; 342, subscript; 342, 343; 342, 348; 343, subscript; 343, 344; 343, 347; 344, attribute; 344, 345; 344, 346; 345, identifier:self; 346, identifier:vts; 347, identifier:vt_id; 348, string:"severities"; 349, identifier:severities; 350, return_statement; 350, 351; 351, call; 351, 352; 351, 353; 352, identifier:len; 353, argument_list; 353, 354; 354, attribute; 354, 355; 354, 356; 355, identifier:self; 356, identifier:vts
def add_vt(self, vt_id, name=None, vt_params=None, vt_refs=None, custom=None, vt_creation_time=None, vt_modification_time=None, vt_dependencies=None, summary=None, impact=None, affected=None, insight=None, solution=None, solution_t=None, detection=None, qod_t=None, qod_v=None, severities=None): if not vt_id: return -2 if self.vt_id_pattern.fullmatch(vt_id) is None: return -2 if vt_id in self.vts: return -1 if name is None: name = '' self.vts[vt_id] = {'name': name} if custom is not None: self.vts[vt_id]["custom"] = custom if vt_params is not None: self.vts[vt_id]["vt_params"] = vt_params if vt_refs is not None: self.vts[vt_id]["vt_refs"] = vt_refs if vt_dependencies is not None: self.vts[vt_id]["vt_dependencies"] = vt_dependencies if vt_creation_time is not None: self.vts[vt_id]["creation_time"] = vt_creation_time if vt_modification_time is not None: self.vts[vt_id]["modification_time"] = vt_modification_time if summary is not None: self.vts[vt_id]["summary"] = summary if impact is not None: self.vts[vt_id]["impact"] = impact if affected is not None: self.vts[vt_id]["affected"] = affected if insight is not None: self.vts[vt_id]["insight"] = insight if solution is not None: self.vts[vt_id]["solution"] = solution if solution_t is not None: self.vts[vt_id]["solution_type"] = solution_t if detection is not None: self.vts[vt_id]["detection"] = detection if qod_t is not None: self.vts[vt_id]["qod_type"] = qod_t elif qod_v is not None: self.vts[vt_id]["qod"] = qod_v if severities is not None: self.vts[vt_id]["severities"] = severities return len(self.vts)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_preprocess_scan_params; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:xml_params; 6, block; 6, 7; 6, 11; 6, 27; 6, 74; 6, 201; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:params; 10, dictionary; 11, for_statement; 11, 12; 11, 13; 11, 14; 12, identifier:param; 13, identifier:xml_params; 14, block; 14, 15; 15, expression_statement; 15, 16; 16, assignment; 16, 17; 16, 22; 17, subscript; 17, 18; 17, 19; 18, identifier:params; 19, attribute; 19, 20; 19, 21; 20, identifier:param; 21, identifier:tag; 22, boolean_operator:or; 22, 23; 22, 26; 23, attribute; 23, 24; 23, 25; 24, identifier:param; 25, identifier:text; 26, string:''; 27, for_statement; 27, 28; 27, 29; 27, 32; 28, identifier:key; 29, attribute; 29, 30; 29, 31; 30, identifier:self; 31, identifier:scanner_params; 32, block; 32, 33; 33, if_statement; 33, 34; 33, 37; 34, comparison_operator:not; 34, 35; 34, 36; 35, identifier:key; 36, identifier:params; 37, block; 37, 38; 37, 49; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 43; 40, subscript; 40, 41; 40, 42; 41, identifier:params; 42, identifier:key; 43, call; 43, 44; 43, 47; 44, attribute; 44, 45; 44, 46; 45, identifier:self; 46, identifier:get_scanner_param_default; 47, argument_list; 47, 48; 48, identifier:key; 49, if_statement; 49, 50; 49, 58; 50, comparison_operator:==; 50, 51; 50, 57; 51, call; 51, 52; 51, 55; 52, attribute; 52, 53; 52, 54; 53, identifier:self; 54, identifier:get_scanner_param_type; 55, argument_list; 55, 56; 56, identifier:key; 57, string:'selection'; 58, block; 58, 59; 59, expression_statement; 59, 60; 60, assignment; 60, 61; 60, 64; 61, subscript; 61, 62; 61, 63; 62, identifier:params; 63, identifier:key; 64, subscript; 64, 65; 64, 73; 65, call; 65, 66; 65, 71; 66, attribute; 66, 67; 66, 70; 67, subscript; 67, 68; 67, 69; 68, identifier:params; 69, identifier:key; 70, identifier:split; 71, argument_list; 71, 72; 72, string:'|'; 73, integer:0; 74, for_statement; 74, 75; 74, 76; 74, 77; 75, identifier:key; 76, identifier:params; 77, block; 77, 78; 77, 87; 77, 92; 77, 123; 77, 179; 78, expression_statement; 78, 79; 79, assignment; 79, 80; 79, 81; 80, identifier:param_type; 81, call; 81, 82; 81, 85; 82, attribute; 82, 83; 82, 84; 83, identifier:self; 84, identifier:get_scanner_param_type; 85, argument_list; 85, 86; 86, identifier:key; 87, if_statement; 87, 88; 87, 90; 88, not_operator; 88, 89; 89, identifier:param_type; 90, block; 90, 91; 91, continue_statement; 92, if_statement; 92, 93; 92, 98; 93, comparison_operator:in; 93, 94; 93, 95; 94, identifier:param_type; 95, list:['integer', 'boolean']; 95, 96; 95, 97; 96, string:'integer'; 97, string:'boolean'; 98, block; 98, 99; 99, try_statement; 99, 100; 99, 112; 100, block; 100, 101; 101, expression_statement; 101, 102; 102, assignment; 102, 103; 102, 106; 103, subscript; 103, 104; 103, 105; 104, identifier:params; 105, identifier:key; 106, call; 106, 107; 106, 108; 107, identifier:int; 108, argument_list; 108, 109; 109, subscript; 109, 110; 109, 111; 110, identifier:params; 111, identifier:key; 112, except_clause; 112, 113; 112, 114; 113, identifier:ValueError; 114, block; 114, 115; 115, raise_statement; 115, 116; 116, call; 116, 117; 116, 118; 117, identifier:OSPDError; 118, argument_list; 118, 119; 118, 122; 119, binary_operator:%; 119, 120; 119, 121; 120, string:'Invalid %s value'; 121, identifier:key; 122, string:'start_scan'; 123, if_statement; 123, 124; 123, 127; 123, 145; 124, comparison_operator:==; 124, 125; 124, 126; 125, identifier:param_type; 126, string:'boolean'; 127, block; 127, 128; 128, if_statement; 128, 129; 128, 136; 129, comparison_operator:not; 129, 130; 129, 133; 130, subscript; 130, 131; 130, 132; 131, identifier:params; 132, identifier:key; 133, list:[0, 1]; 133, 134; 133, 135; 134, integer:0; 135, integer:1; 136, block; 136, 137; 137, raise_statement; 137, 138; 138, call; 138, 139; 138, 140; 139, identifier:OSPDError; 140, argument_list; 140, 141; 140, 144; 141, binary_operator:%; 141, 142; 141, 143; 142, string:'Invalid %s value'; 143, identifier:key; 144, string:'start_scan'; 145, elif_clause; 145, 146; 145, 149; 146, comparison_operator:==; 146, 147; 146, 148; 147, identifier:param_type; 148, string:'selection'; 149, block; 149, 150; 149, 164; 150, expression_statement; 150, 151; 151, assignment; 151, 152; 151, 153; 152, identifier:selection; 153, call; 153, 154; 153, 162; 154, attribute; 154, 155; 154, 161; 155, call; 155, 156; 155, 159; 156, attribute; 156, 157; 156, 158; 157, identifier:self; 158, identifier:get_scanner_param_default; 159, argument_list; 159, 160; 160, identifier:key; 161, identifier:split; 162, argument_list; 162, 163; 163, string:'|'; 164, if_statement; 164, 165; 164, 170; 165, comparison_operator:not; 165, 166; 165, 169; 166, subscript; 166, 167; 166, 168; 167, identifier:params; 168, identifier:key; 169, identifier:selection; 170, block; 170, 171; 171, raise_statement; 171, 172; 172, call; 172, 173; 172, 174; 173, identifier:OSPDError; 174, argument_list; 174, 175; 174, 178; 175, binary_operator:%; 175, 176; 175, 177; 176, string:'Invalid %s value'; 177, identifier:key; 178, string:'start_scan'; 179, if_statement; 179, 180; 179, 192; 180, boolean_operator:and; 180, 181; 180, 187; 181, call; 181, 182; 181, 185; 182, attribute; 182, 183; 182, 184; 183, identifier:self; 184, identifier:get_scanner_param_mandatory; 185, argument_list; 185, 186; 186, identifier:key; 187, comparison_operator:==; 187, 188; 187, 191; 188, subscript; 188, 189; 188, 190; 189, identifier:params; 190, identifier:key; 191, string:''; 192, block; 192, 193; 193, raise_statement; 193, 194; 194, call; 194, 195; 194, 196; 195, identifier:OSPDError; 196, argument_list; 196, 197; 196, 200; 197, binary_operator:%; 197, 198; 197, 199; 198, string:'Mandatory %s value is missing'; 199, identifier:key; 200, string:'start_scan'; 201, return_statement; 201, 202; 202, identifier:params
def _preprocess_scan_params(self, xml_params): params = {} for param in xml_params: params[param.tag] = param.text or '' for key in self.scanner_params: if key not in params: params[key] = self.get_scanner_param_default(key) if self.get_scanner_param_type(key) == 'selection': params[key] = params[key].split('|')[0] for key in params: param_type = self.get_scanner_param_type(key) if not param_type: continue if param_type in ['integer', 'boolean']: try: params[key] = int(params[key]) except ValueError: raise OSPDError('Invalid %s value' % key, 'start_scan') if param_type == 'boolean': if params[key] not in [0, 1]: raise OSPDError('Invalid %s value' % key, 'start_scan') elif param_type == 'selection': selection = self.get_scanner_param_default(key).split('|') if params[key] not in selection: raise OSPDError('Invalid %s value' % key, 'start_scan') if self.get_scanner_param_mandatory(key) and params[key] == '': raise OSPDError('Mandatory %s value is missing' % key, 'start_scan') return params
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:start_scan; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:scan_id; 6, identifier:targets; 7, default_parameter; 7, 8; 7, 9; 8, identifier:parallel; 9, integer:1; 10, block; 10, 11; 10, 17; 10, 21; 10, 29; 10, 33; 10, 47; 10, 171; 10, 211; 11, expression_statement; 11, 12; 12, call; 12, 13; 12, 16; 13, attribute; 13, 14; 13, 15; 14, identifier:os; 15, identifier:setsid; 16, argument_list; 17, expression_statement; 17, 18; 18, assignment; 18, 19; 18, 20; 19, identifier:multiscan_proc; 20, list:[]; 21, expression_statement; 21, 22; 22, call; 22, 23; 22, 26; 23, attribute; 23, 24; 23, 25; 24, identifier:logger; 25, identifier:info; 26, argument_list; 26, 27; 26, 28; 27, string:"%s: Scan started."; 28, identifier:scan_id; 29, expression_statement; 29, 30; 30, assignment; 30, 31; 30, 32; 31, identifier:target_list; 32, identifier:targets; 33, if_statement; 33, 34; 33, 40; 34, boolean_operator:or; 34, 35; 34, 38; 35, comparison_operator:is; 35, 36; 35, 37; 36, identifier:target_list; 37, None; 38, not_operator; 38, 39; 39, identifier:target_list; 40, block; 40, 41; 41, raise_statement; 41, 42; 42, call; 42, 43; 42, 44; 43, identifier:OSPDError; 44, argument_list; 44, 45; 44, 46; 45, string:'Erroneous targets list'; 46, string:'start_scan'; 47, for_statement; 47, 48; 47, 51; 47, 55; 48, pattern_list; 48, 49; 48, 50; 49, identifier:index; 50, identifier:target; 51, call; 51, 52; 51, 53; 52, identifier:enumerate; 53, argument_list; 53, 54; 54, identifier:target_list; 55, block; 55, 56; 55, 98; 55, 111; 55, 124; 55, 144; 55, 155; 55, 161; 56, while_statement; 56, 57; 56, 63; 57, comparison_operator:>=; 57, 58; 57, 62; 58, call; 58, 59; 58, 60; 59, identifier:len; 60, argument_list; 60, 61; 61, identifier:multiscan_proc; 62, identifier:parallel; 63, block; 63, 64; 63, 73; 63, 81; 63, 91; 64, expression_statement; 64, 65; 65, assignment; 65, 66; 65, 67; 66, identifier:progress; 67, call; 67, 68; 67, 71; 68, attribute; 68, 69; 68, 70; 69, identifier:self; 70, identifier:calculate_progress; 71, argument_list; 71, 72; 72, identifier:scan_id; 73, expression_statement; 73, 74; 74, call; 74, 75; 74, 78; 75, attribute; 75, 76; 75, 77; 76, identifier:self; 77, identifier:set_scan_progress; 78, argument_list; 78, 79; 78, 80; 79, identifier:scan_id; 80, identifier:progress; 81, expression_statement; 81, 82; 82, assignment; 82, 83; 82, 84; 83, identifier:multiscan_proc; 84, call; 84, 85; 84, 88; 85, attribute; 85, 86; 85, 87; 86, identifier:self; 87, identifier:check_pending_target; 88, argument_list; 88, 89; 88, 90; 89, identifier:scan_id; 90, identifier:multiscan_proc; 91, expression_statement; 91, 92; 92, call; 92, 93; 92, 96; 93, attribute; 93, 94; 93, 95; 94, identifier:time; 95, identifier:sleep; 96, argument_list; 96, 97; 97, integer:1; 98, if_statement; 98, 99; 98, 109; 99, comparison_operator:==; 99, 100; 99, 106; 100, call; 100, 101; 100, 104; 101, attribute; 101, 102; 101, 103; 102, identifier:self; 103, identifier:get_scan_status; 104, argument_list; 104, 105; 105, identifier:scan_id; 106, attribute; 106, 107; 106, 108; 107, identifier:ScanStatus; 108, identifier:STOPPED; 109, block; 109, 110; 110, return_statement; 111, expression_statement; 111, 112; 112, call; 112, 113; 112, 116; 113, attribute; 113, 114; 113, 115; 114, identifier:logger; 115, identifier:info; 116, argument_list; 116, 117; 116, 118; 116, 121; 117, string:"%s: Host scan started on ports %s."; 118, subscript; 118, 119; 118, 120; 119, identifier:target; 120, integer:0; 121, subscript; 121, 122; 121, 123; 122, identifier:target; 123, integer:1; 124, expression_statement; 124, 125; 125, assignment; 125, 126; 125, 127; 126, identifier:scan_process; 127, call; 127, 128; 127, 131; 128, attribute; 128, 129; 128, 130; 129, identifier:multiprocessing; 130, identifier:Process; 131, argument_list; 131, 132; 131, 137; 132, keyword_argument; 132, 133; 132, 134; 133, identifier:target; 134, attribute; 134, 135; 134, 136; 135, identifier:self; 136, identifier:parallel_scan; 137, keyword_argument; 137, 138; 137, 139; 138, identifier:args; 139, tuple; 139, 140; 139, 141; 140, identifier:scan_id; 141, subscript; 141, 142; 141, 143; 142, identifier:target; 143, integer:0; 144, expression_statement; 144, 145; 145, call; 145, 146; 145, 149; 146, attribute; 146, 147; 146, 148; 147, identifier:multiscan_proc; 148, identifier:append; 149, argument_list; 149, 150; 150, tuple; 150, 151; 150, 152; 151, identifier:scan_process; 152, subscript; 152, 153; 152, 154; 153, identifier:target; 154, integer:0; 155, expression_statement; 155, 156; 156, call; 156, 157; 156, 160; 157, attribute; 157, 158; 157, 159; 158, identifier:scan_process; 159, identifier:start; 160, argument_list; 161, expression_statement; 161, 162; 162, call; 162, 163; 162, 166; 163, attribute; 163, 164; 163, 165; 164, identifier:self; 165, identifier:set_scan_status; 166, argument_list; 166, 167; 166, 168; 167, identifier:scan_id; 168, attribute; 168, 169; 168, 170; 169, identifier:ScanStatus; 170, identifier:RUNNING; 171, while_statement; 171, 172; 171, 173; 172, identifier:multiscan_proc; 173, block; 173, 174; 173, 184; 173, 204; 174, expression_statement; 174, 175; 175, assignment; 175, 176; 175, 177; 176, identifier:multiscan_proc; 177, call; 177, 178; 177, 181; 178, attribute; 178, 179; 178, 180; 179, identifier:self; 180, identifier:check_pending_target; 181, argument_list; 181, 182; 181, 183; 182, identifier:scan_id; 183, identifier:multiscan_proc; 184, if_statement; 184, 185; 184, 186; 185, identifier:multiscan_proc; 186, block; 186, 187; 186, 196; 187, expression_statement; 187, 188; 188, assignment; 188, 189; 188, 190; 189, identifier:progress; 190, call; 190, 191; 190, 194; 191, attribute; 191, 192; 191, 193; 192, identifier:self; 193, identifier:calculate_progress; 194, argument_list; 194, 195; 195, identifier:scan_id; 196, expression_statement; 196, 197; 197, call; 197, 198; 197, 201; 198, attribute; 198, 199; 198, 200; 199, identifier:self; 200, identifier:set_scan_progress; 201, argument_list; 201, 202; 201, 203; 202, identifier:scan_id; 203, identifier:progress; 204, expression_statement; 204, 205; 205, call; 205, 206; 205, 209; 206, attribute; 206, 207; 206, 208; 207, identifier:time; 208, identifier:sleep; 209, argument_list; 209, 210; 210, integer:1; 211, if_statement; 211, 212; 211, 222; 212, comparison_operator:!=; 212, 213; 212, 219; 213, call; 213, 214; 213, 217; 214, attribute; 214, 215; 214, 216; 215, identifier:self; 216, identifier:get_scan_status; 217, argument_list; 217, 218; 218, identifier:scan_id; 219, attribute; 219, 220; 219, 221; 220, identifier:ScanStatus; 221, identifier:STOPPED; 222, block; 222, 223; 223, expression_statement; 223, 224; 224, call; 224, 225; 224, 228; 225, attribute; 225, 226; 225, 227; 226, identifier:self; 227, identifier:finish_scan; 228, argument_list; 228, 229; 229, identifier:scan_id
def start_scan(self, scan_id, targets, parallel=1): os.setsid() multiscan_proc = [] logger.info("%s: Scan started.", scan_id) target_list = targets if target_list is None or not target_list: raise OSPDError('Erroneous targets list', 'start_scan') for index, target in enumerate(target_list): while len(multiscan_proc) >= parallel: progress = self.calculate_progress(scan_id) self.set_scan_progress(scan_id, progress) multiscan_proc = self.check_pending_target(scan_id, multiscan_proc) time.sleep(1) if self.get_scan_status(scan_id) == ScanStatus.STOPPED: return logger.info("%s: Host scan started on ports %s.", target[0], target[1]) scan_process = multiprocessing.Process(target=self.parallel_scan, args=(scan_id, target[0])) multiscan_proc.append((scan_process, target[0])) scan_process.start() self.set_scan_status(scan_id, ScanStatus.RUNNING) while multiscan_proc: multiscan_proc = self.check_pending_target(scan_id, multiscan_proc) if multiscan_proc: progress = self.calculate_progress(scan_id) self.set_scan_progress(scan_id, progress) time.sleep(1) if self.get_scan_status(scan_id) != ScanStatus.STOPPED: self.finish_scan(scan_id)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:ports_as_list; 3, parameters; 3, 4; 4, identifier:port_str; 5, block; 5, 6; 5, 21; 5, 38; 5, 44; 5, 50; 5, 60; 5, 69; 5, 78; 5, 103; 5, 128; 5, 135; 5, 139; 5, 143; 5, 248; 5, 293; 5, 338; 6, if_statement; 6, 7; 6, 9; 7, not_operator; 7, 8; 8, identifier:port_str; 9, block; 9, 10; 9, 17; 10, expression_statement; 10, 11; 11, call; 11, 12; 11, 15; 12, attribute; 12, 13; 12, 14; 13, identifier:LOGGER; 14, identifier:info; 15, argument_list; 15, 16; 16, string:"Invalid port value"; 17, return_statement; 17, 18; 18, list:[None, None]; 18, 19; 18, 20; 19, None; 20, None; 21, if_statement; 21, 22; 21, 26; 22, call; 22, 23; 22, 24; 23, identifier:ports_str_check_failed; 24, argument_list; 24, 25; 25, identifier:port_str; 26, block; 26, 27; 26, 34; 27, expression_statement; 27, 28; 28, call; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, identifier:LOGGER; 31, identifier:info; 32, argument_list; 32, 33; 33, string:"{0}: Port list malformed."; 34, return_statement; 34, 35; 35, list:[None, None]; 35, 36; 35, 37; 36, None; 37, None; 38, expression_statement; 38, 39; 39, assignment; 39, 40; 39, 41; 40, identifier:tcp_list; 41, call; 41, 42; 41, 43; 42, identifier:list; 43, argument_list; 44, expression_statement; 44, 45; 45, assignment; 45, 46; 45, 47; 46, identifier:udp_list; 47, call; 47, 48; 47, 49; 48, identifier:list; 49, argument_list; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 53; 52, identifier:ports; 53, call; 53, 54; 53, 57; 54, attribute; 54, 55; 54, 56; 55, identifier:port_str; 56, identifier:replace; 57, argument_list; 57, 58; 57, 59; 58, string:' '; 59, string:''; 60, expression_statement; 60, 61; 61, assignment; 61, 62; 61, 63; 62, identifier:b_tcp; 63, call; 63, 64; 63, 67; 64, attribute; 64, 65; 64, 66; 65, identifier:ports; 66, identifier:find; 67, argument_list; 67, 68; 68, string:"T"; 69, expression_statement; 69, 70; 70, assignment; 70, 71; 70, 72; 71, identifier:b_udp; 72, call; 72, 73; 72, 76; 73, attribute; 73, 74; 73, 75; 74, identifier:ports; 75, identifier:find; 76, argument_list; 76, 77; 77, string:"U"; 78, if_statement; 78, 79; 78, 86; 79, comparison_operator:==; 79, 80; 79, 85; 80, subscript; 80, 81; 80, 82; 81, identifier:ports; 82, binary_operator:-; 82, 83; 82, 84; 83, identifier:b_tcp; 84, integer:1; 85, string:','; 86, block; 86, 87; 87, expression_statement; 87, 88; 88, assignment; 88, 89; 88, 90; 89, identifier:ports; 90, binary_operator:+; 90, 91; 90, 98; 91, subscript; 91, 92; 91, 93; 92, identifier:ports; 93, slice; 93, 94; 93, 95; 94, colon; 95, binary_operator:-; 95, 96; 95, 97; 96, identifier:b_tcp; 97, integer:1; 98, subscript; 98, 99; 98, 100; 99, identifier:ports; 100, slice; 100, 101; 100, 102; 101, identifier:b_tcp; 102, colon; 103, if_statement; 103, 104; 103, 111; 104, comparison_operator:==; 104, 105; 104, 110; 105, subscript; 105, 106; 105, 107; 106, identifier:ports; 107, binary_operator:-; 107, 108; 107, 109; 108, identifier:b_udp; 109, integer:1; 110, string:','; 111, block; 111, 112; 112, expression_statement; 112, 113; 113, assignment; 113, 114; 113, 115; 114, identifier:ports; 115, binary_operator:+; 115, 116; 115, 123; 116, subscript; 116, 117; 116, 118; 117, identifier:ports; 118, slice; 118, 119; 118, 120; 119, colon; 120, binary_operator:-; 120, 121; 120, 122; 121, identifier:b_udp; 122, integer:1; 123, subscript; 123, 124; 123, 125; 124, identifier:ports; 125, slice; 125, 126; 125, 127; 126, identifier:b_udp; 127, colon; 128, expression_statement; 128, 129; 129, assignment; 129, 130; 129, 131; 130, identifier:ports; 131, call; 131, 132; 131, 133; 132, identifier:port_str_arrange; 133, argument_list; 133, 134; 134, identifier:ports; 135, expression_statement; 135, 136; 136, assignment; 136, 137; 136, 138; 137, identifier:tports; 138, string:''; 139, expression_statement; 139, 140; 140, assignment; 140, 141; 140, 142; 141, identifier:uports; 142, string:''; 143, if_statement; 143, 144; 143, 153; 143, 190; 143, 216; 143, 242; 144, boolean_operator:and; 144, 145; 144, 149; 145, comparison_operator:!=; 145, 146; 145, 147; 146, identifier:b_udp; 147, unary_operator:-; 147, 148; 148, integer:1; 149, comparison_operator:!=; 149, 150; 149, 151; 150, identifier:b_tcp; 151, unary_operator:-; 151, 152; 152, integer:1; 153, block; 153, 154; 153, 175; 154, expression_statement; 154, 155; 155, assignment; 155, 156; 155, 157; 156, identifier:tports; 157, subscript; 157, 158; 157, 159; 158, identifier:ports; 159, slice; 159, 160; 159, 168; 159, 169; 160, binary_operator:+; 160, 161; 160, 167; 161, call; 161, 162; 161, 165; 162, attribute; 162, 163; 162, 164; 163, identifier:ports; 164, identifier:index; 165, argument_list; 165, 166; 166, string:'T:'; 167, integer:2; 168, colon; 169, call; 169, 170; 169, 173; 170, attribute; 170, 171; 170, 172; 171, identifier:ports; 172, identifier:index; 173, argument_list; 173, 174; 174, string:'U:'; 175, expression_statement; 175, 176; 176, assignment; 176, 177; 176, 178; 177, identifier:uports; 178, subscript; 178, 179; 178, 180; 179, identifier:ports; 180, slice; 180, 181; 180, 189; 181, binary_operator:+; 181, 182; 181, 188; 182, call; 182, 183; 182, 186; 183, attribute; 183, 184; 183, 185; 184, identifier:ports; 185, identifier:index; 186, argument_list; 186, 187; 187, string:'U:'; 188, integer:2; 189, colon; 190, elif_clause; 190, 191; 190, 200; 191, boolean_operator:and; 191, 192; 191, 196; 192, comparison_operator:==; 192, 193; 192, 194; 193, identifier:b_tcp; 194, unary_operator:-; 194, 195; 195, integer:1; 196, comparison_operator:!=; 196, 197; 196, 198; 197, identifier:b_udp; 198, unary_operator:-; 198, 199; 199, integer:1; 200, block; 200, 201; 201, expression_statement; 201, 202; 202, assignment; 202, 203; 202, 204; 203, identifier:uports; 204, subscript; 204, 205; 204, 206; 205, identifier:ports; 206, slice; 206, 207; 206, 215; 207, binary_operator:+; 207, 208; 207, 214; 208, call; 208, 209; 208, 212; 209, attribute; 209, 210; 209, 211; 210, identifier:ports; 211, identifier:index; 212, argument_list; 212, 213; 213, string:'U:'; 214, integer:2; 215, colon; 216, elif_clause; 216, 217; 216, 226; 217, boolean_operator:and; 217, 218; 217, 222; 218, comparison_operator:==; 218, 219; 218, 220; 219, identifier:b_udp; 220, unary_operator:-; 220, 221; 221, integer:1; 222, comparison_operator:!=; 222, 223; 222, 224; 223, identifier:b_tcp; 224, unary_operator:-; 224, 225; 225, integer:1; 226, block; 226, 227; 227, expression_statement; 227, 228; 228, assignment; 228, 229; 228, 230; 229, identifier:tports; 230, subscript; 230, 231; 230, 232; 231, identifier:ports; 232, slice; 232, 233; 232, 241; 233, binary_operator:+; 233, 234; 233, 240; 234, call; 234, 235; 234, 238; 235, attribute; 235, 236; 235, 237; 236, identifier:ports; 237, identifier:index; 238, argument_list; 238, 239; 239, string:'T:'; 240, integer:2; 241, colon; 242, else_clause; 242, 243; 243, block; 243, 244; 244, expression_statement; 244, 245; 245, assignment; 245, 246; 245, 247; 246, identifier:tports; 247, identifier:ports; 248, if_statement; 248, 249; 248, 250; 249, identifier:tports; 250, block; 250, 251; 250, 287; 251, for_statement; 251, 252; 251, 253; 251, 259; 252, identifier:port; 253, call; 253, 254; 253, 257; 254, attribute; 254, 255; 254, 256; 255, identifier:tports; 256, identifier:split; 257, argument_list; 257, 258; 258, string:','; 259, block; 259, 260; 260, if_statement; 260, 261; 260, 264; 260, 275; 261, comparison_operator:in; 261, 262; 261, 263; 262, string:'-'; 263, identifier:port; 264, block; 264, 265; 265, expression_statement; 265, 266; 266, call; 266, 267; 266, 270; 267, attribute; 267, 268; 267, 269; 268, identifier:tcp_list; 269, identifier:extend; 270, argument_list; 270, 271; 271, call; 271, 272; 271, 273; 272, identifier:port_range_expand; 273, argument_list; 273, 274; 274, identifier:port; 275, else_clause; 275, 276; 276, block; 276, 277; 277, expression_statement; 277, 278; 278, call; 278, 279; 278, 282; 279, attribute; 279, 280; 279, 281; 280, identifier:tcp_list; 281, identifier:append; 282, argument_list; 282, 283; 283, call; 283, 284; 283, 285; 284, identifier:int; 285, argument_list; 285, 286; 286, identifier:port; 287, expression_statement; 287, 288; 288, call; 288, 289; 288, 292; 289, attribute; 289, 290; 289, 291; 290, identifier:tcp_list; 291, identifier:sort; 292, argument_list; 293, if_statement; 293, 294; 293, 295; 294, identifier:uports; 295, block; 295, 296; 295, 332; 296, for_statement; 296, 297; 296, 298; 296, 304; 297, identifier:port; 298, call; 298, 299; 298, 302; 299, attribute; 299, 300; 299, 301; 300, identifier:uports; 301, identifier:split; 302, argument_list; 302, 303; 303, string:','; 304, block; 304, 305; 305, if_statement; 305, 306; 305, 309; 305, 320; 306, comparison_operator:in; 306, 307; 306, 308; 307, string:'-'; 308, identifier:port; 309, block; 309, 310; 310, expression_statement; 310, 311; 311, call; 311, 312; 311, 315; 312, attribute; 312, 313; 312, 314; 313, identifier:udp_list; 314, identifier:extend; 315, argument_list; 315, 316; 316, call; 316, 317; 316, 318; 317, identifier:port_range_expand; 318, argument_list; 318, 319; 319, identifier:port; 320, else_clause; 320, 321; 321, block; 321, 322; 322, expression_statement; 322, 323; 323, call; 323, 324; 323, 327; 324, attribute; 324, 325; 324, 326; 325, identifier:udp_list; 326, identifier:append; 327, argument_list; 327, 328; 328, call; 328, 329; 328, 330; 329, identifier:int; 330, argument_list; 330, 331; 331, identifier:port; 332, expression_statement; 332, 333; 333, call; 333, 334; 333, 337; 334, attribute; 334, 335; 334, 336; 335, identifier:udp_list; 336, identifier:sort; 337, argument_list; 338, return_statement; 338, 339; 339, tuple; 339, 340; 339, 341; 340, identifier:tcp_list; 341, identifier:udp_list
def ports_as_list(port_str): if not port_str: LOGGER.info("Invalid port value") return [None, None] if ports_str_check_failed(port_str): LOGGER.info("{0}: Port list malformed.") return [None, None] tcp_list = list() udp_list = list() ports = port_str.replace(' ', '') b_tcp = ports.find("T") b_udp = ports.find("U") if ports[b_tcp - 1] == ',': ports = ports[:b_tcp - 1] + ports[b_tcp:] if ports[b_udp - 1] == ',': ports = ports[:b_udp - 1] + ports[b_udp:] ports = port_str_arrange(ports) tports = '' uports = '' if b_udp != -1 and b_tcp != -1: tports = ports[ports.index('T:') + 2:ports.index('U:')] uports = ports[ports.index('U:') + 2:] elif b_tcp == -1 and b_udp != -1: uports = ports[ports.index('U:') + 2:] elif b_udp == -1 and b_tcp != -1: tports = ports[ports.index('T:') + 2:] else: tports = ports if tports: for port in tports.split(','): if '-' in port: tcp_list.extend(port_range_expand(port)) else: tcp_list.append(int(port)) tcp_list.sort() if uports: for port in uports.split(','): if '-' in port: udp_list.extend(port_range_expand(port)) else: udp_list.append(int(port)) udp_list.sort() return (tcp_list, udp_list)
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:create_args_parser; 3, parameters; 3, 4; 4, identifier:description; 5, block; 5, 6; 5, 17; 5, 45; 5, 174; 5, 209; 5, 236; 5, 258; 5, 277; 5, 288; 5, 307; 5, 326; 5, 344; 5, 361; 5, 374; 5, 388; 5, 401; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:parser; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, identifier:argparse; 12, identifier:ArgumentParser; 13, argument_list; 13, 14; 14, keyword_argument; 14, 15; 14, 16; 15, identifier:description; 16, identifier:description; 17, function_definition; 17, 18; 17, 19; 17, 21; 18, function_name:network_port; 19, parameters; 19, 20; 20, identifier:string; 21, block; 21, 22; 21, 29; 21, 43; 22, expression_statement; 22, 23; 23, assignment; 23, 24; 23, 25; 24, identifier:value; 25, call; 25, 26; 25, 27; 26, identifier:int; 27, argument_list; 27, 28; 28, identifier:string; 29, if_statement; 29, 30; 29, 35; 30, not_operator; 30, 31; 31, comparison_operator:<; 31, 32; 31, 33; 31, 34; 32, integer:0; 33, identifier:value; 34, integer:65535; 35, block; 35, 36; 36, raise_statement; 36, 37; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:argparse; 40, identifier:ArgumentTypeError; 41, argument_list; 41, 42; 42, string:'port must be in ]0,65535] interval'; 43, return_statement; 43, 44; 44, identifier:value; 45, function_definition; 45, 46; 45, 47; 45, 49; 46, function_name:cacert_file; 47, parameters; 47, 48; 48, identifier:cacert; 49, block; 49, 50; 49, 78; 49, 134; 49, 153; 49, 172; 50, try_statement; 50, 51; 50, 63; 50, 68; 51, block; 51, 52; 52, expression_statement; 52, 53; 53, assignment; 53, 54; 53, 55; 54, identifier:context; 55, call; 55, 56; 55, 59; 56, attribute; 56, 57; 56, 58; 57, identifier:ssl; 58, identifier:create_default_context; 59, argument_list; 59, 60; 60, keyword_argument; 60, 61; 60, 62; 61, identifier:cafile; 62, identifier:cacert; 63, except_clause; 63, 64; 63, 65; 64, identifier:AttributeError; 65, block; 65, 66; 66, return_statement; 66, 67; 67, identifier:cacert; 68, except_clause; 68, 69; 68, 70; 69, identifier:IOError; 70, block; 70, 71; 71, raise_statement; 71, 72; 72, call; 72, 73; 72, 76; 73, attribute; 73, 74; 73, 75; 74, identifier:argparse; 75, identifier:ArgumentTypeError; 76, argument_list; 76, 77; 77, string:'CA Certificate not found'; 78, try_statement; 78, 79; 78, 122; 79, block; 79, 80; 79, 92; 79, 101; 79, 113; 80, expression_statement; 80, 81; 81, assignment; 81, 82; 81, 83; 82, identifier:not_after; 83, subscript; 83, 84; 83, 91; 84, subscript; 84, 85; 84, 90; 85, call; 85, 86; 85, 89; 86, attribute; 86, 87; 86, 88; 87, identifier:context; 88, identifier:get_ca_certs; 89, argument_list; 90, integer:0; 91, string:'notAfter'; 92, expression_statement; 92, 93; 93, assignment; 93, 94; 93, 95; 94, identifier:not_after; 95, call; 95, 96; 95, 99; 96, attribute; 96, 97; 96, 98; 97, identifier:ssl; 98, identifier:cert_time_to_seconds; 99, argument_list; 99, 100; 100, identifier:not_after; 101, expression_statement; 101, 102; 102, assignment; 102, 103; 102, 104; 103, identifier:not_before; 104, subscript; 104, 105; 104, 112; 105, subscript; 105, 106; 105, 111; 106, call; 106, 107; 106, 110; 107, attribute; 107, 108; 107, 109; 108, identifier:context; 109, identifier:get_ca_certs; 110, argument_list; 111, integer:0; 112, string:'notBefore'; 113, expression_statement; 113, 114; 114, assignment; 114, 115; 114, 116; 115, identifier:not_before; 116, call; 116, 117; 116, 120; 117, attribute; 117, 118; 117, 119; 118, identifier:ssl; 119, identifier:cert_time_to_seconds; 120, argument_list; 120, 121; 121, identifier:not_before; 122, except_clause; 122, 123; 122, 126; 123, tuple; 123, 124; 123, 125; 124, identifier:KeyError; 125, identifier:IndexError; 126, block; 126, 127; 127, raise_statement; 127, 128; 128, call; 128, 129; 128, 132; 129, attribute; 129, 130; 129, 131; 130, identifier:argparse; 131, identifier:ArgumentTypeError; 132, argument_list; 132, 133; 133, string:'CA Certificate is erroneous'; 134, if_statement; 134, 135; 134, 145; 135, comparison_operator:<; 135, 136; 135, 137; 136, identifier:not_after; 137, call; 137, 138; 137, 139; 138, identifier:int; 139, argument_list; 139, 140; 140, call; 140, 141; 140, 144; 141, attribute; 141, 142; 141, 143; 142, identifier:time; 143, identifier:time; 144, argument_list; 145, block; 145, 146; 146, raise_statement; 146, 147; 147, call; 147, 148; 147, 151; 148, attribute; 148, 149; 148, 150; 149, identifier:argparse; 150, identifier:ArgumentTypeError; 151, argument_list; 151, 152; 152, string:'CA Certificate expired'; 153, if_statement; 153, 154; 153, 164; 154, comparison_operator:>; 154, 155; 154, 156; 155, identifier:not_before; 156, call; 156, 157; 156, 158; 157, identifier:int; 158, argument_list; 158, 159; 159, call; 159, 160; 159, 163; 160, attribute; 160, 161; 160, 162; 161, identifier:time; 162, identifier:time; 163, argument_list; 164, block; 164, 165; 165, raise_statement; 165, 166; 166, call; 166, 167; 166, 170; 167, attribute; 167, 168; 167, 169; 168, identifier:argparse; 169, identifier:ArgumentTypeError; 170, argument_list; 170, 171; 171, string:'CA Certificate not active yet'; 172, return_statement; 172, 173; 173, identifier:cacert; 174, function_definition; 174, 175; 174, 176; 174, 178; 175, function_name:log_level; 176, parameters; 176, 177; 177, identifier:string; 178, block; 178, 179; 178, 192; 178, 207; 179, expression_statement; 179, 180; 180, assignment; 180, 181; 180, 182; 181, identifier:value; 182, call; 182, 183; 182, 184; 183, identifier:getattr; 184, argument_list; 184, 185; 184, 186; 184, 191; 185, identifier:logging; 186, call; 186, 187; 186, 190; 187, attribute; 187, 188; 187, 189; 188, identifier:string; 189, identifier:upper; 190, argument_list; 191, None; 192, if_statement; 192, 193; 192, 199; 193, not_operator; 193, 194; 194, call; 194, 195; 194, 196; 195, identifier:isinstance; 196, argument_list; 196, 197; 196, 198; 197, identifier:value; 198, identifier:int; 199, block; 199, 200; 200, raise_statement; 200, 201; 201, call; 201, 202; 201, 205; 202, attribute; 202, 203; 202, 204; 203, identifier:argparse; 204, identifier:ArgumentTypeError; 205, argument_list; 205, 206; 206, string:'log level must be one of {debug,info,warning,error,critical}'; 207, return_statement; 207, 208; 208, identifier:value; 209, function_definition; 209, 210; 209, 211; 209, 213; 210, function_name:filename; 211, parameters; 211, 212; 212, identifier:string; 213, block; 213, 214; 213, 234; 214, if_statement; 214, 215; 214, 224; 215, not_operator; 215, 216; 216, call; 216, 217; 216, 222; 217, attribute; 217, 218; 217, 221; 218, attribute; 218, 219; 218, 220; 219, identifier:os; 220, identifier:path; 221, identifier:isfile; 222, argument_list; 222, 223; 223, identifier:string; 224, block; 224, 225; 225, raise_statement; 225, 226; 226, call; 226, 227; 226, 230; 227, attribute; 227, 228; 227, 229; 228, identifier:argparse; 229, identifier:ArgumentTypeError; 230, argument_list; 230, 231; 231, binary_operator:%; 231, 232; 231, 233; 232, string:'%s is not a valid file path'; 233, identifier:string; 234, return_statement; 234, 235; 235, identifier:string; 236, expression_statement; 236, 237; 237, call; 237, 238; 237, 241; 238, attribute; 238, 239; 238, 240; 239, identifier:parser; 240, identifier:add_argument; 241, argument_list; 241, 242; 241, 243; 241, 244; 241, 247; 241, 250; 242, string:'-p'; 243, string:'--port'; 244, keyword_argument; 244, 245; 244, 246; 245, identifier:default; 246, identifier:PORT; 247, keyword_argument; 247, 248; 247, 249; 248, identifier:type; 249, identifier:network_port; 250, keyword_argument; 250, 251; 250, 252; 251, identifier:help; 252, call; 252, 253; 252, 256; 253, attribute; 253, 254; 253, 255; 254, string:'TCP Port to listen on. Default: {0}'; 255, identifier:format; 256, argument_list; 256, 257; 257, identifier:PORT; 258, expression_statement; 258, 259; 259, call; 259, 260; 259, 263; 260, attribute; 260, 261; 260, 262; 261, identifier:parser; 262, identifier:add_argument; 263, argument_list; 263, 264; 263, 265; 263, 266; 263, 269; 264, string:'-b'; 265, string:'--bind-address'; 266, keyword_argument; 266, 267; 266, 268; 267, identifier:default; 268, identifier:ADDRESS; 269, keyword_argument; 269, 270; 269, 271; 270, identifier:help; 271, call; 271, 272; 271, 275; 272, attribute; 272, 273; 272, 274; 273, string:'Address to listen on. Default: {0}'; 274, identifier:format; 275, argument_list; 275, 276; 276, identifier:ADDRESS; 277, expression_statement; 277, 278; 278, call; 278, 279; 278, 282; 279, attribute; 279, 280; 279, 281; 280, identifier:parser; 281, identifier:add_argument; 282, argument_list; 282, 283; 282, 284; 282, 285; 283, string:'-u'; 284, string:'--unix-socket'; 285, keyword_argument; 285, 286; 285, 287; 286, identifier:help; 287, string:'Unix file socket to listen on.'; 288, expression_statement; 288, 289; 289, call; 289, 290; 289, 293; 290, attribute; 290, 291; 290, 292; 291, identifier:parser; 292, identifier:add_argument; 293, argument_list; 293, 294; 293, 295; 293, 296; 293, 299; 294, string:'-k'; 295, string:'--key-file'; 296, keyword_argument; 296, 297; 296, 298; 297, identifier:type; 298, identifier:filename; 299, keyword_argument; 299, 300; 299, 301; 300, identifier:help; 301, call; 301, 302; 301, 305; 302, attribute; 302, 303; 302, 304; 303, string:'Server key file. Default: {0}'; 304, identifier:format; 305, argument_list; 305, 306; 306, identifier:KEY_FILE; 307, expression_statement; 307, 308; 308, call; 308, 309; 308, 312; 309, attribute; 309, 310; 309, 311; 310, identifier:parser; 311, identifier:add_argument; 312, argument_list; 312, 313; 312, 314; 312, 315; 312, 318; 313, string:'-c'; 314, string:'--cert-file'; 315, keyword_argument; 315, 316; 315, 317; 316, identifier:type; 317, identifier:filename; 318, keyword_argument; 318, 319; 318, 320; 319, identifier:help; 320, call; 320, 321; 320, 324; 321, attribute; 321, 322; 321, 323; 322, string:'Server cert file. Default: {0}'; 323, identifier:format; 324, argument_list; 324, 325; 325, identifier:CERT_FILE; 326, expression_statement; 326, 327; 327, call; 327, 328; 327, 331; 328, attribute; 328, 329; 328, 330; 329, identifier:parser; 330, identifier:add_argument; 331, argument_list; 331, 332; 331, 333; 331, 336; 332, string:'--ca-file'; 333, keyword_argument; 333, 334; 333, 335; 334, identifier:type; 335, identifier:cacert_file; 336, keyword_argument; 336, 337; 336, 338; 337, identifier:help; 338, call; 338, 339; 338, 342; 339, attribute; 339, 340; 339, 341; 340, string:'CA cert file. Default: {0}'; 341, identifier:format; 342, argument_list; 342, 343; 343, identifier:CA_FILE; 344, expression_statement; 344, 345; 345, call; 345, 346; 345, 349; 346, attribute; 346, 347; 346, 348; 347, identifier:parser; 348, identifier:add_argument; 349, argument_list; 349, 350; 349, 351; 349, 352; 349, 355; 349, 358; 350, string:'-L'; 351, string:'--log-level'; 352, keyword_argument; 352, 353; 352, 354; 353, identifier:default; 354, string:'warning'; 355, keyword_argument; 355, 356; 355, 357; 356, identifier:type; 357, identifier:log_level; 358, keyword_argument; 358, 359; 358, 360; 359, identifier:help; 360, string:'Wished level of logging. Default: WARNING'; 361, expression_statement; 361, 362; 362, call; 362, 363; 362, 366; 363, attribute; 363, 364; 363, 365; 364, identifier:parser; 365, identifier:add_argument; 366, argument_list; 366, 367; 366, 368; 366, 371; 367, string:'--foreground'; 368, keyword_argument; 368, 369; 368, 370; 369, identifier:action; 370, string:'store_true'; 371, keyword_argument; 371, 372; 371, 373; 372, identifier:help; 373, string:'Run in foreground and logs all messages to console.'; 374, expression_statement; 374, 375; 375, call; 375, 376; 375, 379; 376, attribute; 376, 377; 376, 378; 377, identifier:parser; 378, identifier:add_argument; 379, argument_list; 379, 380; 379, 381; 379, 382; 379, 385; 380, string:'-l'; 381, string:'--log-file'; 382, keyword_argument; 382, 383; 382, 384; 383, identifier:type; 384, identifier:filename; 385, keyword_argument; 385, 386; 385, 387; 386, identifier:help; 387, string:'Path to the logging file.'; 388, expression_statement; 388, 389; 389, call; 389, 390; 389, 393; 390, attribute; 390, 391; 390, 392; 391, identifier:parser; 392, identifier:add_argument; 393, argument_list; 393, 394; 393, 395; 393, 398; 394, string:'--version'; 395, keyword_argument; 395, 396; 395, 397; 396, identifier:action; 397, string:'store_true'; 398, keyword_argument; 398, 399; 398, 400; 399, identifier:help; 400, string:'Print version then exit.'; 401, return_statement; 401, 402; 402, identifier:parser
def create_args_parser(description): parser = argparse.ArgumentParser(description=description) def network_port(string): value = int(string) if not 0 < value <= 65535: raise argparse.ArgumentTypeError( 'port must be in ]0,65535] interval') return value def cacert_file(cacert): try: context = ssl.create_default_context(cafile=cacert) except AttributeError: return cacert except IOError: raise argparse.ArgumentTypeError('CA Certificate not found') try: not_after = context.get_ca_certs()[0]['notAfter'] not_after = ssl.cert_time_to_seconds(not_after) not_before = context.get_ca_certs()[0]['notBefore'] not_before = ssl.cert_time_to_seconds(not_before) except (KeyError, IndexError): raise argparse.ArgumentTypeError('CA Certificate is erroneous') if not_after < int(time.time()): raise argparse.ArgumentTypeError('CA Certificate expired') if not_before > int(time.time()): raise argparse.ArgumentTypeError('CA Certificate not active yet') return cacert def log_level(string): value = getattr(logging, string.upper(), None) if not isinstance(value, int): raise argparse.ArgumentTypeError( 'log level must be one of {debug,info,warning,error,critical}') return value def filename(string): if not os.path.isfile(string): raise argparse.ArgumentTypeError( '%s is not a valid file path' % string) return string parser.add_argument('-p', '--port', default=PORT, type=network_port, help='TCP Port to listen on. Default: {0}'.format(PORT)) parser.add_argument('-b', '--bind-address', default=ADDRESS, help='Address to listen on. Default: {0}' .format(ADDRESS)) parser.add_argument('-u', '--unix-socket', help='Unix file socket to listen on.') parser.add_argument('-k', '--key-file', type=filename, help='Server key file. Default: {0}'.format(KEY_FILE)) parser.add_argument('-c', '--cert-file', type=filename, help='Server cert file. Default: {0}'.format(CERT_FILE)) parser.add_argument('--ca-file', type=cacert_file, help='CA cert file. Default: {0}'.format(CA_FILE)) parser.add_argument('-L', '--log-level', default='warning', type=log_level, help='Wished level of logging. Default: WARNING') parser.add_argument('--foreground', action='store_true', help='Run in foreground and logs all messages to console.') parser.add_argument('-l', '--log-file', type=filename, help='Path to the logging file.') parser.add_argument('--version', action='store_true', help='Print version then exit.') return parser
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:_handle_func; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:value; 6, identifier:rule; 7, identifier:path; 8, default_parameter; 8, 9; 8, 10; 9, identifier:done; 10, None; 11, block; 11, 12; 11, 18; 11, 23; 11, 27; 11, 113; 12, expression_statement; 12, 13; 13, assignment; 13, 14; 13, 15; 14, identifier:func; 15, attribute; 15, 16; 15, 17; 16, identifier:rule; 17, identifier:func; 18, if_statement; 18, 19; 18, 21; 19, not_operator; 19, 20; 20, identifier:func; 21, block; 21, 22; 22, return_statement; 23, expression_statement; 23, 24; 24, assignment; 24, 25; 24, 26; 25, identifier:found_method; 26, False; 27, for_statement; 27, 28; 27, 29; 27, 32; 28, identifier:extension; 29, attribute; 29, 30; 29, 31; 30, identifier:self; 31, identifier:loaded_extensions; 32, block; 32, 33; 32, 42; 33, expression_statement; 33, 34; 34, assignment; 34, 35; 34, 36; 35, identifier:method; 36, call; 36, 37; 36, 38; 37, identifier:getattr; 38, argument_list; 38, 39; 38, 40; 38, 41; 39, identifier:extension; 40, identifier:func; 41, None; 42, if_statement; 42, 43; 42, 44; 43, identifier:method; 44, block; 44, 45; 44, 49; 44, 58; 44, 98; 44, 112; 45, expression_statement; 45, 46; 46, assignment; 46, 47; 46, 48; 47, identifier:found_method; 48, True; 49, expression_statement; 49, 50; 50, assignment; 50, 51; 50, 52; 51, identifier:ret; 52, call; 52, 53; 52, 54; 53, identifier:method; 54, argument_list; 54, 55; 54, 56; 54, 57; 55, identifier:value; 56, identifier:rule; 57, identifier:path; 58, if_statement; 58, 59; 58, 66; 59, boolean_operator:and; 59, 60; 59, 63; 60, comparison_operator:is; 60, 61; 60, 62; 61, identifier:ret; 62, True; 63, comparison_operator:is; 63, 64; 63, 65; 64, identifier:ret; 65, None; 66, block; 66, 67; 66, 76; 67, expression_statement; 67, 68; 68, assignment; 68, 69; 68, 70; 69, identifier:msg; 70, binary_operator:%; 70, 71; 70, 72; 71, string:'%s. Path: {path}'; 72, call; 72, 73; 72, 74; 73, identifier:unicode; 74, argument_list; 74, 75; 75, identifier:ret; 76, expression_statement; 76, 77; 77, call; 77, 78; 77, 83; 78, attribute; 78, 79; 78, 82; 79, attribute; 79, 80; 79, 81; 80, identifier:self; 81, identifier:errors; 82, identifier:append; 83, argument_list; 83, 84; 84, call; 84, 85; 84, 88; 85, attribute; 85, 86; 85, 87; 86, identifier:SchemaError; 87, identifier:SchemaErrorEntry; 88, argument_list; 88, 89; 88, 92; 88, 95; 89, keyword_argument; 89, 90; 89, 91; 90, identifier:msg; 91, identifier:msg; 92, keyword_argument; 92, 93; 92, 94; 93, identifier:path; 94, identifier:path; 95, keyword_argument; 95, 96; 95, 97; 96, identifier:value; 97, None; 98, if_statement; 98, 99; 98, 101; 99, not_operator; 99, 100; 100, identifier:ret; 101, block; 101, 102; 102, raise_statement; 102, 103; 103, call; 103, 104; 103, 105; 104, identifier:CoreError; 105, argument_list; 105, 106; 106, call; 106, 107; 106, 110; 107, attribute; 107, 108; 107, 109; 108, string:u"Error when running extension function : {0}"; 109, identifier:format; 110, argument_list; 110, 111; 111, identifier:func; 112, break_statement; 113, if_statement; 113, 114; 113, 116; 114, not_operator; 114, 115; 115, identifier:found_method; 116, block; 116, 117; 117, raise_statement; 117, 118; 118, call; 118, 119; 118, 120; 119, identifier:CoreError; 120, argument_list; 120, 121; 121, call; 121, 122; 121, 125; 122, attribute; 122, 123; 122, 124; 123, string:u"Did not find method '{0}' in any loaded extension file"; 124, identifier:format; 125, argument_list; 125, 126; 126, identifier:func
def _handle_func(self, value, rule, path, done=None): func = rule.func if not func: return found_method = False for extension in self.loaded_extensions: method = getattr(extension, func, None) if method: found_method = True ret = method(value, rule, path) if ret is not True and ret is not None: msg = '%s. Path: {path}' % unicode(ret) self.errors.append(SchemaError.SchemaErrorEntry( msg=msg, path=path, value=None)) if not ret: raise CoreError(u"Error when running extension function : {0}".format(func)) break if not found_method: raise CoreError(u"Did not find method '{0}' in any loaded extension file".format(func))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:_validate_range; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 4, identifier:self; 5, identifier:max_; 6, identifier:min_; 7, identifier:max_ex; 8, identifier:min_ex; 9, identifier:value; 10, identifier:path; 11, identifier:prefix; 12, block; 12, 13; 12, 33; 12, 46; 12, 94; 12, 142; 12, 190; 13, if_statement; 13, 14; 13, 27; 14, boolean_operator:and; 14, 15; 14, 21; 15, not_operator; 15, 16; 16, call; 16, 17; 16, 18; 17, identifier:isinstance; 18, argument_list; 18, 19; 18, 20; 19, identifier:value; 20, identifier:int; 21, not_operator; 21, 22; 22, call; 22, 23; 22, 24; 23, identifier:isinstance; 24, argument_list; 24, 25; 24, 26; 25, identifier:value; 26, identifier:float; 27, block; 27, 28; 28, raise_statement; 28, 29; 29, call; 29, 30; 29, 31; 30, identifier:CoreError; 31, argument_list; 31, 32; 32, string:"Value must be a integer type"; 33, expression_statement; 33, 34; 34, call; 34, 35; 34, 38; 35, attribute; 35, 36; 35, 37; 36, identifier:log; 37, identifier:debug; 38, argument_list; 38, 39; 38, 40; 38, 41; 38, 42; 38, 43; 38, 44; 38, 45; 39, string:u"Validate range : %s : %s : %s : %s : %s : %s"; 40, identifier:max_; 41, identifier:min_; 42, identifier:max_ex; 43, identifier:min_ex; 44, identifier:value; 45, identifier:path; 46, if_statement; 46, 47; 46, 54; 47, boolean_operator:and; 47, 48; 47, 51; 48, comparison_operator:is; 48, 49; 48, 50; 49, identifier:max_; 50, None; 51, comparison_operator:<; 51, 52; 51, 53; 52, identifier:max_; 53, identifier:value; 54, block; 54, 55; 55, expression_statement; 55, 56; 56, call; 56, 57; 56, 62; 57, attribute; 57, 58; 57, 61; 58, attribute; 58, 59; 58, 60; 59, identifier:self; 60, identifier:errors; 61, identifier:append; 62, argument_list; 62, 63; 63, call; 63, 64; 63, 67; 64, attribute; 64, 65; 64, 66; 65, identifier:SchemaError; 66, identifier:SchemaErrorEntry; 67, argument_list; 67, 68; 67, 71; 67, 74; 67, 88; 67, 91; 68, keyword_argument; 68, 69; 68, 70; 69, identifier:msg; 70, string:u"Type '{prefix}' has size of '{value}', greater than max limit '{max_}'. Path: '{path}'"; 71, keyword_argument; 71, 72; 71, 73; 72, identifier:path; 73, identifier:path; 74, keyword_argument; 74, 75; 74, 76; 75, identifier:value; 76, conditional_expression:if; 76, 77; 76, 81; 76, 87; 77, call; 77, 78; 77, 79; 78, identifier:nativestr; 79, argument_list; 79, 80; 80, identifier:value; 81, call; 81, 82; 81, 85; 82, subscript; 82, 83; 82, 84; 83, identifier:tt; 84, string:'str'; 85, argument_list; 85, 86; 86, identifier:value; 87, identifier:value; 88, keyword_argument; 88, 89; 88, 90; 89, identifier:prefix; 90, identifier:prefix; 91, keyword_argument; 91, 92; 91, 93; 92, identifier:max_; 93, identifier:max_; 94, if_statement; 94, 95; 94, 102; 95, boolean_operator:and; 95, 96; 95, 99; 96, comparison_operator:is; 96, 97; 96, 98; 97, identifier:min_; 98, None; 99, comparison_operator:>; 99, 100; 99, 101; 100, identifier:min_; 101, identifier:value; 102, block; 102, 103; 103, expression_statement; 103, 104; 104, call; 104, 105; 104, 110; 105, attribute; 105, 106; 105, 109; 106, attribute; 106, 107; 106, 108; 107, identifier:self; 108, identifier:errors; 109, identifier:append; 110, argument_list; 110, 111; 111, call; 111, 112; 111, 115; 112, attribute; 112, 113; 112, 114; 113, identifier:SchemaError; 114, identifier:SchemaErrorEntry; 115, argument_list; 115, 116; 115, 119; 115, 122; 115, 136; 115, 139; 116, keyword_argument; 116, 117; 116, 118; 117, identifier:msg; 118, string:u"Type '{prefix}' has size of '{value}', less than min limit '{min_}'. Path: '{path}'"; 119, keyword_argument; 119, 120; 119, 121; 120, identifier:path; 121, identifier:path; 122, keyword_argument; 122, 123; 122, 124; 123, identifier:value; 124, conditional_expression:if; 124, 125; 124, 129; 124, 135; 125, call; 125, 126; 125, 127; 126, identifier:nativestr; 127, argument_list; 127, 128; 128, identifier:value; 129, call; 129, 130; 129, 133; 130, subscript; 130, 131; 130, 132; 131, identifier:tt; 132, string:'str'; 133, argument_list; 133, 134; 134, identifier:value; 135, identifier:value; 136, keyword_argument; 136, 137; 136, 138; 137, identifier:prefix; 138, identifier:prefix; 139, keyword_argument; 139, 140; 139, 141; 140, identifier:min_; 141, identifier:min_; 142, if_statement; 142, 143; 142, 150; 143, boolean_operator:and; 143, 144; 143, 147; 144, comparison_operator:is; 144, 145; 144, 146; 145, identifier:max_ex; 146, None; 147, comparison_operator:<=; 147, 148; 147, 149; 148, identifier:max_ex; 149, identifier:value; 150, block; 150, 151; 151, expression_statement; 151, 152; 152, call; 152, 153; 152, 158; 153, attribute; 153, 154; 153, 157; 154, attribute; 154, 155; 154, 156; 155, identifier:self; 156, identifier:errors; 157, identifier:append; 158, argument_list; 158, 159; 159, call; 159, 160; 159, 163; 160, attribute; 160, 161; 160, 162; 161, identifier:SchemaError; 162, identifier:SchemaErrorEntry; 163, argument_list; 163, 164; 163, 167; 163, 170; 163, 184; 163, 187; 164, keyword_argument; 164, 165; 164, 166; 165, identifier:msg; 166, string:u"Type '{prefix}' has size of '{value}', greater than or equals to max limit(exclusive) '{max_ex}'. Path: '{path}'"; 167, keyword_argument; 167, 168; 167, 169; 168, identifier:path; 169, identifier:path; 170, keyword_argument; 170, 171; 170, 172; 171, identifier:value; 172, conditional_expression:if; 172, 173; 172, 177; 172, 183; 173, call; 173, 174; 173, 175; 174, identifier:nativestr; 175, argument_list; 175, 176; 176, identifier:value; 177, call; 177, 178; 177, 181; 178, subscript; 178, 179; 178, 180; 179, identifier:tt; 180, string:'str'; 181, argument_list; 181, 182; 182, identifier:value; 183, identifier:value; 184, keyword_argument; 184, 185; 184, 186; 185, identifier:prefix; 186, identifier:prefix; 187, keyword_argument; 187, 188; 187, 189; 188, identifier:max_ex; 189, identifier:max_ex; 190, if_statement; 190, 191; 190, 198; 191, boolean_operator:and; 191, 192; 191, 195; 192, comparison_operator:is; 192, 193; 192, 194; 193, identifier:min_ex; 194, None; 195, comparison_operator:>=; 195, 196; 195, 197; 196, identifier:min_ex; 197, identifier:value; 198, block; 198, 199; 199, expression_statement; 199, 200; 200, call; 200, 201; 200, 206; 201, attribute; 201, 202; 201, 205; 202, attribute; 202, 203; 202, 204; 203, identifier:self; 204, identifier:errors; 205, identifier:append; 206, argument_list; 206, 207; 207, call; 207, 208; 207, 211; 208, attribute; 208, 209; 208, 210; 209, identifier:SchemaError; 210, identifier:SchemaErrorEntry; 211, argument_list; 211, 212; 211, 215; 211, 218; 211, 232; 211, 235; 212, keyword_argument; 212, 213; 212, 214; 213, identifier:msg; 214, string:u"Type '{prefix}' has size of '{value}', less than or equals to min limit(exclusive) '{min_ex}'. Path: '{path}'"; 215, keyword_argument; 215, 216; 215, 217; 216, identifier:path; 217, identifier:path; 218, keyword_argument; 218, 219; 218, 220; 219, identifier:value; 220, conditional_expression:if; 220, 221; 220, 225; 220, 231; 221, call; 221, 222; 221, 223; 222, identifier:nativestr; 223, argument_list; 223, 224; 224, identifier:value; 225, call; 225, 226; 225, 229; 226, subscript; 226, 227; 226, 228; 227, identifier:tt; 228, string:'str'; 229, argument_list; 229, 230; 230, identifier:value; 231, identifier:value; 232, keyword_argument; 232, 233; 232, 234; 233, identifier:prefix; 234, identifier:prefix; 235, keyword_argument; 235, 236; 235, 237; 236, identifier:min_ex; 237, identifier:min_ex
def _validate_range(self, max_, min_, max_ex, min_ex, value, path, prefix): if not isinstance(value, int) and not isinstance(value, float): raise CoreError("Value must be a integer type") log.debug( u"Validate range : %s : %s : %s : %s : %s : %s", max_, min_, max_ex, min_ex, value, path, ) if max_ is not None and max_ < value: self.errors.append(SchemaError.SchemaErrorEntry( msg=u"Type '{prefix}' has size of '{value}', greater than max limit '{max_}'. Path: '{path}'", path=path, value=nativestr(value) if tt['str'](value) else value, prefix=prefix, max_=max_)) if min_ is not None and min_ > value: self.errors.append(SchemaError.SchemaErrorEntry( msg=u"Type '{prefix}' has size of '{value}', less than min limit '{min_}'. Path: '{path}'", path=path, value=nativestr(value) if tt['str'](value) else value, prefix=prefix, min_=min_)) if max_ex is not None and max_ex <= value: self.errors.append(SchemaError.SchemaErrorEntry( msg=u"Type '{prefix}' has size of '{value}', greater than or equals to max limit(exclusive) '{max_ex}'. Path: '{path}'", path=path, value=nativestr(value) if tt['str'](value) else value, prefix=prefix, max_ex=max_ex)) if min_ex is not None and min_ex >= value: self.errors.append(SchemaError.SchemaErrorEntry( msg=u"Type '{prefix}' has size of '{value}', less than or equals to min limit(exclusive) '{min_ex}'. Path: '{path}'", path=path, value=nativestr(value) if tt['str'](value) else value, prefix=prefix, min_ex=min_ex))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 23; 2, function_name:tsses; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 4, identifier:db; 5, default_parameter; 5, 6; 5, 7; 6, identifier:merge_overlapping; 7, False; 8, default_parameter; 8, 9; 8, 10; 9, identifier:attrs; 10, None; 11, default_parameter; 11, 12; 11, 13; 12, identifier:attrs_sep; 13, string:":"; 14, default_parameter; 14, 15; 14, 16; 15, identifier:merge_kwargs; 16, None; 17, default_parameter; 17, 18; 17, 19; 18, identifier:as_bed6; 19, False; 20, default_parameter; 20, 21; 20, 22; 21, identifier:bedtools_227_or_later; 22, True; 23, block; 23, 24; 23, 36; 23, 73; 23, 108; 23, 120; 23, 188; 23, 203; 23, 227; 23, 306; 23, 384; 24, expression_statement; 24, 25; 25, assignment; 25, 26; 25, 27; 26, identifier:_override; 27, call; 27, 28; 27, 33; 28, attribute; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, identifier:os; 31, identifier:environ; 32, identifier:get; 33, argument_list; 33, 34; 33, 35; 34, string:'GFFUTILS_USES_BEDTOOLS_227_OR_LATER'; 35, None; 36, if_statement; 36, 37; 36, 40; 37, comparison_operator:is; 37, 38; 37, 39; 38, identifier:_override; 39, None; 40, block; 40, 41; 41, if_statement; 41, 42; 41, 45; 41, 50; 41, 59; 42, comparison_operator:==; 42, 43; 42, 44; 43, identifier:_override; 44, string:'true'; 45, block; 45, 46; 46, expression_statement; 46, 47; 47, assignment; 47, 48; 47, 49; 48, identifier:bedtools_227_or_later; 49, True; 50, elif_clause; 50, 51; 50, 54; 51, comparison_operator:==; 51, 52; 51, 53; 52, identifier:_override; 53, string:'false'; 54, block; 54, 55; 55, expression_statement; 55, 56; 56, assignment; 56, 57; 56, 58; 57, identifier:bedtools_227_or_later; 58, False; 59, else_clause; 59, 60; 60, block; 60, 61; 61, raise_statement; 61, 62; 62, call; 62, 63; 62, 64; 63, identifier:ValueError; 64, argument_list; 64, 65; 65, call; 65, 66; 65, 71; 66, attribute; 66, 67; 66, 70; 67, concatenated_string; 67, 68; 67, 69; 68, string:"Unknown value for GFFUTILS_USES_BEDTOOLS_227_OR_LATER "; 69, string:"environment variable: {0}"; 70, identifier:format; 71, argument_list; 71, 72; 72, identifier:_override; 73, if_statement; 73, 74; 73, 75; 73, 91; 74, identifier:bedtools_227_or_later; 75, block; 75, 76; 76, expression_statement; 76, 77; 77, assignment; 77, 78; 77, 79; 78, identifier:_merge_kwargs; 79, call; 79, 80; 79, 81; 80, identifier:dict; 81, argument_list; 81, 82; 81, 85; 81, 88; 82, keyword_argument; 82, 83; 82, 84; 83, identifier:o; 84, string:'distinct'; 85, keyword_argument; 85, 86; 85, 87; 86, identifier:s; 87, True; 88, keyword_argument; 88, 89; 88, 90; 89, identifier:c; 90, string:'4,5,6'; 91, else_clause; 91, 92; 92, block; 92, 93; 93, expression_statement; 93, 94; 94, assignment; 94, 95; 94, 96; 95, identifier:_merge_kwargs; 96, call; 96, 97; 96, 98; 97, identifier:dict; 98, argument_list; 98, 99; 98, 102; 98, 105; 99, keyword_argument; 99, 100; 99, 101; 100, identifier:o; 101, string:'distinct'; 102, keyword_argument; 102, 103; 102, 104; 103, identifier:s; 104, True; 105, keyword_argument; 105, 106; 105, 107; 106, identifier:c; 107, string:'4'; 108, if_statement; 108, 109; 108, 112; 109, comparison_operator:is; 109, 110; 109, 111; 110, identifier:merge_kwargs; 111, None; 112, block; 112, 113; 113, expression_statement; 113, 114; 114, call; 114, 115; 114, 118; 115, attribute; 115, 116; 115, 117; 116, identifier:_merge_kwargs; 117, identifier:update; 118, argument_list; 118, 119; 119, identifier:merge_kwargs; 120, function_definition; 120, 121; 120, 122; 120, 123; 121, function_name:gen; 122, parameters; 123, block; 123, 124; 124, for_statement; 124, 125; 124, 126; 124, 132; 125, identifier:gene; 126, call; 126, 127; 126, 130; 127, attribute; 127, 128; 127, 129; 128, identifier:db; 129, identifier:features_of_type; 130, argument_list; 130, 131; 131, string:'gene'; 132, block; 132, 133; 133, for_statement; 133, 134; 133, 135; 133, 144; 134, identifier:transcript; 135, call; 135, 136; 135, 139; 136, attribute; 136, 137; 136, 138; 137, identifier:db; 138, identifier:children; 139, argument_list; 139, 140; 139, 141; 140, identifier:gene; 141, keyword_argument; 141, 142; 141, 143; 142, identifier:level; 143, integer:1; 144, block; 144, 145; 144, 170; 144, 180; 145, if_statement; 145, 146; 145, 151; 145, 160; 146, comparison_operator:==; 146, 147; 146, 150; 147, attribute; 147, 148; 147, 149; 148, identifier:transcript; 149, identifier:strand; 150, string:'-'; 151, block; 151, 152; 152, expression_statement; 152, 153; 153, assignment; 153, 154; 153, 157; 154, attribute; 154, 155; 154, 156; 155, identifier:transcript; 156, identifier:start; 157, attribute; 157, 158; 157, 159; 158, identifier:transcript; 159, identifier:stop; 160, else_clause; 160, 161; 161, block; 161, 162; 162, expression_statement; 162, 163; 163, assignment; 163, 164; 163, 167; 164, attribute; 164, 165; 164, 166; 165, identifier:transcript; 166, identifier:stop; 167, attribute; 167, 168; 167, 169; 168, identifier:transcript; 169, identifier:start; 170, expression_statement; 170, 171; 171, assignment; 171, 172; 171, 175; 172, attribute; 172, 173; 172, 174; 173, identifier:transcript; 174, identifier:featuretype; 175, binary_operator:+; 175, 176; 175, 179; 176, attribute; 176, 177; 176, 178; 177, identifier:transcript; 178, identifier:featuretype; 179, string:'_TSS'; 180, expression_statement; 180, 181; 181, yield; 181, 182; 182, call; 182, 183; 182, 186; 183, attribute; 183, 184; 183, 185; 184, identifier:helpers; 185, identifier:asinterval; 186, argument_list; 186, 187; 187, identifier:transcript; 188, expression_statement; 188, 189; 189, assignment; 189, 190; 189, 191; 190, identifier:x; 191, call; 191, 192; 191, 202; 192, attribute; 192, 193; 192, 201; 193, call; 193, 194; 193, 197; 194, attribute; 194, 195; 194, 196; 195, identifier:pybedtools; 196, identifier:BedTool; 197, argument_list; 197, 198; 198, call; 198, 199; 198, 200; 199, identifier:gen; 200, argument_list; 201, identifier:sort; 202, argument_list; 203, if_statement; 203, 204; 203, 207; 204, comparison_operator:is; 204, 205; 204, 206; 205, identifier:attrs; 206, None; 207, block; 207, 208; 208, if_statement; 208, 209; 208, 216; 208, 221; 209, comparison_operator:==; 209, 210; 209, 215; 210, subscript; 210, 211; 210, 214; 211, attribute; 211, 212; 211, 213; 212, identifier:db; 213, identifier:dialect; 214, string:'fmt'; 215, string:'gtf'; 216, block; 216, 217; 217, expression_statement; 217, 218; 218, assignment; 218, 219; 218, 220; 219, identifier:attrs; 220, string:'gene_id'; 221, else_clause; 221, 222; 222, block; 222, 223; 223, expression_statement; 223, 224; 224, assignment; 224, 225; 224, 226; 225, identifier:attrs; 226, string:'ID'; 227, if_statement; 227, 228; 227, 231; 228, boolean_operator:or; 228, 229; 228, 230; 229, identifier:merge_overlapping; 230, identifier:as_bed6; 231, block; 231, 232; 231, 246; 231, 293; 232, if_statement; 232, 233; 232, 240; 233, call; 233, 234; 233, 235; 234, identifier:isinstance; 235, argument_list; 235, 236; 235, 237; 236, identifier:attrs; 237, attribute; 237, 238; 237, 239; 238, identifier:six; 239, identifier:string_types; 240, block; 240, 241; 241, expression_statement; 241, 242; 242, assignment; 242, 243; 242, 244; 243, identifier:attrs; 244, list:[attrs]; 244, 245; 245, identifier:attrs; 246, function_definition; 246, 247; 246, 248; 246, 250; 247, function_name:to_bed; 248, parameters; 248, 249; 249, identifier:f; 250, block; 250, 251; 250, 268; 251, expression_statement; 251, 252; 252, assignment; 252, 253; 252, 254; 253, identifier:name; 254, call; 254, 255; 254, 258; 255, attribute; 255, 256; 255, 257; 256, identifier:attrs_sep; 257, identifier:join; 258, argument_list; 258, 259; 259, list_comprehension; 259, 260; 259, 265; 260, subscript; 260, 261; 260, 264; 261, attribute; 261, 262; 261, 263; 262, identifier:f; 263, identifier:attrs; 264, identifier:i; 265, for_in_clause; 265, 266; 265, 267; 266, identifier:i; 267, identifier:attrs; 268, return_statement; 268, 269; 269, call; 269, 270; 269, 273; 270, attribute; 270, 271; 270, 272; 271, identifier:pybedtools; 272, identifier:Interval; 273, argument_list; 273, 274; 273, 277; 273, 280; 273, 283; 273, 284; 273, 290; 274, attribute; 274, 275; 274, 276; 275, identifier:f; 276, identifier:chrom; 277, attribute; 277, 278; 277, 279; 278, identifier:f; 279, identifier:start; 280, attribute; 280, 281; 280, 282; 281, identifier:f; 282, identifier:stop; 283, identifier:name; 284, call; 284, 285; 284, 286; 285, identifier:str; 286, argument_list; 286, 287; 287, attribute; 287, 288; 287, 289; 288, identifier:f; 289, identifier:score; 290, attribute; 290, 291; 290, 292; 291, identifier:f; 292, identifier:strand; 293, expression_statement; 293, 294; 294, assignment; 294, 295; 294, 296; 295, identifier:x; 296, call; 296, 297; 296, 305; 297, attribute; 297, 298; 297, 304; 298, call; 298, 299; 298, 302; 299, attribute; 299, 300; 299, 301; 300, identifier:x; 301, identifier:each; 302, argument_list; 302, 303; 303, identifier:to_bed; 304, identifier:saveas; 305, argument_list; 306, if_statement; 306, 307; 306, 308; 307, identifier:merge_overlapping; 308, block; 308, 309; 309, if_statement; 309, 310; 309, 311; 309, 322; 310, identifier:bedtools_227_or_later; 311, block; 311, 312; 312, expression_statement; 312, 313; 313, assignment; 313, 314; 313, 315; 314, identifier:x; 315, call; 315, 316; 315, 319; 316, attribute; 316, 317; 316, 318; 317, identifier:x; 318, identifier:merge; 319, argument_list; 319, 320; 320, dictionary_splat; 320, 321; 321, identifier:_merge_kwargs; 322, else_clause; 322, 323; 323, block; 323, 324; 323, 361; 324, function_definition; 324, 325; 324, 326; 324, 328; 325, function_name:fix_merge; 326, parameters; 326, 327; 327, identifier:f; 328, block; 328, 329; 328, 339; 329, expression_statement; 329, 330; 330, assignment; 330, 331; 330, 332; 331, identifier:f; 332, call; 332, 333; 332, 336; 333, attribute; 333, 334; 333, 335; 334, identifier:featurefuncs; 335, identifier:extend_fields; 336, argument_list; 336, 337; 336, 338; 337, identifier:f; 338, integer:6; 339, return_statement; 339, 340; 340, call; 340, 341; 340, 344; 341, attribute; 341, 342; 341, 343; 342, identifier:pybedtools; 343, identifier:Interval; 344, argument_list; 344, 345; 344, 348; 344, 351; 344, 354; 344, 357; 344, 358; 345, attribute; 345, 346; 345, 347; 346, identifier:f; 347, identifier:chrom; 348, attribute; 348, 349; 348, 350; 349, identifier:f; 350, identifier:start; 351, attribute; 351, 352; 351, 353; 352, identifier:f; 353, identifier:stop; 354, subscript; 354, 355; 354, 356; 355, identifier:f; 356, integer:4; 357, string:'.'; 358, subscript; 358, 359; 358, 360; 359, identifier:f; 360, integer:3; 361, expression_statement; 361, 362; 362, assignment; 362, 363; 362, 364; 363, identifier:x; 364, call; 364, 365; 364, 383; 365, attribute; 365, 366; 365, 382; 366, call; 366, 367; 366, 380; 367, attribute; 367, 368; 367, 379; 368, call; 368, 369; 368, 378; 369, attribute; 369, 370; 369, 377; 370, call; 370, 371; 370, 374; 371, attribute; 371, 372; 371, 373; 372, identifier:x; 373, identifier:merge; 374, argument_list; 374, 375; 375, dictionary_splat; 375, 376; 376, identifier:_merge_kwargs; 377, identifier:saveas; 378, argument_list; 379, identifier:each; 380, argument_list; 380, 381; 381, identifier:fix_merge; 382, identifier:saveas; 383, argument_list; 384, return_statement; 384, 385; 385, identifier:x
def tsses(db, merge_overlapping=False, attrs=None, attrs_sep=":", merge_kwargs=None, as_bed6=False, bedtools_227_or_later=True): _override = os.environ.get('GFFUTILS_USES_BEDTOOLS_227_OR_LATER', None) if _override is not None: if _override == 'true': bedtools_227_or_later = True elif _override == 'false': bedtools_227_or_later = False else: raise ValueError( "Unknown value for GFFUTILS_USES_BEDTOOLS_227_OR_LATER " "environment variable: {0}".format(_override)) if bedtools_227_or_later: _merge_kwargs = dict(o='distinct', s=True, c='4,5,6') else: _merge_kwargs = dict(o='distinct', s=True, c='4') if merge_kwargs is not None: _merge_kwargs.update(merge_kwargs) def gen(): for gene in db.features_of_type('gene'): for transcript in db.children(gene, level=1): if transcript.strand == '-': transcript.start = transcript.stop else: transcript.stop = transcript.start transcript.featuretype = transcript.featuretype + '_TSS' yield helpers.asinterval(transcript) x = pybedtools.BedTool(gen()).sort() if attrs is None: if db.dialect['fmt'] == 'gtf': attrs = 'gene_id' else: attrs = 'ID' if merge_overlapping or as_bed6: if isinstance(attrs, six.string_types): attrs = [attrs] def to_bed(f): name = attrs_sep.join([f.attrs[i] for i in attrs]) return pybedtools.Interval( f.chrom, f.start, f.stop, name, str(f.score), f.strand) x = x.each(to_bed).saveas() if merge_overlapping: if bedtools_227_or_later: x = x.merge(**_merge_kwargs) else: def fix_merge(f): f = featurefuncs.extend_fields(f, 6) return pybedtools.Interval( f.chrom, f.start, f.stop, f[4], '.', f[3]) x = x.merge(**_merge_kwargs).saveas().each(fix_merge).saveas() return x
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 21; 2, function_name:interfeatures; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 15; 3, 18; 4, identifier:self; 5, identifier:features; 6, default_parameter; 6, 7; 6, 8; 7, identifier:new_featuretype; 8, None; 9, default_parameter; 9, 10; 9, 11; 10, identifier:merge_attributes; 11, True; 12, default_parameter; 12, 13; 12, 14; 13, identifier:dialect; 14, None; 15, default_parameter; 15, 16; 15, 17; 16, identifier:attribute_func; 17, None; 18, default_parameter; 18, 19; 18, 20; 19, identifier:update_attributes; 20, None; 21, block; 21, 22; 22, for_statement; 22, 23; 22, 26; 22, 30; 23, pattern_list; 23, 24; 23, 25; 24, identifier:i; 25, identifier:f; 26, call; 26, 27; 26, 28; 27, identifier:enumerate; 28, argument_list; 28, 29; 29, identifier:features; 30, block; 30, 31; 30, 47; 30, 53; 30, 70; 30, 91; 30, 105; 30, 109; 30, 115; 30, 119; 30, 123; 30, 146; 30, 156; 30, 169; 30, 173; 30, 209; 30, 229; 30, 238; 31, if_statement; 31, 32; 31, 35; 32, comparison_operator:==; 32, 33; 32, 34; 33, identifier:i; 34, integer:0; 35, block; 35, 36; 35, 42; 35, 46; 36, expression_statement; 36, 37; 37, assignment; 37, 38; 37, 39; 38, identifier:interfeature_start; 39, attribute; 39, 40; 39, 41; 40, identifier:f; 41, identifier:stop; 42, expression_statement; 42, 43; 43, assignment; 43, 44; 43, 45; 44, identifier:last_feature; 45, identifier:f; 46, continue_statement; 47, expression_statement; 47, 48; 48, assignment; 48, 49; 48, 50; 49, identifier:interfeature_stop; 50, attribute; 50, 51; 50, 52; 51, identifier:f; 52, identifier:start; 53, if_statement; 53, 54; 53, 57; 54, comparison_operator:is; 54, 55; 54, 56; 55, identifier:new_featuretype; 56, None; 57, block; 57, 58; 58, expression_statement; 58, 59; 59, assignment; 59, 60; 59, 61; 60, identifier:new_featuretype; 61, binary_operator:%; 61, 62; 61, 63; 62, string:'inter_%s_%s'; 63, tuple; 63, 64; 63, 67; 64, attribute; 64, 65; 64, 66; 65, identifier:last_feature; 66, identifier:featuretype; 67, attribute; 67, 68; 67, 69; 68, identifier:f; 69, identifier:featuretype; 70, if_statement; 70, 71; 70, 78; 70, 83; 71, comparison_operator:!=; 71, 72; 71, 75; 72, attribute; 72, 73; 72, 74; 73, identifier:last_feature; 74, identifier:strand; 75, attribute; 75, 76; 75, 77; 76, identifier:f; 77, identifier:strand; 78, block; 78, 79; 79, expression_statement; 79, 80; 80, assignment; 80, 81; 80, 82; 81, identifier:new_strand; 82, string:'.'; 83, else_clause; 83, 84; 84, block; 84, 85; 85, expression_statement; 85, 86; 86, assignment; 86, 87; 86, 88; 87, identifier:new_strand; 88, attribute; 88, 89; 88, 90; 89, identifier:f; 90, identifier:strand; 91, if_statement; 91, 92; 91, 99; 92, comparison_operator:!=; 92, 93; 92, 96; 93, attribute; 93, 94; 93, 95; 94, identifier:last_feature; 95, identifier:chrom; 96, attribute; 96, 97; 96, 98; 97, identifier:f; 98, identifier:chrom; 99, block; 99, 100; 99, 104; 100, expression_statement; 100, 101; 101, assignment; 101, 102; 101, 103; 102, identifier:last_feature; 103, identifier:f; 104, continue_statement; 105, expression_statement; 105, 106; 106, assignment; 106, 107; 106, 108; 107, identifier:strand; 108, identifier:new_strand; 109, expression_statement; 109, 110; 110, assignment; 110, 111; 110, 112; 111, identifier:chrom; 112, attribute; 112, 113; 112, 114; 113, identifier:last_feature; 114, identifier:chrom; 115, expression_statement; 115, 116; 116, augmented_assignment:+=; 116, 117; 116, 118; 117, identifier:interfeature_start; 118, integer:1; 119, expression_statement; 119, 120; 120, augmented_assignment:-=; 120, 121; 120, 122; 121, identifier:interfeature_stop; 122, integer:1; 123, if_statement; 123, 124; 123, 125; 123, 140; 124, identifier:merge_attributes; 125, block; 125, 126; 126, expression_statement; 126, 127; 127, assignment; 127, 128; 127, 129; 128, identifier:new_attributes; 129, call; 129, 130; 129, 133; 130, attribute; 130, 131; 130, 132; 131, identifier:helpers; 132, identifier:merge_attributes; 133, argument_list; 133, 134; 133, 137; 134, attribute; 134, 135; 134, 136; 135, identifier:last_feature; 136, identifier:attributes; 137, attribute; 137, 138; 137, 139; 138, identifier:f; 139, identifier:attributes; 140, else_clause; 140, 141; 141, block; 141, 142; 142, expression_statement; 142, 143; 143, assignment; 143, 144; 143, 145; 144, identifier:new_attributes; 145, dictionary; 146, if_statement; 146, 147; 146, 148; 147, identifier:update_attributes; 148, block; 148, 149; 149, expression_statement; 149, 150; 150, call; 150, 151; 150, 154; 151, attribute; 151, 152; 151, 153; 152, identifier:new_attributes; 153, identifier:update; 154, argument_list; 154, 155; 155, identifier:update_attributes; 156, expression_statement; 156, 157; 157, assignment; 157, 158; 157, 159; 158, identifier:new_bin; 159, call; 159, 160; 159, 163; 160, attribute; 160, 161; 160, 162; 161, identifier:bins; 162, identifier:bins; 163, argument_list; 163, 164; 163, 165; 163, 166; 164, identifier:interfeature_start; 165, identifier:interfeature_stop; 166, keyword_argument; 166, 167; 166, 168; 167, identifier:one; 168, True; 169, expression_statement; 169, 170; 170, assignment; 170, 171; 170, 172; 171, identifier:_id; 172, None; 173, expression_statement; 173, 174; 174, assignment; 174, 175; 174, 176; 175, identifier:fields; 176, call; 176, 177; 176, 178; 177, identifier:dict; 178, argument_list; 178, 179; 178, 182; 178, 185; 178, 188; 178, 191; 178, 194; 178, 197; 178, 200; 178, 203; 178, 206; 179, keyword_argument; 179, 180; 179, 181; 180, identifier:seqid; 181, identifier:chrom; 182, keyword_argument; 182, 183; 182, 184; 183, identifier:source; 184, string:'gffutils_derived'; 185, keyword_argument; 185, 186; 185, 187; 186, identifier:featuretype; 187, identifier:new_featuretype; 188, keyword_argument; 188, 189; 188, 190; 189, identifier:start; 190, identifier:interfeature_start; 191, keyword_argument; 191, 192; 191, 193; 192, identifier:end; 193, identifier:interfeature_stop; 194, keyword_argument; 194, 195; 194, 196; 195, identifier:score; 196, string:'.'; 197, keyword_argument; 197, 198; 197, 199; 198, identifier:strand; 199, identifier:strand; 200, keyword_argument; 200, 201; 200, 202; 201, identifier:frame; 202, string:'.'; 203, keyword_argument; 203, 204; 203, 205; 204, identifier:attributes; 205, identifier:new_attributes; 206, keyword_argument; 206, 207; 206, 208; 207, identifier:bin; 208, identifier:new_bin; 209, if_statement; 209, 210; 209, 213; 210, comparison_operator:is; 210, 211; 210, 212; 211, identifier:dialect; 212, None; 213, block; 213, 214; 214, try_statement; 214, 215; 214, 222; 215, block; 215, 216; 216, expression_statement; 216, 217; 217, assignment; 217, 218; 217, 219; 218, identifier:dialect; 219, attribute; 219, 220; 219, 221; 220, identifier:self; 221, identifier:dialect; 222, except_clause; 222, 223; 222, 224; 223, identifier:AttributeError; 224, block; 224, 225; 225, expression_statement; 225, 226; 226, assignment; 226, 227; 226, 228; 227, identifier:dialect; 228, None; 229, expression_statement; 229, 230; 230, yield; 230, 231; 231, call; 231, 232; 231, 235; 232, attribute; 232, 233; 232, 234; 233, identifier:self; 234, identifier:_feature_returner; 235, argument_list; 235, 236; 236, dictionary_splat; 236, 237; 237, identifier:fields; 238, expression_statement; 238, 239; 239, assignment; 239, 240; 239, 241; 240, identifier:interfeature_start; 241, attribute; 241, 242; 241, 243; 242, identifier:f; 243, identifier:stop
def interfeatures(self, features, new_featuretype=None, merge_attributes=True, dialect=None, attribute_func=None, update_attributes=None): for i, f in enumerate(features): if i == 0: interfeature_start = f.stop last_feature = f continue interfeature_stop = f.start if new_featuretype is None: new_featuretype = 'inter_%s_%s' % ( last_feature.featuretype, f.featuretype) if last_feature.strand != f.strand: new_strand = '.' else: new_strand = f.strand if last_feature.chrom != f.chrom: last_feature = f continue strand = new_strand chrom = last_feature.chrom interfeature_start += 1 interfeature_stop -= 1 if merge_attributes: new_attributes = helpers.merge_attributes( last_feature.attributes, f.attributes) else: new_attributes = {} if update_attributes: new_attributes.update(update_attributes) new_bin = bins.bins( interfeature_start, interfeature_stop, one=True) _id = None fields = dict( seqid=chrom, source='gffutils_derived', featuretype=new_featuretype, start=interfeature_start, end=interfeature_stop, score='.', strand=strand, frame='.', attributes=new_attributes, bin=new_bin) if dialect is None: try: dialect = self.dialect except AttributeError: dialect = None yield self._feature_returner(**fields) interfeature_start = f.stop
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:update; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 4, identifier:self; 5, identifier:data; 6, default_parameter; 6, 7; 6, 8; 7, identifier:make_backup; 8, True; 9, dictionary_splat_pattern; 9, 10; 10, identifier:kwargs; 11, block; 11, 12; 11, 17; 11, 22; 11, 50; 11, 54; 11, 77; 11, 88; 11, 184; 11, 191; 11, 197; 11, 203; 12, import_from_statement; 12, 13; 12, 15; 13, dotted_name; 13, 14; 14, identifier:gffutils; 15, dotted_name; 15, 16; 16, identifier:create; 17, import_from_statement; 17, 18; 17, 20; 18, dotted_name; 18, 19; 19, identifier:gffutils; 20, dotted_name; 20, 21; 21, identifier:iterators; 22, if_statement; 22, 23; 22, 24; 23, identifier:make_backup; 24, block; 24, 25; 25, if_statement; 25, 26; 25, 35; 26, call; 26, 27; 26, 28; 27, identifier:isinstance; 28, argument_list; 28, 29; 28, 32; 29, attribute; 29, 30; 29, 31; 30, identifier:self; 31, identifier:dbfn; 32, attribute; 32, 33; 32, 34; 33, identifier:six; 34, identifier:string_types; 35, block; 35, 36; 36, expression_statement; 36, 37; 37, call; 37, 38; 37, 41; 38, attribute; 38, 39; 38, 40; 39, identifier:shutil; 40, identifier:copy2; 41, argument_list; 41, 42; 41, 45; 42, attribute; 42, 43; 42, 44; 43, identifier:self; 44, identifier:dbfn; 45, binary_operator:+; 45, 46; 45, 49; 46, attribute; 46, 47; 46, 48; 47, identifier:self; 48, identifier:dbfn; 49, string:'.bak'; 50, expression_statement; 50, 51; 51, assignment; 51, 52; 51, 53; 52, identifier:_iterator_kwargs; 53, dictionary; 54, for_statement; 54, 55; 54, 58; 54, 63; 55, pattern_list; 55, 56; 55, 57; 56, identifier:k; 57, identifier:v; 58, call; 58, 59; 58, 62; 59, attribute; 59, 60; 59, 61; 60, identifier:kwargs; 61, identifier:items; 62, argument_list; 63, block; 63, 64; 64, if_statement; 64, 65; 64, 70; 65, comparison_operator:in; 65, 66; 65, 67; 66, identifier:k; 67, attribute; 67, 68; 67, 69; 68, identifier:constants; 69, identifier:_iterator_kwargs; 70, block; 70, 71; 71, expression_statement; 71, 72; 72, assignment; 72, 73; 72, 76; 73, subscript; 73, 74; 73, 75; 74, identifier:_iterator_kwargs; 75, identifier:k; 76, identifier:v; 77, expression_statement; 77, 78; 78, assignment; 78, 79; 78, 80; 79, identifier:data; 80, call; 80, 81; 80, 84; 81, attribute; 81, 82; 81, 83; 82, identifier:iterators; 83, identifier:DataIterator; 84, argument_list; 84, 85; 84, 86; 85, identifier:data; 86, dictionary_splat; 86, 87; 87, identifier:_iterator_kwargs; 88, if_statement; 88, 89; 88, 96; 88, 137; 88, 180; 89, comparison_operator:==; 89, 90; 89, 95; 90, subscript; 90, 91; 90, 94; 91, attribute; 91, 92; 91, 93; 92, identifier:self; 93, identifier:dialect; 94, string:'fmt'; 95, string:'gtf'; 96, block; 96, 97; 96, 114; 97, if_statement; 97, 98; 97, 101; 98, comparison_operator:not; 98, 99; 98, 100; 99, string:'id_spec'; 100, identifier:kwargs; 101, block; 101, 102; 102, expression_statement; 102, 103; 103, assignment; 103, 104; 103, 107; 104, subscript; 104, 105; 104, 106; 105, identifier:kwargs; 106, string:'id_spec'; 107, dictionary; 107, 108; 107, 111; 108, pair; 108, 109; 108, 110; 109, string:'gene'; 110, string:'gene_id'; 111, pair; 111, 112; 111, 113; 112, string:'transcript'; 113, string:'transcript_id'; 114, expression_statement; 114, 115; 115, assignment; 115, 116; 115, 117; 116, identifier:db; 117, call; 117, 118; 117, 121; 118, attribute; 118, 119; 118, 120; 119, identifier:create; 120, identifier:_GTFDBCreator; 121, argument_list; 121, 122; 121, 125; 121, 130; 121, 135; 122, keyword_argument; 122, 123; 122, 124; 123, identifier:data; 124, identifier:data; 125, keyword_argument; 125, 126; 125, 127; 126, identifier:dbfn; 127, attribute; 127, 128; 127, 129; 128, identifier:self; 129, identifier:dbfn; 130, keyword_argument; 130, 131; 130, 132; 131, identifier:dialect; 132, attribute; 132, 133; 132, 134; 133, identifier:self; 134, identifier:dialect; 135, dictionary_splat; 135, 136; 136, identifier:kwargs; 137, elif_clause; 137, 138; 137, 145; 138, comparison_operator:==; 138, 139; 138, 144; 139, subscript; 139, 140; 139, 143; 140, attribute; 140, 141; 140, 142; 141, identifier:self; 142, identifier:dialect; 143, string:'fmt'; 144, string:'gff3'; 145, block; 145, 146; 145, 157; 146, if_statement; 146, 147; 146, 150; 147, comparison_operator:not; 147, 148; 147, 149; 148, string:'id_spec'; 149, identifier:kwargs; 150, block; 150, 151; 151, expression_statement; 151, 152; 152, assignment; 152, 153; 152, 156; 153, subscript; 153, 154; 153, 155; 154, identifier:kwargs; 155, string:'id_spec'; 156, string:'ID'; 157, expression_statement; 157, 158; 158, assignment; 158, 159; 158, 160; 159, identifier:db; 160, call; 160, 161; 160, 164; 161, attribute; 161, 162; 161, 163; 162, identifier:create; 163, identifier:_GFFDBCreator; 164, argument_list; 164, 165; 164, 168; 164, 173; 164, 178; 165, keyword_argument; 165, 166; 165, 167; 166, identifier:data; 167, identifier:data; 168, keyword_argument; 168, 169; 168, 170; 169, identifier:dbfn; 170, attribute; 170, 171; 170, 172; 171, identifier:self; 172, identifier:dbfn; 173, keyword_argument; 173, 174; 173, 175; 174, identifier:dialect; 175, attribute; 175, 176; 175, 177; 176, identifier:self; 177, identifier:dialect; 178, dictionary_splat; 178, 179; 179, identifier:kwargs; 180, else_clause; 180, 181; 181, block; 181, 182; 182, raise_statement; 182, 183; 183, identifier:ValueError; 184, expression_statement; 184, 185; 185, call; 185, 186; 185, 189; 186, attribute; 186, 187; 186, 188; 187, identifier:db; 188, identifier:_populate_from_lines; 189, argument_list; 189, 190; 190, identifier:data; 191, expression_statement; 191, 192; 192, call; 192, 193; 192, 196; 193, attribute; 193, 194; 193, 195; 194, identifier:db; 195, identifier:_update_relations; 196, argument_list; 197, expression_statement; 197, 198; 198, call; 198, 199; 198, 202; 199, attribute; 199, 200; 199, 201; 200, identifier:db; 201, identifier:_finalize; 202, argument_list; 203, return_statement; 203, 204; 204, identifier:db
def update(self, data, make_backup=True, **kwargs): from gffutils import create from gffutils import iterators if make_backup: if isinstance(self.dbfn, six.string_types): shutil.copy2(self.dbfn, self.dbfn + '.bak') _iterator_kwargs = {} for k, v in kwargs.items(): if k in constants._iterator_kwargs: _iterator_kwargs[k] = v data = iterators.DataIterator(data, **_iterator_kwargs) if self.dialect['fmt'] == 'gtf': if 'id_spec' not in kwargs: kwargs['id_spec'] = { 'gene': 'gene_id', 'transcript': 'transcript_id'} db = create._GTFDBCreator( data=data, dbfn=self.dbfn, dialect=self.dialect, **kwargs) elif self.dialect['fmt'] == 'gff3': if 'id_spec' not in kwargs: kwargs['id_spec'] = 'ID' db = create._GFFDBCreator( data=data, dbfn=self.dbfn, dialect=self.dialect, **kwargs) else: raise ValueError db._populate_from_lines(data) db._update_relations() db._finalize() return db
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:create_introns; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:exon_featuretype; 7, string:'exon'; 8, default_parameter; 8, 9; 8, 10; 9, identifier:grandparent_featuretype; 10, string:'gene'; 11, default_parameter; 11, 12; 11, 13; 12, identifier:parent_featuretype; 13, None; 14, default_parameter; 14, 15; 14, 16; 15, identifier:new_featuretype; 16, string:'intron'; 17, default_parameter; 17, 18; 17, 19; 18, identifier:merge_attributes; 19, True; 20, block; 20, 21; 20, 43; 20, 93; 21, if_statement; 21, 22; 21, 35; 22, boolean_operator:or; 22, 23; 22, 27; 23, parenthesized_expression; 23, 24; 24, boolean_operator:and; 24, 25; 24, 26; 25, identifier:grandparent_featuretype; 26, identifier:parent_featuretype; 27, parenthesized_expression; 27, 28; 28, boolean_operator:and; 28, 29; 28, 32; 29, comparison_operator:is; 29, 30; 29, 31; 30, identifier:grandparent_featuretype; 31, None; 32, comparison_operator:is; 32, 33; 32, 34; 33, identifier:parent_featuretype; 34, None; 35, block; 35, 36; 36, raise_statement; 36, 37; 37, call; 37, 38; 37, 39; 38, identifier:ValueError; 39, argument_list; 39, 40; 40, concatenated_string; 40, 41; 40, 42; 41, string:"exactly one of `grandparent_featuretype` or "; 42, string:"`parent_featuretype` should be provided"; 43, if_statement; 43, 44; 43, 45; 43, 74; 44, identifier:grandparent_featuretype; 45, block; 45, 46; 46, function_definition; 46, 47; 46, 48; 46, 49; 47, function_name:child_gen; 48, parameters; 49, block; 49, 50; 50, for_statement; 50, 51; 50, 52; 50, 58; 51, identifier:gene; 52, call; 52, 53; 52, 56; 53, attribute; 53, 54; 53, 55; 54, identifier:self; 55, identifier:features_of_type; 56, argument_list; 56, 57; 57, identifier:grandparent_featuretype; 58, block; 58, 59; 59, for_statement; 59, 60; 59, 61; 59, 70; 60, identifier:child; 61, call; 61, 62; 61, 65; 62, attribute; 62, 63; 62, 64; 63, identifier:self; 64, identifier:children; 65, argument_list; 65, 66; 65, 67; 66, identifier:gene; 67, keyword_argument; 67, 68; 67, 69; 68, identifier:level; 69, integer:1; 70, block; 70, 71; 71, expression_statement; 71, 72; 72, yield; 72, 73; 73, identifier:child; 74, elif_clause; 74, 75; 74, 76; 75, identifier:parent_featuretype; 76, block; 76, 77; 77, function_definition; 77, 78; 77, 79; 77, 80; 78, function_name:child_gen; 79, parameters; 80, block; 80, 81; 81, for_statement; 81, 82; 81, 83; 81, 89; 82, identifier:child; 83, call; 83, 84; 83, 87; 84, attribute; 84, 85; 84, 86; 85, identifier:self; 86, identifier:features_of_type; 87, argument_list; 87, 88; 88, identifier:parent_featuretype; 89, block; 89, 90; 90, expression_statement; 90, 91; 91, yield; 91, 92; 92, identifier:child; 93, for_statement; 93, 94; 93, 95; 93, 98; 94, identifier:child; 95, call; 95, 96; 95, 97; 96, identifier:child_gen; 97, argument_list; 98, block; 98, 99; 98, 117; 99, expression_statement; 99, 100; 100, assignment; 100, 101; 100, 102; 101, identifier:exons; 102, call; 102, 103; 102, 106; 103, attribute; 103, 104; 103, 105; 104, identifier:self; 105, identifier:children; 106, argument_list; 106, 107; 106, 108; 106, 111; 106, 114; 107, identifier:child; 108, keyword_argument; 108, 109; 108, 110; 109, identifier:level; 110, integer:1; 111, keyword_argument; 111, 112; 111, 113; 112, identifier:featuretype; 113, identifier:exon_featuretype; 114, keyword_argument; 114, 115; 114, 116; 115, identifier:order_by; 116, string:'start'; 117, for_statement; 117, 118; 117, 119; 117, 136; 118, identifier:intron; 119, call; 119, 120; 119, 123; 120, attribute; 120, 121; 120, 122; 121, identifier:self; 122, identifier:interfeatures; 123, argument_list; 123, 124; 123, 125; 123, 128; 123, 131; 124, identifier:exons; 125, keyword_argument; 125, 126; 125, 127; 126, identifier:new_featuretype; 127, identifier:new_featuretype; 128, keyword_argument; 128, 129; 128, 130; 129, identifier:merge_attributes; 130, identifier:merge_attributes; 131, keyword_argument; 131, 132; 131, 133; 132, identifier:dialect; 133, attribute; 133, 134; 133, 135; 134, identifier:self; 135, identifier:dialect; 136, block; 136, 137; 137, expression_statement; 137, 138; 138, yield; 138, 139; 139, identifier:intron
def create_introns(self, exon_featuretype='exon', grandparent_featuretype='gene', parent_featuretype=None, new_featuretype='intron', merge_attributes=True): if (grandparent_featuretype and parent_featuretype) or ( grandparent_featuretype is None and parent_featuretype is None ): raise ValueError("exactly one of `grandparent_featuretype` or " "`parent_featuretype` should be provided") if grandparent_featuretype: def child_gen(): for gene in self.features_of_type(grandparent_featuretype): for child in self.children(gene, level=1): yield child elif parent_featuretype: def child_gen(): for child in self.features_of_type(parent_featuretype): yield child for child in child_gen(): exons = self.children(child, level=1, featuretype=exon_featuretype, order_by='start') for intron in self.interfeatures( exons, new_featuretype=new_featuretype, merge_attributes=merge_attributes, dialect=self.dialect ): yield intron