How to use names method in wpt

Best JavaScript code snippet using wpt

cc_toolchain_config.bzl

Source:cc_toolchain_config.bzl Github

copy

Full Screen

1# Copyright 2019 The Bazel Authors. All rights reserved.2#3# Licensed under the Apache License, Version 2.0 (the "License");4# you may not use this file except in compliance with the License.5# You may obtain a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# See the License for the specific language governing permissions and13# limitations under the License.14"""A Starlark cc_toolchain configuration rule"""15load(16 "@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl",17 "action_config",18 "artifact_name_pattern",19 "env_entry",20 "env_set",21 "feature",22 "feature_set",23 "flag_group",24 "flag_set",25 "tool",26 "tool_path",27 "variable_with_value",28 "with_feature_set",29)30load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")31all_compile_actions = [32 ACTION_NAMES.c_compile,33 ACTION_NAMES.cpp_compile,34 ACTION_NAMES.linkstamp_compile,35 ACTION_NAMES.assemble,36 ACTION_NAMES.preprocess_assemble,37 ACTION_NAMES.cpp_header_parsing,38 ACTION_NAMES.cpp_module_compile,39 ACTION_NAMES.cpp_module_codegen,40 ACTION_NAMES.clif_match,41 ACTION_NAMES.lto_backend,42]43all_cpp_compile_actions = [44 ACTION_NAMES.cpp_compile,45 ACTION_NAMES.linkstamp_compile,46 ACTION_NAMES.cpp_header_parsing,47 ACTION_NAMES.cpp_module_compile,48 ACTION_NAMES.cpp_module_codegen,49 ACTION_NAMES.clif_match,50]51preprocessor_compile_actions = [52 ACTION_NAMES.c_compile,53 ACTION_NAMES.cpp_compile,54 ACTION_NAMES.linkstamp_compile,55 ACTION_NAMES.preprocess_assemble,56 ACTION_NAMES.cpp_header_parsing,57 ACTION_NAMES.cpp_module_compile,58 ACTION_NAMES.clif_match,59]60codegen_compile_actions = [61 ACTION_NAMES.c_compile,62 ACTION_NAMES.cpp_compile,63 ACTION_NAMES.linkstamp_compile,64 ACTION_NAMES.assemble,65 ACTION_NAMES.preprocess_assemble,66 ACTION_NAMES.cpp_module_codegen,67 ACTION_NAMES.lto_backend,68]69all_link_actions = [70 ACTION_NAMES.cpp_link_executable,71 ACTION_NAMES.cpp_link_dynamic_library,72 ACTION_NAMES.cpp_link_nodeps_dynamic_library,73]74def _windows_msvc_impl(ctx):75 toolchain_identifier = "msvc_x64"76 host_system_name = "local"77 target_system_name = "local"78 target_cpu = "x64_windows"79 target_libc = "msvcrt"80 compiler = "msvc-cl"81 abi_version = "local"82 abi_libc_version = "local"83 cc_target_os = None84 builtin_sysroot = None85 cxx_builtin_include_directories = [86 "/usr/local/include",87 "/usr/local/lib/clang/7.0.0/include",88 "/usr/include/x86_64-linux-gnu",89 "/usr/include",90 "/usr/include/c++/4.9",91 "/usr/include/x86_64-linux-gnu/c++/4.9",92 "/usr/include/c++/4.9/backward",93 ]94 cpp_link_nodeps_dynamic_library_action = action_config(95 action_name = ACTION_NAMES.cpp_link_nodeps_dynamic_library,96 implies = [97 "nologo",98 "shared_flag",99 "linkstamps",100 "output_execpath_flags",101 "input_param_flags",102 "user_link_flags",103 "default_link_flags",104 "linker_subsystem_flag",105 "linker_param_file",106 "msvc_env",107 "no_stripping",108 "has_configured_linker_path",109 "def_file",110 ],111 tools = [tool(path = "")],112 )113 cpp_link_static_library_action = action_config(114 action_name = ACTION_NAMES.cpp_link_static_library,115 implies = [116 "nologo",117 "archiver_flags",118 "input_param_flags",119 "linker_param_file",120 "msvc_env",121 ],122 tools = [tool(path = "")],123 )124 assemble_action = action_config(125 action_name = ACTION_NAMES.assemble,126 implies = [127 "compiler_input_flags",128 "compiler_output_flags",129 "nologo",130 "msvc_env",131 "sysroot",132 ],133 tools = [tool(path = "")],134 )135 preprocess_assemble_action = action_config(136 action_name = ACTION_NAMES.preprocess_assemble,137 implies = [138 "compiler_input_flags",139 "compiler_output_flags",140 "nologo",141 "msvc_env",142 "sysroot",143 ],144 tools = [tool(path = "")],145 )146 c_compile_action = action_config(147 action_name = ACTION_NAMES.c_compile,148 implies = [149 "compiler_input_flags",150 "compiler_output_flags",151 "default_compile_flags",152 "nologo",153 "msvc_env",154 "parse_showincludes",155 "user_compile_flags",156 "sysroot",157 "unfiltered_compile_flags",158 ],159 tools = [tool(path = "")],160 )161 cpp_compile_action = action_config(162 action_name = ACTION_NAMES.cpp_compile,163 implies = [164 "compiler_input_flags",165 "compiler_output_flags",166 "default_compile_flags",167 "nologo",168 "msvc_env",169 "parse_showincludes",170 "user_compile_flags",171 "sysroot",172 "unfiltered_compile_flags",173 ],174 tools = [tool(path = "")],175 )176 cpp_link_executable_action = action_config(177 action_name = ACTION_NAMES.cpp_link_executable,178 implies = [179 "nologo",180 "linkstamps",181 "output_execpath_flags",182 "input_param_flags",183 "user_link_flags",184 "default_link_flags",185 "linker_subsystem_flag",186 "linker_param_file",187 "msvc_env",188 "no_stripping",189 ],190 tools = [tool(path = "")],191 )192 cpp_link_dynamic_library_action = action_config(193 action_name = ACTION_NAMES.cpp_link_dynamic_library,194 implies = [195 "nologo",196 "shared_flag",197 "linkstamps",198 "output_execpath_flags",199 "input_param_flags",200 "user_link_flags",201 "default_link_flags",202 "linker_subsystem_flag",203 "linker_param_file",204 "msvc_env",205 "no_stripping",206 "has_configured_linker_path",207 "def_file",208 ],209 tools = [tool(path = "")],210 )211 action_configs = [212 assemble_action,213 preprocess_assemble_action,214 c_compile_action,215 cpp_compile_action,216 cpp_link_executable_action,217 cpp_link_dynamic_library_action,218 cpp_link_nodeps_dynamic_library_action,219 cpp_link_static_library_action,220 ]221 msvc_link_env_feature = feature(222 name = "msvc_link_env",223 env_sets = [224 env_set(225 actions = all_link_actions +226 [ACTION_NAMES.cpp_link_static_library],227 env_entries = [env_entry(key = "LIB", value = "")],228 ),229 ],230 )231 shared_flag_feature = feature(232 name = "shared_flag",233 flag_sets = [234 flag_set(235 actions = [236 ACTION_NAMES.cpp_link_dynamic_library,237 ACTION_NAMES.cpp_link_nodeps_dynamic_library,238 ],239 flag_groups = [flag_group(flags = ["/DLL"])],240 ),241 ],242 )243 determinism_feature = feature(244 name = "determinism",245 enabled = True,246 flag_sets = [247 flag_set(248 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],249 flag_groups = [250 flag_group(251 flags = [252 "/wd4117",253 "-D__DATE__=\"redacted\"",254 "-D__TIMESTAMP__=\"redacted\"",255 "-D__TIME__=\"redacted\"",256 ],257 ),258 ],259 ),260 ],261 )262 sysroot_feature = feature(263 name = "sysroot",264 flag_sets = [265 flag_set(266 actions = [267 ACTION_NAMES.assemble,268 ACTION_NAMES.preprocess_assemble,269 ACTION_NAMES.c_compile,270 ACTION_NAMES.cpp_compile,271 ACTION_NAMES.cpp_header_parsing,272 ACTION_NAMES.cpp_module_compile,273 ACTION_NAMES.cpp_module_codegen,274 ACTION_NAMES.cpp_link_executable,275 ACTION_NAMES.cpp_link_dynamic_library,276 ACTION_NAMES.cpp_link_nodeps_dynamic_library,277 ],278 flag_groups = [279 flag_group(280 flags = ["--sysroot=%{sysroot}"],281 iterate_over = "sysroot",282 expand_if_available = "sysroot",283 ),284 ],285 ),286 ],287 )288 unfiltered_compile_flags_feature = feature(289 name = "unfiltered_compile_flags",290 flag_sets = [291 flag_set(292 actions = [293 ACTION_NAMES.preprocess_assemble,294 ACTION_NAMES.c_compile,295 ACTION_NAMES.cpp_compile,296 ACTION_NAMES.cpp_header_parsing,297 ACTION_NAMES.cpp_module_compile,298 ACTION_NAMES.cpp_module_codegen,299 ],300 flag_groups = [301 flag_group(302 flags = ["%{unfiltered_compile_flags}"],303 iterate_over = "unfiltered_compile_flags",304 expand_if_available = "unfiltered_compile_flags",305 ),306 ],307 ),308 ],309 )310 copy_dynamic_libraries_to_binary_feature = feature(name = "copy_dynamic_libraries_to_binary")311 input_param_flags_feature = feature(312 name = "input_param_flags",313 flag_sets = [314 flag_set(315 actions = [316 ACTION_NAMES.cpp_link_dynamic_library,317 ACTION_NAMES.cpp_link_nodeps_dynamic_library,318 ],319 flag_groups = [320 flag_group(321 flags = ["/IMPLIB:%{interface_library_output_path}"],322 expand_if_available = "interface_library_output_path",323 ),324 ],325 ),326 flag_set(327 actions = all_link_actions,328 flag_groups = [329 flag_group(330 flags = ["%{libopts}"],331 iterate_over = "libopts",332 expand_if_available = "libopts",333 ),334 ],335 ),336 flag_set(337 actions = all_link_actions +338 [ACTION_NAMES.cpp_link_static_library],339 flag_groups = [340 flag_group(341 iterate_over = "libraries_to_link",342 flag_groups = [343 flag_group(344 iterate_over = "libraries_to_link.object_files",345 flag_groups = [flag_group(flags = ["%{libraries_to_link.object_files}"])],346 expand_if_equal = variable_with_value(347 name = "libraries_to_link.type",348 value = "object_file_group",349 ),350 ),351 flag_group(352 flag_groups = [flag_group(flags = ["%{libraries_to_link.name}"])],353 expand_if_equal = variable_with_value(354 name = "libraries_to_link.type",355 value = "object_file",356 ),357 ),358 flag_group(359 flag_groups = [flag_group(flags = ["%{libraries_to_link.name}"])],360 expand_if_equal = variable_with_value(361 name = "libraries_to_link.type",362 value = "interface_library",363 ),364 ),365 flag_group(366 flag_groups = [367 flag_group(368 flags = ["%{libraries_to_link.name}"],369 expand_if_false = "libraries_to_link.is_whole_archive",370 ),371 flag_group(372 flags = ["/WHOLEARCHIVE:%{libraries_to_link.name}"],373 expand_if_true = "libraries_to_link.is_whole_archive",374 ),375 ],376 expand_if_equal = variable_with_value(377 name = "libraries_to_link.type",378 value = "static_library",379 ),380 ),381 ],382 expand_if_available = "libraries_to_link",383 ),384 ],385 ),386 ],387 )388 fastbuild_feature = feature(389 name = "fastbuild",390 flag_sets = [391 flag_set(392 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],393 flag_groups = [flag_group(flags = ["/Od", "/Z7"])],394 ),395 flag_set(396 actions = all_link_actions,397 flag_groups = [398 flag_group(399 flags = ["", "/INCREMENTAL:NO"],400 ),401 ],402 ),403 ],404 implies = ["generate_pdb_file"],405 )406 user_compile_flags_feature = feature(407 name = "user_compile_flags",408 flag_sets = [409 flag_set(410 actions = [411 ACTION_NAMES.preprocess_assemble,412 ACTION_NAMES.c_compile,413 ACTION_NAMES.cpp_compile,414 ACTION_NAMES.cpp_header_parsing,415 ACTION_NAMES.cpp_module_compile,416 ACTION_NAMES.cpp_module_codegen,417 ],418 flag_groups = [419 flag_group(420 flags = ["%{user_compile_flags}"],421 iterate_over = "user_compile_flags",422 expand_if_available = "user_compile_flags",423 ),424 ],425 ),426 ],427 )428 archiver_flags_feature = feature(429 name = "archiver_flags",430 flag_sets = [431 flag_set(432 actions = [ACTION_NAMES.cpp_link_static_library],433 flag_groups = [434 flag_group(435 flags = ["/OUT:%{output_execpath}"],436 expand_if_available = "output_execpath",437 ),438 ],439 ),440 ],441 )442 default_link_flags_feature = feature(443 name = "default_link_flags",444 enabled = True,445 flag_sets = [446 flag_set(447 actions = all_link_actions,448 flag_groups = [flag_group(flags = ["/MACHINE:X64"])],449 ),450 ],451 )452 static_link_msvcrt_feature = feature(name = "static_link_msvcrt")453 dynamic_link_msvcrt_debug_feature = feature(454 name = "dynamic_link_msvcrt_debug",455 flag_sets = [456 flag_set(457 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],458 flag_groups = [flag_group(flags = ["/MDd"])],459 ),460 flag_set(461 actions = all_link_actions,462 flag_groups = [flag_group(flags = ["/DEFAULTLIB:msvcrtd.lib"])],463 ),464 ],465 requires = [feature_set(features = ["dbg"])],466 )467 dbg_feature = feature(468 name = "dbg",469 flag_sets = [470 flag_set(471 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],472 flag_groups = [flag_group(flags = ["/Od", "/Z7"])],473 ),474 flag_set(475 actions = all_link_actions,476 flag_groups = [477 flag_group(478 flags = ["", "/INCREMENTAL:NO"],479 ),480 ],481 ),482 ],483 implies = ["generate_pdb_file"],484 )485 opt_feature = feature(486 name = "opt",487 flag_sets = [488 flag_set(489 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],490 flag_groups = [flag_group(flags = ["/O2"])],491 ),492 ],493 implies = ["frame_pointer"],494 )495 supports_interface_shared_libraries_feature = feature(496 name = "supports_interface_shared_libraries",497 enabled = True,498 )499 user_link_flags_feature = feature(500 name = "user_link_flags",501 flag_sets = [502 flag_set(503 actions = all_link_actions,504 flag_groups = [505 flag_group(506 flags = ["%{user_link_flags}"],507 iterate_over = "user_link_flags",508 expand_if_available = "user_link_flags",509 ),510 ],511 ),512 ],513 )514 default_compile_flags_feature = feature(515 name = "default_compile_flags",516 enabled = True,517 flag_sets = [518 flag_set(519 actions = [520 ACTION_NAMES.assemble,521 ACTION_NAMES.preprocess_assemble,522 ACTION_NAMES.linkstamp_compile,523 ACTION_NAMES.c_compile,524 ACTION_NAMES.cpp_compile,525 ACTION_NAMES.cpp_header_parsing,526 ACTION_NAMES.cpp_module_compile,527 ACTION_NAMES.cpp_module_codegen,528 ACTION_NAMES.lto_backend,529 ACTION_NAMES.clif_match,530 ],531 flag_groups = [532 flag_group(533 flags = [534 "/DCOMPILER_MSVC",535 "/DNOMINMAX",536 "/D_WIN32_WINNT=0x0601",537 "/D_CRT_SECURE_NO_DEPRECATE",538 "/D_CRT_SECURE_NO_WARNINGS",539 "/bigobj",540 "/Zm500",541 "/EHsc",542 "/wd4351",543 "/wd4291",544 "/wd4250",545 "/wd4996",546 ],547 ),548 ],549 ),550 ],551 )552 msvc_compile_env_feature = feature(553 name = "msvc_compile_env",554 env_sets = [555 env_set(556 actions = [557 ACTION_NAMES.c_compile,558 ACTION_NAMES.cpp_compile,559 ACTION_NAMES.cpp_module_compile,560 ACTION_NAMES.cpp_module_codegen,561 ACTION_NAMES.cpp_header_parsing,562 ACTION_NAMES.assemble,563 ACTION_NAMES.preprocess_assemble,564 ],565 env_entries = [env_entry(key = "INCLUDE", value = "")],566 ),567 ],568 )569 preprocessor_defines_feature = feature(570 name = "preprocessor_defines",571 enabled = True,572 flag_sets = [573 flag_set(574 actions = [575 ACTION_NAMES.assemble,576 ACTION_NAMES.preprocess_assemble,577 ACTION_NAMES.c_compile,578 ACTION_NAMES.cpp_compile,579 ACTION_NAMES.cpp_header_parsing,580 ACTION_NAMES.cpp_module_compile,581 ],582 flag_groups = [583 flag_group(584 flags = ["/D%{preprocessor_defines}"],585 iterate_over = "preprocessor_defines",586 ),587 ],588 ),589 ],590 )591 generate_pdb_file_feature = feature(592 name = "generate_pdb_file",593 requires = [594 feature_set(features = ["dbg"]),595 feature_set(features = ["fastbuild"]),596 ],597 )598 output_execpath_flags_feature = feature(599 name = "output_execpath_flags",600 flag_sets = [601 flag_set(602 actions = all_link_actions,603 flag_groups = [604 flag_group(605 flags = ["/OUT:%{output_execpath}"],606 expand_if_available = "output_execpath",607 ),608 ],609 ),610 ],611 )612 dynamic_link_msvcrt_no_debug_feature = feature(613 name = "dynamic_link_msvcrt_no_debug",614 flag_sets = [615 flag_set(616 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],617 flag_groups = [flag_group(flags = ["/MD"])],618 ),619 flag_set(620 actions = all_link_actions,621 flag_groups = [flag_group(flags = ["/DEFAULTLIB:msvcrt.lib"])],622 ),623 ],624 requires = [625 feature_set(features = ["fastbuild"]),626 feature_set(features = ["opt"]),627 ],628 )629 disable_assertions_feature = feature(630 name = "disable_assertions",631 enabled = True,632 flag_sets = [633 flag_set(634 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],635 flag_groups = [flag_group(flags = ["/DNDEBUG"])],636 with_features = [with_feature_set(features = ["opt"])],637 ),638 ],639 )640 has_configured_linker_path_feature = feature(name = "has_configured_linker_path")641 supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True)642 no_stripping_feature = feature(name = "no_stripping")643 linker_param_file_feature = feature(644 name = "linker_param_file",645 flag_sets = [646 flag_set(647 actions = all_link_actions +648 [ACTION_NAMES.cpp_link_static_library],649 flag_groups = [650 flag_group(651 flags = ["@%{linker_param_file}"],652 expand_if_available = "linker_param_file",653 ),654 ],655 ),656 ],657 )658 ignore_noisy_warnings_feature = feature(659 name = "ignore_noisy_warnings",660 enabled = True,661 flag_sets = [662 flag_set(663 actions = [ACTION_NAMES.cpp_link_static_library],664 flag_groups = [flag_group(flags = ["/ignore:4221"])],665 ),666 ],667 )668 no_legacy_features_feature = feature(name = "no_legacy_features")669 parse_showincludes_feature = feature(670 name = "parse_showincludes",671 flag_sets = [672 flag_set(673 actions = [674 ACTION_NAMES.preprocess_assemble,675 ACTION_NAMES.c_compile,676 ACTION_NAMES.cpp_compile,677 ACTION_NAMES.cpp_module_compile,678 ACTION_NAMES.cpp_header_parsing,679 ],680 flag_groups = [flag_group(flags = ["/showIncludes"])],681 ),682 ],683 )684 static_link_msvcrt_no_debug_feature = feature(685 name = "static_link_msvcrt_no_debug",686 flag_sets = [687 flag_set(688 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],689 flag_groups = [flag_group(flags = ["/MT"])],690 ),691 flag_set(692 actions = all_link_actions,693 flag_groups = [flag_group(flags = ["/DEFAULTLIB:libcmt.lib"])],694 ),695 ],696 requires = [697 feature_set(features = ["fastbuild"]),698 feature_set(features = ["opt"]),699 ],700 )701 treat_warnings_as_errors_feature = feature(702 name = "treat_warnings_as_errors",703 flag_sets = [704 flag_set(705 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],706 flag_groups = [flag_group(flags = ["/WX"])],707 ),708 ],709 )710 windows_export_all_symbols_feature = feature(name = "windows_export_all_symbols")711 no_windows_export_all_symbols_feature = feature(name = "no_windows_export_all_symbols")712 include_paths_feature = feature(713 name = "include_paths",714 enabled = True,715 flag_sets = [716 flag_set(717 actions = [718 ACTION_NAMES.assemble,719 ACTION_NAMES.preprocess_assemble,720 ACTION_NAMES.c_compile,721 ACTION_NAMES.cpp_compile,722 ACTION_NAMES.cpp_header_parsing,723 ACTION_NAMES.cpp_module_compile,724 ],725 flag_groups = [726 flag_group(727 flags = ["/I%{quote_include_paths}"],728 iterate_over = "quote_include_paths",729 ),730 flag_group(731 flags = ["/I%{include_paths}"],732 iterate_over = "include_paths",733 ),734 flag_group(735 flags = ["/I%{system_include_paths}"],736 iterate_over = "system_include_paths",737 ),738 ],739 ),740 ],741 )742 linkstamps_feature = feature(743 name = "linkstamps",744 flag_sets = [745 flag_set(746 actions = all_link_actions,747 flag_groups = [748 flag_group(749 flags = ["%{linkstamp_paths}"],750 iterate_over = "linkstamp_paths",751 expand_if_available = "linkstamp_paths",752 ),753 ],754 ),755 ],756 )757 targets_windows_feature = feature(758 name = "targets_windows",759 enabled = True,760 implies = ["copy_dynamic_libraries_to_binary"],761 )762 linker_subsystem_flag_feature = feature(763 name = "linker_subsystem_flag",764 flag_sets = [765 flag_set(766 actions = all_link_actions,767 flag_groups = [flag_group(flags = ["/SUBSYSTEM:CONSOLE"])],768 ),769 ],770 )771 static_link_msvcrt_debug_feature = feature(772 name = "static_link_msvcrt_debug",773 flag_sets = [774 flag_set(775 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],776 flag_groups = [flag_group(flags = ["/MTd"])],777 ),778 flag_set(779 actions = all_link_actions,780 flag_groups = [flag_group(flags = ["/DEFAULTLIB:libcmtd.lib"])],781 ),782 ],783 requires = [feature_set(features = ["dbg"])],784 )785 frame_pointer_feature = feature(786 name = "frame_pointer",787 flag_sets = [788 flag_set(789 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],790 flag_groups = [flag_group(flags = ["/Oy-"])],791 ),792 ],793 )794 compiler_output_flags_feature = feature(795 name = "compiler_output_flags",796 flag_sets = [797 flag_set(798 actions = [ACTION_NAMES.assemble],799 flag_groups = [800 flag_group(801 flag_groups = [802 flag_group(803 flags = ["/Fo%{output_file}", "/Zi"],804 expand_if_available = "output_file",805 expand_if_not_available = "output_assembly_file",806 ),807 ],808 expand_if_not_available = "output_preprocess_file",809 ),810 ],811 ),812 flag_set(813 actions = [814 ACTION_NAMES.preprocess_assemble,815 ACTION_NAMES.c_compile,816 ACTION_NAMES.cpp_compile,817 ACTION_NAMES.cpp_header_parsing,818 ACTION_NAMES.cpp_module_compile,819 ACTION_NAMES.cpp_module_codegen,820 ],821 flag_groups = [822 flag_group(823 flag_groups = [824 flag_group(825 flags = ["/Fo%{output_file}"],826 expand_if_not_available = "output_preprocess_file",827 ),828 ],829 expand_if_available = "output_file",830 expand_if_not_available = "output_assembly_file",831 ),832 flag_group(833 flag_groups = [834 flag_group(835 flags = ["/Fa%{output_file}"],836 expand_if_available = "output_assembly_file",837 ),838 ],839 expand_if_available = "output_file",840 ),841 flag_group(842 flag_groups = [843 flag_group(844 flags = ["/P", "/Fi%{output_file}"],845 expand_if_available = "output_preprocess_file",846 ),847 ],848 expand_if_available = "output_file",849 ),850 ],851 ),852 ],853 )854 nologo_feature = feature(855 name = "nologo",856 flag_sets = [857 flag_set(858 actions = [859 ACTION_NAMES.c_compile,860 ACTION_NAMES.cpp_compile,861 ACTION_NAMES.cpp_module_compile,862 ACTION_NAMES.cpp_module_codegen,863 ACTION_NAMES.cpp_header_parsing,864 ACTION_NAMES.assemble,865 ACTION_NAMES.preprocess_assemble,866 ACTION_NAMES.cpp_link_executable,867 ACTION_NAMES.cpp_link_dynamic_library,868 ACTION_NAMES.cpp_link_nodeps_dynamic_library,869 ACTION_NAMES.cpp_link_static_library,870 ],871 flag_groups = [flag_group(flags = ["/nologo"])],872 ),873 ],874 )875 smaller_binary_feature = feature(876 name = "smaller_binary",877 enabled = True,878 flag_sets = [879 flag_set(880 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],881 flag_groups = [flag_group(flags = ["/Gy", "/Gw"])],882 with_features = [with_feature_set(features = ["opt"])],883 ),884 flag_set(885 actions = all_link_actions,886 flag_groups = [flag_group(flags = ["/OPT:ICF", "/OPT:REF"])],887 with_features = [with_feature_set(features = ["opt"])],888 ),889 ],890 )891 compiler_input_flags_feature = feature(892 name = "compiler_input_flags",893 flag_sets = [894 flag_set(895 actions = [896 ACTION_NAMES.assemble,897 ACTION_NAMES.preprocess_assemble,898 ACTION_NAMES.c_compile,899 ACTION_NAMES.cpp_compile,900 ACTION_NAMES.cpp_header_parsing,901 ACTION_NAMES.cpp_module_compile,902 ACTION_NAMES.cpp_module_codegen,903 ],904 flag_groups = [905 flag_group(906 flags = ["/c", "%{source_file}"],907 expand_if_available = "source_file",908 ),909 ],910 ),911 ],912 )913 def_file_feature = feature(914 name = "def_file",915 flag_sets = [916 flag_set(917 actions = all_link_actions,918 flag_groups = [919 flag_group(920 flags = ["/DEF:%{def_file_path}", "/ignore:4070"],921 expand_if_available = "def_file_path",922 ),923 ],924 ),925 ],926 )927 msvc_env_feature = feature(928 name = "msvc_env",929 env_sets = [930 env_set(931 actions = [932 ACTION_NAMES.c_compile,933 ACTION_NAMES.cpp_compile,934 ACTION_NAMES.cpp_module_compile,935 ACTION_NAMES.cpp_module_codegen,936 ACTION_NAMES.cpp_header_parsing,937 ACTION_NAMES.assemble,938 ACTION_NAMES.preprocess_assemble,939 ACTION_NAMES.cpp_link_executable,940 ACTION_NAMES.cpp_link_dynamic_library,941 ACTION_NAMES.cpp_link_nodeps_dynamic_library,942 ACTION_NAMES.cpp_link_static_library,943 ],944 env_entries = [945 env_entry(key = "PATH", value = ""),946 env_entry(key = "TMP", value = ""),947 env_entry(key = "TEMP", value = ""),948 ],949 ),950 ],951 implies = ["msvc_compile_env", "msvc_link_env"],952 )953 features = [954 no_legacy_features_feature,955 nologo_feature,956 has_configured_linker_path_feature,957 no_stripping_feature,958 targets_windows_feature,959 copy_dynamic_libraries_to_binary_feature,960 default_compile_flags_feature,961 msvc_env_feature,962 msvc_compile_env_feature,963 msvc_link_env_feature,964 include_paths_feature,965 preprocessor_defines_feature,966 parse_showincludes_feature,967 generate_pdb_file_feature,968 shared_flag_feature,969 linkstamps_feature,970 output_execpath_flags_feature,971 archiver_flags_feature,972 input_param_flags_feature,973 linker_subsystem_flag_feature,974 user_link_flags_feature,975 default_link_flags_feature,976 linker_param_file_feature,977 static_link_msvcrt_feature,978 static_link_msvcrt_no_debug_feature,979 dynamic_link_msvcrt_no_debug_feature,980 static_link_msvcrt_debug_feature,981 dynamic_link_msvcrt_debug_feature,982 dbg_feature,983 fastbuild_feature,984 opt_feature,985 frame_pointer_feature,986 disable_assertions_feature,987 determinism_feature,988 treat_warnings_as_errors_feature,989 smaller_binary_feature,990 ignore_noisy_warnings_feature,991 user_compile_flags_feature,992 sysroot_feature,993 unfiltered_compile_flags_feature,994 compiler_output_flags_feature,995 compiler_input_flags_feature,996 def_file_feature,997 windows_export_all_symbols_feature,998 no_windows_export_all_symbols_feature,999 supports_dynamic_linker_feature,1000 supports_interface_shared_libraries_feature,1001 ]1002 artifact_name_patterns = [1003 artifact_name_pattern(1004 category_name = "object_file",1005 prefix = "",1006 extension = ".obj",1007 ),1008 artifact_name_pattern(1009 category_name = "static_library",1010 prefix = "",1011 extension = ".lib",1012 ),1013 artifact_name_pattern(1014 category_name = "alwayslink_static_library",1015 prefix = "",1016 extension = ".lo.lib",1017 ),1018 artifact_name_pattern(1019 category_name = "executable",1020 prefix = "",1021 extension = ".exe",1022 ),1023 artifact_name_pattern(1024 category_name = "dynamic_library",1025 prefix = "",1026 extension = ".dll",1027 ),1028 artifact_name_pattern(1029 category_name = "interface_library",1030 prefix = "",1031 extension = ".if.lib",1032 ),1033 ]1034 make_variables = []1035 tool_paths = [1036 tool_path(name = "ar", path = ""),1037 tool_path(name = "ml", path = ""),1038 tool_path(name = "cpp", path = ""),1039 tool_path(name = "gcc", path = ""),1040 tool_path(name = "gcov", path = "wrapper/bin/msvc_nop.bat"),1041 tool_path(name = "ld", path = ""),1042 tool_path(name = "nm", path = "wrapper/bin/msvc_nop.bat"),1043 tool_path(1044 name = "objcopy",1045 path = "wrapper/bin/msvc_nop.bat",1046 ),1047 tool_path(1048 name = "objdump",1049 path = "wrapper/bin/msvc_nop.bat",1050 ),1051 tool_path(1052 name = "strip",1053 path = "wrapper/bin/msvc_nop.bat",1054 ),1055 ]1056 return cc_common.create_cc_toolchain_config_info(1057 ctx = ctx,1058 features = features,1059 action_configs = action_configs,1060 artifact_name_patterns = artifact_name_patterns,1061 cxx_builtin_include_directories = cxx_builtin_include_directories,1062 toolchain_identifier = toolchain_identifier,1063 host_system_name = host_system_name,1064 target_system_name = target_system_name,1065 target_cpu = target_cpu,1066 target_libc = target_libc,1067 compiler = compiler,1068 abi_version = abi_version,1069 abi_libc_version = abi_libc_version,1070 tool_paths = tool_paths,1071 make_variables = make_variables,1072 builtin_sysroot = builtin_sysroot,1073 cc_target_os = None,1074 )1075def _windows_msys_mingw_impl(ctx):1076 toolchain_identifier = "msys_x64_mingw"1077 host_system_name = "local"1078 target_system_name = "local"1079 target_cpu = "x64_windows"1080 target_libc = "mingw"1081 compiler = "mingw-gcc"1082 abi_version = "local"1083 abi_libc_version = "local"1084 cc_target_os = None1085 builtin_sysroot = None1086 action_configs = []1087 targets_windows_feature = feature(1088 name = "targets_windows",1089 implies = ["copy_dynamic_libraries_to_binary"],1090 enabled = True,1091 )1092 copy_dynamic_libraries_to_binary_feature = feature(name = "copy_dynamic_libraries_to_binary")1093 gcc_env_feature = feature(1094 name = "gcc_env",1095 enabled = True,1096 env_sets = [1097 env_set(1098 actions = [1099 ACTION_NAMES.c_compile,1100 ACTION_NAMES.cpp_compile,1101 ACTION_NAMES.cpp_module_compile,1102 ACTION_NAMES.cpp_module_codegen,1103 ACTION_NAMES.cpp_header_parsing,1104 ACTION_NAMES.assemble,1105 ACTION_NAMES.preprocess_assemble,1106 ACTION_NAMES.cpp_link_executable,1107 ACTION_NAMES.cpp_link_dynamic_library,1108 ACTION_NAMES.cpp_link_nodeps_dynamic_library,1109 ACTION_NAMES.cpp_link_static_library,1110 ],1111 env_entries = [1112 env_entry(key = "PATH", value = "NOT_USED"),1113 ],1114 ),1115 ],1116 )1117 msys_mingw_flags = [1118 ]1119 msys_mingw_link_flags = [1120 ]1121 default_compile_flags_feature = feature(1122 name = "default_compile_flags",1123 enabled = True,1124 flag_sets = [1125 flag_set(1126 actions = [1127 ACTION_NAMES.assemble,1128 ACTION_NAMES.preprocess_assemble,1129 ACTION_NAMES.linkstamp_compile,1130 ACTION_NAMES.c_compile,1131 ACTION_NAMES.cpp_compile,1132 ACTION_NAMES.cpp_header_parsing,1133 ACTION_NAMES.cpp_module_compile,1134 ACTION_NAMES.cpp_module_codegen,1135 ACTION_NAMES.lto_backend,1136 ACTION_NAMES.clif_match,1137 ],1138 ),1139 flag_set(1140 actions = [1141 ACTION_NAMES.linkstamp_compile,1142 ACTION_NAMES.cpp_compile,1143 ACTION_NAMES.cpp_header_parsing,1144 ACTION_NAMES.cpp_module_compile,1145 ACTION_NAMES.cpp_module_codegen,1146 ACTION_NAMES.lto_backend,1147 ACTION_NAMES.clif_match,1148 ],1149 flag_groups = ([flag_group(flags = msys_mingw_flags)] if msys_mingw_flags else []),1150 ),1151 ],1152 )1153 default_link_flags_feature = feature(1154 name = "default_link_flags",1155 enabled = True,1156 flag_sets = [1157 flag_set(1158 actions = all_link_actions,1159 flag_groups = ([flag_group(flags = msys_mingw_link_flags)] if msys_mingw_link_flags else []),1160 ),1161 ],1162 )1163 supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True)1164 features = [1165 targets_windows_feature,1166 copy_dynamic_libraries_to_binary_feature,1167 gcc_env_feature,1168 default_compile_flags_feature,1169 default_link_flags_feature,1170 supports_dynamic_linker_feature,1171 ]1172 cxx_builtin_include_directories = [1173 ]1174 artifact_name_patterns = [1175 artifact_name_pattern(1176 category_name = "executable",1177 prefix = "",1178 extension = ".exe",1179 ),1180 ]1181 make_variables = []1182 tool_paths = [1183 ]1184 return cc_common.create_cc_toolchain_config_info(1185 ctx = ctx,1186 features = features,1187 action_configs = action_configs,1188 artifact_name_patterns = artifact_name_patterns,1189 cxx_builtin_include_directories = cxx_builtin_include_directories,1190 toolchain_identifier = toolchain_identifier,1191 host_system_name = host_system_name,1192 target_system_name = target_system_name,1193 target_cpu = target_cpu,1194 target_libc = target_libc,1195 compiler = compiler,1196 abi_version = abi_version,1197 abi_libc_version = abi_libc_version,1198 tool_paths = tool_paths,1199 make_variables = make_variables,1200 builtin_sysroot = builtin_sysroot,1201 cc_target_os = cc_target_os,1202 )1203def _armeabi_impl(ctx):1204 toolchain_identifier = "stub_armeabi-v7a"1205 host_system_name = "armeabi-v7a"1206 target_system_name = "armeabi-v7a"1207 target_cpu = "armeabi-v7a"1208 target_libc = "armeabi-v7a"1209 compiler = "compiler"1210 abi_version = "armeabi-v7a"1211 abi_libc_version = "armeabi-v7a"1212 cc_target_os = None1213 builtin_sysroot = None1214 action_configs = []1215 supports_pic_feature = feature(name = "supports_pic", enabled = True)1216 supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True)1217 features = [supports_dynamic_linker_feature, supports_pic_feature]1218 cxx_builtin_include_directories = []1219 artifact_name_patterns = []1220 make_variables = []1221 tool_paths = [1222 tool_path(name = "ar", path = "/bin/false"),1223 tool_path(name = "compat-ld", path = "/bin/false"),1224 tool_path(name = "cpp", path = "/bin/false"),1225 tool_path(name = "dwp", path = "/bin/false"),1226 tool_path(name = "gcc", path = "/bin/false"),1227 tool_path(name = "gcov", path = "/bin/false"),1228 tool_path(name = "ld", path = "/bin/false"),1229 tool_path(name = "nm", path = "/bin/false"),1230 tool_path(name = "objcopy", path = "/bin/false"),1231 tool_path(name = "objdump", path = "/bin/false"),1232 tool_path(name = "strip", path = "/bin/false"),1233 ]1234 return cc_common.create_cc_toolchain_config_info(1235 ctx = ctx,1236 features = features,1237 action_configs = action_configs,1238 artifact_name_patterns = artifact_name_patterns,1239 cxx_builtin_include_directories = cxx_builtin_include_directories,1240 toolchain_identifier = toolchain_identifier,1241 host_system_name = host_system_name,1242 target_system_name = target_system_name,1243 target_cpu = target_cpu,1244 target_libc = target_libc,1245 compiler = compiler,1246 abi_version = abi_version,1247 abi_libc_version = abi_libc_version,1248 tool_paths = tool_paths,1249 make_variables = make_variables,1250 builtin_sysroot = builtin_sysroot,1251 cc_target_os = cc_target_os,1252 )1253def _impl(ctx):1254 if ctx.attr.cpu == "armeabi-v7a":1255 return _armeabi_impl(ctx)1256 elif ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "msvc-cl":1257 return _windows_msvc_impl(ctx)1258 elif ctx.attr.cpu == "x64_windows" and ctx.attr.compiler == "mingw-gcc":1259 return _windows_msys_mingw_impl(ctx)1260 tool_paths = [1261 tool_path(name = "ar", path = "/usr/bin/ar"),1262 tool_path(name = "ld", path = "/usr/bin/ld"),1263 tool_path(name = "cpp", path = "/usr/bin/cpp"),1264 tool_path(name = "gcc", path = "/usr/local/bin/clang"),1265 tool_path(name = "dwp", path = "/usr/bin/dwp"),1266 tool_path(name = "gcov", path = "None"),1267 tool_path(name = "nm", path = "/usr/bin/nm"),1268 tool_path(name = "objcopy", path = "/usr/bin/objcopy"),1269 tool_path(name = "objdump", path = "/usr/bin/objdump"),1270 tool_path(name = "strip", path = "/usr/bin/strip"),1271 ]1272 cxx_builtin_include_directories = [1273 "/usr/local/include",1274 "/usr/local/lib/clang/7.0.0/include",1275 "/usr/include/x86_64-linux-gnu",1276 "/usr/include",1277 "/usr/include/c++/4.9",1278 "/usr/include/x86_64-linux-gnu/c++/4.9",1279 "/usr/include/c++/4.9/backward",1280 ]1281 action_configs = []1282 compile_flags = [1283 "-U_FORTIFY_SOURCE",1284 "-fstack-protector",1285 "-Wall",1286 "-Wthread-safety",1287 "-Wself-assign",1288 "-fcolor-diagnostics",1289 "-fno-omit-frame-pointer",1290 ]1291 dbg_compile_flags = [1292 "-g",1293 ]1294 opt_compile_flags = [1295 "-g0",1296 "-O2",1297 "-D_FORTIFY_SOURCE=1",1298 "-DNDEBUG",1299 "-ffunction-sections",1300 "-fdata-sections",1301 ]1302 cxx_flags = [1303 "-std=c++0x",1304 ]1305 link_flags = [1306 "-fuse-ld=gold",1307 "-Wl,-no-as-needed",1308 "-Wl,-z,relro,-z,now",1309 "-B/usr/local/bin",1310 "-lstdc++",1311 "-lm",1312 ]1313 opt_link_flags = [1314 "-Wl,--gc-sections",1315 ]1316 unfiltered_compile_flags = [1317 "-no-canonical-prefixes",1318 "-Wno-builtin-macro-redefined",1319 "-D__DATE__=\"redacted\"",1320 "-D__TIMESTAMP__=\"redacted\"",1321 "-D__TIME__=\"redacted\"",1322 ]1323 targets_windows_feature = feature(1324 name = "targets_windows",1325 implies = ["copy_dynamic_libraries_to_binary"],1326 enabled = True,1327 )1328 copy_dynamic_libraries_to_binary_feature = feature(name = "copy_dynamic_libraries_to_binary")1329 gcc_env_feature = feature(1330 name = "gcc_env",1331 enabled = True,1332 env_sets = [1333 env_set(1334 actions = [1335 ACTION_NAMES.c_compile,1336 ACTION_NAMES.cpp_compile,1337 ACTION_NAMES.cpp_module_compile,1338 ACTION_NAMES.cpp_module_codegen,1339 ACTION_NAMES.cpp_header_parsing,1340 ACTION_NAMES.assemble,1341 ACTION_NAMES.preprocess_assemble,1342 ACTION_NAMES.cpp_link_executable,1343 ACTION_NAMES.cpp_link_dynamic_library,1344 ACTION_NAMES.cpp_link_nodeps_dynamic_library,1345 ACTION_NAMES.cpp_link_static_library,1346 ],1347 env_entries = [1348 env_entry(key = "PATH", value = "NOT_USED"),1349 ],1350 ),1351 ],1352 )1353 windows_features = [1354 targets_windows_feature,1355 copy_dynamic_libraries_to_binary_feature,1356 gcc_env_feature,1357 ]1358 coverage_feature = feature(1359 name = "coverage",1360 provides = ["profile"],1361 flag_sets = [1362 flag_set(1363 actions = [1364 ACTION_NAMES.preprocess_assemble,1365 ACTION_NAMES.c_compile,1366 ACTION_NAMES.cpp_compile,1367 ACTION_NAMES.cpp_header_parsing,1368 ACTION_NAMES.cpp_module_compile,1369 ],1370 flag_groups = [1371 flag_group(flags = ["--coverage"]),1372 ],1373 ),1374 flag_set(1375 actions = [1376 ACTION_NAMES.cpp_link_dynamic_library,1377 ACTION_NAMES.cpp_link_nodeps_dynamic_library,1378 ACTION_NAMES.cpp_link_executable,1379 ],1380 flag_groups = [1381 flag_group(flags = ["--coverage"]),1382 ],1383 ),1384 ],1385 )1386 supports_pic_feature = feature(1387 name = "supports_pic",1388 enabled = True,1389 )1390 supports_start_end_lib_feature = feature(1391 name = "supports_start_end_lib",1392 enabled = True,1393 )1394 default_compile_flags_feature = feature(1395 name = "default_compile_flags",1396 enabled = True,1397 flag_sets = [1398 flag_set(1399 actions = [1400 ACTION_NAMES.assemble,1401 ACTION_NAMES.preprocess_assemble,1402 ACTION_NAMES.linkstamp_compile,1403 ACTION_NAMES.c_compile,1404 ACTION_NAMES.cpp_compile,1405 ACTION_NAMES.cpp_header_parsing,1406 ACTION_NAMES.cpp_module_compile,1407 ACTION_NAMES.cpp_module_codegen,1408 ACTION_NAMES.lto_backend,1409 ACTION_NAMES.clif_match,1410 ],1411 flag_groups = ([flag_group(flags = compile_flags)] if compile_flags else []),1412 ),1413 flag_set(1414 actions = [1415 ACTION_NAMES.assemble,1416 ACTION_NAMES.preprocess_assemble,1417 ACTION_NAMES.linkstamp_compile,1418 ACTION_NAMES.c_compile,1419 ACTION_NAMES.cpp_compile,1420 ACTION_NAMES.cpp_header_parsing,1421 ACTION_NAMES.cpp_module_compile,1422 ACTION_NAMES.cpp_module_codegen,1423 ACTION_NAMES.lto_backend,1424 ACTION_NAMES.clif_match,1425 ],1426 flag_groups = ([flag_group(flags = dbg_compile_flags)] if dbg_compile_flags else []),1427 with_features = [with_feature_set(features = ["dbg"])],1428 ),1429 flag_set(1430 actions = [1431 ACTION_NAMES.assemble,1432 ACTION_NAMES.preprocess_assemble,1433 ACTION_NAMES.linkstamp_compile,1434 ACTION_NAMES.c_compile,1435 ACTION_NAMES.cpp_compile,1436 ACTION_NAMES.cpp_header_parsing,1437 ACTION_NAMES.cpp_module_compile,1438 ACTION_NAMES.cpp_module_codegen,1439 ACTION_NAMES.lto_backend,1440 ACTION_NAMES.clif_match,1441 ],1442 flag_groups = ([flag_group(flags = opt_compile_flags)] if opt_compile_flags else []),1443 with_features = [with_feature_set(features = ["opt"])],1444 ),1445 flag_set(1446 actions = [1447 ACTION_NAMES.linkstamp_compile,1448 ACTION_NAMES.cpp_compile,1449 ACTION_NAMES.cpp_header_parsing,1450 ACTION_NAMES.cpp_module_compile,1451 ACTION_NAMES.cpp_module_codegen,1452 ACTION_NAMES.lto_backend,1453 ACTION_NAMES.clif_match,1454 ],1455 flag_groups = ([flag_group(flags = cxx_flags)] if cxx_flags else []),1456 ),1457 ],1458 )1459 default_link_flags_feature = feature(1460 name = "default_link_flags",1461 enabled = True,1462 flag_sets = [1463 flag_set(1464 actions = all_link_actions,1465 flag_groups = ([flag_group(flags = link_flags)] if link_flags else []),1466 ),1467 flag_set(1468 actions = all_link_actions,1469 flag_groups = ([flag_group(flags = opt_link_flags)] if opt_link_flags else []),1470 with_features = [with_feature_set(features = ["opt"])],1471 ),1472 ],1473 )1474 dbg_feature = feature(name = "dbg")1475 opt_feature = feature(name = "opt")1476 sysroot_feature = feature(1477 name = "sysroot",1478 enabled = True,1479 flag_sets = [1480 flag_set(1481 actions = [1482 ACTION_NAMES.preprocess_assemble,1483 ACTION_NAMES.linkstamp_compile,1484 ACTION_NAMES.c_compile,1485 ACTION_NAMES.cpp_compile,1486 ACTION_NAMES.cpp_header_parsing,1487 ACTION_NAMES.cpp_module_compile,1488 ACTION_NAMES.cpp_module_codegen,1489 ACTION_NAMES.lto_backend,1490 ACTION_NAMES.clif_match,1491 ACTION_NAMES.cpp_link_executable,1492 ACTION_NAMES.cpp_link_dynamic_library,1493 ACTION_NAMES.cpp_link_nodeps_dynamic_library,1494 ],1495 flag_groups = [1496 flag_group(1497 flags = ["--sysroot=%{sysroot}"],1498 expand_if_available = "sysroot",1499 ),1500 ],1501 ),1502 ],1503 )1504 fdo_optimize_feature = feature(1505 name = "fdo_optimize",1506 flag_sets = [1507 flag_set(1508 actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile],1509 flag_groups = [1510 flag_group(1511 flags = [1512 "-fprofile-use=%{fdo_profile_path}",1513 "-fprofile-correction",1514 ],1515 expand_if_available = "fdo_profile_path",1516 ),1517 ],1518 ),1519 ],1520 provides = ["profile"],1521 )1522 supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True)1523 user_compile_flags_feature = feature(1524 name = "user_compile_flags",1525 enabled = True,1526 flag_sets = [1527 flag_set(1528 actions = [1529 ACTION_NAMES.assemble,1530 ACTION_NAMES.preprocess_assemble,1531 ACTION_NAMES.linkstamp_compile,1532 ACTION_NAMES.c_compile,1533 ACTION_NAMES.cpp_compile,1534 ACTION_NAMES.cpp_header_parsing,1535 ACTION_NAMES.cpp_module_compile,1536 ACTION_NAMES.cpp_module_codegen,1537 ACTION_NAMES.lto_backend,1538 ACTION_NAMES.clif_match,1539 ],1540 flag_groups = [1541 flag_group(1542 flags = ["%{user_compile_flags}"],1543 iterate_over = "user_compile_flags",1544 expand_if_available = "user_compile_flags",1545 ),1546 ],1547 ),1548 ],1549 )1550 unfiltered_compile_flags_feature = feature(1551 name = "unfiltered_compile_flags",1552 enabled = True,1553 flag_sets = [1554 flag_set(1555 actions = [1556 ACTION_NAMES.assemble,1557 ACTION_NAMES.preprocess_assemble,1558 ACTION_NAMES.linkstamp_compile,1559 ACTION_NAMES.c_compile,1560 ACTION_NAMES.cpp_compile,1561 ACTION_NAMES.cpp_header_parsing,1562 ACTION_NAMES.cpp_module_compile,1563 ACTION_NAMES.cpp_module_codegen,1564 ACTION_NAMES.lto_backend,1565 ACTION_NAMES.clif_match,1566 ],1567 flag_groups = ([flag_group(flags = unfiltered_compile_flags)] if unfiltered_compile_flags else []),1568 ),1569 ],1570 )1571 features = [1572 supports_pic_feature,1573 supports_start_end_lib_feature,1574 coverage_feature,1575 default_compile_flags_feature,1576 default_link_flags_feature,1577 fdo_optimize_feature,1578 supports_dynamic_linker_feature,1579 dbg_feature,1580 opt_feature,1581 user_compile_flags_feature,1582 sysroot_feature,1583 unfiltered_compile_flags_feature,1584 ]1585 artifact_name_patterns = [1586 ]1587 make_variables = []1588 return cc_common.create_cc_toolchain_config_info(1589 ctx = ctx,1590 features = features,1591 action_configs = action_configs,1592 artifact_name_patterns = artifact_name_patterns,1593 cxx_builtin_include_directories = cxx_builtin_include_directories,1594 toolchain_identifier = "linux_gnu_x86",1595 host_system_name = "i686-unknown-linux-gnu",1596 target_system_name = "x86_64-unknown-linux-gnu",1597 target_cpu = "k8",1598 target_libc = "glibc_2.19",1599 compiler = "clang",1600 abi_version = "gcc",1601 abi_libc_version = "glibc_2.19",1602 tool_paths = tool_paths,1603 make_variables = make_variables,1604 builtin_sysroot = "",1605 cc_target_os = None,1606 )1607cc_toolchain_config = rule(1608 implementation = _impl,1609 attrs = {1610 "cpu": attr.string(mandatory = True),1611 "compiler": attr.string(),1612 },1613 provides = [CcToolchainConfigInfo],...

Full Screen

Full Screen

save_plan_step_data.py

Source:save_plan_step_data.py Github

copy

Full Screen

1# Copyright (C) 2013 Ion Torrent Systems, Inc. All Rights Reserved2from django.utils.translation import ugettext as _3from django.core.urlresolvers import reverse4from iondb.rundb.plan.page_plan.kits_step_data import KitsFieldNames5from iondb.rundb.plan.page_plan.abstract_step_data import AbstractStepData6from iondb.rundb.models import (7 dnaBarcode,8 SampleAnnotation_CV,9 KitInfo,10 QCType,11 PlannedExperiment,12 Sample,13)14from iondb.rundb.labels import (15 Sample as _Sample,16 ModelsQcTypeToLabelsQcTypeAsDict,17 ModelsQcTypeToLabelsQcType,18)19from iondb.utils import validation20from iondb.rundb.plan.page_plan.step_helper_types import StepHelperType21from iondb.rundb.plan.page_plan.step_names import StepNames22from iondb.rundb.plan.page_plan.application_step_data import ApplicationFieldNames23from iondb.rundb.plan.page_plan.reference_step_data import ReferenceFieldNames24from iondb.rundb.plan.page_plan.ionreporter_step_data import IonReporterFieldNames25from iondb.rundb.plan.plan_validator import (26 validate_plan_name,27 validate_notes,28 validate_sample_name,29 validate_sample_tube_label,30 validate_barcode_sample_association,31 validate_QC,32 validate_targetRegionBedFile_for_runType,33 validate_chipBarcode,34)35from iondb.utils.utils import convert36from collections import OrderedDict37# from iondb.utils import toBoolean38import json39import logging40logger = logging.getLogger(__name__)41MAX_LENGTH_SAMPLE_DESCRIPTION = 102442MAX_LENGTH_SAMPLE_NAME = 12743class SavePlanFieldNames:44 UPLOADERS = "uploaders"45 SET_ID = "setid"46 SETID_SUFFIX = "setid_suffix"47 EXTERNAL_ID = "externalId"48 WORKFLOW = "Workflow"49 GENDER = "Gender"50 POPULATION = "Population"51 MOUSE_STRAINS = "mouseStrains"52 CANCER_TYPE = "cancerType"53 CELLULARITY_PCT = "cellularityPct"54 BIOPSY_DAYS = "biopsyDays"55 CELL_NUM = "cellNum"56 COUPLE_ID = "coupleID"57 EMBRYO_ID = "embryoID"58 BACTERIAL_MARKER_TYPE = "BacterialMarkerType"59 WITNESS = "Witness"60 NUCLEOTIDE_TYPE = "NucleotideType"61 RELATIONSHIP_TYPE = "Relation"62 RELATION_ROLE = "RelationRole"63 PLAN_NAME = "planName"64 SAMPLE = "sample"65 NOTE = "note"66 SAMPLE_COLLECTION_DATE = "SampleCollectionDate"67 SAMPLE_RECEIPT_DATE = "SampleReceiptDate"68 SELECTED_IR = "selectedIr"69 IR_CONFIG_JSON = "irConfigJson"70 BARCODE_SET = "barcodeSet"71 BARCODE_SAMPLE_TUBE_LABEL = "barcodeSampleTubeLabel"72 BARCODE_TO_SAMPLE = "barcodeToSample"73 BARCODE_SETS = "barcodeSets"74 BARCODE_SETS_BARCODES = "barcodeSets_barcodes"75 BARCODE_SETS_STATIC = "barcodeSets_static"76 END_BARCODE_SET = "endBarcodeSet"77 END_BARCODE_SETS = "endBarcodeSets"78 END_BARCODES_SUBSET = "endBarcodes_subset"79 END_BARCODE_SETS_BARCODES = "endBarcodeSets_barcodes"80 # note: barcodeKitName was named barcodeId in the plannedexperiment API for backward compatibility. It could be confusing81 # since UI uses barcodeId and endBarcodeId to represent selected barcode for a sample82 END_BARCODE_ID = "endBarcodeId"83 BARCODE_SAMPLE_BARCODE_ID_UI_KEY = "barcodeId"84 BARCODE_SAMPLE_END_BARCODE_ID_UI_KEY = "endBarcodeId"85 DUAL_BARCODES_DB_KEY = "dualBarcodes"86 SAMPLE_TO_BARCODE = "sampleToBarcode"87 SAMPLE_EXTERNAL_ID = "sampleExternalId"88 SAMPLE_NAME = "sampleName"89 SAMPLE_DESCRIPTION = "sampleDescription"90 TUBE_LABEL = "tubeLabel"91 CHIP_BARCODE_LABEL = "chipBarcodeLabel"92 CHIP_BARCODE = "chipBarcode"93 IR_SAMPLE_COLLECTION_DATE = "irSampleCollectionDate"94 IR_SAMPLE_RECEIPT_DATE = "irSampleReceiptDate"95 IR_PLUGIN_ENTRIES = "irPluginEntries"96 IR_GENDER = "irGender"97 IR_POPULATION = "irPopulation"98 IR_MOUSE_STRAINS = "irmouseStrains"99 IR_CANCER_TYPE = "ircancerType"100 IR_CELLULARITY_PCT = "ircellularityPct"101 IR_BIOPSY_DAYS = "irbiopsyDays"102 IR_CELL_NUM = "ircellNum"103 IR_COUPLE_ID = "ircoupleID"104 IR_EMBRYO_ID = "irembryoID"105 IR_BACTERIAL_MARKER_TYPE = "irBacterialMarkerType"106 IR_WITNESS = "irWitness"107 IR_WORKFLOW = "irWorkflow"108 IR_MULTIPLE_WORKFLOW_SINGLE_SAMPLE = "irMultipleWorkflowSelected"109 IR_ISFACTORY = "tag_isFactoryProvidedWorkflow"110 IR_DOWN = "irDown"111 IR_RELATION_ROLE = "irRelationRole"112 IR_RELATIONSHIP_TYPE = "irRelationshipType"113 IR_APPLICATION_TYPE = "ApplicationType"114 IR_SET_ID = "irSetID"115 BAD_SAMPLE_NAME = "bad_sample_name"116 BAD_SAMPLE_EXTERNAL_ID = "bad_sample_external_id"117 BAD_SAMPLE_DESCRIPTION = "bad_sample_description"118 BAD_TUBE_LABEL = "bad_tube_label"119 BAD_CHIP_BARCODE = "bad_chip_barcode"120 BARCODE_SAMPLE_NUCLEOTIDE_TYPE = "nucleotideType"121 BARCODE_SAMPLE_REFERENCE = "reference"122 BARCODE_SAMPLE_TARGET_REGION_BED_FILE = "targetRegionBedFile"123 BARCODE_SAMPLE_HOTSPOT_REGION_BED_FILE = "hotSpotRegionBedFile"124 BARCODE_SAMPLE_SSE_BED_FILE = "sseBedFile"125 BARCODE_SAMPLE_CONTROL_SEQ_TYPE = "controlSequenceType"126 BARCODE_SAMPLE_CONTROL_TYPE = "controlType"127 BARCODE_SAMPLE_END_BARCODE_DB_KEY = "endBarcode"128 BARCODE_SAMPLE_INFO = "barcodeSampleInfo"129 NO_SAMPLES = "no_samples"130 DESCRIPTION = "description"131 BAD_IR_SET_ID = "badIrSetId"132 SAMPLE_ANNOTATIONS = "sampleAnnotations"133 CONTROL_SEQ_TYPES = "controlSeqTypes"134 BARCODE_KIT_SELECTABLE_TYPE = "barcodeKitSelectableType"135 PLAN_REFERENCE = "plan_reference"136 PLAN_TARGET_REGION_BED_FILE = "plan_targetRegionBedFile"137 PLAN_HOTSPOT_REGION_BED_FILE = "plan_hotSpotRegionBedFile"138 SAMPLES_TABLE_LIST = "samplesTableList"139 SAMPLES_TABLE = "samplesTable"140 NUM_SAMPLES = "numberOfSamples"141 APPL_PRODUCT = "applProduct"142 RUN_TYPE = "runType"143 ONCO_SAME_SAMPLE = "isOncoSameSample"144 REFERENCE_STEP_HELPER = "referenceStepHelper"145 NO_BARCODE = "no_barcode"146 BAD_BARCODES = "bad_barcodes"147 APPLICATION_TYPE = "applicationType"148 FIRE_VALIDATION = "fireValidation"149 LIMS_META = "LIMS_meta"150 META = "meta"151 APPLICATION_GROUP_NAME = "applicationGroupName"152 HAS_PGS_DATA = "hasPgsData"153 HAS_ONCO_DATA = "hasOncoData"154class MonitoringFieldNames:155 QC_TYPES = "qcTypes"156def get_ir_userinput_dict(row, irWorkflow):157 sample_name = row.get(SavePlanFieldNames.SAMPLE_NAME, "").strip()158 ir_userinput_dict = {159 SavePlanFieldNames.SAMPLE: sample_name,160 SavePlanFieldNames.SAMPLE_NAME: sample_name.replace(" ", "_"),161 SavePlanFieldNames.SAMPLE_EXTERNAL_ID: row.get(162 SavePlanFieldNames.SAMPLE_EXTERNAL_ID, ""163 ),164 SavePlanFieldNames.SAMPLE_DESCRIPTION: row.get(165 SavePlanFieldNames.SAMPLE_DESCRIPTION, ""166 ),167 SavePlanFieldNames.SAMPLE_COLLECTION_DATE: row.get(168 SavePlanFieldNames.IR_SAMPLE_COLLECTION_DATE, ""169 ),170 SavePlanFieldNames.SAMPLE_RECEIPT_DATE: row.get(171 SavePlanFieldNames.IR_SAMPLE_RECEIPT_DATE, ""172 ),173 SavePlanFieldNames.WORKFLOW: irWorkflow,174 SavePlanFieldNames.IR_ISFACTORY: row.get(175 SavePlanFieldNames.IR_ISFACTORY176 ),177 SavePlanFieldNames.RELATION_ROLE: row.get(178 SavePlanFieldNames.IR_RELATION_ROLE, ""179 ),180 SavePlanFieldNames.RELATIONSHIP_TYPE: row.get(181 SavePlanFieldNames.IR_RELATIONSHIP_TYPE, ""182 ),183 SavePlanFieldNames.SET_ID: row.get(SavePlanFieldNames.IR_SET_ID, ""),184 SavePlanFieldNames.GENDER: row.get(SavePlanFieldNames.IR_GENDER, ""),185 SavePlanFieldNames.POPULATION: row.get(186 SavePlanFieldNames.IR_POPULATION, ""187 ),188 SavePlanFieldNames.MOUSE_STRAINS: row.get(189 SavePlanFieldNames.IR_MOUSE_STRAINS, ""190 ),191 SavePlanFieldNames.NUCLEOTIDE_TYPE: row.get(192 SavePlanFieldNames.BARCODE_SAMPLE_NUCLEOTIDE_TYPE, ""193 ),194 SavePlanFieldNames.CANCER_TYPE: row.get(195 SavePlanFieldNames.IR_CANCER_TYPE, ""196 ),197 SavePlanFieldNames.CELLULARITY_PCT: row.get(198 SavePlanFieldNames.IR_CELLULARITY_PCT, ""199 ),200 SavePlanFieldNames.BIOPSY_DAYS: row.get(201 SavePlanFieldNames.IR_BIOPSY_DAYS, ""202 ),203 SavePlanFieldNames.CELL_NUM: row.get(204 SavePlanFieldNames.IR_CELL_NUM, ""205 ),206 SavePlanFieldNames.COUPLE_ID: row.get(207 SavePlanFieldNames.IR_COUPLE_ID, ""208 ),209 SavePlanFieldNames.EMBRYO_ID: row.get(210 SavePlanFieldNames.IR_EMBRYO_ID, ""211 ),212 SavePlanFieldNames.BACTERIAL_MARKER_TYPE: row.get(SavePlanFieldNames.IR_BACTERIAL_MARKER_TYPE, ""),213 SavePlanFieldNames.WITNESS: row.get(SavePlanFieldNames.IR_WITNESS, ""),214 SavePlanFieldNames.IR_APPLICATION_TYPE: row.get(215 SavePlanFieldNames.IR_APPLICATION_TYPE, ""216 ),217 }218 barcode_id = row.get(SavePlanFieldNames.BARCODE_SAMPLE_BARCODE_ID_UI_KEY)219 if barcode_id:220 ir_userinput_dict[KitsFieldNames.BARCODE_ID] = barcode_id221 endBarcode_id = row.get(222 SavePlanFieldNames.BARCODE_SAMPLE_END_BARCODE_ID_UI_KEY223 )224 if endBarcode_id:225 ir_userinput_dict[SavePlanFieldNames.END_BARCODE_ID] = endBarcode_id226 return ir_userinput_dict227def update_ir_plugin_from_samples_table(samplesTable):228 # save IR fields for non-barcoded and barcoded plans229 userInputInfo = []230 for row in samplesTable:231 sample_name = row.get(SavePlanFieldNames.SAMPLE_NAME, "").strip()232 if sample_name:233 multiWorkflowSelectedObj = row.get(SavePlanFieldNames.IR_MULTIPLE_WORKFLOW_SINGLE_SAMPLE) or []234 if multiWorkflowSelectedObj and isinstance(multiWorkflowSelectedObj[0], dict):235 multiWorkflowSelectedList = [obj.get('workflow') for obj in multiWorkflowSelectedObj]236 if "Upload Only" not in multiWorkflowSelectedList:237 for obj in multiWorkflowSelectedObj:238 row[SavePlanFieldNames.IR_ISFACTORY] = obj["tag"]239 ir_userinput_dict = get_ir_userinput_dict(row, obj["workflow"])240 userInputInfo.append(ir_userinput_dict)241 else:242 irWorflowSelected = row.get(SavePlanFieldNames.IR_WORKFLOW, "")243 ir_userinput_dict = get_ir_userinput_dict(row, irWorflowSelected)244 userInputInfo.append(ir_userinput_dict)245 return userInputInfo246class SavePlanStepData(AbstractStepData):247 def __init__(self, sh_type):248 super(SavePlanStepData, self).__init__(sh_type)249 self.resourcePath = "rundb/plan/page_plan/page_plan_save_plan.html"250 self.prev_step_url = reverse("page_plan_output")251 self.next_step_url = reverse("page_plan_save")252 self.savedFields = OrderedDict()253 self.savedFields[SavePlanFieldNames.PLAN_NAME] = None254 self.savedFields[SavePlanFieldNames.NOTE] = None255 self.savedFields[SavePlanFieldNames.APPLICATION_TYPE] = ""256 self.savedFields[SavePlanFieldNames.IR_DOWN] = "0"257 self.savedFields[SavePlanFieldNames.BARCODE_SET] = ""258 self.savedFields[SavePlanFieldNames.END_BARCODE_SET] = ""259 self.prepopulatedFields[SavePlanFieldNames.PLAN_REFERENCE] = ""260 self.prepopulatedFields[SavePlanFieldNames.PLAN_TARGET_REGION_BED_FILE] = ""261 self.prepopulatedFields[SavePlanFieldNames.PLAN_HOTSPOT_REGION_BED_FILE] = ""262 self.prepopulatedFields[SavePlanFieldNames.SELECTED_IR] = None263 self.prepopulatedFields[SavePlanFieldNames.IR_WORKFLOW] = None264 self.prepopulatedFields[SavePlanFieldNames.IR_ISFACTORY] = False265 self.prepopulatedFields[SavePlanFieldNames.IR_CONFIG_JSON] = None266 self.prepopulatedFields[SavePlanFieldNames.SAMPLE_ANNOTATIONS] = list(267 SampleAnnotation_CV.objects.filter(isActive=True).order_by(268 "annotationType", "value"269 )270 )271 self.savedFields[SavePlanFieldNames.BARCODE_SAMPLE_TUBE_LABEL] = None272 self.savedFields[SavePlanFieldNames.CHIP_BARCODE_LABEL] = None273 self.savedObjects[SavePlanFieldNames.BARCODE_TO_SAMPLE] = OrderedDict()274 barcodeObjs_list = list(275 dnaBarcode.objects.filter(active=True)276 .values_list("name", flat=True)277 .distinct()278 .order_by("name")279 )280 self.prepopulatedFields[SavePlanFieldNames.BARCODE_SETS] = barcodeObjs_list281 all_barcodes = {}282 for bc in (283 dnaBarcode.objects.filter(active=True)284 .order_by("name", "index")285 .values("name", "id_str", "sequence")286 ):287 all_barcodes.setdefault(bc["name"], []).append(bc)288 self.prepopulatedFields[SavePlanFieldNames.BARCODE_SETS_BARCODES] = json.dumps(289 all_barcodes290 )291 self.prepopulatedFields[SavePlanFieldNames.BARCODE_SETS_STATIC] = (292 dnaBarcode.objects.filter(active=True)293 .exclude(end_sequence="")294 .values_list("name", flat=True)295 .distinct()296 )297 self.prepopulatedFields[SavePlanFieldNames.END_BARCODE_SETS] = barcodeObjs_list298 self.prepopulatedFields[299 SavePlanFieldNames.END_BARCODE_SETS_BARCODES300 ] = json.dumps(all_barcodes)301 self.savedObjects[SavePlanFieldNames.SAMPLE_TO_BARCODE] = OrderedDict()302 self.savedObjects[SavePlanFieldNames.IR_PLUGIN_ENTRIES] = []303 self.prepopulatedFields[SavePlanFieldNames.FIRE_VALIDATION] = "1"304 self.savedObjects[SavePlanFieldNames.SAMPLES_TABLE_LIST] = [305 {"row": "1", "sampleName": u"Sample 1"}306 ]307 self.savedFields[SavePlanFieldNames.SAMPLES_TABLE] = json.dumps(308 self.savedObjects[SavePlanFieldNames.SAMPLES_TABLE_LIST]309 )310 self.prepopulatedFields[SavePlanFieldNames.NUM_SAMPLES] = 1311 self.savedFields[SavePlanFieldNames.ONCO_SAME_SAMPLE] = False312 # logger.debug("save_plan_step_data samplesTable=%s" %(self.savedFields[SavePlanFieldNames.SAMPLES_TABLE]))313 self.prepopulatedFields[314 SavePlanFieldNames.CONTROL_SEQ_TYPES315 ] = KitInfo.objects.filter(316 kitType="ControlSequenceKitType", isActive=True317 ).order_by(318 "name"319 )320 self.savedObjects[SavePlanFieldNames.REFERENCE_STEP_HELPER] = None321 self.savedObjects[SavePlanFieldNames.APPL_PRODUCT] = None322 self.savedFields[SavePlanFieldNames.LIMS_META] = None323 self.savedObjects[SavePlanFieldNames.META] = {}324 self.prepopulatedFields[SavePlanFieldNames.APPLICATION_GROUP_NAME] = ""325 self.prepopulatedFields[SavePlanFieldNames.HAS_ONCO_DATA] = False326 self.prepopulatedFields[SavePlanFieldNames.HAS_PGS_DATA] = False327 self._dependsOn.append(StepNames.IONREPORTER)328 self._dependsOn.append(StepNames.APPLICATION)329 self._dependsOn.append(StepNames.KITS)330 # self._dependsOn.append(StepNames.REFERENCE)331 self.sh_type = sh_type332 # Monitoring333 self.qcNames = []334 self.ModelsQcTypeToLabelsQcTypeAsDict = ModelsQcTypeToLabelsQcTypeAsDict335 all_qc_types = list(QCType.objects.all().order_by("qcName"))336 self.prepopulatedFields[MonitoringFieldNames.QC_TYPES] = all_qc_types337 for qc_type in all_qc_types:338 self.savedFields[qc_type.qcName] = qc_type.defaultThreshold339 self.qcNames.append(qc_type.qcName)340 def getStepName(self):341 return StepNames.SAVE_PLAN342 def validateField(self, field_name, new_field_value):343 self.validationErrors.pop(field_name, None)344 # if the plan has been sequenced, do not enforce the target bed file to be selected345 planStatus = self.getDefaultSectionPrepopulatedFieldDict().get("planStatus", "")346 if field_name == SavePlanFieldNames.PLAN_NAME:347 errors = validate_plan_name(348 new_field_value,349 field_label=_("workflow.step.saveplan.fields.planName.label"),350 ) # 'Plan Name'351 if errors:352 self.validationErrors[field_name] = "\n".join(errors)353 elif field_name == SavePlanFieldNames.NOTE:354 errors = validate_notes(355 new_field_value,356 field_label=_("workflow.step.saveplan.fields.note.label"),357 )358 if errors:359 self.validationErrors[field_name] = "\n".join(errors)360 elif field_name == SavePlanFieldNames.BARCODE_SAMPLE_TUBE_LABEL:361 errors = validate_sample_tube_label(362 new_field_value,363 field_label=_(364 "workflow.step.sample.fields.barcodeSampleTubeLabel.label"365 ),366 )367 if errors:368 self.validationErrors[field_name] = "\n".join(errors)369 elif field_name == SavePlanFieldNames.CHIP_BARCODE_LABEL:370 errors = validate_chipBarcode(371 new_field_value,372 field_label=_("workflow.step.saveplan.fields.chipBarcodeLabel.label"),373 )374 if errors:375 self.validationErrors[field_name] = "\n".join(errors)376 elif field_name in self.qcNames:377 """378 All qc thresholds must be positive integers379 """380 errors = validate_QC(381 new_field_value, ModelsQcTypeToLabelsQcType(field_name)382 )383 if errors:384 self.validationErrors[field_name] = errors[0]385 else:386 self.validationErrors.pop(field_name, None)387 elif field_name == SavePlanFieldNames.SAMPLES_TABLE:388 sample_table_list = json.loads(new_field_value)389 samples_errors = []390 applProduct = self.savedObjects[SavePlanFieldNames.APPL_PRODUCT]391 # applProduct object is not saved yet392 if applProduct:393 isTargetRegionSelectionRequired = (394 applProduct.isTargetRegionBEDFileSelectionRequiredForRefSelection395 )396 else:397 isTargetRegionSelectionRequired = False398 applicationGroupName = self.prepopulatedFields[399 SavePlanFieldNames.APPLICATION_GROUP_NAME400 ]401 for row in sample_table_list:402 sample_name = row.get(SavePlanFieldNames.SAMPLE_NAME, "").strip()403 if sample_name:404 sample_nucleotideType = row.get(405 SavePlanFieldNames.BARCODE_SAMPLE_NUCLEOTIDE_TYPE, ""406 )407 sampleReference = row.get(408 SavePlanFieldNames.BARCODE_SAMPLE_REFERENCE, ""409 )410 sampleTargetRegionBedFile = row.get(411 SavePlanFieldNames.BARCODE_SAMPLE_TARGET_REGION_BED_FILE, ""412 )413 runType = self.prepopulatedFields[SavePlanFieldNames.RUN_TYPE]414 errors = []415 # if the plan has been sequenced, do not enforce the target bed file to be selected416 isMainBEDFileValidated = (417 "default_targetBedFile" in self.validationErrors418 )419 if (420 not isMainBEDFileValidated421 and planStatus != "run"422 and (self.sh_type not in StepHelperType.TEMPLATE_TYPES)423 ):424 sampleTargetRegionBedFile_label = _(425 "workflow.step.saveplan.bysample.fields.targetRegionBedFile.label"426 ) % {"sampleName": sample_name}427 errors = validate_targetRegionBedFile_for_runType(428 sampleTargetRegionBedFile,429 field_label=sampleTargetRegionBedFile_label,430 runType=runType,431 reference=sampleReference,432 nucleotideType=sample_nucleotideType,433 applicationGroupName=applicationGroupName,434 ) # "Target Regions BED File for %(sampleName)s"435 if errors:436 samples_errors.append("\n".join(errors))437 if samples_errors:438 self.validationErrors[field_name] = "\n".join(samples_errors)439 def validateStep(self):440 any_samples = False441 self.validationErrors[SavePlanFieldNames.BAD_SAMPLE_NAME] = []442 self.validationErrors[SavePlanFieldNames.BAD_SAMPLE_EXTERNAL_ID] = []443 self.validationErrors[SavePlanFieldNames.BAD_SAMPLE_DESCRIPTION] = []444 self.validationErrors[SavePlanFieldNames.BAD_TUBE_LABEL] = []445 self.validationErrors[SavePlanFieldNames.BAD_CHIP_BARCODE] = []446 self.validationErrors[SavePlanFieldNames.BAD_IR_SET_ID] = []447 self.validationErrors.pop(SavePlanFieldNames.NO_BARCODE, None)448 self.validationErrors.pop(SavePlanFieldNames.BAD_BARCODES, None)449 barcodeSet = self.savedFields[SavePlanFieldNames.BARCODE_SET]450 selectedBarcodes = []451 endBarcodeSet = self.savedFields[SavePlanFieldNames.END_BARCODE_SET]452 selectedEndBarcodes = []453 samplesTable = json.loads(self.savedFields[SavePlanFieldNames.SAMPLES_TABLE])454 # logger.debug("save_plan_step_data - anySamples? samplesTable=%s" %(samplesTable))455 for row in samplesTable:456 sample_name = row.get(SavePlanFieldNames.SAMPLE_NAME, "").strip()457 # logger.debug("save_plan_step_data - anySamples? sampleName=%s" %(sample_name))458 if sample_name:459 any_samples = True460 if validate_sample_name(461 sample_name, field_label=_Sample.displayedName.verbose_name462 ):463 self.validationErrors[SavePlanFieldNames.BAD_SAMPLE_NAME].append(464 sample_name465 )466 external_id = row.get(SavePlanFieldNames.SAMPLE_EXTERNAL_ID, "")467 if external_id:468 self.validate_field(469 external_id,470 self.validationErrors[471 SavePlanFieldNames.BAD_SAMPLE_EXTERNAL_ID472 ],473 )474 description = row.get(SavePlanFieldNames.SAMPLE_DESCRIPTION, "")475 if description:476 self.validate_field(477 description,478 self.validationErrors[479 SavePlanFieldNames.BAD_SAMPLE_DESCRIPTION480 ],481 False,482 MAX_LENGTH_SAMPLE_DESCRIPTION,483 )484 ir_set_id = row.get("irSetId", "")485 if ir_set_id and not (str(ir_set_id).isdigit()):486 self.validationErrors[SavePlanFieldNames.BAD_IR_SET_ID].append(487 ir_set_id488 )489 tube_label = row.get("tubeLabel", "")490 if validate_sample_tube_label(491 tube_label,492 field_label=_(493 "workflow.step.saveplan.fields.barcodeSampleTubeLabel.label"494 ),495 ):496 self.validationErrors[SavePlanFieldNames.BAD_TUBE_LABEL].append(497 tube_label498 )499 chip_barcode = row.get("chipBarcode", "")500 if validate_chipBarcode(501 chip_barcode,502 field_label=_(503 "workflow.step.saveplan.fields.chipBarcodeLabel.label"504 ),505 ):506 self.validationErrors[SavePlanFieldNames.BAD_CHIP_BARCODE].append(507 chip_barcode508 )509 if barcodeSet:510 selectedBarcodes.append(511 row.get(SavePlanFieldNames.BARCODE_SAMPLE_BARCODE_ID_UI_KEY)512 )513 if endBarcodeSet:514 endBarcode_id_value = row.get(515 SavePlanFieldNames.BARCODE_SAMPLE_END_BARCODE_ID_UI_KEY516 )517 if endBarcode_id_value:518 selectedEndBarcodes.append(endBarcode_id_value)519 if any_samples:520 self.validationErrors.pop(SavePlanFieldNames.NO_SAMPLES, None)521 else:522 self.validationErrors[523 SavePlanFieldNames.NO_SAMPLES524 ] = validation.invalid_required_at_least_one(_Sample.verbose_name)525 if not self.validationErrors[SavePlanFieldNames.BAD_SAMPLE_NAME]:526 self.validationErrors.pop(SavePlanFieldNames.BAD_SAMPLE_NAME, None)527 if not self.validationErrors[SavePlanFieldNames.BAD_TUBE_LABEL]:528 self.validationErrors.pop(SavePlanFieldNames.BAD_TUBE_LABEL, None)529 if not self.validationErrors[SavePlanFieldNames.BAD_CHIP_BARCODE]:530 self.validationErrors.pop(SavePlanFieldNames.BAD_CHIP_BARCODE, None)531 if not self.validationErrors[SavePlanFieldNames.BAD_SAMPLE_EXTERNAL_ID]:532 self.validationErrors.pop(SavePlanFieldNames.BAD_SAMPLE_EXTERNAL_ID, None)533 if not self.validationErrors[SavePlanFieldNames.BAD_SAMPLE_DESCRIPTION]:534 self.validationErrors.pop(SavePlanFieldNames.BAD_SAMPLE_DESCRIPTION, None)535 if not self.validationErrors[SavePlanFieldNames.BAD_IR_SET_ID]:536 self.validationErrors.pop(SavePlanFieldNames.BAD_IR_SET_ID, None)537 # 20170928-TODO-WIP538 if barcodeSet:539 errors = validate_barcode_sample_association(selectedBarcodes, barcodeSet)540 myErrors = convert(errors)541 if myErrors.get("MISSING_BARCODE", ""):542 self.validationErrors[SavePlanFieldNames.NO_BARCODE] = myErrors.get(543 "MISSING_BARCODE", ""544 )545 if myErrors.get("DUPLICATE_BARCODE", ""):546 self.validationErrors[SavePlanFieldNames.BAD_BARCODES] = myErrors.get(547 "DUPLICATE_BARCODE", ""548 )549 if selectedEndBarcodes:550 applProduct = self.savedObjects[SavePlanFieldNames.APPL_PRODUCT]551 if applProduct and applProduct.dualBarcodingRule == "no_reuse":552 errors = validate_barcode_sample_association(553 selectedEndBarcodes, endBarcodeSet, isEndBarcodeExists=True554 )555 myErrors = convert(errors)556 if myErrors.get("DUPLICATE_BARCODE", ""):557 self.validationErrors[558 SavePlanFieldNames.BAD_BARCODES559 ] = myErrors.get("DUPLICATE_BARCODE", "")560 def validate_field(561 self,562 value,563 bad_samples,564 validate_leading_chars=True,565 max_length=MAX_LENGTH_SAMPLE_NAME,566 ):567 exists = False568 if value:569 exists = True570 if not validation.is_valid_chars(value):571 bad_samples.append(value)572 if (573 validate_leading_chars574 and value not in bad_samples575 and not validation.is_valid_leading_chars(value)576 ):577 bad_samples.append(value)578 if value not in bad_samples and not validation.is_valid_length(579 value, max_length580 ):581 bad_samples.append(value)582 return exists583 def updateSavedObjectsFromSavedFields(self):584 self.prepopulatedFields["fireValidation"] = "0"585 for section, sectionObj in list(self.step_sections.items()):586 sectionObj.updateSavedObjectsFromSavedFields()587 if section == StepNames.REFERENCE:588 self.prepopulatedFields[589 SavePlanFieldNames.PLAN_REFERENCE590 ] = sectionObj.savedFields.get(ReferenceFieldNames.REFERENCE, "")591 self.prepopulatedFields[592 SavePlanFieldNames.PLAN_TARGET_REGION_BED_FILE593 ] = sectionObj.savedFields.get(ReferenceFieldNames.TARGET_BED_FILE, "")594 self.prepopulatedFields[595 SavePlanFieldNames.PLAN_HOTSPOT_REGION_BED_FILE596 ] = sectionObj.savedFields.get(597 ReferenceFieldNames.HOT_SPOT_BED_FILE, ""598 )599 # logger.debug("save_plan_step_data.updateSavedObjectsFromSavedFields() REFERENCE reference.savedFields=%s" %(sectionObj.savedFields))600 self.savedObjects[SavePlanFieldNames.SAMPLES_TABLE_LIST] = json.loads(601 self.savedFields[SavePlanFieldNames.SAMPLES_TABLE]602 )603 self.prepopulatedFields[SavePlanFieldNames.NUM_SAMPLES] = len(604 self.savedObjects[SavePlanFieldNames.SAMPLES_TABLE_LIST]605 )606 self.savedObjects[607 SavePlanFieldNames.IR_PLUGIN_ENTRIES608 ] = update_ir_plugin_from_samples_table(609 self.savedObjects[SavePlanFieldNames.SAMPLES_TABLE_LIST]610 )611 if self.savedFields[SavePlanFieldNames.BARCODE_SET]:612 planReference = self.prepopulatedFields[SavePlanFieldNames.PLAN_REFERENCE]613 planHotSptRegionBedFile = self.prepopulatedFields[614 SavePlanFieldNames.PLAN_HOTSPOT_REGION_BED_FILE615 ]616 planTargetRegionBedFile = self.prepopulatedFields[617 SavePlanFieldNames.PLAN_TARGET_REGION_BED_FILE618 ]619 logger.debug(620 "save_plan_step_data.updateSavedObjectsFromSavedFields() BARCODE_SET PLAN_REFERENCE=%s; TARGET_REGION=%s; HOTSPOT_REGION=%s;"621 % (planReference, planTargetRegionBedFile, planHotSptRegionBedFile)622 )623 reference_step_helper = self.savedObjects[624 SavePlanFieldNames.REFERENCE_STEP_HELPER625 ]626 endBarcodeKit = self.savedFields[SavePlanFieldNames.END_BARCODE_SET]627 self.savedObjects[SavePlanFieldNames.SAMPLE_TO_BARCODE] = {}628 for row in self.savedObjects[SavePlanFieldNames.SAMPLES_TABLE_LIST]:629 logger.debug(630 "save_plan_step_data.updateSavedObjectsFromSavedFields() BARCODE_SET LOOP row=%s"631 % (row)632 )633 sample_name = row.get(SavePlanFieldNames.SAMPLE_NAME, "").strip()634 if sample_name:635 id_str = row[SavePlanFieldNames.BARCODE_SAMPLE_BARCODE_ID_UI_KEY]636 end_id_str = row[637 SavePlanFieldNames.BARCODE_SAMPLE_END_BARCODE_ID_UI_KEY638 ]639 # update barcodedSamples dict640 if (641 sample_name642 not in self.savedObjects[SavePlanFieldNames.SAMPLE_TO_BARCODE]643 ):644 self.savedObjects[SavePlanFieldNames.SAMPLE_TO_BARCODE][645 sample_name646 ] = {647 KitsFieldNames.BARCODES: [],648 SavePlanFieldNames.BARCODE_SAMPLE_INFO: {},649 SavePlanFieldNames.DUAL_BARCODES_DB_KEY: [],650 }651 sample_nucleotideType = row.get(652 SavePlanFieldNames.BARCODE_SAMPLE_NUCLEOTIDE_TYPE, ""653 )654 sampleReference = row.get(655 SavePlanFieldNames.BARCODE_SAMPLE_REFERENCE, ""656 )657 sampleHotSpotRegionBedFile = row.get(658 SavePlanFieldNames.BARCODE_SAMPLE_HOTSPOT_REGION_BED_FILE, ""659 )660 sampleTargetRegionBedFile = row.get(661 SavePlanFieldNames.BARCODE_SAMPLE_TARGET_REGION_BED_FILE, ""662 )663 runType = self.prepopulatedFields[SavePlanFieldNames.RUN_TYPE]664 # logger.debug("save_plan_step_data.updateSavedObjectsFromSavedFields() SETTING reference step helper runType=%s; sample_nucleotideType=%s; sampleReference=%s" %(runType, sample_nucleotideType, sampleReference))665 sseBedFile = ""666 if reference_step_helper:667 sseBedFile = reference_step_helper.get_sseBedFile(668 sampleTargetRegionBedFile669 )670 self.savedObjects[SavePlanFieldNames.SAMPLE_TO_BARCODE][671 sample_name672 ][KitsFieldNames.BARCODES].append(id_str)673 self.savedObjects[SavePlanFieldNames.SAMPLE_TO_BARCODE][674 sample_name675 ][SavePlanFieldNames.BARCODE_SAMPLE_INFO][id_str] = {676 SavePlanFieldNames.EXTERNAL_ID: row.get(677 SavePlanFieldNames.SAMPLE_EXTERNAL_ID, ""678 ),679 SavePlanFieldNames.DESCRIPTION: row.get(680 SavePlanFieldNames.SAMPLE_DESCRIPTION, ""681 ),682 SavePlanFieldNames.BARCODE_SAMPLE_NUCLEOTIDE_TYPE: sample_nucleotideType,683 SavePlanFieldNames.BARCODE_SAMPLE_REFERENCE: sampleReference,684 SavePlanFieldNames.BARCODE_SAMPLE_TARGET_REGION_BED_FILE: sampleTargetRegionBedFile,685 SavePlanFieldNames.BARCODE_SAMPLE_HOTSPOT_REGION_BED_FILE: sampleHotSpotRegionBedFile,686 SavePlanFieldNames.BARCODE_SAMPLE_SSE_BED_FILE: sseBedFile,687 SavePlanFieldNames.BARCODE_SAMPLE_END_BARCODE_DB_KEY: row.get(688 SavePlanFieldNames.BARCODE_SAMPLE_END_BARCODE_ID_UI_KEY, ""689 ),690 SavePlanFieldNames.BARCODE_SAMPLE_CONTROL_SEQ_TYPE: row.get(691 SavePlanFieldNames.BARCODE_SAMPLE_CONTROL_SEQ_TYPE, ""692 ),693 SavePlanFieldNames.BARCODE_SAMPLE_CONTROL_TYPE: row.get(694 SavePlanFieldNames.BARCODE_SAMPLE_CONTROL_TYPE, ""695 ),696 }697 if endBarcodeKit and id_str:698 if end_id_str:699 self.savedObjects[SavePlanFieldNames.SAMPLE_TO_BARCODE][700 sample_name701 ][SavePlanFieldNames.DUAL_BARCODES_DB_KEY].append(702 id_str703 + PlannedExperiment.get_dualBarcodes_delimiter()704 + end_id_str705 )706 else:707 self.savedObjects[SavePlanFieldNames.SAMPLE_TO_BARCODE][708 sample_name709 ][SavePlanFieldNames.DUAL_BARCODES_DB_KEY].append(id_str)710 def alternateUpdateFromStep(self, updated_step):711 """712 also runs if editing a plan post-sequencing and Application is updated713 """714 if updated_step.getStepName() == StepNames.APPLICATION:715 if updated_step.savedObjects[ApplicationFieldNames.RUN_TYPE]:716 runTypeObj = updated_step.savedObjects[ApplicationFieldNames.RUN_TYPE]717 # make sure hidden nucleotide type field is updated for new Application718 if (719 self.prepopulatedFields.get(SavePlanFieldNames.RUN_TYPE)720 and self.prepopulatedFields[SavePlanFieldNames.RUN_TYPE]721 != runTypeObj.runType722 ):723 nucleotideType = runTypeObj.nucleotideType.upper()724 if nucleotideType in ["DNA", "RNA"]:725 for row in self.savedObjects[726 SavePlanFieldNames.SAMPLES_TABLE_LIST727 ]:728 row[729 SavePlanFieldNames.BARCODE_SAMPLE_NUCLEOTIDE_TYPE730 ] = nucleotideType731 self.savedFields[SavePlanFieldNames.SAMPLES_TABLE] = json.dumps(732 self.savedObjects[SavePlanFieldNames.SAMPLES_TABLE_LIST]733 )734 self.prepopulatedFields[735 SavePlanFieldNames.RUN_TYPE736 ] = runTypeObj.runType737 else:738 self.prepopulatedFields[SavePlanFieldNames.RUN_TYPE] = ""739 def updateFromStep(self, updated_step):740 if updated_step.getStepName() not in self._dependsOn:741 for sectionKey, sectionObj in list(self.step_sections.items()):742 if sectionObj:743 # logger.debug("save_plan_step_data.updateFromStep() sectionKey=%s" %(sectionKey))744 for key in list(sectionObj.getCurrentSavedFieldDict().keys()):745 sectionObj.updateFromStep(updated_step)746 return747 self.alternateUpdateFromStep(updated_step)748 if updated_step.getStepName() == StepNames.APPLICATION:749 if not updated_step.savedObjects[ApplicationFieldNames.APPL_PRODUCT]:750 logger.debug(751 "save_plan_step_data.updateFromStep() --- NO-OP --- APPLICATION APPL_PRODUCT IS NOT YET SET!!! "752 )753 return754 if (755 updated_step.getStepName() == StepNames.APPLICATION756 and updated_step.savedObjects[ApplicationFieldNames.APPL_PRODUCT]757 ):758 self.savedObjects[759 SavePlanFieldNames.APPL_PRODUCT760 ] = updated_step.savedObjects[ApplicationFieldNames.APPL_PRODUCT]761 if updated_step.getStepName() == StepNames.KITS:762 barcode_set = updated_step.savedFields[KitsFieldNames.BARCODE_ID]763 if str(barcode_set) != str(764 self.savedFields[SavePlanFieldNames.BARCODE_SET]765 ):766 self.savedFields[SavePlanFieldNames.BARCODE_SET] = barcode_set767 if barcode_set:768 barcodes = list(769 dnaBarcode.objects.filter(name=barcode_set).order_by("index")770 )771 bc_count = min(772 len(barcodes),773 len(self.savedObjects[SavePlanFieldNames.SAMPLES_TABLE_LIST]),774 )775 self.savedObjects[776 SavePlanFieldNames.SAMPLES_TABLE_LIST777 ] = self.savedObjects[SavePlanFieldNames.SAMPLES_TABLE_LIST][778 :bc_count779 ]780 for i in range(bc_count):781 self.savedObjects[SavePlanFieldNames.SAMPLES_TABLE_LIST][i][782 SavePlanFieldNames.BARCODE_SAMPLE_BARCODE_ID_UI_KEY783 ] = barcodes[i].id_str784 self.savedFields[SavePlanFieldNames.SAMPLES_TABLE] = json.dumps(785 self.savedObjects[SavePlanFieldNames.SAMPLES_TABLE_LIST]786 )787 # if barcode kit selection changes, re-validate788 self.validateStep()789 if updated_step.getStepName() == StepNames.IONREPORTER:790 ir_account_id = updated_step.savedFields[791 IonReporterFieldNames.IR_ACCOUNT_ID792 ]793 ir_workflow = updated_step.savedFields[IonReporterFieldNames.IR_WORKFLOW]794 ir_isfactory = updated_step.savedFields[IonReporterFieldNames.IR_ISFACTORY]795 if ir_account_id and ir_account_id != "0":796 if (797 self.prepopulatedFields[SavePlanFieldNames.IR_WORKFLOW]798 != ir_workflow799 or self.prepopulatedFields[SavePlanFieldNames.IR_ISFACTORY]800 != ir_isfactory801 ):802 for row in self.savedObjects[SavePlanFieldNames.SAMPLES_TABLE_LIST]:803 row[SavePlanFieldNames.IR_WORKFLOW] = ir_workflow804 row[SavePlanFieldNames.IR_ISFACTORY] = ir_isfactory805 self.savedFields[SavePlanFieldNames.SAMPLES_TABLE] = json.dumps(806 self.savedObjects[SavePlanFieldNames.SAMPLES_TABLE_LIST]807 )808 self.prepopulatedFields[SavePlanFieldNames.IR_WORKFLOW] = ir_workflow809 self.prepopulatedFields[SavePlanFieldNames.IR_ISFACTORY] = ir_isfactory810 self.prepopulatedFields[SavePlanFieldNames.SELECTED_IR] = ir_account_id811 for sectionKey, sectionObj in list(self.step_sections.items()):812 if sectionObj:813 sectionObj.updateFromStep(updated_step)814 logger.debug(815 "EXIT save_plan_step_data.updateFromStep() self.savedFields=%s"816 % (self.savedFields)817 )818 def getDefaultSection(self):819 """820 Sections are optional for a step. Return the default section821 """822 if not self.step_sections:823 return None824 return self.step_sections.get(StepNames.REFERENCE, None)825 def getDefaultSectionSavedFieldDict(self):826 """827 Sections are optional for a step. Return the savedFields dictionary of the default section if it exists.828 Otherwise, return an empty dictionary829 """830 default_value = {}831 if not self.step_sections:832 return default_value833 sectionObj = self.step_sections.get(StepNames.REFERENCE, None)834 if sectionObj:835 # logger.debug("save_plan_step_data.getDefaultSectionSavedFieldDict() sectionObj.savedFields=%s" %(sectionObj.savedFields))836 return sectionObj.savedFields837 else:838 return default_value839 def getDefaultSectionPrepopulatedFieldDict(self):840 """841 Sections are optional for a step. Return the prepopuldatedFields dictionary of the default section if it exists.842 Otherwise, return an empty dictionary843 """844 default_value = {}845 if not self.step_sections:846 return default_value847 sectionObj = self.step_sections.get(StepNames.REFERENCE, None)848 if sectionObj:849 # logger.debug("save_plan_step_data.getDefaultSectionPrepopulatedFieldsFieldDict() sectionObj.prepopulatedFields=%s" %(sectionObj.prepopulatedFields))850 return sectionObj.prepopulatedFields851 else:...

Full Screen

Full Screen

barcode_by_sample_step_data.py

Source:barcode_by_sample_step_data.py Github

copy

Full Screen

1# Copyright (C) 2013 Ion Torrent Systems, Inc. All Rights Reserved2from collections import OrderedDict3from iondb.rundb.plan.page_plan.abstract_step_data import AbstractStepData4from iondb.rundb.models import (5 dnaBarcode,6 SampleAnnotation_CV,7 RunType,8 PlannedExperiment,9)10from iondb.rundb.plan.page_plan.step_names import StepNames11from iondb.rundb.plan.page_plan.application_step_data import ApplicationFieldNames12from iondb.rundb.plan.page_plan.kits_step_data import KitsFieldNames13from iondb.rundb.plan.page_plan.reference_step_data import ReferenceFieldNames14from iondb.rundb.plan.page_plan.save_plan_step_data import (15 SavePlanFieldNames,16 update_ir_plugin_from_samples_table,17)18from iondb.rundb.plan.plan_validator import (19 validate_sample_tube_label,20 validate_barcode_sample_association,21 validate_targetRegionBedFile_for_runType,22 validate_chipBarcode,23)24from iondb.rundb.plan.page_plan.ionreporter_step_data import IonReporterFieldNames25from iondb.utils.utils import convert26from django.core.serializers.json import DjangoJSONEncoder27from django.core.urlresolvers import reverse28from django.utils.translation import ugettext as _29import json30import logging31logger = logging.getLogger(__name__)32class BarcodeBySampleFieldNames:33 # NOTE: this step uses field names from save_plan_step_data for consistency34 SAMPLESET_ITEMS = "samplesetitems"35 ONCO_SAME_SAMPLE = "isOncoSameSample"36 HAS_PGS_DATA = "hasPgsData"37 HAS_ONCO_DATA = "hasOncoData"38 SHOW_SAMPLESET_INFO = "showSampleSetInfo"39class BarcodeBySampleStepData(AbstractStepData):40 def __init__(self, sh_type):41 super(BarcodeBySampleStepData, self).__init__(sh_type)42 self.resourcePath = "rundb/plan/page_plan/page_plan_by_sample_barcode.html"43 self.prev_step_url = reverse("page_plan_plugins")44 self.next_step_url = reverse("page_plan_output")45 self.savedFields = OrderedDict()46 self.savedFields[SavePlanFieldNames.BARCODE_SET] = ""47 self.savedFields[SavePlanFieldNames.BARCODE_SAMPLE_TUBE_LABEL] = ""48 self.savedFields[SavePlanFieldNames.CHIP_BARCODE_LABEL] = ""49 # for non-barcoded planBySampleSet50 self.savedFields[SavePlanFieldNames.TUBE_LABEL] = ""51 self.savedFields[SavePlanFieldNames.APPLICATION_TYPE] = ""52 self.savedFields[SavePlanFieldNames.IR_DOWN] = "0"53 self.prepopulatedFields[SavePlanFieldNames.SELECTED_IR] = None54 self.prepopulatedFields[SavePlanFieldNames.IR_WORKFLOW] = None55 self.prepopulatedFields[SavePlanFieldNames.IR_ISFACTORY] = False56 self.prepopulatedFields[BarcodeBySampleFieldNames.SAMPLESET_ITEMS] = []57 self.prepopulatedFields[BarcodeBySampleFieldNames.SHOW_SAMPLESET_INFO] = False58 self.prepopulatedFields[SavePlanFieldNames.SAMPLE_ANNOTATIONS] = list(59 SampleAnnotation_CV.objects.filter(isActive=True).order_by(60 "annotationType", "value"61 )62 )63 self.prepopulatedFields[SavePlanFieldNames.FIRE_VALIDATION] = "1"64 self.savedObjects[SavePlanFieldNames.IR_PLUGIN_ENTRIES] = []65 self.savedObjects[SavePlanFieldNames.SAMPLE_TO_BARCODE] = OrderedDict()66 barcodeObjs_list = list(67 dnaBarcode.objects.filter(active=True)68 .values_list("name", flat=True)69 .distinct()70 .order_by("name")71 )72 self.prepopulatedFields[SavePlanFieldNames.BARCODE_SETS] = barcodeObjs_list73 all_barcodes = {}74 for bc in (75 dnaBarcode.objects.filter(active=True)76 .order_by("name", "index")77 .values("name", "id_str", "sequence")78 ):79 all_barcodes.setdefault(bc["name"], []).append(bc)80 self.prepopulatedFields[SavePlanFieldNames.BARCODE_SETS_BARCODES] = json.dumps(81 all_barcodes82 )83 self.prepopulatedFields[SavePlanFieldNames.BARCODE_SETS_STATIC] = (84 dnaBarcode.objects.filter(active=True)85 .exclude(end_sequence="")86 .values_list("name", flat=True)87 .distinct()88 )89 self.prepopulatedFields[SavePlanFieldNames.END_BARCODE_SETS] = barcodeObjs_list90 self.prepopulatedFields[91 SavePlanFieldNames.END_BARCODE_SETS_BARCODES92 ] = json.dumps(all_barcodes)93 self.savedObjects[SavePlanFieldNames.SAMPLES_TABLE_LIST] = [{"row": "1"}]94 self.savedFields[SavePlanFieldNames.SAMPLES_TABLE] = json.dumps(95 self.savedObjects[SavePlanFieldNames.SAMPLES_TABLE_LIST]96 )97 self.prepopulatedFields[SavePlanFieldNames.NUM_SAMPLES] = 198 self.savedFields[SavePlanFieldNames.ONCO_SAME_SAMPLE] = False99 self.savedObjects[SavePlanFieldNames.REFERENCE_STEP_HELPER] = None100 self.savedObjects[SavePlanFieldNames.APPL_PRODUCT] = None101 self.prepopulatedFields[SavePlanFieldNames.PLAN_REFERENCE] = ""102 self.prepopulatedFields[SavePlanFieldNames.PLAN_TARGET_REGION_BED_FILE] = ""103 self.prepopulatedFields[SavePlanFieldNames.PLAN_HOTSPOT_REGION_BED_FILE] = ""104 self.prepopulatedFields[SavePlanFieldNames.RUN_TYPE] = ""105 self.prepopulatedFields[SavePlanFieldNames.APPLICATION_GROUP_NAME] = ""106 self.prepopulatedFields[BarcodeBySampleFieldNames.HAS_ONCO_DATA] = False107 self.prepopulatedFields[BarcodeBySampleFieldNames.HAS_PGS_DATA] = False108 self._dependsOn.append(StepNames.IONREPORTER)109 self._dependsOn.append(StepNames.APPLICATION)110 # self._dependsOn.append(StepNames.REFERENCE)111 self.sh_type = sh_type112 def getStepName(self):113 return StepNames.BARCODE_BY_SAMPLE114 def alternateUpdateFromStep(self, updated_step):115 """116 also runs if editing a plan post-sequencing and Application is updated117 """118 if updated_step.getStepName() == StepNames.APPLICATION:119 if updated_step.savedObjects[ApplicationFieldNames.RUN_TYPE]:120 runTypeObj = updated_step.savedObjects[ApplicationFieldNames.RUN_TYPE]121 # make sure hidden nucleotide type field is updated for new Application122 if (123 self.prepopulatedFields.get(SavePlanFieldNames.RUN_TYPE)124 and self.prepopulatedFields[SavePlanFieldNames.RUN_TYPE]125 != runTypeObj.runType126 ):127 nucleotideType = runTypeObj.nucleotideType.upper()128 if nucleotideType in ["DNA", "RNA"]:129 for row in self.savedObjects[130 SavePlanFieldNames.SAMPLES_TABLE_LIST131 ]:132 row["nucleotideType"] = nucleotideType133 self.savedFields[SavePlanFieldNames.SAMPLES_TABLE] = json.dumps(134 self.savedObjects[SavePlanFieldNames.SAMPLES_TABLE_LIST]135 )136 self.prepopulatedFields[137 SavePlanFieldNames.RUN_TYPE138 ] = runTypeObj.runType139 else:140 self.prepopulatedFields[SavePlanFieldNames.RUN_TYPE] = ""141 def updateFromStep(self, updated_step):142 if updated_step.getStepName() not in self._dependsOn:143 return144 self.alternateUpdateFromStep(updated_step)145 if updated_step.getStepName() == StepNames.APPLICATION:146 if not updated_step.savedObjects[ApplicationFieldNames.APPL_PRODUCT]:147 logger.debug(148 "barcode_by_sample_step_data.updateFromStep() --- NO-OP --- APPLICATION APPL_PRODUCT IS NOT YET SET!!! "149 )150 return151 if updated_step.getStepName() == StepNames.IONREPORTER:152 ir_account_id = updated_step.savedFields[153 IonReporterFieldNames.IR_ACCOUNT_ID154 ]155 ir_workflow = updated_step.savedFields[IonReporterFieldNames.IR_WORKFLOW]156 ir_isfactory = updated_step.savedFields[IonReporterFieldNames.IR_ISFACTORY]157 # update samples table with saved sampleset items fields for IR158 if ir_account_id and ir_account_id != "0":159 if (160 self.prepopulatedFields[SavePlanFieldNames.IR_WORKFLOW]161 != ir_workflow162 or self.prepopulatedFields[SavePlanFieldNames.IR_ISFACTORY]163 != ir_isfactory164 ):165 sorted_sampleSetItems = self.prepopulatedFields[166 BarcodeBySampleFieldNames.SAMPLESET_ITEMS167 ]168 for row in self.savedObjects[SavePlanFieldNames.SAMPLES_TABLE_LIST]:169 row[SavePlanFieldNames.IR_WORKFLOW] = ir_workflow170 row[SavePlanFieldNames.IR_ISFACTORY] = ir_isfactory171 sampleset_item = [172 item173 for item in sorted_sampleSetItems174 if item.sample.displayedName == row["sampleName"]175 ]176 if len(sampleset_item) > 0:177 row[178 SavePlanFieldNames.IR_SAMPLE_COLLECTION_DATE179 ] = sampleset_item[0].sampleCollectionDate180 row[181 SavePlanFieldNames.IR_SAMPLE_RECEIPT_DATE182 ] = sampleset_item[0].sampleReceiptDate183 row[SavePlanFieldNames.IR_GENDER] = sampleset_item[0].gender184 row[SavePlanFieldNames.IR_POPULATION] = sampleset_item[185 0186 ].population187 row[SavePlanFieldNames.IR_MOUSE_STRAINS] = sampleset_item[188 0189 ].mouseStrains190 row[SavePlanFieldNames.IR_RELATION_ROLE] = sampleset_item[191 0192 ].relationshipRole193 row[SavePlanFieldNames.IR_SET_ID] = sampleset_item[194 0195 ].relationshipGroup196 row[SavePlanFieldNames.IR_CANCER_TYPE] = sampleset_item[197 0198 ].cancerType199 row[SavePlanFieldNames.IR_CELLULARITY_PCT] = sampleset_item[200 0201 ].cellularityPct202 row[SavePlanFieldNames.IR_BIOPSY_DAYS] = sampleset_item[203 0204 ].biopsyDays205 row[SavePlanFieldNames.IR_CELL_NUM] = sampleset_item[206 0207 ].cellNum208 row[SavePlanFieldNames.IR_COUPLE_ID] = sampleset_item[209 0210 ].coupleId211 row[SavePlanFieldNames.IR_EMBRYO_ID] = sampleset_item[212 0213 ].embryoId214 self.savedFields[SavePlanFieldNames.SAMPLES_TABLE] = json.dumps(215 self.savedObjects[SavePlanFieldNames.SAMPLES_TABLE_LIST],216 cls=DjangoJSONEncoder,217 )218 self.prepopulatedFields[SavePlanFieldNames.IR_WORKFLOW] = ir_workflow219 self.prepopulatedFields[SavePlanFieldNames.IR_ISFACTORY] = ir_isfactory220 self.prepopulatedFields[SavePlanFieldNames.SELECTED_IR] = ir_account_id221 if (222 updated_step.getStepName() == StepNames.APPLICATION223 and updated_step.savedObjects[ApplicationFieldNames.APPL_PRODUCT]224 ):225 self.savedObjects[226 SavePlanFieldNames.APPL_PRODUCT227 ] = updated_step.savedObjects[ApplicationFieldNames.APPL_PRODUCT]228 def validateField(self, field_name, new_field_value):229 self.validationErrors.pop(field_name, None)230 errors = None231 if field_name == SavePlanFieldNames.CHIP_BARCODE_LABEL:232 errors = validate_chipBarcode(233 new_field_value,234 field_label=_("workflow.step.sample.fields.chipBarcodeLabel.label"),235 )236 if errors:237 self.validationErrors[field_name] = "\n".join(errors)238 if field_name == SavePlanFieldNames.BARCODE_SAMPLE_TUBE_LABEL:239 errors = validate_sample_tube_label(240 new_field_value,241 field_label=_(242 "workflow.step.sample.fields.barcodeSampleTubeLabel.label"243 ),244 )245 if errors:246 self.validationErrors[field_name] = "\n".join(errors)247 # if the plan has been sequenced, do not enforce the target bed file to be selected248 planStatus = self.getDefaultSectionPrepopulatedFieldDict().get("planStatus", "")249 if field_name == SavePlanFieldNames.SAMPLES_TABLE:250 sample_table_list = json.loads(new_field_value)251 samples_errors = []252 applProduct = self.savedObjects[SavePlanFieldNames.APPL_PRODUCT]253 # applProduct object is not saved yet254 if applProduct:255 isTargetRegionSelectionRequired = (256 applProduct.isTargetRegionBEDFileSelectionRequiredForRefSelection257 )258 else:259 isTargetRegionSelectionRequired = False260 applicationGroupName = self.prepopulatedFields[261 SavePlanFieldNames.APPLICATION_GROUP_NAME262 ]263 for row in sample_table_list:264 sample_name = row.get(SavePlanFieldNames.SAMPLE_NAME, "").strip()265 if sample_name:266 sample_nucleotideType = row.get(267 SavePlanFieldNames.BARCODE_SAMPLE_NUCLEOTIDE_TYPE, ""268 )269 sampleReference = row.get(270 SavePlanFieldNames.BARCODE_SAMPLE_REFERENCE, ""271 )272 sampleTargetRegionBedFile = row.get(273 SavePlanFieldNames.BARCODE_SAMPLE_TARGET_REGION_BED_FILE, ""274 )275 runType = self.prepopulatedFields[SavePlanFieldNames.RUN_TYPE]276 logger.debug(277 "barcode_by_sample_step_data.validateField() sampleName=%s runType=%s; sample_nucleotideType=%s; sampleReference=%s; sampleTargetRegionBedFile=%s"278 % (279 sample_name,280 runType,281 sample_nucleotideType,282 sampleReference,283 sampleTargetRegionBedFile,284 )285 )286 errors = []287 # if the plan has been sequenced, do not enforce the target bed file to be selected288 if planStatus != "run":289 sampleTargetRegionBedFile_label = _(290 "workflow.step.saveplan.bysample.fields.targetRegionBedFile.label"291 ) % {"sampleName": sample_name}292 errors = validate_targetRegionBedFile_for_runType(293 sampleTargetRegionBedFile,294 field_label=sampleTargetRegionBedFile_label,295 runType=runType,296 reference=sampleReference,297 nucleotideType=sample_nucleotideType,298 applicationGroupName=applicationGroupName,299 ) # "Target Regions BED File for %(sampleName)s"300 if errors:301 samples_errors.append("\n".join(errors))302 if samples_errors:303 logger.debug(304 "barcode_by_sample_step_data.validateField() samples_errors=%s"305 % (samples_errors)306 )307 self.validationErrors[field_name] = "\n".join(samples_errors)308 def validateStep(self):309 self.validationErrors.pop(SavePlanFieldNames.NO_BARCODE, None)310 self.validationErrors.pop(SavePlanFieldNames.BAD_BARCODES, None)311 samplesTable = json.loads(self.savedFields[SavePlanFieldNames.SAMPLES_TABLE])312 barcodeSet = self.savedFields[SavePlanFieldNames.BARCODE_SET]313 selectedBarcodes = []314 endBarcodeSet = self.savedFields[SavePlanFieldNames.END_BARCODE_SET]315 selectedEndBarcodes = []316 for row in samplesTable:317 sample_name = row.get(SavePlanFieldNames.SAMPLE_NAME, "").strip()318 if sample_name:319 if barcodeSet:320 selectedBarcodes.append(321 row.get(SavePlanFieldNames.BARCODE_SAMPLE_BARCODE_ID_UI_KEY)322 )323 if endBarcodeSet:324 endBarcode_id_value = row.get(325 SavePlanFieldNames.BARCODE_SAMPLE_END_BARCODE_ID_UI_KEY326 )327 if endBarcode_id_value:328 selectedEndBarcodes.append(endBarcode_id_value)329 if barcodeSet:330 errors = validate_barcode_sample_association(selectedBarcodes, barcodeSet)331 myErrors = convert(errors)332 if myErrors.get("MISSING_BARCODE", ""):333 self.validationErrors[SavePlanFieldNames.NO_BARCODE] = myErrors.get(334 "MISSING_BARCODE", ""335 )336 if myErrors.get("DUPLICATE_BARCODE", ""):337 self.validationErrors[SavePlanFieldNames.BAD_BARCODES] = myErrors.get(338 "DUPLICATE_BARCODE", ""339 )340 if selectedEndBarcodes:341 applProduct = self.savedObjects[SavePlanFieldNames.APPL_PRODUCT]342 if applProduct and applProduct.dualBarcodingRule == "no_reuse":343 errors = validate_barcode_sample_association(344 selectedEndBarcodes, endBarcodeSet, isEndBarcodeExists=True345 )346 myErrors = convert(errors)347 if myErrors.get("DUPLICATE_BARCODE", ""):348 self.validationErrors[349 SavePlanFieldNames.BAD_BARCODES350 ] = myErrors.get("DUPLICATE_BARCODE", "")351 self.prepopulatedFields[SavePlanFieldNames.FIRE_VALIDATION] = "0"352 def updateSavedObjectsFromSavedFields(self):353 # logger.debug("ENTER barcode_by_sample_step_data.updateSavedObjectsFromSavedFields() self.savedFields[SavePlanFieldNames.BARCODE_SET]=%s" %(self.savedFields[SavePlanFieldNames.BARCODE_SET]))354 self.savedObjects[SavePlanFieldNames.SAMPLES_TABLE_LIST] = json.loads(355 self.savedFields[SavePlanFieldNames.SAMPLES_TABLE]356 )357 self.prepopulatedFields[SavePlanFieldNames.NUM_SAMPLES] = len(358 self.savedObjects[SavePlanFieldNames.SAMPLES_TABLE_LIST]359 )360 self.savedObjects[361 SavePlanFieldNames.IR_PLUGIN_ENTRIES362 ] = update_ir_plugin_from_samples_table(363 self.savedObjects[SavePlanFieldNames.SAMPLES_TABLE_LIST]364 )365 self.prepopulatedFields[366 SavePlanFieldNames.BARCODE_SAMPLE_TUBE_LABEL367 ] = self.savedFields[SavePlanFieldNames.BARCODE_SAMPLE_TUBE_LABEL]368 self.prepopulatedFields[369 SavePlanFieldNames.CHIP_BARCODE_LABEL370 ] = self.savedFields[SavePlanFieldNames.CHIP_BARCODE_LABEL]371 if self.savedFields[SavePlanFieldNames.BARCODE_SET]:372 # logger.debug("barcode_by_sample_step_data.updateSavedObjectsFromSavedFields() BARCODE_SET self.savedFields=%s" %(self.savedFields))373 # logger.debug("barcode_by_sample_step_data.updateSavedObjectsFromSavedFields() BARCODE_SET self=%s" %(self))374 planReference = self.prepopulatedFields[SavePlanFieldNames.PLAN_REFERENCE]375 planHotSpotRegionBedFile = self.prepopulatedFields[376 SavePlanFieldNames.PLAN_HOTSPOT_REGION_BED_FILE377 ]378 planTargetRegionBedFile = self.prepopulatedFields[379 SavePlanFieldNames.PLAN_TARGET_REGION_BED_FILE380 ]381 logger.debug(382 "barcode_by_sample_step_data.updateSavedObjectsFromSavedFields() BARCODE_SET PLAN_REFERENCE=%s; TARGET_REGION=%s; HOTSPOT_REGION=%s;"383 % (planReference, planTargetRegionBedFile, planHotSpotRegionBedFile)384 )385 reference_step_helper = self.savedObjects[386 SavePlanFieldNames.REFERENCE_STEP_HELPER387 ]388 endBarcodeKit = self.savedFields[SavePlanFieldNames.END_BARCODE_SET]389 self.savedObjects[SavePlanFieldNames.SAMPLE_TO_BARCODE] = {}390 for row in self.savedObjects[SavePlanFieldNames.SAMPLES_TABLE_LIST]:391 sample_name = row.get(SavePlanFieldNames.SAMPLE_NAME, "").strip()392 if sample_name:393 id_str = row[SavePlanFieldNames.BARCODE_SAMPLE_BARCODE_ID_UI_KEY]394 end_id_str = row[395 SavePlanFieldNames.BARCODE_SAMPLE_END_BARCODE_ID_UI_KEY396 ]397 # update barcodedSamples dict398 if (399 sample_name400 not in self.savedObjects[SavePlanFieldNames.SAMPLE_TO_BARCODE]401 ):402 self.savedObjects[SavePlanFieldNames.SAMPLE_TO_BARCODE][403 sample_name404 ] = {405 KitsFieldNames.BARCODES: [],406 SavePlanFieldNames.BARCODE_SAMPLE_INFO: {},407 SavePlanFieldNames.DUAL_BARCODES_DB_KEY: [],408 }409 sample_nucleotideType = row.get(410 SavePlanFieldNames.BARCODE_SAMPLE_NUCLEOTIDE_TYPE, ""411 )412 sampleReference = row.get(413 SavePlanFieldNames.BARCODE_SAMPLE_REFERENCE, ""414 )415 sampleHotSpotRegionBedFile = row.get(416 SavePlanFieldNames.BARCODE_SAMPLE_HOTSPOT_REGION_BED_FILE, ""417 )418 sampleTargetRegionBedFile = row.get(419 SavePlanFieldNames.BARCODE_SAMPLE_TARGET_REGION_BED_FILE, ""420 )421 runType = self.prepopulatedFields[SavePlanFieldNames.RUN_TYPE]422 # logger.debug("barcode_by_sample_step_data SETTING reference step helper runType=%s; sample_nucleotideType=%s; sampleReference=%s" %(runType, sample_nucleotideType, sampleReference))423 if not sample_nucleotideType:424 applicationGroupName = self.prepopulatedFields[425 SavePlanFieldNames.APPLICATION_GROUP_NAME426 ]427 planNucleotideType = self._get_nucleotideType_barcodedSamples(428 appGroup=applicationGroupName, runType=runType429 )430 if planNucleotideType:431 sample_nucleotideType = planNucleotideType432 sseBedFile = ""433 if reference_step_helper:434 sseBedFile = reference_step_helper.get_sseBedFile(435 sampleTargetRegionBedFile436 )437 self.savedObjects[SavePlanFieldNames.SAMPLE_TO_BARCODE][438 sample_name439 ][KitsFieldNames.BARCODES].append(id_str)440 self.savedObjects[SavePlanFieldNames.SAMPLE_TO_BARCODE][441 sample_name442 ][SavePlanFieldNames.BARCODE_SAMPLE_INFO][id_str] = {443 SavePlanFieldNames.EXTERNAL_ID: row.get(444 SavePlanFieldNames.SAMPLE_EXTERNAL_ID, ""445 ),446 SavePlanFieldNames.DESCRIPTION: row.get(447 SavePlanFieldNames.SAMPLE_DESCRIPTION, ""448 ),449 SavePlanFieldNames.BARCODE_SAMPLE_NUCLEOTIDE_TYPE: sample_nucleotideType,450 SavePlanFieldNames.BARCODE_SAMPLE_REFERENCE: sampleReference,451 SavePlanFieldNames.BARCODE_SAMPLE_TARGET_REGION_BED_FILE: sampleTargetRegionBedFile,452 SavePlanFieldNames.BARCODE_SAMPLE_HOTSPOT_REGION_BED_FILE: sampleHotSpotRegionBedFile,453 SavePlanFieldNames.BARCODE_SAMPLE_SSE_BED_FILE: sseBedFile,454 SavePlanFieldNames.BARCODE_SAMPLE_END_BARCODE_DB_KEY: row.get(455 SavePlanFieldNames.BARCODE_SAMPLE_END_BARCODE_ID_UI_KEY, ""456 ),457 SavePlanFieldNames.BARCODE_SAMPLE_CONTROL_SEQ_TYPE: row.get(458 SavePlanFieldNames.BARCODE_SAMPLE_CONTROL_SEQ_TYPE, ""459 ),460 SavePlanFieldNames.BARCODE_SAMPLE_CONTROL_TYPE: row.get(461 SavePlanFieldNames.BARCODE_SAMPLE_CONTROL_TYPE, ""462 ),463 }464 if endBarcodeKit and id_str:465 if end_id_str:466 self.savedObjects[SavePlanFieldNames.SAMPLE_TO_BARCODE][467 sample_name468 ][SavePlanFieldNames.DUAL_BARCODES_DB_KEY].append(469 id_str470 + PlannedExperiment.get_dualBarcodes_delimiter()471 + end_id_str472 )473 else:474 self.savedObjects[SavePlanFieldNames.SAMPLE_TO_BARCODE][475 sample_name476 ][SavePlanFieldNames.DUAL_BARCODES_DB_KEY].append(id_str)477 def _get_nucleotideType_barcodedSamples(self, appGroup=None, runType=None):478 value = ""479 runTypeObjs = RunType.objects.filter(runType=runType)480 if runTypeObjs:481 value = runTypeObjs[0].nucleotideType.upper()482 if value not in ["DNA", "RNA"] and appGroup:483 value = appGroup...

Full Screen

Full Screen

analysis_params_step_data.py

Source:analysis_params_step_data.py Github

copy

Full Screen

1# Copyright (C) 2015 Ion Torrent Systems, Inc. All Rights Reserved2from django.utils.translation import ugettext as _3from iondb.rundb.plan.page_plan.abstract_step_data import AbstractStepData4from django.conf import settings5from iondb.utils import validation6from iondb.rundb.models import AnalysisArgs7from iondb.rundb.plan.page_plan.step_names import StepNames8from iondb.rundb.plan.page_plan.application_step_data import ApplicationFieldNames9from iondb.rundb.plan.page_plan.kits_step_data import KitsFieldNames10from iondb.rundb.plan.page_plan.step_helper_types import StepHelperType11import logging12logger = logging.getLogger(__name__)13class AnalysisParamsFieldNames:14 # AP_DICT = "analysisParamsDict"15 AP_ENTRIES = "analysisParamsEntries"16 AP_DISPLAYED_NAMES = "analysisParamsNames"17 AP_ENTRY_SELECTED = "analysisParamsEntrySelected"18 AP_CUSTOM = "analysisParamsCustom"19 AP_ENTRY_PREVIOUSLY_SELECTED = "analysisParamsEntryPreviouslySelected"20 AP_ENTRY_SYSTEM_SELECTED = "analysisParamsEntrySystemSelected"21 AP_ENTRY_SELECTED_VALUE = _(22 "workflow.step.analysisparams.fields.analysis_params.choice.AP_ENTRY_SELECTED_VALUE"23 ) # "<Previous custom selection>"24 AP_ENTRY_PREVIOUSLY_SELECTED_VALUE = _(25 "workflow.step.analysisparams.fields.analysis_params.choice.AP_ENTRY_PREVIOUSLY_SELECTED_VALUE"26 ) # "<Selection before chip/kits selection change>"27 AP_ENTRY_BEST_MATCH_PLAN_VALUE = _(28 "workflow.step.analysisparams.fields.analysis_params.choice.AP_ENTRY_BEST_MATCH_PLAN_VALUE"29 ) # "System default for this plan"30 AP_ENTRY_BEST_MATCH_TEMPLATE_VALUE = _(31 "workflow.step.analysisparams.fields.analysis_params.choice.AP_ENTRY_BEST_MATCH_TEMPLATE_VALUE"32 ) # "System default for this template"33 AP_BEADFIND_SELECTED = "beadFindSelected"34 AP_ANALYSISARGS_SELECTED = "analysisArgsSelected"35 AP_PREBASECALLER_SELECTED = "preBaseCallerSelected"36 AP_CALIBRATE_SELECTED = "calibrateSelected"37 AP_BASECALLER_SELECTED = "baseCallerSelected"38 AP_ALIGNMENT_SELECTED = "alignmentSelected"39 AP_IONSTATS_SELECTED = "ionStatsSelected"40 AP_THUMBNAIL_BEADFIND_SELECTED = "thumbnailBeadFindSelected"41 AP_THUMBNAIL_ANALYSISARGS_SELECTED = "thumbnailAnalysisArgsSelected"42 AP_THUMBNAIL_PREBASECALLER_SELECTED = "thumbnailPreBaseCallerSelected"43 AP_THUMBNAIL_CALIBRATE_SELECTED = "thumbnailCalibrateSelected"44 AP_THUMBNAIL_BASECALLER_SELECTED = "thumbnailBaseCallerSelected"45 AP_THUMBNAIL_ALIGNMENT_SELECTED = "thumbnailAlignmentSelected"46 AP_THUMBNAIL_IONSTATS_SELECTED = "thumbnailIonStatsSelected"47 APPL_PRODUCT = "applProduct"48 RUN_TYPE = "runType"49 APPLICATION_GROUP_NAME = "applicationGroupName"50 CHIP_TYPE = "chipType"51 SAMPLE_PREPARATION_KIT = "samplePreparationKit"52 LIBRARY_KIT_NAME = "librarykitname"53 TEMPLATE_KIT_NAME = "templatekitname"54 SEQUENCE_KIT_NAME = "sequencekitname"55 CATEGORIES = "categories"56class AnalysisParamsStepData(AbstractStepData):57 def __init__(self, sh_type):58 super(AnalysisParamsStepData, self).__init__(sh_type)59 self.resourcePath = "rundb/plan/page_plan/page_plan_analysis_params.html"60 self._dependsOn.append(StepNames.APPLICATION)61 self._dependsOn.append(StepNames.KITS)62 analysisParamsEntries = list(AnalysisArgs.objects.all().filter(active=True))63 self.prepopulatedFields[64 AnalysisParamsFieldNames.AP_ENTRIES65 ] = analysisParamsEntries66 self.prepopulatedFields[AnalysisParamsFieldNames.AP_DISPLAYED_NAMES] = [67 ap.description for ap in analysisParamsEntries68 ]69 # self.prepopulatedFields[AnalysisParamsFieldNames.AP_ENTRY_BEST_MATCH] = None70 self.savedObjects[AnalysisParamsFieldNames.AP_ENTRY_SELECTED] = ""71 self.savedObjects[AnalysisParamsFieldNames.AP_ENTRY_PREVIOUSLY_SELECTED] = ""72 self.savedFields[AnalysisParamsFieldNames.AP_BEADFIND_SELECTED] = ""73 self.savedFields[AnalysisParamsFieldNames.AP_ANALYSISARGS_SELECTED] = ""74 self.savedFields[AnalysisParamsFieldNames.AP_PREBASECALLER_SELECTED] = ""75 self.savedFields[AnalysisParamsFieldNames.AP_CALIBRATE_SELECTED] = ""76 self.savedFields[AnalysisParamsFieldNames.AP_BASECALLER_SELECTED] = ""77 self.savedFields[AnalysisParamsFieldNames.AP_ALIGNMENT_SELECTED] = ""78 self.savedFields[AnalysisParamsFieldNames.AP_IONSTATS_SELECTED] = ""79 self.savedFields[AnalysisParamsFieldNames.AP_THUMBNAIL_BEADFIND_SELECTED] = ""80 self.savedFields[81 AnalysisParamsFieldNames.AP_THUMBNAIL_ANALYSISARGS_SELECTED82 ] = ""83 self.savedFields[84 AnalysisParamsFieldNames.AP_THUMBNAIL_PREBASECALLER_SELECTED85 ] = ""86 self.savedFields[AnalysisParamsFieldNames.AP_THUMBNAIL_CALIBRATE_SELECTED] = ""87 self.savedFields[AnalysisParamsFieldNames.AP_THUMBNAIL_BASECALLER_SELECTED] = ""88 self.savedFields[AnalysisParamsFieldNames.AP_THUMBNAIL_ALIGNMENT_SELECTED] = ""89 self.savedFields[AnalysisParamsFieldNames.AP_THUMBNAIL_IONSTATS_SELECTED] = ""90 self.savedFields[AnalysisParamsFieldNames.AP_CUSTOM] = "False"91 self.prepopulatedFields[AnalysisParamsFieldNames.APPL_PRODUCT] = ""92 self.prepopulatedFields[AnalysisParamsFieldNames.RUN_TYPE] = ""93 self.prepopulatedFields[AnalysisParamsFieldNames.APPLICATION_GROUP_NAME] = ""94 self.prepopulatedFields[AnalysisParamsFieldNames.CATEGORIES] = ""95 self.prepopulatedFields[AnalysisParamsFieldNames.CHIP_TYPE] = ""96 self.prepopulatedFields[AnalysisParamsFieldNames.SAMPLE_PREPARATION_KIT] = ""97 self.prepopulatedFields[AnalysisParamsFieldNames.LIBRARY_KIT_NAME] = ""98 self.prepopulatedFields[AnalysisParamsFieldNames.TEMPLATE_KIT_NAME] = ""99 self.prepopulatedFields[AnalysisParamsFieldNames.SEQUENCE_KIT_NAME] = ""100 self.sh_type = sh_type101 def getStepName(self):102 return StepNames.ANALYSIS_PARAMS103 def updateSavedObjectsFromSavedFields(self):104 pass105 def validate(self):106 pass107 def hasErrors(self):108 """109 This step is a section of another step. It is crucial not to advertise having errors or110 user will be re-directed to analysis args' resourcePath for error correction.111 Let the parent step take care of the error broadcasting.112 """113 return False114 def validateField(self, field_name, new_field_value):115 pass116 def validateField_in_section(self, field_name, new_field_value):117 """118 field validation for a step that acts as a section to another step119 """120 logger.debug(121 "at analysis_params_step_data.validateField_in_section field_name=%s; new_field_value=%s"122 % (field_name, new_field_value)123 )124 pass125 def updateFromStep(self, updated_step):126 if updated_step.getStepName() not in self._dependsOn:127 return128 # reset best match if key attributes on other chevrons have changed129 needToRefreshSelectionList = False130 if (131 updated_step.getStepName() == StepNames.APPLICATION132 and updated_step.savedObjects[ApplicationFieldNames.APPL_PRODUCT]133 ):134 applProduct = updated_step.savedObjects[ApplicationFieldNames.APPL_PRODUCT]135 logger.debug(136 "analysis_params_step_data - APPL CHEVRON... applProduct %s; runType=%s; applicationGroupName=%s"137 % (138 applProduct.productCode,139 updated_step.savedObjects[ApplicationFieldNames.RUN_TYPE].runType,140 updated_step.savedFields[141 ApplicationFieldNames.APPLICATION_GROUP_NAME142 ],143 )144 )145 if (146 self.prepopulatedFields[AnalysisParamsFieldNames.RUN_TYPE]147 != updated_step.savedObjects[ApplicationFieldNames.RUN_TYPE].runType148 or self.prepopulatedFields[149 AnalysisParamsFieldNames.APPLICATION_GROUP_NAME150 ]151 != updated_step.savedFields[152 ApplicationFieldNames.APPLICATION_GROUP_NAME153 ]154 ):155 needToRefreshSelectionList = True156 self.prepopulatedFields[AnalysisParamsFieldNames.APPL_PRODUCT] = ""157 self.prepopulatedFields[158 AnalysisParamsFieldNames.RUN_TYPE159 ] = updated_step.savedObjects[ApplicationFieldNames.RUN_TYPE].runType160 self.prepopulatedFields[161 AnalysisParamsFieldNames.APPLICATION_GROUP_NAME162 ] = updated_step.savedFields[ApplicationFieldNames.APPLICATION_GROUP_NAME]163 elif updated_step.getStepName() == StepNames.KITS:164 if (165 self.prepopulatedFields[AnalysisParamsFieldNames.CHIP_TYPE]166 != updated_step.savedFields[KitsFieldNames.CHIP_TYPE]167 or self.prepopulatedFields[168 AnalysisParamsFieldNames.SAMPLE_PREPARATION_KIT169 ]170 != updated_step.savedFields[KitsFieldNames.SAMPLE_PREPARATION_KIT]171 or self.prepopulatedFields[AnalysisParamsFieldNames.LIBRARY_KIT_NAME]172 != updated_step.savedFields[KitsFieldNames.LIBRARY_KIT_NAME]173 or self.prepopulatedFields[AnalysisParamsFieldNames.TEMPLATE_KIT_NAME]174 != updated_step.savedFields[KitsFieldNames.TEMPLATE_KIT_NAME]175 or self.prepopulatedFields[AnalysisParamsFieldNames.SEQUENCE_KIT_NAME]176 != updated_step.savedFields[KitsFieldNames.SEQUENCE_KIT_NAME]177 ):178 needToRefreshSelectionList = True179 self.prepopulatedFields[AnalysisParamsFieldNames.CHIP_TYPE] = (180 updated_step.savedFields[KitsFieldNames.CHIP_TYPE]181 if updated_step.savedFields[KitsFieldNames.CHIP_TYPE]182 else ""183 )184 self.prepopulatedFields[185 AnalysisParamsFieldNames.SAMPLE_PREPARATION_KIT186 ] = updated_step.savedFields[KitsFieldNames.SAMPLE_PREPARATION_KIT]187 self.prepopulatedFields[188 AnalysisParamsFieldNames.LIBRARY_KIT_NAME189 ] = updated_step.savedFields[KitsFieldNames.LIBRARY_KIT_NAME]190 self.prepopulatedFields[191 AnalysisParamsFieldNames.TEMPLATE_KIT_NAME192 ] = updated_step.savedFields[KitsFieldNames.TEMPLATE_KIT_NAME]193 self.prepopulatedFields[194 AnalysisParamsFieldNames.SEQUENCE_KIT_NAME195 ] = updated_step.savedFields[KitsFieldNames.SEQUENCE_KIT_NAME]196 if needToRefreshSelectionList:197 self._update_analysisParamsData_selection_list(198 self.prepopulatedFields[AnalysisParamsFieldNames.CHIP_TYPE],199 self.prepopulatedFields[AnalysisParamsFieldNames.SEQUENCE_KIT_NAME],200 self.prepopulatedFields[AnalysisParamsFieldNames.TEMPLATE_KIT_NAME],201 self.prepopulatedFields[AnalysisParamsFieldNames.LIBRARY_KIT_NAME],202 self.prepopulatedFields[203 AnalysisParamsFieldNames.SAMPLE_PREPARATION_KIT204 ],205 self.prepopulatedFields[AnalysisParamsFieldNames.RUN_TYPE],206 self.prepopulatedFields[207 AnalysisParamsFieldNames.APPLICATION_GROUP_NAME208 ],209 self.prepopulatedFields[AnalysisParamsFieldNames.CATEGORIES],210 )211 def _update_analysisParamsData_selection_list(212 self,213 chipType,214 sequenceKitName,215 templatingKitName,216 libraryKitName,217 samplePrepKitName,218 applicationType,219 applicationGroupName,220 applicationCategories,221 ):222 possible_match_entries = AnalysisArgs.possible_matches(223 chipType,224 sequenceKitName,225 templatingKitName,226 libraryKitName,227 samplePrepKitName,228 None,229 applicationType,230 applicationGroupName,231 applicationCategories,232 )233 logger.debug(234 "_update_analysisParamsData_selection_list() applicationType=%s; applicationGroupName=%s; applicationCategories=%s"235 % (applicationType, applicationGroupName, applicationCategories)236 )237 best_match_entry = AnalysisArgs.best_match(238 chipType,239 sequenceKitName,240 templatingKitName,241 libraryKitName,242 samplePrepKitName,243 None,244 applicationType,245 applicationGroupName,246 applicationCategories,247 )248 if best_match_entry:249 isTemplate = self.sh_type in StepHelperType.TEMPLATE_TYPES250 for ap in possible_match_entries:251 if ap.name == best_match_entry.name:252 ap.name = (253 AnalysisParamsFieldNames.AP_ENTRY_BEST_MATCH_TEMPLATE_VALUE254 if isTemplate255 else AnalysisParamsFieldNames.AP_ENTRY_BEST_MATCH_PLAN_VALUE256 )257 ap.best_match = True258 if self.savedFields[AnalysisParamsFieldNames.AP_CUSTOM] == "False":259 previously_selected_analysisArgs = {260 "description": AnalysisParamsFieldNames.AP_ENTRY_PREVIOUSLY_SELECTED_VALUE,261 "name": "",262 "beadfindargs": self.savedFields[263 AnalysisParamsFieldNames.AP_BEADFIND_SELECTED264 ],265 "analysisargs": self.savedFields[266 AnalysisParamsFieldNames.AP_ANALYSISARGS_SELECTED267 ],268 "prebasecallerargs": self.savedFields[269 AnalysisParamsFieldNames.AP_PREBASECALLER_SELECTED270 ],271 "calibrateargs": self.savedFields[272 AnalysisParamsFieldNames.AP_CALIBRATE_SELECTED273 ],274 "basecallerargs": self.savedFields[275 AnalysisParamsFieldNames.AP_BASECALLER_SELECTED276 ],277 "alignmentargs": self.savedFields[278 AnalysisParamsFieldNames.AP_ALIGNMENT_SELECTED279 ],280 "ionstatsargs": self.savedFields[281 AnalysisParamsFieldNames.AP_IONSTATS_SELECTED282 ],283 "thumbnailbeadfindargs": self.savedFields[284 AnalysisParamsFieldNames.AP_THUMBNAIL_BEADFIND_SELECTED285 ],286 "thumbnailanalysisargs": self.savedFields[287 AnalysisParamsFieldNames.AP_THUMBNAIL_ANALYSISARGS_SELECTED288 ],289 "prethumbnailbasecallerargs": self.savedFields[290 AnalysisParamsFieldNames.AP_THUMBNAIL_PREBASECALLER_SELECTED291 ],292 "thumbnailcalibrateargs": self.savedFields[293 AnalysisParamsFieldNames.AP_THUMBNAIL_CALIBRATE_SELECTED294 ],295 "thumbnailbasecallerargs": self.savedFields[296 AnalysisParamsFieldNames.AP_THUMBNAIL_BASECALLER_SELECTED297 ],298 "thumbnailalignmentargs": self.savedFields[299 AnalysisParamsFieldNames.AP_THUMBNAIL_ALIGNMENT_SELECTED300 ],301 "thumbnailionstatsargs": self.savedFields[302 AnalysisParamsFieldNames.AP_THUMBNAIL_IONSTATS_SELECTED303 ],304 }305 self.savedObjects[306 AnalysisParamsFieldNames.AP_ENTRY_PREVIOUSLY_SELECTED307 ] = previously_selected_analysisArgs308 best_match_entry.description = (309 AnalysisParamsFieldNames.AP_ENTRY_SELECTED_VALUE310 )311 self.savedObjects[312 AnalysisParamsFieldNames.AP_ENTRY_SELECTED313 ] = best_match_entry314 self.savedFields[315 AnalysisParamsFieldNames.AP_BEADFIND_SELECTED316 ] = best_match_entry.beadfindargs317 self.savedFields[318 AnalysisParamsFieldNames.AP_ANALYSISARGS_SELECTED319 ] = best_match_entry.analysisargs320 self.savedFields[321 AnalysisParamsFieldNames.AP_PREBASECALLER_SELECTED322 ] = best_match_entry.prebasecallerargs323 self.savedFields[324 AnalysisParamsFieldNames.AP_CALIBRATE_SELECTED325 ] = best_match_entry.calibrateargs326 self.savedFields[327 AnalysisParamsFieldNames.AP_BASECALLER_SELECTED328 ] = best_match_entry.basecallerargs329 self.savedFields[330 AnalysisParamsFieldNames.AP_ALIGNMENT_SELECTED331 ] = best_match_entry.alignmentargs332 self.savedFields[333 AnalysisParamsFieldNames.AP_IONSTATS_SELECTED334 ] = best_match_entry.ionstatsargs335 self.savedFields[336 AnalysisParamsFieldNames.AP_THUMBNAIL_BEADFIND_SELECTED337 ] = best_match_entry.thumbnailbeadfindargs338 self.savedFields[339 AnalysisParamsFieldNames.AP_THUMBNAIL_ANALYSISARGS_SELECTED340 ] = best_match_entry.thumbnailanalysisargs341 self.savedFields[342 AnalysisParamsFieldNames.AP_THUMBNAIL_PREBASECALLER_SELECTED343 ] = best_match_entry.prethumbnailbasecallerargs344 self.savedFields[345 AnalysisParamsFieldNames.AP_THUMBNAIL_CALIBRATE_SELECTED346 ] = best_match_entry.thumbnailcalibrateargs347 self.savedFields[348 AnalysisParamsFieldNames.AP_THUMBNAIL_BASECALLER_SELECTED349 ] = best_match_entry.thumbnailbasecallerargs350 self.savedFields[351 AnalysisParamsFieldNames.AP_THUMBNAIL_ALIGNMENT_SELECTED352 ] = best_match_entry.thumbnailalignmentargs353 self.savedFields[354 AnalysisParamsFieldNames.AP_THUMBNAIL_IONSTATS_SELECTED355 ] = best_match_entry.thumbnailionstatsargs356 else:357 logger.debug(358 "analysis_params_step_data._update_analysisParamsData_selection_list() BEST MATCH NOT FOUND!!! chipType=%s;"359 % (chipType)360 )361 self.prepopulatedFields[362 AnalysisParamsFieldNames.AP_ENTRIES363 ] = possible_match_entries364 self.prepopulatedFields[AnalysisParamsFieldNames.AP_DISPLAYED_NAMES] = [365 ap.description for ap in possible_match_entries...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

1"""2Package generated from /System/Library/CoreServices/Finder.app3"""4from warnings import warnpy3k5warnpy3k("In 3.x, the Finder package is removed.", stacklevel=2)6import aetools7Error = aetools.Error8import Standard_Suite9import Legacy_suite10import Containers_and_folders11import Files12import Finder_Basics13import Finder_items14import Window_classes15import Type_Definitions16import Enumerations17_code_to_module = {18 'CoRe' : Standard_Suite,19 'fleg' : Legacy_suite,20 'fndr' : Containers_and_folders,21 'fndr' : Files,22 'fndr' : Finder_Basics,23 'fndr' : Finder_items,24 'fndr' : Window_classes,25 'tpdf' : Type_Definitions,26 'tpnm' : Enumerations,27}28_code_to_fullname = {29 'CoRe' : ('Finder.Standard_Suite', 'Standard_Suite'),30 'fleg' : ('Finder.Legacy_suite', 'Legacy_suite'),31 'fndr' : ('Finder.Containers_and_folders', 'Containers_and_folders'),32 'fndr' : ('Finder.Files', 'Files'),33 'fndr' : ('Finder.Finder_Basics', 'Finder_Basics'),34 'fndr' : ('Finder.Finder_items', 'Finder_items'),35 'fndr' : ('Finder.Window_classes', 'Window_classes'),36 'tpdf' : ('Finder.Type_Definitions', 'Type_Definitions'),37 'tpnm' : ('Finder.Enumerations', 'Enumerations'),38}39from Standard_Suite import *40from Legacy_suite import *41from Containers_and_folders import *42from Files import *43from Finder_Basics import *44from Finder_items import *45from Window_classes import *46from Type_Definitions import *47from Enumerations import *48def getbaseclasses(v):49 if not getattr(v, '_propdict', None):50 v._propdict = {}51 v._elemdict = {}52 for superclassname in getattr(v, '_superclassnames', []):53 superclass = eval(superclassname)54 getbaseclasses(superclass)55 v._propdict.update(getattr(superclass, '_propdict', {}))56 v._elemdict.update(getattr(superclass, '_elemdict', {}))57 v._propdict.update(getattr(v, '_privpropdict', {}))58 v._elemdict.update(getattr(v, '_privelemdict', {}))59import StdSuites60#61# Set property and element dictionaries now that all classes have been defined62#63getbaseclasses(StdSuites.Type_Names_Suite.small_integer)64getbaseclasses(StdSuites.Type_Names_Suite.system_dictionary)65getbaseclasses(StdSuites.Type_Names_Suite.color_table)66getbaseclasses(StdSuites.Type_Names_Suite.fixed_point)67getbaseclasses(StdSuites.Type_Names_Suite.string)68getbaseclasses(StdSuites.Type_Names_Suite.type_element_info)69getbaseclasses(StdSuites.Type_Names_Suite.machine_location)70getbaseclasses(StdSuites.Type_Names_Suite.PostScript_picture)71getbaseclasses(StdSuites.Type_Names_Suite.type_property_info)72getbaseclasses(StdSuites.Type_Names_Suite.menu_item)73getbaseclasses(StdSuites.Type_Names_Suite.scrap_styles)74getbaseclasses(StdSuites.Type_Names_Suite.fixed_rectangle)75getbaseclasses(StdSuites.Type_Names_Suite.null)76getbaseclasses(StdSuites.Type_Names_Suite.type_event_info)77getbaseclasses(StdSuites.Type_Names_Suite.rotation)78getbaseclasses(StdSuites.Type_Names_Suite.long_fixed_rectangle)79getbaseclasses(StdSuites.Type_Names_Suite.long_point)80getbaseclasses(StdSuites.Type_Names_Suite.target_id)81getbaseclasses(StdSuites.Type_Names_Suite.type_suite_info)82getbaseclasses(StdSuites.Type_Names_Suite.type_parameter_info)83getbaseclasses(StdSuites.Type_Names_Suite.long_fixed_point)84getbaseclasses(StdSuites.Type_Names_Suite.bounding_rectangle)85getbaseclasses(StdSuites.Type_Names_Suite.TIFF_picture)86getbaseclasses(StdSuites.Type_Names_Suite.long_fixed)87getbaseclasses(StdSuites.Type_Names_Suite.version)88getbaseclasses(StdSuites.Type_Names_Suite.RGB16_color)89getbaseclasses(StdSuites.Type_Names_Suite.double_integer)90getbaseclasses(StdSuites.Type_Names_Suite.location_reference)91getbaseclasses(StdSuites.Type_Names_Suite.point)92getbaseclasses(StdSuites.Type_Names_Suite.application_dictionary)93getbaseclasses(StdSuites.Type_Names_Suite.unsigned_integer)94getbaseclasses(StdSuites.Type_Names_Suite.menu)95getbaseclasses(StdSuites.Type_Names_Suite.small_real)96getbaseclasses(StdSuites.Type_Names_Suite.fixed)97getbaseclasses(StdSuites.Type_Names_Suite.type_class_info)98getbaseclasses(StdSuites.Type_Names_Suite.RGB96_color)99getbaseclasses(StdSuites.Type_Names_Suite.dash_style)100getbaseclasses(StdSuites.Type_Names_Suite.pixel_map_record)101getbaseclasses(StdSuites.Type_Names_Suite.extended_real)102getbaseclasses(StdSuites.Type_Names_Suite.long_rectangle)103getbaseclasses(process)104getbaseclasses(application_process)105getbaseclasses(desk_accessory_process)106getbaseclasses(application)107getbaseclasses(trash_2d_object)108getbaseclasses(desktop_2d_object)109getbaseclasses(container)110getbaseclasses(folder)111getbaseclasses(disk)112getbaseclasses(application)113getbaseclasses(alias_file)114getbaseclasses(package)115getbaseclasses(file)116getbaseclasses(application_file)117getbaseclasses(internet_location_file)118getbaseclasses(document_file)119getbaseclasses(clipping)120getbaseclasses(preferences_window)121getbaseclasses(Finder_window)122getbaseclasses(window)123getbaseclasses(clipping_window)124getbaseclasses(information_window)125getbaseclasses(item)126getbaseclasses(icon_view_options)127getbaseclasses(preferences)128getbaseclasses(alias_list)129getbaseclasses(icon_family)130getbaseclasses(label)131getbaseclasses(column)132getbaseclasses(list_view_options)133#134# Indices of types declared in this module135#136_classdeclarations = {137 'shor' : StdSuites.Type_Names_Suite.small_integer,138 'aeut' : StdSuites.Type_Names_Suite.system_dictionary,139 'clrt' : StdSuites.Type_Names_Suite.color_table,140 'fpnt' : StdSuites.Type_Names_Suite.fixed_point,141 'TEXT' : StdSuites.Type_Names_Suite.string,142 'elin' : StdSuites.Type_Names_Suite.type_element_info,143 'mLoc' : StdSuites.Type_Names_Suite.machine_location,144 'EPS ' : StdSuites.Type_Names_Suite.PostScript_picture,145 'pinf' : StdSuites.Type_Names_Suite.type_property_info,146 'cmen' : StdSuites.Type_Names_Suite.menu_item,147 'styl' : StdSuites.Type_Names_Suite.scrap_styles,148 'frct' : StdSuites.Type_Names_Suite.fixed_rectangle,149 'null' : StdSuites.Type_Names_Suite.null,150 'evin' : StdSuites.Type_Names_Suite.type_event_info,151 'trot' : StdSuites.Type_Names_Suite.rotation,152 'lfrc' : StdSuites.Type_Names_Suite.long_fixed_rectangle,153 'lpnt' : StdSuites.Type_Names_Suite.long_point,154 'targ' : StdSuites.Type_Names_Suite.target_id,155 'suin' : StdSuites.Type_Names_Suite.type_suite_info,156 'pmin' : StdSuites.Type_Names_Suite.type_parameter_info,157 'lfpt' : StdSuites.Type_Names_Suite.long_fixed_point,158 'qdrt' : StdSuites.Type_Names_Suite.bounding_rectangle,159 'TIFF' : StdSuites.Type_Names_Suite.TIFF_picture,160 'lfxd' : StdSuites.Type_Names_Suite.long_fixed,161 'vers' : StdSuites.Type_Names_Suite.version,162 'tr16' : StdSuites.Type_Names_Suite.RGB16_color,163 'comp' : StdSuites.Type_Names_Suite.double_integer,164 'insl' : StdSuites.Type_Names_Suite.location_reference,165 'QDpt' : StdSuites.Type_Names_Suite.point,166 'aete' : StdSuites.Type_Names_Suite.application_dictionary,167 'magn' : StdSuites.Type_Names_Suite.unsigned_integer,168 'cmnu' : StdSuites.Type_Names_Suite.menu,169 'sing' : StdSuites.Type_Names_Suite.small_real,170 'fixd' : StdSuites.Type_Names_Suite.fixed,171 'gcli' : StdSuites.Type_Names_Suite.type_class_info,172 'tr96' : StdSuites.Type_Names_Suite.RGB96_color,173 'tdas' : StdSuites.Type_Names_Suite.dash_style,174 'tpmm' : StdSuites.Type_Names_Suite.pixel_map_record,175 'exte' : StdSuites.Type_Names_Suite.extended_real,176 'lrct' : StdSuites.Type_Names_Suite.long_rectangle,177 'prcs' : process,178 'pcap' : application_process,179 'pcda' : desk_accessory_process,180 'capp' : application,181 'ctrs' : trash_2d_object,182 'cdsk' : desktop_2d_object,183 'ctnr' : container,184 'cfol' : folder,185 'cdis' : disk,186 'capp' : application,187 'alia' : alias_file,188 'pack' : package,189 'file' : file,190 'appf' : application_file,191 'inlf' : internet_location_file,192 'docf' : document_file,193 'clpf' : clipping,194 'pwnd' : preferences_window,195 'brow' : Finder_window,196 'cwin' : window,197 'lwnd' : clipping_window,198 'iwnd' : information_window,199 'cobj' : item,200 'icop' : icon_view_options,201 'cprf' : preferences,202 'alst' : alias_list,203 'ifam' : icon_family,204 'clbl' : label,205 'lvcl' : column,206 'lvop' : list_view_options,207}208class Finder(Standard_Suite_Events,209 Legacy_suite_Events,210 Containers_and_folders_Events,211 Files_Events,212 Finder_Basics_Events,213 Finder_items_Events,214 Window_classes_Events,215 Type_Definitions_Events,216 Enumerations_Events,217 aetools.TalkTo):218 _signature = 'MACS'219 _moduleName = 'Finder'220 _elemdict = application._elemdict...

Full Screen

Full Screen

collect_coco_voc_gtgraph.py

Source:collect_coco_voc_gtgraph.py Github

copy

Full Screen

1import pickle2import numpy as np3#compute attribute graph4NUM_ATTR_REL = 2005def cout_w(prob, num=NUM_ATTR_REL,dim=1):6 prob_weight = prob[:, :num]7 sum_value = np.sum(prob_weight, keepdims=True, axis=dim) + 0.18 prob_weight = prob_weight / np.repeat(sum_value, prob_weight.shape[dim], axis=dim)9 return prob_weight10def cp_kl(a, b):11 # compute kl diverse12 if np.sum(a) == 0 or np.sum(b) == 0:13 return 114 sum_ = a * np.log(a / b)15 all_value = [x for x in sum_ if str(x) != 'nan' and str(x) != 'inf']16 kl = np.sum(all_value)17 return kl18def compute_js(attr_prob):19 cls_num = attr_prob.shape[0]20 similarity = np.zeros((cls_num, cls_num))21 similarity[0, 1:] = 122 similarity[1:, 0] = 123 for i in range(1, cls_num):24 if i % 50 == 0:25 print('had proccessed {} cls...\n'.format(i))26 for j in range(1, cls_num):27 if i == j:28 similarity[i,j] = 029 else:30 similarity[i,j] = 0.5 * (cp_kl(attr_prob[i, :], 0.5*(attr_prob[i, :] + attr_prob[j,:]))31 + cp_kl(attr_prob[j, :], 0.5*(attr_prob[i, :] + attr_prob[j, :])))32 return similarity33if __name__ == '__main__':34 # We collect coco/voc gt graph by matching classes names with VG.35 # First, you should download attribute/relationship frequency statistic matrix.36 # Second, you should save your dataset classes names. We provide VG names and COCO names.37 data_path = 'Your Path ...'38 vg_class_names_dict = pickle.load(open(data_path + 'vg_3000_name_to_ind.pkl', 'rb'))39 dataset = 'coco'40 vg_ind_cls = {v: k for k, v in vg_class_names_dict.items()}41 vg_class_names = []42 vg_class_names_list = list(vg_class_names_dict)43 for i in vg_class_names_list:44 if i == '__background__':45 vg_class_names.append(i)46 else:47 vg_class_names.append(i.split('.')[0])48 # replace voc name with corresponding to VG49 VOC_class_names = pickle.load(open(data_path + 'VOC_class_names.pkl', 'rb'))50 VOC_class_names = list(VOC_class_names)51 VOC_class_names[VOC_class_names.index('aeroplane')] = 'airplane'52 VOC_class_names[VOC_class_names.index('diningtable')] = 'table'53 VOC_class_names[VOC_class_names.index('motorbike')] = 'motorcycle'54 VOC_class_names[VOC_class_names.index('pottedplant')] = 'plant'55 VOC_class_names[VOC_class_names.index('tvmonitor')] = 'television'56 # replace COCO name with corresponding to VG57 COCO_class_names = pickle.load(open('/data/detection/coco/coco_name.pkl', 'rb'))58 COCO_class_names = list(COCO_class_names)59 COCO_class_names = [n.strip().replace(' ', '_') for n in COCO_class_names]60 COCO_class_names[COCO_class_names.index('tv')] = 'television'61 COCO_class_names[COCO_class_names.index('fire_hydrant')] = 'fireplug'62 COCO_class_names[COCO_class_names.index('stop_sign')] = 'sign'63 COCO_class_names[COCO_class_names.index('handbag')] = 'bag'64 COCO_class_names[COCO_class_names.index('suitcase')] = 'case'65 COCO_class_names[COCO_class_names.index('skis')] = 'ski'66 COCO_class_names[COCO_class_names.index('sports_ball')] = 'ball'67 COCO_class_names[COCO_class_names.index('wine_glass')] = 'goblet'68 COCO_class_names[COCO_class_names.index('orange')] = 'fruit' # mandarin citrus69 COCO_class_names[COCO_class_names.index('hot_dog')] = 'hotdog'70 COCO_class_names[COCO_class_names.index('donut')] = 'doughnut'71 COCO_class_names[COCO_class_names.index('couch')] = 'sofa'72 COCO_class_names[COCO_class_names.index('remote')] = 'remote_control'73 COCO_class_names[COCO_class_names.index('cell_phone')] = 'mobile'74 COCO_class_names[COCO_class_names.index('dining_table')] = 'table'75 COCO_class_names[COCO_class_names.index('teddy_bear')] = 'teddy'76 COCO_class_names[COCO_class_names.index('hair_drier')] = 'hand_blower'77 index_vg_of_DATASET = []78 if dataset == 'voc':79 for i in COCO_class_names:80 if i == 'potted_plant':81 index_vg_of_DATASET.append(1333)82 else:83 index_vg_of_DATASET.append(vg_class_names.index(i))84 elif dataset == 'coco':85 for i in COCO_class_names:86 index_vg_of_DATASET.append(vg_class_names.index(i))87 # Attribute graph88 graph_a = pickle.load(open(data_path + 'vg_attr_frequency_3000.pkl', 'rb'))89 new_graph = graph_a[index_vg_of_DATASET,]90 new_graph = cout_w(new_graph, num=len(new_graph))91 new_graph = compute_js(new_graph)92 new_graph = 1 - new_graph93 pickle.dump(new_graph, open(data_path + dataset + '_graph_a.pkl', 'wb'))94 # Relation graph95 graph_r = pickle.load(open(data_path + 'vg_pair_frequency_3000.pkl', 'rb'))96 index_vg_of_DATASET_ = [x for x in index_vg_of_DATASET[1:]]97 # graph_r_COCO = graph_r[[x for x in index_vg_of_COCO_big],]98 new_graph = graph_r[index_vg_of_DATASET_, :]99 new_graph = new_graph[:, index_vg_of_DATASET_]100 relation_matrix = new_graph + new_graph.transpose()101 relation_matrix_row_sum = relation_matrix.sum(1)102 num_classes = len(index_vg_of_DATASET) - 1103 for i in range(num_classes):104 relation_matrix[i, i] = relation_matrix_row_sum[i] + 1105 prob_relation_matrix = np.zeros((num_classes, num_classes))106 for i in range(num_classes):107 for j in range(num_classes):108 prob_relation_matrix[i, j] = relation_matrix[i, j] / (109 np.sqrt(relation_matrix[i, i]) * np.sqrt(relation_matrix[j, j]))110 graph_r_ = np.zeros((num_classes + 1, num_classes + 1))111 graph_r_[1:, 1:] = prob_relation_matrix...

Full Screen

Full Screen

test_names.py

Source:test_names.py Github

copy

Full Screen

2Tests for `api.names`.3"""4from textwrap import dedent5import pytest6def _assert_definition_names(definitions, names):7 assert [d.name for d in definitions] == names8def _check_names(get_names, source, names):9 definitions = get_names(dedent(source))10 _assert_definition_names(definitions, names)11 return definitions12def test_get_definitions_flat(get_names):13 _check_names(get_names, """14 import module15 class Class:16 pass17 def func():18 pass19 data = None20 """, ['module', 'Class', 'func', 'data'])21def test_dotted_assignment(get_names):22 _check_names(get_names, """23 x = Class()24 x.y.z = None25 """, ['x', 'z']) # TODO is this behavior what we want?26def test_multiple_assignment(get_names):27 _check_names(get_names, "x = y = None", ['x', 'y'])28def test_multiple_imports(get_names):29 _check_names(get_names, """30 from module import a, b31 from another_module import *32 """, ['a', 'b'])33def test_nested_definitions(get_names):34 definitions = _check_names(get_names, """35 class Class:36 def f():37 pass38 def g():39 pass40 """, ['Class'])41 subdefinitions = definitions[0].defined_names()42 _assert_definition_names(subdefinitions, ['f', 'g'])43 assert [d.full_name for d in subdefinitions] == ['__main__.Class.f', '__main__.Class.g']44def test_nested_class(get_names):45 definitions = _check_names(get_names, """46 class L1:47 class L2:48 class L3:49 def f(): pass50 def f(): pass51 def f(): pass52 def f(): pass53 """, ['L1', 'f'])54 subdefs = definitions[0].defined_names()55 subsubdefs = subdefs[0].defined_names()56 _assert_definition_names(subdefs, ['L2', 'f'])57 _assert_definition_names(subsubdefs, ['L3', 'f'])58 _assert_definition_names(subsubdefs[0].defined_names(), ['f'])59def test_class_fields_with_all_scopes_false(get_names):60 definitions = _check_names(get_names, """61 from module import f62 g = f(f)63 class C:64 h = g65 def foo(x=a):66 bar = x67 return bar68 """, ['f', 'g', 'C', 'foo'])69 C_subdefs = definitions[-2].defined_names()70 foo_subdefs = definitions[-1].defined_names()71 _assert_definition_names(C_subdefs, ['h'])72 _assert_definition_names(foo_subdefs, ['x', 'bar'])73def test_async_stmt_with_all_scopes_false(get_names):74 definitions = _check_names(get_names, """75 from module import f76 import asyncio77 g = f(f)78 class C:79 h = g80 def __init__(self):81 pass82 async def __aenter__(self):83 pass84 def foo(x=a):85 bar = x86 return bar87 async def async_foo(duration):88 async def wait():89 await asyncio.sleep(100)90 for i in range(duration//100):91 await wait()92 return duration//100*10093 async with C() as cinst:94 d = cinst95 """, ['f', 'asyncio', 'g', 'C', 'foo', 'async_foo', 'cinst', 'd'])96 C_subdefs = definitions[3].defined_names()97 foo_subdefs = definitions[4].defined_names()98 async_foo_subdefs = definitions[5].defined_names()99 cinst_subdefs = definitions[6].defined_names()100 _assert_definition_names(C_subdefs, ['h', '__init__', '__aenter__'])101 _assert_definition_names(foo_subdefs, ['x', 'bar'])102 _assert_definition_names(async_foo_subdefs, ['duration', 'wait', 'i'])103 # We treat d as a name outside `async with` block104 _assert_definition_names(cinst_subdefs, [])105def test_follow_imports(get_names):106 # github issue #344107 imp = get_names('import datetime')[0]108 assert imp.name == 'datetime'109 datetime_names = [str(d.name) for d in imp.defined_names()]110 assert 'timedelta' in datetime_names111def test_names_twice(get_names):112 code = dedent('''113 def lol():114 pass115 ''')116 defs = get_names(code)117 assert defs[0].defined_names() == []118def test_simple_name(get_names):119 defs = get_names('foo', references=True)120 assert not defs[0]._name.infer()121def test_no_error(get_names):122 code = dedent("""123 def foo(a, b):124 if a == 10:125 if b is None:126 print("foo")127 a = 20128 """)129 func_name, = get_names(code)130 a, b, a20 = func_name.defined_names()131 assert a.name == 'a'132 assert b.name == 'b'133 assert a20.name == 'a'134 assert a20.goto() == [a20]135@pytest.mark.parametrize(136 'code, index, is_side_effect', [137 ('x', 0, False),138 ('x.x', 0, False),139 ('x.x', 1, False),140 ('x.x = 3', 0, False),141 ('x.x = 3', 1, True),142 ('def x(x): x.x = 3', 1, False),143 ('def x(x): x.x = 3', 3, True),144 ('import sys; sys.path', 0, False),145 ('import sys; sys.path', 1, False),146 ('import sys; sys.path', 2, False),147 ('import sys; sys.path = []', 2, True),148 ]149)150def test_is_side_effect(get_names, code, index, is_side_effect):151 names = get_names(code, references=True, all_scopes=True)...

Full Screen

Full Screen

format_ids.py

Source:format_ids.py Github

copy

Full Screen

1from struct import pack, unpack2def parseIP(string):3 bunch = map(int, string.split('.'))4 # pack to bytes5 p = pack('4B', *bunch)6 # unpack as u167 return unpack('>I', p)[0]8def writeIP(raw):9 # pack to bytes10 p = pack('>I', raw)11 # unpack12 return '.'.join(map(str, unpack('4B', p)))13def writeFloat(raw):14 # this is just how floats get printed...15 return '{0:.6f}'.format(raw)16xml_formats = {17 1 : { 'names' : ['void']},18 2 : { 'type' : 'b', 'count' : 1, 'names' : ['s8']},19 3 : { 'type' : 'B', 'count' : 1, 'names' : ['u8']},20 4 : { 'type' : 'h', 'count' : 1, 'names' : ['s16']},21 5 : { 'type' : 'H', 'count' : 1, 'names' : ['u16']},22 6 : { 'type' : 'i', 'count' : 1, 'names' : ['s32']},23 7 : { 'type' : 'I', 'count' : 1, 'names' : ['u32']},24 8 : { 'type' : 'q', 'count' : 1, 'names' : ['s64']},25 9 : { 'type' : 'Q', 'count' : 1, 'names' : ['u64']},26 10 : { 'type' : 'B', 'count' : -1, 'names' : ['bin', 'binary'], 'fromStr' : None},27 11 : { 'type' : 'B', 'count' : -1, 'names' : ['str', 'string'], 'fromStr' : None},28 12 : { 'type' : 'I', 'count' : 1, 'names' : ['ip4'], 'fromStr' : parseIP, 'toStr' : writeIP},29 13 : { 'type' : 'I', 'count' : 1, 'names' : ['time']}, # unix timestamp30 14 : { 'type' : 'f', 'count' : 1, 'names' : ['float', 'f'], 'fromStr' : float, 'toStr' : writeFloat},31 15 : { 'type' : 'd', 'count' : 1, 'names' : ['double', 'd'], 'fromStr' : float, 'toStr' : writeFloat},32 16 : { 'type' : 'b', 'count' : 2, 'names' : ['2s8']},33 17 : { 'type' : 'B', 'count' : 2, 'names' : ['2u8']},34 18 : { 'type' : 'h', 'count' : 2, 'names' : ['2s16']},35 19 : { 'type' : 'H', 'count' : 2, 'names' : ['2u16']},36 20 : { 'type' : 'i', 'count' : 2, 'names' : ['2s32']},37 21 : { 'type' : 'I', 'count' : 2, 'names' : ['2u32']},38 22 : { 'type' : 'q', 'count' : 2, 'names' : ['2s64', 'vs64']},39 23 : { 'type' : 'Q', 'count' : 2, 'names' : ['2u64', 'vu64']},40 24 : { 'type' : 'f', 'count' : 2, 'names' : ['2f'], 'fromStr' : float, 'toStr' : writeFloat},41 25 : { 'type' : 'd', 'count' : 2, 'names' : ['2d', 'vd'], 'fromStr' : float, 'toStr' : writeFloat},42 26 : { 'type' : 'b', 'count' : 3, 'names' : ['3s8']},43 27 : { 'type' : 'B', 'count' : 3, 'names' : ['3u8']},44 28 : { 'type' : 'h', 'count' : 3, 'names' : ['3s16']},45 29 : { 'type' : 'H', 'count' : 3, 'names' : ['3u16']},46 30 : { 'type' : 'i', 'count' : 3, 'names' : ['3s32']},47 31 : { 'type' : 'I', 'count' : 3, 'names' : ['3u32']},48 32 : { 'type' : 'q', 'count' : 3, 'names' : ['3s64']},49 33 : { 'type' : 'Q', 'count' : 3, 'names' : ['3u64']},50 34 : { 'type' : 'f', 'count' : 3, 'names' : ['3f'], 'fromStr' : float, 'toStr' : writeFloat},51 35 : { 'type' : 'd', 'count' : 3, 'names' : ['3d'], 'fromStr' : float, 'toStr' : writeFloat},52 36 : { 'type' : 'b', 'count' : 4, 'names' : ['4s8']},53 37 : { 'type' : 'B', 'count' : 4, 'names' : ['4u8']},54 38 : { 'type' : 'h', 'count' : 4, 'names' : ['4s16']},55 39 : { 'type' : 'H', 'count' : 4, 'names' : ['4u16']},56 40 : { 'type' : 'i', 'count' : 4, 'names' : ['4s32', 'vs32']},57 41 : { 'type' : 'I', 'count' : 4, 'names' : ['4u32', 'vu32']},58 42 : { 'type' : 'q', 'count' : 4, 'names' : ['4s64']},59 43 : { 'type' : 'Q', 'count' : 4, 'names' : ['4u64']},60 44 : { 'type' : 'f', 'count' : 4, 'names' : ['4f', 'vf'], 'fromStr' : float, 'toStr' : writeFloat},61 45 : { 'type' : 'd', 'count' : 4, 'names' : ['4d'], 'fromStr' : float, 'toStr' : writeFloat},62 46 : { 'names' : ['attr']},63 #47 : { 'names' : ['array']}, # TODO: how does this work?64 48 : { 'type' : 'b', 'count' : 16, 'names' : ['vs8']},65 49 : { 'type' : 'B', 'count' : 16, 'names' : ['vu8']},66 50 : { 'type' : 'h', 'count' : 8, 'names' : ['vs16']},67 51 : { 'type' : 'H', 'count' : 8, 'names' : ['vu16']},68 52 : { 'type' : 'b', 'count' : 1, 'names' : ['bool', 'b']},69 53 : { 'type' : 'b', 'count' : 2, 'names' : ['2b']},70 54 : { 'type' : 'b', 'count' : 3, 'names' : ['3b']},71 55 : { 'type' : 'b', 'count' : 4, 'names' : ['4b']},72 56 : { 'type' : 'b', 'count' : 16, 'names' : ['vb']}73}74# little less boilerplate for writing75for key, val in xml_formats.items():76 xml_formats[key]['name'] = xml_formats[key]['names'][0]77xml_types = {}78for key, val in xml_formats.items():79 for n in val['names']:80 xml_types[n] = key81xml_types['nodeStart'] = 182xml_types['nodeEnd'] = 190...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.getLocations(function(err, data) {4 if (err) return console.error(err);5 console.log(data);6});7var wpt = require('webpagetest');8var wpt = new WebPageTest('www.webpagetest.org');9var options = {10};11wpt.runTest(url, options, function(err, data) {12 if (err) return console.error(err);13 console.log(data);14});15var wpt = require('webpagetest');16var wpt = new WebPageTest('www.webpagetest.org');17var testId = '150404_0R_1';18wpt.getTestStatus(testId, function(err, data) {19 if (err) return console.error(err);20 console.log(data);21});22var wpt = require('webpagetest');23var wpt = new WebPageTest('www.webpagetest.org');24var testId = '150404_0R_1';25wpt.getTestResults(testId, function(err, data) {26 if (err) return console.error(err);27 console.log(data);28});29var wpt = require('webpagetest');30var wpt = new WebPageTest('www.webpagetest.org');31var testId = '150404_0R_1';32wpt.getTestVideo(testId, function(err, data) {33 if (err) return console.error(err);34 console.log(data);35});36var wpt = require('webpagetest');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3var options = {4};5wpt.runTest('www.google.com', options, function(err, data) {6 if (err) return console.error(err);7 wpt.getTestResults(data.data.testId, function(err, data) {8 if (err) return console.error(err);9 console.log(data.data.median.firstView.SpeedIndex);10 });11});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var test = wpt('www.webpagetest.org');3 if (err) return console.error(err);4 console.log('Test status: ' + data.statusText);5 test.getTestStatus(data.data.testId, function(err, data) {6 if (err) return console.error(err);7 console.log('Test status: ' + data.statusText);8 test.getTestResults(data.data.testId, function(err, data) {9 if (err) return console.error(err);10 console.log('Test results: ' + data.statusText);11 console.log('First View: ' + data.data.average.firstView.loadTime);12 console.log('Repeat View: ' + data.data.average.repeatView.loadTime);13 });14 });15});16test.getLocations(function(err, data) {17 if (err) return console.error(err);18 console.log('Locations: ' + data.statusText);19 console.log('Locations: ' + data.data);20});21test.getTesters(function(err, data) {22 if (err) return console.error(err);23 console.log('Testers: ' + data.statusText);24 console.log('Testers: ' + data.data);25});26test.getTesters(function(err, data) {27 if (err) return console.error(err);28 console.log('Testers: ' + data.statusText);29 console.log('Testers: ' + data.data);30});31test.getTesters(function(err, data) {32 if (err) return console.error(err);33 console.log('Testers: ' + data.statusText);34 console.log('Testers: ' + data.data);35});36test.getTesters(function(err, data) {37 if (err) return console.error(err);38 console.log('Testers: ' + data.statusText);39 console.log('Testers: ' + data.data);40});41test.getTesters(function(err, data) {42 if (err) return console.error(err);43 console.log('Testers: ' + data.statusText);44 console.log('Testers: ' + data.data);45});46test.getTesters(function(err, data) {47 if (err) return console.error(err);48 console.log('Testers: ' + data.statusText);49 console.log('Testers: ' + data.data);50});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var fs = require('fs');3wptools.page('Barack Obama').then(function(page) {4 return page.names();5}).then(function(names) {6 console.log(names);7 fs.writeFile('names.json', JSON.stringify(names, null, 4), function(err) {8 console.log('File successfully written! - Check your project directory for the names.json file');9 });10}).catch(function(err) {11 console.log(err);12});13var wptools = require('wptools');14var fs = require('fs');15wptools.page('Barack Obama').then(function(page) {16 return page.coordinates();17}).then(function(coordinates) {18 console.log(coordinates);19 fs.writeFile('coordinates.json', JSON.stringify(coordinates, null, 4), function(err) {20 console.log('File successfully written! - Check your project directory for the coordinates.json file');21 });22}).catch(function(err) {23 console.log(err);24});25var wptools = require('wptools');26var fs = require('fs');27wptools.page('Barack Obama').then(function(page) {28 return page.categories();29}).then(function(categories) {30 console.log(categories);31 fs.writeFile('categories.json', JSON.stringify(categories, null, 4), function(err) {32 console.log('File successfully written! - Check your project directory for the categories.json file');33 });34}).catch(function(err) {35 console.log(err);36});37var wptools = require('wptools');38var fs = require('fs');39wptools.page('Barack Obama').then(function(page) {40 return page.infobox();41}).then(function(infobox) {42 console.log(infobox);43 fs.writeFile('infobox.json', JSON.stringify(infobox, null, 4), function(err) {44 console.log('File successfully written! - Check your project directory for the infobox.json file');45 });46}).catch(function(err) {47 console.log(err);48});49var wptools = require('wptools');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2wptools.page('Barack Obama').get(function(err, page) {3 console.log(page.infobox('name'));4});5var wptools = require('wptools');6wptools.page('Barack Obama').get(function(err, page) {7 console.log(page.infobox('name'));8});9var wptools = require('wptools');10wptools.page('Barack Obama').get(function(err, page) {11 console.log(page.infobox('name'));12});13var wptools = require('wptools');14wptools.page('Barack Obama').get(function(err, page) {15 console.log(page.infobox('name'));16});17var wptools = require('wptools');18wptools.page('Barack Obama').get(function(err, page) {19 console.log(page.infobox('name'));20});21var wptools = require('wptools');22wptools.page('Barack Obama').get(function(err, page) {23 console.log(page.infobox('name'));24});25var wptools = require('wptools');26wptools.page('Barack Obama').get(function(err, page) {27 console.log(page.infobox('name'));28});29var wptools = require('wptools');30wptools.page('Barack Obama').get(function(err, page) {31 console.log(page.infobox('name'));32});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful