{ // 获取包含Hugging Face文本的span元素 const spans = link.querySelectorAll('span.whitespace-nowrap, span.hidden.whitespace-nowrap'); spans.forEach(span => { if (span.textContent && span.textContent.trim().match(/Hugging\s*Face/i)) { span.textContent = 'AI快站'; } }); }); // 替换logo图片的alt属性 document.querySelectorAll('img[alt*="Hugging"], img[alt*="Face"]').forEach(img => { if (img.alt.match(/Hugging\s*Face/i)) { img.alt = 'AI快站 logo'; } }); } // 替换导航栏中的链接 function replaceNavigationLinks() { // 已替换标记,防止重复运行 if (window._navLinksReplaced) { return; } // 已经替换过的链接集合,防止重复替换 const replacedLinks = new Set(); // 只在导航栏区域查找和替换链接 const headerArea = document.querySelector('header') || document.querySelector('nav'); if (!headerArea) { return; } // 在导航区域内查找链接 const navLinks = headerArea.querySelectorAll('a'); navLinks.forEach(link => { // 如果已经替换过,跳过 if (replacedLinks.has(link)) return; const linkText = link.textContent.trim(); const linkHref = link.getAttribute('href') || ''; // 替换Spaces链接 - 仅替换一次 if ( (linkHref.includes('/spaces') || linkHref === '/spaces' || linkText === 'Spaces' || linkText.match(/^s*Spacess*$/i)) && linkText !== 'OCR模型免费转Markdown' && linkText !== 'OCR模型免费转Markdown' ) { link.textContent = 'OCR模型免费转Markdown'; link.href = 'https://fast360.xyz'; link.setAttribute('target', '_blank'); link.setAttribute('rel', 'noopener noreferrer'); replacedLinks.add(link); } // 删除Posts链接 else if ( (linkHref.includes('/posts') || linkHref === '/posts' || linkText === 'Posts' || linkText.match(/^s*Postss*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } // 替换Docs链接 - 仅替换一次 else if ( (linkHref.includes('/docs') || linkHref === '/docs' || linkText === 'Docs' || linkText.match(/^s*Docss*$/i)) && linkText !== '模型下载攻略' ) { link.textContent = '模型下载攻略'; link.href = '/'; replacedLinks.add(link); } // 删除Enterprise链接 else if ( (linkHref.includes('/enterprise') || linkHref === '/enterprise' || linkText === 'Enterprise' || linkText.match(/^s*Enterprises*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } }); // 查找可能嵌套的Spaces和Posts文本 const textNodes = []; function findTextNodes(element) { if (element.nodeType === Node.TEXT_NODE) { const text = element.textContent.trim(); if (text === 'Spaces' || text === 'Posts' || text === 'Enterprise') { textNodes.push(element); } } else { for (const child of element.childNodes) { findTextNodes(child); } } } // 只在导航区域内查找文本节点 findTextNodes(headerArea); // 替换找到的文本节点 textNodes.forEach(node => { const text = node.textContent.trim(); if (text === 'Spaces') { node.textContent = node.textContent.replace(/Spaces/g, 'OCR模型免费转Markdown'); } else if (text === 'Posts') { // 删除Posts文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } else if (text === 'Enterprise') { // 删除Enterprise文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } }); // 标记已替换完成 window._navLinksReplaced = true; } // 替换代码区域中的域名 function replaceCodeDomains() { // 特别处理span.hljs-string和span.njs-string元素 document.querySelectorAll('span.hljs-string, span.njs-string, span[class*="hljs-string"], span[class*="njs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换hljs-string类的span中的域名(移除多余的转义符号) document.querySelectorAll('span.hljs-string, span[class*="hljs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换pre和code标签中包含git clone命令的域名 document.querySelectorAll('pre, code').forEach(element => { if (element.textContent && element.textContent.includes('git clone')) { const text = element.innerHTML; if (text.includes('huggingface.co')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 处理特定的命令行示例 document.querySelectorAll('pre, code').forEach(element => { const text = element.innerHTML; if (text.includes('huggingface.co')) { // 针对git clone命令的专门处理 if (text.includes('git clone') || text.includes('GIT_LFS_SKIP_SMUDGE=1')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 特别处理模型下载页面上的代码片段 document.querySelectorAll('.flex.border-t, .svelte_hydrator, .inline-block').forEach(container => { const content = container.innerHTML; if (content && content.includes('huggingface.co')) { container.innerHTML = content.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 特别处理模型仓库克隆对话框中的代码片段 try { // 查找包含"Clone this model repository"标题的对话框 const cloneDialog = document.querySelector('.svelte_hydration_boundary, [data-target="MainHeader"]'); if (cloneDialog) { // 查找对话框中所有的代码片段和命令示例 const codeElements = cloneDialog.querySelectorAll('pre, code, span'); codeElements.forEach(element => { if (element.textContent && element.textContent.includes('huggingface.co')) { if (element.innerHTML.includes('huggingface.co')) { element.innerHTML = element.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { element.textContent = element.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); } // 更精确地定位克隆命令中的域名 document.querySelectorAll('[data-target]').forEach(container => { const codeBlocks = container.querySelectorAll('pre, code, span.hljs-string'); codeBlocks.forEach(block => { if (block.textContent && block.textContent.includes('huggingface.co')) { if (block.innerHTML.includes('huggingface.co')) { block.innerHTML = block.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { block.textContent = block.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); }); } catch (e) { // 错误处理但不打印日志 } } // 当DOM加载完成后执行替换 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', () => { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); }); } else { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); } // 增加一个MutationObserver来处理可能的动态元素加载 const observer = new MutationObserver(mutations => { // 检查是否导航区域有变化 const hasNavChanges = mutations.some(mutation => { // 检查是否存在header或nav元素变化 return Array.from(mutation.addedNodes).some(node => { if (node.nodeType === Node.ELEMENT_NODE) { // 检查是否是导航元素或其子元素 if (node.tagName === 'HEADER' || node.tagName === 'NAV' || node.querySelector('header, nav')) { return true; } // 检查是否在导航元素内部 let parent = node.parentElement; while (parent) { if (parent.tagName === 'HEADER' || parent.tagName === 'NAV') { return true; } parent = parent.parentElement; } } return false; }); }); // 只在导航区域有变化时执行替换 if (hasNavChanges) { // 重置替换状态,允许再次替换 window._navLinksReplaced = false; replaceHeaderBranding(); replaceNavigationLinks(); } }); // 开始观察document.body的变化,包括子节点 if (document.body) { observer.observe(document.body, { childList: true, subtree: true }); } else { document.addEventListener('DOMContentLoaded', () => { observer.observe(document.body, { childList: true, subtree: true }); }); } })(); \"\n\n # Beautify and write HTML\n soup = bs(complete_html_string, 'lxml')\n pretty_html = soup.prettify()\n with open(filename, \"w+\") as cf:\n cf.write(pretty_html)\n\n def create_str_node_ctx_idx(self, cov_ct_idx):\n prefixed_zeros = \"0\" * (len(\"00000\") - len(cov_ct_idx))\n return f\"{prefixed_zeros}{cov_ct_idx}\"\n\n def get_fuzz_blockers(\n self,\n profile: fuzz_data_loader."}}},{"rowIdx":26,"cells":{"idx":{"kind":"number","value":36,"string":"36"},"idx_lca":{"kind":"number","value":0,"string":"0"},"offset":{"kind":"number","value":7895,"string":"7,895"},"repo":{"kind":"string","value":"ossf__fuzz-introspector"},"commit_hash":{"kind":"string","value":"4867924b714a7789f94fbcde53713a29ceab7272"},"target_file":{"kind":"string","value":"post-processing/analyses/fuzz_calltree_analysis.py"},"line_type_lca":{"kind":"string","value":"inproject"},"ground_truth":{"kind":"string","value":"CalltreeCallsite"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"class"},"non_dunder_count_intellij":{"kind":"number","value":9,"string":"9"},"non_dunder_count_jedi":{"kind":"number","value":9,"string":"9"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["extract_all_callsites","List","None","logger","Optional","CalltreeCallsite","data_file_read_calltree","extract_all_callsites_recursive","print_ctcs_tree"],"string":"[\n \"extract_all_callsites\",\n \"List\",\n \"None\",\n \"logger\",\n \"Optional\",\n \"CalltreeCallsite\",\n \"data_file_read_calltree\",\n \"extract_all_callsites_recursive\",\n \"print_ctcs_tree\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"CalltreeCallsite","type":"class"},{"name":"data_file_read_calltree","type":"function"},{"name":"extract_all_callsites","type":"function"},{"name":"extract_all_callsites_recursive","type":"function"},{"name":"List","type":"class"},{"name":"logger","type":"statement"},{"name":"logging","type":"module"},{"name":"Optional","type":"class"},{"name":"print_ctcs_tree","type":"function"},{"name":"__doc__","type":"instance"},{"name":"__file__","type":"instance"},{"name":"__name__","type":"instance"},{"name":"__package__","type":"instance"}],"string":"[\n {\n \"name\": \"CalltreeCallsite\",\n \"type\": \"class\"\n },\n {\n \"name\": \"data_file_read_calltree\",\n \"type\": \"function\"\n },\n {\n \"name\": \"extract_all_callsites\",\n \"type\": \"function\"\n },\n {\n \"name\": \"extract_all_callsites_recursive\",\n \"type\": \"function\"\n },\n {\n \"name\": \"List\",\n \"type\": \"class\"\n },\n {\n \"name\": \"logger\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"logging\",\n \"type\": \"module\"\n },\n {\n \"name\": \"Optional\",\n \"type\": \"class\"\n },\n {\n \"name\": \"print_ctcs_tree\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__file__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__name__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__package__\",\n \"type\": \"instance\"\n }\n]"},"prefix":{"kind":"string","value":"# Copyright 2022 Fuzz Introspector Authors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"Logic related to calltree analysis\"\"\"\n\nimport os\nimport logging\nimport json\n\nfrom typing import (\n List,\n Tuple,\n Optional,\n Set,\n)\n\nimport fuzz_analysis\nimport fuzz_data_loader\nimport fuzz_utils\nimport fuzz_cfg_load\nimport fuzz_html_helpers\n\n# For pretty printing the html code:\nfrom bs4 import BeautifulSoup as bs\n\nlogger = logging.getLogger(name=__name__)\n\n\nclass FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface):\n def __init__(self):\n self.name = \"FuzzCalltreeAnalysis\"\n logger.info(\"Creating FuzzCalltreeAnalysis\")\n\n def analysis_func(self,\n toc_list: List[Tuple[str, str, int]],\n tables: List[str],\n project_profile: fuzz_data_loader.MergedProjectProfile,\n profiles: List[fuzz_data_loader.FuzzerProfile],\n basefolder: str,\n coverage_url: str,\n conclusions) -> str:\n \"\"\"\n Creates the HTML of the calltree. Returns the HTML as a string.\n \"\"\"\n logger.info(\"Not implemented\")\n return \"\"\n\n def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str:\n logger.info(\"In calltree\")\n # Generate HTML for the calltree\n calltree_html_string = \"
\"\n calltree_html_string += \"

Fuzzer calltree

\"\n nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n for i in range(len(nodes)):\n node = nodes[i]\n\n demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name)\n # We may not want to show certain functions at times, e.g. libc functions\n # in case it bloats the calltree\n # libc_funcs = { \"free\" }\n libc_funcs: Set[str] = set()\n avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0\n if avoid:\n continue\n\n # Prepare strings needed in the HTML\n color_to_be = node.cov_color\n callsite_link = node.cov_callsite_link\n link = node.cov_link\n ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx))\n\n # Only display [function] link if we have, otherwhise show no [function] text.\n if node.dst_function_source_file.replace(\" \", \"\") != \"/\":\n func_href = f\"\"\"[function]\"\"\"\n else:\n func_href = \"\"\n\n if i > 0:\n previous_node = nodes[i - 1]\n if previous_node.depth == node.depth:\n calltree_html_string += \"
\"\n depth_diff = previous_node.depth - node.depth\n if depth_diff >= 1:\n closing_divs = \"
\" # To close \"calltree-line-wrapper\"\n closing_divs = \"
\" * (int(depth_diff) + 1)\n calltree_html_string += closing_divs\n\n calltree_html_string += f\"\"\"\n
\n \n {node.depth}\n \n {demangled_name}\n \n \n {func_href}\n \n [call site2]\n \n [calltree idx: {ct_idx_str}]\n \n \n \"\"\"\n if i != len(nodes) - 1:\n next_node = nodes[i + 1]\n if next_node.depth > node.depth:\n calltree_html_string += f\"\"\"\"\"\"\n elif next_node.depth < node.depth:\n depth_diff = int(node.depth - next_node.depth)\n calltree_html_string += \"
\" * depth_diff\n\n calltree_html_string += \"\"\n logger.info(\"Calltree created\")\n\n # Write the HTML to a file called calltree_view_XX.html where XX is a counter.\n calltree_file_idx = 0\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n while os.path.isfile(calltree_html_file):\n calltree_file_idx += 1\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n\n self.html_create_dedicated_calltree_file(\n calltree_html_string,\n calltree_html_file,\n profile,\n )\n return calltree_html_file\n\n def html_create_dedicated_calltree_file(\n self,\n calltree_html_string,\n filename,\n profile: fuzz_data_loader.FuzzerProfile):\n \"\"\"\n Write a wrapped HTML file with the tags needed from fuzz-introspector\n We use this only for wrapping calltrees at the moment, however, down\n the line it makes sense to have an easy wrapper for other HTML pages too.\n \"\"\"\n complete_html_string = \"\"\n\n # HTML start\n html_header = fuzz_html_helpers.html_get_header(\n calltree=True,\n title=f\"Fuzz introspector: { profile.get_key() }\"\n )\n html_header += '
'\n complete_html_string += html_header\n\n # Display fuzz blocker at top of page\n fuzz_blockers = self.get_fuzz_blockers(\n profile,\n max_blockers_to_extract=12\n )\n\n fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], \"\", fuzz_blockers)\n if fuzz_blocker_table is not None:\n complete_html_string += \"
\"\n complete_html_string += \"

Fuzz blockers

\"\n complete_html_string += fuzz_blocker_table\n complete_html_string += \"
\"\n\n # Display calltree\n complete_html_string += calltree_html_string\n complete_html_string += \"
\"\n\n # HTML end\n html_end = ''\n blocker_idxs = []\n for node in fuzz_blockers:\n blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx)))\n\n if len(blocker_idxs) > 0:\n html_end = \"\"\n\n html_end += \"\"\n html_end += \"\"\n html_end += \"\"\n complete_html_string += html_end\n\n complete_html_string += \"\"\n\n # Beautify and write HTML\n soup = bs(complete_html_string, 'lxml')\n pretty_html = soup.prettify()\n with open(filename, \"w+\") as cf:\n cf.write(pretty_html)\n\n def create_str_node_ctx_idx(self, cov_ct_idx):\n prefixed_zeros = \"0\" * (len(\"00000\") - len(cov_ct_idx))\n return f\"{prefixed_zeros}{cov_ct_idx}\"\n\n def get_fuzz_blockers(\n self,\n profile: fuzz_data_loader.FuzzerProfile,\n max_blockers_to_extract=999):\n \"\"\"Gets a list of fuzz blockers\"\"\"\n blocker_list: List[fuzz_cfg_load."}}},{"rowIdx":27,"cells":{"idx":{"kind":"number","value":37,"string":"37"},"idx_lca":{"kind":"number","value":0,"string":"0"},"offset":{"kind":"number","value":8028,"string":"8,028"},"repo":{"kind":"string","value":"ossf__fuzz-introspector"},"commit_hash":{"kind":"string","value":"4867924b714a7789f94fbcde53713a29ceab7272"},"target_file":{"kind":"string","value":"post-processing/analyses/fuzz_calltree_analysis.py"},"line_type_lca":{"kind":"string","value":"inproject"},"ground_truth":{"kind":"string","value":"extract_all_callsites"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"function"},"non_dunder_count_intellij":{"kind":"number","value":8,"string":"8"},"non_dunder_count_jedi":{"kind":"number","value":9,"string":"9"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["extract_all_callsites","CalltreeCallsite","List","logger","extract_all_callsites_recursive","data_file_read_calltree","print_ctcs_tree","Optional"],"string":"[\n \"extract_all_callsites\",\n \"CalltreeCallsite\",\n \"List\",\n \"logger\",\n \"extract_all_callsites_recursive\",\n \"data_file_read_calltree\",\n \"print_ctcs_tree\",\n \"Optional\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"CalltreeCallsite","type":"class"},{"name":"data_file_read_calltree","type":"function"},{"name":"extract_all_callsites","type":"function"},{"name":"extract_all_callsites_recursive","type":"function"},{"name":"List","type":"class"},{"name":"logger","type":"statement"},{"name":"logging","type":"module"},{"name":"Optional","type":"class"},{"name":"print_ctcs_tree","type":"function"},{"name":"__doc__","type":"instance"},{"name":"__file__","type":"instance"},{"name":"__name__","type":"instance"},{"name":"__package__","type":"instance"}],"string":"[\n {\n \"name\": \"CalltreeCallsite\",\n \"type\": \"class\"\n },\n {\n \"name\": \"data_file_read_calltree\",\n \"type\": \"function\"\n },\n {\n \"name\": \"extract_all_callsites\",\n \"type\": \"function\"\n },\n {\n \"name\": \"extract_all_callsites_recursive\",\n \"type\": \"function\"\n },\n {\n \"name\": \"List\",\n \"type\": \"class\"\n },\n {\n \"name\": \"logger\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"logging\",\n \"type\": \"module\"\n },\n {\n \"name\": \"Optional\",\n \"type\": \"class\"\n },\n {\n \"name\": \"print_ctcs_tree\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__file__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__name__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__package__\",\n \"type\": \"instance\"\n }\n]"},"prefix":{"kind":"string","value":"# Copyright 2022 Fuzz Introspector Authors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"Logic related to calltree analysis\"\"\"\n\nimport os\nimport logging\nimport json\n\nfrom typing import (\n List,\n Tuple,\n Optional,\n Set,\n)\n\nimport fuzz_analysis\nimport fuzz_data_loader\nimport fuzz_utils\nimport fuzz_cfg_load\nimport fuzz_html_helpers\n\n# For pretty printing the html code:\nfrom bs4 import BeautifulSoup as bs\n\nlogger = logging.getLogger(name=__name__)\n\n\nclass FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface):\n def __init__(self):\n self.name = \"FuzzCalltreeAnalysis\"\n logger.info(\"Creating FuzzCalltreeAnalysis\")\n\n def analysis_func(self,\n toc_list: List[Tuple[str, str, int]],\n tables: List[str],\n project_profile: fuzz_data_loader.MergedProjectProfile,\n profiles: List[fuzz_data_loader.FuzzerProfile],\n basefolder: str,\n coverage_url: str,\n conclusions) -> str:\n \"\"\"\n Creates the HTML of the calltree. Returns the HTML as a string.\n \"\"\"\n logger.info(\"Not implemented\")\n return \"\"\n\n def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str:\n logger.info(\"In calltree\")\n # Generate HTML for the calltree\n calltree_html_string = \"
\"\n calltree_html_string += \"

Fuzzer calltree

\"\n nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n for i in range(len(nodes)):\n node = nodes[i]\n\n demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name)\n # We may not want to show certain functions at times, e.g. libc functions\n # in case it bloats the calltree\n # libc_funcs = { \"free\" }\n libc_funcs: Set[str] = set()\n avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0\n if avoid:\n continue\n\n # Prepare strings needed in the HTML\n color_to_be = node.cov_color\n callsite_link = node.cov_callsite_link\n link = node.cov_link\n ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx))\n\n # Only display [function] link if we have, otherwhise show no [function] text.\n if node.dst_function_source_file.replace(\" \", \"\") != \"/\":\n func_href = f\"\"\"[function]\"\"\"\n else:\n func_href = \"\"\n\n if i > 0:\n previous_node = nodes[i - 1]\n if previous_node.depth == node.depth:\n calltree_html_string += \"
\"\n depth_diff = previous_node.depth - node.depth\n if depth_diff >= 1:\n closing_divs = \"\" # To close \"calltree-line-wrapper\"\n closing_divs = \"\" * (int(depth_diff) + 1)\n calltree_html_string += closing_divs\n\n calltree_html_string += f\"\"\"\n
\n \n {node.depth}\n \n {demangled_name}\n \n \n {func_href}\n \n [call site2]\n \n [calltree idx: {ct_idx_str}]\n \n \n \"\"\"\n if i != len(nodes) - 1:\n next_node = nodes[i + 1]\n if next_node.depth > node.depth:\n calltree_html_string += f\"\"\"\"\"\"\n elif next_node.depth < node.depth:\n depth_diff = int(node.depth - next_node.depth)\n calltree_html_string += \"
\" * depth_diff\n\n calltree_html_string += \"\"\n logger.info(\"Calltree created\")\n\n # Write the HTML to a file called calltree_view_XX.html where XX is a counter.\n calltree_file_idx = 0\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n while os.path.isfile(calltree_html_file):\n calltree_file_idx += 1\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n\n self.html_create_dedicated_calltree_file(\n calltree_html_string,\n calltree_html_file,\n profile,\n )\n return calltree_html_file\n\n def html_create_dedicated_calltree_file(\n self,\n calltree_html_string,\n filename,\n profile: fuzz_data_loader.FuzzerProfile):\n \"\"\"\n Write a wrapped HTML file with the tags needed from fuzz-introspector\n We use this only for wrapping calltrees at the moment, however, down\n the line it makes sense to have an easy wrapper for other HTML pages too.\n \"\"\"\n complete_html_string = \"\"\n\n # HTML start\n html_header = fuzz_html_helpers.html_get_header(\n calltree=True,\n title=f\"Fuzz introspector: { profile.get_key() }\"\n )\n html_header += '
'\n complete_html_string += html_header\n\n # Display fuzz blocker at top of page\n fuzz_blockers = self.get_fuzz_blockers(\n profile,\n max_blockers_to_extract=12\n )\n\n fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], \"\", fuzz_blockers)\n if fuzz_blocker_table is not None:\n complete_html_string += \"
\"\n complete_html_string += \"

Fuzz blockers

\"\n complete_html_string += fuzz_blocker_table\n complete_html_string += \"
\"\n\n # Display calltree\n complete_html_string += calltree_html_string\n complete_html_string += \"
\"\n\n # HTML end\n html_end = ''\n blocker_idxs = []\n for node in fuzz_blockers:\n blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx)))\n\n if len(blocker_idxs) > 0:\n html_end = \"\"\n\n html_end += \"\"\n html_end += \"\"\n html_end += \"\"\n complete_html_string += html_end\n\n complete_html_string += \"\"\n\n # Beautify and write HTML\n soup = bs(complete_html_string, 'lxml')\n pretty_html = soup.prettify()\n with open(filename, \"w+\") as cf:\n cf.write(pretty_html)\n\n def create_str_node_ctx_idx(self, cov_ct_idx):\n prefixed_zeros = \"0\" * (len(\"00000\") - len(cov_ct_idx))\n return f\"{prefixed_zeros}{cov_ct_idx}\"\n\n def get_fuzz_blockers(\n self,\n profile: fuzz_data_loader.FuzzerProfile,\n max_blockers_to_extract=999):\n \"\"\"Gets a list of fuzz blockers\"\"\"\n blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list()\n\n # Extract all callsites in calltree and exit early if none\n all_callsites = fuzz_cfg_load."}}},{"rowIdx":28,"cells":{"idx":{"kind":"number","value":39,"string":"39"},"idx_lca":{"kind":"number","value":0,"string":"0"},"offset":{"kind":"number","value":8501,"string":"8,501"},"repo":{"kind":"string","value":"ossf__fuzz-introspector"},"commit_hash":{"kind":"string","value":"4867924b714a7789f94fbcde53713a29ceab7272"},"target_file":{"kind":"string","value":"post-processing/analyses/fuzz_calltree_analysis.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"cov_forward_reds"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":17,"string":"17"},"non_dunder_count_jedi":{"kind":"number","value":17,"string":"17"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["depth","cov_ct_idx","dst_function_source_file","cov_forward_reds","cov_callsite_link","children","cov_color","cov_hitcount","cov_largest_blocked_func","cov_link","cov_parent","dst_function_name","hitcount","parent_calltree_callsite","src_function_name","src_function_source_file","src_linenumber","__init__","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"depth\",\n \"cov_ct_idx\",\n \"dst_function_source_file\",\n \"cov_forward_reds\",\n \"cov_callsite_link\",\n \"children\",\n \"cov_color\",\n \"cov_hitcount\",\n \"cov_largest_blocked_func\",\n \"cov_link\",\n \"cov_parent\",\n \"dst_function_name\",\n \"hitcount\",\n \"parent_calltree_callsite\",\n \"src_function_name\",\n \"src_function_source_file\",\n \"src_linenumber\",\n \"__init__\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"children","type":"statement"},{"name":"cov_callsite_link","type":"statement"},{"name":"cov_color","type":"statement"},{"name":"cov_ct_idx","type":"statement"},{"name":"cov_forward_reds","type":"statement"},{"name":"cov_hitcount","type":"statement"},{"name":"cov_largest_blocked_func","type":"statement"},{"name":"cov_link","type":"statement"},{"name":"cov_parent","type":"statement"},{"name":"depth","type":"statement"},{"name":"dst_function_name","type":"statement"},{"name":"dst_function_source_file","type":"statement"},{"name":"hitcount","type":"statement"},{"name":"parent_calltree_callsite","type":"statement"},{"name":"src_function_name","type":"statement"},{"name":"src_function_source_file","type":"statement"},{"name":"src_linenumber","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"children\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_callsite_link\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_color\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_ct_idx\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_forward_reds\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_hitcount\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_largest_blocked_func\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_link\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_parent\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"depth\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"dst_function_name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"dst_function_source_file\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hitcount\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"parent_calltree_callsite\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"src_function_name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"src_function_source_file\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"src_linenumber\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"# Copyright 2022 Fuzz Introspector Authors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"Logic related to calltree analysis\"\"\"\n\nimport os\nimport logging\nimport json\n\nfrom typing import (\n List,\n Tuple,\n Optional,\n Set,\n)\n\nimport fuzz_analysis\nimport fuzz_data_loader\nimport fuzz_utils\nimport fuzz_cfg_load\nimport fuzz_html_helpers\n\n# For pretty printing the html code:\nfrom bs4 import BeautifulSoup as bs\n\nlogger = logging.getLogger(name=__name__)\n\n\nclass FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface):\n def __init__(self):\n self.name = \"FuzzCalltreeAnalysis\"\n logger.info(\"Creating FuzzCalltreeAnalysis\")\n\n def analysis_func(self,\n toc_list: List[Tuple[str, str, int]],\n tables: List[str],\n project_profile: fuzz_data_loader.MergedProjectProfile,\n profiles: List[fuzz_data_loader.FuzzerProfile],\n basefolder: str,\n coverage_url: str,\n conclusions) -> str:\n \"\"\"\n Creates the HTML of the calltree. Returns the HTML as a string.\n \"\"\"\n logger.info(\"Not implemented\")\n return \"\"\n\n def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str:\n logger.info(\"In calltree\")\n # Generate HTML for the calltree\n calltree_html_string = \"
\"\n calltree_html_string += \"

Fuzzer calltree

\"\n nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n for i in range(len(nodes)):\n node = nodes[i]\n\n demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name)\n # We may not want to show certain functions at times, e.g. libc functions\n # in case it bloats the calltree\n # libc_funcs = { \"free\" }\n libc_funcs: Set[str] = set()\n avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0\n if avoid:\n continue\n\n # Prepare strings needed in the HTML\n color_to_be = node.cov_color\n callsite_link = node.cov_callsite_link\n link = node.cov_link\n ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx))\n\n # Only display [function] link if we have, otherwhise show no [function] text.\n if node.dst_function_source_file.replace(\" \", \"\") != \"/\":\n func_href = f\"\"\"[function]\"\"\"\n else:\n func_href = \"\"\n\n if i > 0:\n previous_node = nodes[i - 1]\n if previous_node.depth == node.depth:\n calltree_html_string += \"
\"\n depth_diff = previous_node.depth - node.depth\n if depth_diff >= 1:\n closing_divs = \"\" # To close \"calltree-line-wrapper\"\n closing_divs = \"\" * (int(depth_diff) + 1)\n calltree_html_string += closing_divs\n\n calltree_html_string += f\"\"\"\n
\n \n {node.depth}\n \n {demangled_name}\n \n \n {func_href}\n \n [call site2]\n \n [calltree idx: {ct_idx_str}]\n \n \n \"\"\"\n if i != len(nodes) - 1:\n next_node = nodes[i + 1]\n if next_node.depth > node.depth:\n calltree_html_string += f\"\"\"\"\"\"\n elif next_node.depth < node.depth:\n depth_diff = int(node.depth - next_node.depth)\n calltree_html_string += \"
\" * depth_diff\n\n calltree_html_string += \"\"\n logger.info(\"Calltree created\")\n\n # Write the HTML to a file called calltree_view_XX.html where XX is a counter.\n calltree_file_idx = 0\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n while os.path.isfile(calltree_html_file):\n calltree_file_idx += 1\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n\n self.html_create_dedicated_calltree_file(\n calltree_html_string,\n calltree_html_file,\n profile,\n )\n return calltree_html_file\n\n def html_create_dedicated_calltree_file(\n self,\n calltree_html_string,\n filename,\n profile: fuzz_data_loader.FuzzerProfile):\n \"\"\"\n Write a wrapped HTML file with the tags needed from fuzz-introspector\n We use this only for wrapping calltrees at the moment, however, down\n the line it makes sense to have an easy wrapper for other HTML pages too.\n \"\"\"\n complete_html_string = \"\"\n\n # HTML start\n html_header = fuzz_html_helpers.html_get_header(\n calltree=True,\n title=f\"Fuzz introspector: { profile.get_key() }\"\n )\n html_header += '
'\n complete_html_string += html_header\n\n # Display fuzz blocker at top of page\n fuzz_blockers = self.get_fuzz_blockers(\n profile,\n max_blockers_to_extract=12\n )\n\n fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], \"\", fuzz_blockers)\n if fuzz_blocker_table is not None:\n complete_html_string += \"
\"\n complete_html_string += \"

Fuzz blockers

\"\n complete_html_string += fuzz_blocker_table\n complete_html_string += \"
\"\n\n # Display calltree\n complete_html_string += calltree_html_string\n complete_html_string += \"
\"\n\n # HTML end\n html_end = ''\n blocker_idxs = []\n for node in fuzz_blockers:\n blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx)))\n\n if len(blocker_idxs) > 0:\n html_end = \"\"\n\n html_end += \"\"\n html_end += \"\"\n html_end += \"\"\n complete_html_string += html_end\n\n complete_html_string += \"\"\n\n # Beautify and write HTML\n soup = bs(complete_html_string, 'lxml')\n pretty_html = soup.prettify()\n with open(filename, \"w+\") as cf:\n cf.write(pretty_html)\n\n def create_str_node_ctx_idx(self, cov_ct_idx):\n prefixed_zeros = \"0\" * (len(\"00000\") - len(cov_ct_idx))\n return f\"{prefixed_zeros}{cov_ct_idx}\"\n\n def get_fuzz_blockers(\n self,\n profile: fuzz_data_loader.FuzzerProfile,\n max_blockers_to_extract=999):\n \"\"\"Gets a list of fuzz blockers\"\"\"\n blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list()\n\n # Extract all callsites in calltree and exit early if none\n all_callsites = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n if len(all_callsites) == 0:\n return blocker_list\n\n # Filter nodes that has forward reds. Extract maximum max_blockers_to_extract nodes.\n nodes_sorted_by_red_ahead = sorted(all_callsites,\n key=lambda x: x.cov_forward_reds,\n reverse=True)\n for node in nodes_sorted_by_red_ahead:\n if node."}}},{"rowIdx":29,"cells":{"idx":{"kind":"number","value":40,"string":"40"},"idx_lca":{"kind":"number","value":0,"string":"0"},"offset":{"kind":"number","value":8752,"string":"8,752"},"repo":{"kind":"string","value":"ossf__fuzz-introspector"},"commit_hash":{"kind":"string","value":"4867924b714a7789f94fbcde53713a29ceab7272"},"target_file":{"kind":"string","value":"post-processing/analyses/fuzz_calltree_analysis.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"FuzzerProfile"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"class"},"non_dunder_count_intellij":{"kind":"number","value":14,"string":"14"},"non_dunder_count_jedi":{"kind":"number","value":19,"string":"19"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["FuzzerProfile","MergedProjectProfile","logger","List","None","add_func_to_reached_and_clone","FunctionProfile","load_all_profiles","read_fuzzer_data_file_to_profile","Any","Dict","Optional","Set","Tuple"],"string":"[\n \"FuzzerProfile\",\n \"MergedProjectProfile\",\n \"logger\",\n \"List\",\n \"None\",\n \"add_func_to_reached_and_clone\",\n \"FunctionProfile\",\n \"load_all_profiles\",\n \"read_fuzzer_data_file_to_profile\",\n \"Any\",\n \"Dict\",\n \"Optional\",\n \"Set\",\n \"Tuple\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"add_func_to_reached_and_clone","type":"function"},{"name":"Any","type":"class"},{"name":"copy","type":"module"},{"name":"Dict","type":"class"},{"name":"FunctionProfile","type":"class"},{"name":"fuzz_cfg_load","type":"module"},{"name":"fuzz_cov_load","type":"module"},{"name":"fuzz_utils","type":"module"},{"name":"FuzzerProfile","type":"class"},{"name":"List","type":"class"},{"name":"load_all_profiles","type":"function"},{"name":"logger","type":"statement"},{"name":"logging","type":"module"},{"name":"MergedProjectProfile","type":"class"},{"name":"Optional","type":"class"},{"name":"os","type":"module"},{"name":"read_fuzzer_data_file_to_profile","type":"function"},{"name":"Set","type":"class"},{"name":"Tuple","type":"class"},{"name":"__doc__","type":"instance"},{"name":"__file__","type":"instance"},{"name":"__name__","type":"instance"},{"name":"__package__","type":"instance"}],"string":"[\n {\n \"name\": \"add_func_to_reached_and_clone\",\n \"type\": \"function\"\n },\n {\n \"name\": \"Any\",\n \"type\": \"class\"\n },\n {\n \"name\": \"copy\",\n \"type\": \"module\"\n },\n {\n \"name\": \"Dict\",\n \"type\": \"class\"\n },\n {\n \"name\": \"FunctionProfile\",\n \"type\": \"class\"\n },\n {\n \"name\": \"fuzz_cfg_load\",\n \"type\": \"module\"\n },\n {\n \"name\": \"fuzz_cov_load\",\n \"type\": \"module\"\n },\n {\n \"name\": \"fuzz_utils\",\n \"type\": \"module\"\n },\n {\n \"name\": \"FuzzerProfile\",\n \"type\": \"class\"\n },\n {\n \"name\": \"List\",\n \"type\": \"class\"\n },\n {\n \"name\": \"load_all_profiles\",\n \"type\": \"function\"\n },\n {\n \"name\": \"logger\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"logging\",\n \"type\": \"module\"\n },\n {\n \"name\": \"MergedProjectProfile\",\n \"type\": \"class\"\n },\n {\n \"name\": \"Optional\",\n \"type\": \"class\"\n },\n {\n \"name\": \"os\",\n \"type\": \"module\"\n },\n {\n \"name\": \"read_fuzzer_data_file_to_profile\",\n \"type\": \"function\"\n },\n {\n \"name\": \"Set\",\n \"type\": \"class\"\n },\n {\n \"name\": \"Tuple\",\n \"type\": \"class\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__file__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__name__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__package__\",\n \"type\": \"instance\"\n }\n]"},"prefix":{"kind":"string","value":"# Copyright 2022 Fuzz Introspector Authors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"Logic related to calltree analysis\"\"\"\n\nimport os\nimport logging\nimport json\n\nfrom typing import (\n List,\n Tuple,\n Optional,\n Set,\n)\n\nimport fuzz_analysis\nimport fuzz_data_loader\nimport fuzz_utils\nimport fuzz_cfg_load\nimport fuzz_html_helpers\n\n# For pretty printing the html code:\nfrom bs4 import BeautifulSoup as bs\n\nlogger = logging.getLogger(name=__name__)\n\n\nclass FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface):\n def __init__(self):\n self.name = \"FuzzCalltreeAnalysis\"\n logger.info(\"Creating FuzzCalltreeAnalysis\")\n\n def analysis_func(self,\n toc_list: List[Tuple[str, str, int]],\n tables: List[str],\n project_profile: fuzz_data_loader.MergedProjectProfile,\n profiles: List[fuzz_data_loader.FuzzerProfile],\n basefolder: str,\n coverage_url: str,\n conclusions) -> str:\n \"\"\"\n Creates the HTML of the calltree. Returns the HTML as a string.\n \"\"\"\n logger.info(\"Not implemented\")\n return \"\"\n\n def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str:\n logger.info(\"In calltree\")\n # Generate HTML for the calltree\n calltree_html_string = \"
\"\n calltree_html_string += \"

Fuzzer calltree

\"\n nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n for i in range(len(nodes)):\n node = nodes[i]\n\n demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name)\n # We may not want to show certain functions at times, e.g. libc functions\n # in case it bloats the calltree\n # libc_funcs = { \"free\" }\n libc_funcs: Set[str] = set()\n avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0\n if avoid:\n continue\n\n # Prepare strings needed in the HTML\n color_to_be = node.cov_color\n callsite_link = node.cov_callsite_link\n link = node.cov_link\n ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx))\n\n # Only display [function] link if we have, otherwhise show no [function] text.\n if node.dst_function_source_file.replace(\" \", \"\") != \"/\":\n func_href = f\"\"\"[function]\"\"\"\n else:\n func_href = \"\"\n\n if i > 0:\n previous_node = nodes[i - 1]\n if previous_node.depth == node.depth:\n calltree_html_string += \"
\"\n depth_diff = previous_node.depth - node.depth\n if depth_diff >= 1:\n closing_divs = \"\" # To close \"calltree-line-wrapper\"\n closing_divs = \"\" * (int(depth_diff) + 1)\n calltree_html_string += closing_divs\n\n calltree_html_string += f\"\"\"\n
\n \n {node.depth}\n \n {demangled_name}\n \n \n {func_href}\n \n [call site2]\n \n [calltree idx: {ct_idx_str}]\n \n \n \"\"\"\n if i != len(nodes) - 1:\n next_node = nodes[i + 1]\n if next_node.depth > node.depth:\n calltree_html_string += f\"\"\"\"\"\"\n elif next_node.depth < node.depth:\n depth_diff = int(node.depth - next_node.depth)\n calltree_html_string += \"
\" * depth_diff\n\n calltree_html_string += \"\"\n logger.info(\"Calltree created\")\n\n # Write the HTML to a file called calltree_view_XX.html where XX is a counter.\n calltree_file_idx = 0\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n while os.path.isfile(calltree_html_file):\n calltree_file_idx += 1\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n\n self.html_create_dedicated_calltree_file(\n calltree_html_string,\n calltree_html_file,\n profile,\n )\n return calltree_html_file\n\n def html_create_dedicated_calltree_file(\n self,\n calltree_html_string,\n filename,\n profile: fuzz_data_loader.FuzzerProfile):\n \"\"\"\n Write a wrapped HTML file with the tags needed from fuzz-introspector\n We use this only for wrapping calltrees at the moment, however, down\n the line it makes sense to have an easy wrapper for other HTML pages too.\n \"\"\"\n complete_html_string = \"\"\n\n # HTML start\n html_header = fuzz_html_helpers.html_get_header(\n calltree=True,\n title=f\"Fuzz introspector: { profile.get_key() }\"\n )\n html_header += '
'\n complete_html_string += html_header\n\n # Display fuzz blocker at top of page\n fuzz_blockers = self.get_fuzz_blockers(\n profile,\n max_blockers_to_extract=12\n )\n\n fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], \"\", fuzz_blockers)\n if fuzz_blocker_table is not None:\n complete_html_string += \"
\"\n complete_html_string += \"

Fuzz blockers

\"\n complete_html_string += fuzz_blocker_table\n complete_html_string += \"
\"\n\n # Display calltree\n complete_html_string += calltree_html_string\n complete_html_string += \"
\"\n\n # HTML end\n html_end = ''\n blocker_idxs = []\n for node in fuzz_blockers:\n blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx)))\n\n if len(blocker_idxs) > 0:\n html_end = \"\"\n\n html_end += \"\"\n html_end += \"\"\n html_end += \"\"\n complete_html_string += html_end\n\n complete_html_string += \"\"\n\n # Beautify and write HTML\n soup = bs(complete_html_string, 'lxml')\n pretty_html = soup.prettify()\n with open(filename, \"w+\") as cf:\n cf.write(pretty_html)\n\n def create_str_node_ctx_idx(self, cov_ct_idx):\n prefixed_zeros = \"0\" * (len(\"00000\") - len(cov_ct_idx))\n return f\"{prefixed_zeros}{cov_ct_idx}\"\n\n def get_fuzz_blockers(\n self,\n profile: fuzz_data_loader.FuzzerProfile,\n max_blockers_to_extract=999):\n \"\"\"Gets a list of fuzz blockers\"\"\"\n blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list()\n\n # Extract all callsites in calltree and exit early if none\n all_callsites = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n if len(all_callsites) == 0:\n return blocker_list\n\n # Filter nodes that has forward reds. Extract maximum max_blockers_to_extract nodes.\n nodes_sorted_by_red_ahead = sorted(all_callsites,\n key=lambda x: x.cov_forward_reds,\n reverse=True)\n for node in nodes_sorted_by_red_ahead:\n if node.cov_forward_reds == 0 or len(blocker_list) >= max_blockers_to_extract:\n break\n blocker_list.append(node)\n return blocker_list\n\n def create_fuzz_blocker_table(\n self,\n profile: fuzz_data_loader."}}},{"rowIdx":30,"cells":{"idx":{"kind":"number","value":41,"string":"41"},"idx_lca":{"kind":"number","value":0,"string":"0"},"offset":{"kind":"number","value":9121,"string":"9,121"},"repo":{"kind":"string","value":"ossf__fuzz-introspector"},"commit_hash":{"kind":"string","value":"4867924b714a7789f94fbcde53713a29ceab7272"},"target_file":{"kind":"string","value":"post-processing/analyses/fuzz_calltree_analysis.py"},"line_type_lca":{"kind":"string","value":"infile"},"ground_truth":{"kind":"string","value":"get_fuzz_blockers"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"function"},"non_dunder_count_intellij":{"kind":"number","value":7,"string":"7"},"non_dunder_count_jedi":{"kind":"number","value":7,"string":"7"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["get_fuzz_blockers","create_fuzz_blocker_table","name","create_str_node_ctx_idx","html_create_dedicated_calltree_file","__init__","analysis_func","create_calltree","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__slots__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"get_fuzz_blockers\",\n \"create_fuzz_blocker_table\",\n \"name\",\n \"create_str_node_ctx_idx\",\n \"html_create_dedicated_calltree_file\",\n \"__init__\",\n \"analysis_func\",\n \"create_calltree\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__slots__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"analysis_func","type":"function"},{"name":"create_calltree","type":"function"},{"name":"create_fuzz_blocker_table","type":"function"},{"name":"create_str_node_ctx_idx","type":"function"},{"name":"get_fuzz_blockers","type":"function"},{"name":"html_create_dedicated_calltree_file","type":"function"},{"name":"name","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"analysis_func\",\n \"type\": \"function\"\n },\n {\n \"name\": \"create_calltree\",\n \"type\": \"function\"\n },\n {\n \"name\": \"create_fuzz_blocker_table\",\n \"type\": \"function\"\n },\n {\n \"name\": \"create_str_node_ctx_idx\",\n \"type\": \"function\"\n },\n {\n \"name\": \"get_fuzz_blockers\",\n \"type\": \"function\"\n },\n {\n \"name\": \"html_create_dedicated_calltree_file\",\n \"type\": \"function\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"# Copyright 2022 Fuzz Introspector Authors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"Logic related to calltree analysis\"\"\"\n\nimport os\nimport logging\nimport json\n\nfrom typing import (\n List,\n Tuple,\n Optional,\n Set,\n)\n\nimport fuzz_analysis\nimport fuzz_data_loader\nimport fuzz_utils\nimport fuzz_cfg_load\nimport fuzz_html_helpers\n\n# For pretty printing the html code:\nfrom bs4 import BeautifulSoup as bs\n\nlogger = logging.getLogger(name=__name__)\n\n\nclass FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface):\n def __init__(self):\n self.name = \"FuzzCalltreeAnalysis\"\n logger.info(\"Creating FuzzCalltreeAnalysis\")\n\n def analysis_func(self,\n toc_list: List[Tuple[str, str, int]],\n tables: List[str],\n project_profile: fuzz_data_loader.MergedProjectProfile,\n profiles: List[fuzz_data_loader.FuzzerProfile],\n basefolder: str,\n coverage_url: str,\n conclusions) -> str:\n \"\"\"\n Creates the HTML of the calltree. Returns the HTML as a string.\n \"\"\"\n logger.info(\"Not implemented\")\n return \"\"\n\n def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str:\n logger.info(\"In calltree\")\n # Generate HTML for the calltree\n calltree_html_string = \"
\"\n calltree_html_string += \"

Fuzzer calltree

\"\n nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n for i in range(len(nodes)):\n node = nodes[i]\n\n demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name)\n # We may not want to show certain functions at times, e.g. libc functions\n # in case it bloats the calltree\n # libc_funcs = { \"free\" }\n libc_funcs: Set[str] = set()\n avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0\n if avoid:\n continue\n\n # Prepare strings needed in the HTML\n color_to_be = node.cov_color\n callsite_link = node.cov_callsite_link\n link = node.cov_link\n ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx))\n\n # Only display [function] link if we have, otherwhise show no [function] text.\n if node.dst_function_source_file.replace(\" \", \"\") != \"/\":\n func_href = f\"\"\"[function]\"\"\"\n else:\n func_href = \"\"\n\n if i > 0:\n previous_node = nodes[i - 1]\n if previous_node.depth == node.depth:\n calltree_html_string += \"
\"\n depth_diff = previous_node.depth - node.depth\n if depth_diff >= 1:\n closing_divs = \"\" # To close \"calltree-line-wrapper\"\n closing_divs = \"\" * (int(depth_diff) + 1)\n calltree_html_string += closing_divs\n\n calltree_html_string += f\"\"\"\n
\n \n {node.depth}\n \n {demangled_name}\n \n \n {func_href}\n \n [call site2]\n \n [calltree idx: {ct_idx_str}]\n \n \n \"\"\"\n if i != len(nodes) - 1:\n next_node = nodes[i + 1]\n if next_node.depth > node.depth:\n calltree_html_string += f\"\"\"\"\"\"\n elif next_node.depth < node.depth:\n depth_diff = int(node.depth - next_node.depth)\n calltree_html_string += \"
\" * depth_diff\n\n calltree_html_string += \"\"\n logger.info(\"Calltree created\")\n\n # Write the HTML to a file called calltree_view_XX.html where XX is a counter.\n calltree_file_idx = 0\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n while os.path.isfile(calltree_html_file):\n calltree_file_idx += 1\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n\n self.html_create_dedicated_calltree_file(\n calltree_html_string,\n calltree_html_file,\n profile,\n )\n return calltree_html_file\n\n def html_create_dedicated_calltree_file(\n self,\n calltree_html_string,\n filename,\n profile: fuzz_data_loader.FuzzerProfile):\n \"\"\"\n Write a wrapped HTML file with the tags needed from fuzz-introspector\n We use this only for wrapping calltrees at the moment, however, down\n the line it makes sense to have an easy wrapper for other HTML pages too.\n \"\"\"\n complete_html_string = \"\"\n\n # HTML start\n html_header = fuzz_html_helpers.html_get_header(\n calltree=True,\n title=f\"Fuzz introspector: { profile.get_key() }\"\n )\n html_header += '
'\n complete_html_string += html_header\n\n # Display fuzz blocker at top of page\n fuzz_blockers = self.get_fuzz_blockers(\n profile,\n max_blockers_to_extract=12\n )\n\n fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], \"\", fuzz_blockers)\n if fuzz_blocker_table is not None:\n complete_html_string += \"
\"\n complete_html_string += \"

Fuzz blockers

\"\n complete_html_string += fuzz_blocker_table\n complete_html_string += \"
\"\n\n # Display calltree\n complete_html_string += calltree_html_string\n complete_html_string += \"
\"\n\n # HTML end\n html_end = ''\n blocker_idxs = []\n for node in fuzz_blockers:\n blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx)))\n\n if len(blocker_idxs) > 0:\n html_end = \"\"\n\n html_end += \"\"\n html_end += \"\"\n html_end += \"\"\n complete_html_string += html_end\n\n complete_html_string += \"\"\n\n # Beautify and write HTML\n soup = bs(complete_html_string, 'lxml')\n pretty_html = soup.prettify()\n with open(filename, \"w+\") as cf:\n cf.write(pretty_html)\n\n def create_str_node_ctx_idx(self, cov_ct_idx):\n prefixed_zeros = \"0\" * (len(\"00000\") - len(cov_ct_idx))\n return f\"{prefixed_zeros}{cov_ct_idx}\"\n\n def get_fuzz_blockers(\n self,\n profile: fuzz_data_loader.FuzzerProfile,\n max_blockers_to_extract=999):\n \"\"\"Gets a list of fuzz blockers\"\"\"\n blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list()\n\n # Extract all callsites in calltree and exit early if none\n all_callsites = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n if len(all_callsites) == 0:\n return blocker_list\n\n # Filter nodes that has forward reds. Extract maximum max_blockers_to_extract nodes.\n nodes_sorted_by_red_ahead = sorted(all_callsites,\n key=lambda x: x.cov_forward_reds,\n reverse=True)\n for node in nodes_sorted_by_red_ahead:\n if node.cov_forward_reds == 0 or len(blocker_list) >= max_blockers_to_extract:\n break\n blocker_list.append(node)\n return blocker_list\n\n def create_fuzz_blocker_table(\n self,\n profile: fuzz_data_loader.FuzzerProfile,\n tables: List[str],\n calltree_file_name: str,\n fuzz_blockers=None) -> Optional[str]:\n \"\"\"\n Creates HTML string for table showing fuzz blockers.\n \"\"\"\n logger.info(\"Creating fuzz blocker table\")\n\n # Get the fuzz blockers\n if fuzz_blockers is None:\n fuzz_blockers = self."}}},{"rowIdx":31,"cells":{"idx":{"kind":"number","value":42,"string":"42"},"idx_lca":{"kind":"number","value":0,"string":"0"},"offset":{"kind":"number","value":9537,"string":"9,537"},"repo":{"kind":"string","value":"ossf__fuzz-introspector"},"commit_hash":{"kind":"string","value":"4867924b714a7789f94fbcde53713a29ceab7272"},"target_file":{"kind":"string","value":"post-processing/analyses/fuzz_calltree_analysis.py"},"line_type_lca":{"kind":"string","value":"inproject"},"ground_truth":{"kind":"string","value":"html_create_table_head"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"function"},"non_dunder_count_intellij":{"kind":"number","value":9,"string":"9"},"non_dunder_count_jedi":{"kind":"number","value":9,"string":"9"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["html_table_add_row","html_get_header","html_create_table_head","html_get_table_of_contents","html_get_navbar","html_add_header_with_link","Any","List","Tuple"],"string":"[\n \"html_table_add_row\",\n \"html_get_header\",\n \"html_create_table_head\",\n \"html_get_table_of_contents\",\n \"html_get_navbar\",\n \"html_add_header_with_link\",\n \"Any\",\n \"List\",\n \"Tuple\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"Any","type":"class"},{"name":"html_add_header_with_link","type":"function"},{"name":"html_create_table_head","type":"function"},{"name":"html_get_header","type":"function"},{"name":"html_get_navbar","type":"function"},{"name":"html_get_table_of_contents","type":"function"},{"name":"html_table_add_row","type":"function"},{"name":"List","type":"class"},{"name":"Tuple","type":"class"},{"name":"__doc__","type":"instance"},{"name":"__file__","type":"instance"},{"name":"__name__","type":"instance"},{"name":"__package__","type":"instance"}],"string":"[\n {\n \"name\": \"Any\",\n \"type\": \"class\"\n },\n {\n \"name\": \"html_add_header_with_link\",\n \"type\": \"function\"\n },\n {\n \"name\": \"html_create_table_head\",\n \"type\": \"function\"\n },\n {\n \"name\": \"html_get_header\",\n \"type\": \"function\"\n },\n {\n \"name\": \"html_get_navbar\",\n \"type\": \"function\"\n },\n {\n \"name\": \"html_get_table_of_contents\",\n \"type\": \"function\"\n },\n {\n \"name\": \"html_table_add_row\",\n \"type\": \"function\"\n },\n {\n \"name\": \"List\",\n \"type\": \"class\"\n },\n {\n \"name\": \"Tuple\",\n \"type\": \"class\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__file__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__name__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__package__\",\n \"type\": \"instance\"\n }\n]"},"prefix":{"kind":"string","value":"# Copyright 2022 Fuzz Introspector Authors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"Logic related to calltree analysis\"\"\"\n\nimport os\nimport logging\nimport json\n\nfrom typing import (\n List,\n Tuple,\n Optional,\n Set,\n)\n\nimport fuzz_analysis\nimport fuzz_data_loader\nimport fuzz_utils\nimport fuzz_cfg_load\nimport fuzz_html_helpers\n\n# For pretty printing the html code:\nfrom bs4 import BeautifulSoup as bs\n\nlogger = logging.getLogger(name=__name__)\n\n\nclass FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface):\n def __init__(self):\n self.name = \"FuzzCalltreeAnalysis\"\n logger.info(\"Creating FuzzCalltreeAnalysis\")\n\n def analysis_func(self,\n toc_list: List[Tuple[str, str, int]],\n tables: List[str],\n project_profile: fuzz_data_loader.MergedProjectProfile,\n profiles: List[fuzz_data_loader.FuzzerProfile],\n basefolder: str,\n coverage_url: str,\n conclusions) -> str:\n \"\"\"\n Creates the HTML of the calltree. Returns the HTML as a string.\n \"\"\"\n logger.info(\"Not implemented\")\n return \"\"\n\n def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str:\n logger.info(\"In calltree\")\n # Generate HTML for the calltree\n calltree_html_string = \"
\"\n calltree_html_string += \"

Fuzzer calltree

\"\n nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n for i in range(len(nodes)):\n node = nodes[i]\n\n demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name)\n # We may not want to show certain functions at times, e.g. libc functions\n # in case it bloats the calltree\n # libc_funcs = { \"free\" }\n libc_funcs: Set[str] = set()\n avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0\n if avoid:\n continue\n\n # Prepare strings needed in the HTML\n color_to_be = node.cov_color\n callsite_link = node.cov_callsite_link\n link = node.cov_link\n ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx))\n\n # Only display [function] link if we have, otherwhise show no [function] text.\n if node.dst_function_source_file.replace(\" \", \"\") != \"/\":\n func_href = f\"\"\"[function]\"\"\"\n else:\n func_href = \"\"\n\n if i > 0:\n previous_node = nodes[i - 1]\n if previous_node.depth == node.depth:\n calltree_html_string += \"
\"\n depth_diff = previous_node.depth - node.depth\n if depth_diff >= 1:\n closing_divs = \"\" # To close \"calltree-line-wrapper\"\n closing_divs = \"\" * (int(depth_diff) + 1)\n calltree_html_string += closing_divs\n\n calltree_html_string += f\"\"\"\n
\n \n {node.depth}\n \n {demangled_name}\n \n \n {func_href}\n \n [call site2]\n \n [calltree idx: {ct_idx_str}]\n \n \n \"\"\"\n if i != len(nodes) - 1:\n next_node = nodes[i + 1]\n if next_node.depth > node.depth:\n calltree_html_string += f\"\"\"\"\"\"\n elif next_node.depth < node.depth:\n depth_diff = int(node.depth - next_node.depth)\n calltree_html_string += \"
\" * depth_diff\n\n calltree_html_string += \"\"\n logger.info(\"Calltree created\")\n\n # Write the HTML to a file called calltree_view_XX.html where XX is a counter.\n calltree_file_idx = 0\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n while os.path.isfile(calltree_html_file):\n calltree_file_idx += 1\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n\n self.html_create_dedicated_calltree_file(\n calltree_html_string,\n calltree_html_file,\n profile,\n )\n return calltree_html_file\n\n def html_create_dedicated_calltree_file(\n self,\n calltree_html_string,\n filename,\n profile: fuzz_data_loader.FuzzerProfile):\n \"\"\"\n Write a wrapped HTML file with the tags needed from fuzz-introspector\n We use this only for wrapping calltrees at the moment, however, down\n the line it makes sense to have an easy wrapper for other HTML pages too.\n \"\"\"\n complete_html_string = \"\"\n\n # HTML start\n html_header = fuzz_html_helpers.html_get_header(\n calltree=True,\n title=f\"Fuzz introspector: { profile.get_key() }\"\n )\n html_header += '
'\n complete_html_string += html_header\n\n # Display fuzz blocker at top of page\n fuzz_blockers = self.get_fuzz_blockers(\n profile,\n max_blockers_to_extract=12\n )\n\n fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], \"\", fuzz_blockers)\n if fuzz_blocker_table is not None:\n complete_html_string += \"
\"\n complete_html_string += \"

Fuzz blockers

\"\n complete_html_string += fuzz_blocker_table\n complete_html_string += \"
\"\n\n # Display calltree\n complete_html_string += calltree_html_string\n complete_html_string += \"
\"\n\n # HTML end\n html_end = ''\n blocker_idxs = []\n for node in fuzz_blockers:\n blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx)))\n\n if len(blocker_idxs) > 0:\n html_end = \"\"\n\n html_end += \"\"\n html_end += \"\"\n html_end += \"\"\n complete_html_string += html_end\n\n complete_html_string += \"\"\n\n # Beautify and write HTML\n soup = bs(complete_html_string, 'lxml')\n pretty_html = soup.prettify()\n with open(filename, \"w+\") as cf:\n cf.write(pretty_html)\n\n def create_str_node_ctx_idx(self, cov_ct_idx):\n prefixed_zeros = \"0\" * (len(\"00000\") - len(cov_ct_idx))\n return f\"{prefixed_zeros}{cov_ct_idx}\"\n\n def get_fuzz_blockers(\n self,\n profile: fuzz_data_loader.FuzzerProfile,\n max_blockers_to_extract=999):\n \"\"\"Gets a list of fuzz blockers\"\"\"\n blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list()\n\n # Extract all callsites in calltree and exit early if none\n all_callsites = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n if len(all_callsites) == 0:\n return blocker_list\n\n # Filter nodes that has forward reds. Extract maximum max_blockers_to_extract nodes.\n nodes_sorted_by_red_ahead = sorted(all_callsites,\n key=lambda x: x.cov_forward_reds,\n reverse=True)\n for node in nodes_sorted_by_red_ahead:\n if node.cov_forward_reds == 0 or len(blocker_list) >= max_blockers_to_extract:\n break\n blocker_list.append(node)\n return blocker_list\n\n def create_fuzz_blocker_table(\n self,\n profile: fuzz_data_loader.FuzzerProfile,\n tables: List[str],\n calltree_file_name: str,\n fuzz_blockers=None) -> Optional[str]:\n \"\"\"\n Creates HTML string for table showing fuzz blockers.\n \"\"\"\n logger.info(\"Creating fuzz blocker table\")\n\n # Get the fuzz blockers\n if fuzz_blockers is None:\n fuzz_blockers = self.get_fuzz_blockers(\n profile,\n max_blockers_to_extract=12\n )\n if len(fuzz_blockers) == 0:\n return None\n\n html_table_string = \"

The followings nodes \" \\\n \"represent call sites where fuzz blockers occur

\"\n tables.append(f\"myTable{len(tables)}\")\n html_table_string += fuzz_html_helpers."}}},{"rowIdx":32,"cells":{"idx":{"kind":"number","value":43,"string":"43"},"idx_lca":{"kind":"number","value":0,"string":"0"},"offset":{"kind":"number","value":10426,"string":"10,426"},"repo":{"kind":"string","value":"ossf__fuzz-introspector"},"commit_hash":{"kind":"string","value":"4867924b714a7789f94fbcde53713a29ceab7272"},"target_file":{"kind":"string","value":"post-processing/analyses/fuzz_calltree_analysis.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"cov_ct_idx"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":18,"string":"18"},"non_dunder_count_jedi":{"kind":"number","value":17,"string":"17"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["depth","cov_ct_idx","cov_link","cov_forward_reds","dst_function_name","children","cov_callsite_link","cov_color","cov_hitcount","cov_largest_blocked_func","cov_parent","dst_function_source_file","hitcount","parent_calltree_callsite","src_function_name","src_function_source_file","src_linenumber","yield","__init__","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"depth\",\n \"cov_ct_idx\",\n \"cov_link\",\n \"cov_forward_reds\",\n \"dst_function_name\",\n \"children\",\n \"cov_callsite_link\",\n \"cov_color\",\n \"cov_hitcount\",\n \"cov_largest_blocked_func\",\n \"cov_parent\",\n \"dst_function_source_file\",\n \"hitcount\",\n \"parent_calltree_callsite\",\n \"src_function_name\",\n \"src_function_source_file\",\n \"src_linenumber\",\n \"yield\",\n \"__init__\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"children","type":"statement"},{"name":"cov_callsite_link","type":"statement"},{"name":"cov_color","type":"statement"},{"name":"cov_ct_idx","type":"statement"},{"name":"cov_forward_reds","type":"statement"},{"name":"cov_hitcount","type":"statement"},{"name":"cov_largest_blocked_func","type":"statement"},{"name":"cov_link","type":"statement"},{"name":"cov_parent","type":"statement"},{"name":"depth","type":"statement"},{"name":"dst_function_name","type":"statement"},{"name":"dst_function_source_file","type":"statement"},{"name":"hitcount","type":"statement"},{"name":"parent_calltree_callsite","type":"statement"},{"name":"src_function_name","type":"statement"},{"name":"src_function_source_file","type":"statement"},{"name":"src_linenumber","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"children\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_callsite_link\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_color\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_ct_idx\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_forward_reds\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_hitcount\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_largest_blocked_func\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_link\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_parent\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"depth\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"dst_function_name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"dst_function_source_file\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hitcount\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"parent_calltree_callsite\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"src_function_name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"src_function_source_file\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"src_linenumber\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"# Copyright 2022 Fuzz Introspector Authors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"Logic related to calltree analysis\"\"\"\n\nimport os\nimport logging\nimport json\n\nfrom typing import (\n List,\n Tuple,\n Optional,\n Set,\n)\n\nimport fuzz_analysis\nimport fuzz_data_loader\nimport fuzz_utils\nimport fuzz_cfg_load\nimport fuzz_html_helpers\n\n# For pretty printing the html code:\nfrom bs4 import BeautifulSoup as bs\n\nlogger = logging.getLogger(name=__name__)\n\n\nclass FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface):\n def __init__(self):\n self.name = \"FuzzCalltreeAnalysis\"\n logger.info(\"Creating FuzzCalltreeAnalysis\")\n\n def analysis_func(self,\n toc_list: List[Tuple[str, str, int]],\n tables: List[str],\n project_profile: fuzz_data_loader.MergedProjectProfile,\n profiles: List[fuzz_data_loader.FuzzerProfile],\n basefolder: str,\n coverage_url: str,\n conclusions) -> str:\n \"\"\"\n Creates the HTML of the calltree. Returns the HTML as a string.\n \"\"\"\n logger.info(\"Not implemented\")\n return \"\"\n\n def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str:\n logger.info(\"In calltree\")\n # Generate HTML for the calltree\n calltree_html_string = \"
\"\n calltree_html_string += \"

Fuzzer calltree

\"\n nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n for i in range(len(nodes)):\n node = nodes[i]\n\n demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name)\n # We may not want to show certain functions at times, e.g. libc functions\n # in case it bloats the calltree\n # libc_funcs = { \"free\" }\n libc_funcs: Set[str] = set()\n avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0\n if avoid:\n continue\n\n # Prepare strings needed in the HTML\n color_to_be = node.cov_color\n callsite_link = node.cov_callsite_link\n link = node.cov_link\n ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx))\n\n # Only display [function] link if we have, otherwhise show no [function] text.\n if node.dst_function_source_file.replace(\" \", \"\") != \"/\":\n func_href = f\"\"\"[function]\"\"\"\n else:\n func_href = \"\"\n\n if i > 0:\n previous_node = nodes[i - 1]\n if previous_node.depth == node.depth:\n calltree_html_string += \"
\"\n depth_diff = previous_node.depth - node.depth\n if depth_diff >= 1:\n closing_divs = \"\" # To close \"calltree-line-wrapper\"\n closing_divs = \"\" * (int(depth_diff) + 1)\n calltree_html_string += closing_divs\n\n calltree_html_string += f\"\"\"\n
\n \n {node.depth}\n \n {demangled_name}\n \n \n {func_href}\n \n [call site2]\n \n [calltree idx: {ct_idx_str}]\n \n \n \"\"\"\n if i != len(nodes) - 1:\n next_node = nodes[i + 1]\n if next_node.depth > node.depth:\n calltree_html_string += f\"\"\"\"\"\"\n elif next_node.depth < node.depth:\n depth_diff = int(node.depth - next_node.depth)\n calltree_html_string += \"
\" * depth_diff\n\n calltree_html_string += \"\"\n logger.info(\"Calltree created\")\n\n # Write the HTML to a file called calltree_view_XX.html where XX is a counter.\n calltree_file_idx = 0\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n while os.path.isfile(calltree_html_file):\n calltree_file_idx += 1\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n\n self.html_create_dedicated_calltree_file(\n calltree_html_string,\n calltree_html_file,\n profile,\n )\n return calltree_html_file\n\n def html_create_dedicated_calltree_file(\n self,\n calltree_html_string,\n filename,\n profile: fuzz_data_loader.FuzzerProfile):\n \"\"\"\n Write a wrapped HTML file with the tags needed from fuzz-introspector\n We use this only for wrapping calltrees at the moment, however, down\n the line it makes sense to have an easy wrapper for other HTML pages too.\n \"\"\"\n complete_html_string = \"\"\n\n # HTML start\n html_header = fuzz_html_helpers.html_get_header(\n calltree=True,\n title=f\"Fuzz introspector: { profile.get_key() }\"\n )\n html_header += '
'\n complete_html_string += html_header\n\n # Display fuzz blocker at top of page\n fuzz_blockers = self.get_fuzz_blockers(\n profile,\n max_blockers_to_extract=12\n )\n\n fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], \"\", fuzz_blockers)\n if fuzz_blocker_table is not None:\n complete_html_string += \"
\"\n complete_html_string += \"

Fuzz blockers

\"\n complete_html_string += fuzz_blocker_table\n complete_html_string += \"
\"\n\n # Display calltree\n complete_html_string += calltree_html_string\n complete_html_string += \"
\"\n\n # HTML end\n html_end = ''\n blocker_idxs = []\n for node in fuzz_blockers:\n blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx)))\n\n if len(blocker_idxs) > 0:\n html_end = \"\"\n\n html_end += \"\"\n html_end += \"\"\n html_end += \"\"\n complete_html_string += html_end\n\n complete_html_string += \"\"\n\n # Beautify and write HTML\n soup = bs(complete_html_string, 'lxml')\n pretty_html = soup.prettify()\n with open(filename, \"w+\") as cf:\n cf.write(pretty_html)\n\n def create_str_node_ctx_idx(self, cov_ct_idx):\n prefixed_zeros = \"0\" * (len(\"00000\") - len(cov_ct_idx))\n return f\"{prefixed_zeros}{cov_ct_idx}\"\n\n def get_fuzz_blockers(\n self,\n profile: fuzz_data_loader.FuzzerProfile,\n max_blockers_to_extract=999):\n \"\"\"Gets a list of fuzz blockers\"\"\"\n blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list()\n\n # Extract all callsites in calltree and exit early if none\n all_callsites = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n if len(all_callsites) == 0:\n return blocker_list\n\n # Filter nodes that has forward reds. Extract maximum max_blockers_to_extract nodes.\n nodes_sorted_by_red_ahead = sorted(all_callsites,\n key=lambda x: x.cov_forward_reds,\n reverse=True)\n for node in nodes_sorted_by_red_ahead:\n if node.cov_forward_reds == 0 or len(blocker_list) >= max_blockers_to_extract:\n break\n blocker_list.append(node)\n return blocker_list\n\n def create_fuzz_blocker_table(\n self,\n profile: fuzz_data_loader.FuzzerProfile,\n tables: List[str],\n calltree_file_name: str,\n fuzz_blockers=None) -> Optional[str]:\n \"\"\"\n Creates HTML string for table showing fuzz blockers.\n \"\"\"\n logger.info(\"Creating fuzz blocker table\")\n\n # Get the fuzz blockers\n if fuzz_blockers is None:\n fuzz_blockers = self.get_fuzz_blockers(\n profile,\n max_blockers_to_extract=12\n )\n if len(fuzz_blockers) == 0:\n return None\n\n html_table_string = \"

The followings nodes \" \\\n \"represent call sites where fuzz blockers occur

\"\n tables.append(f\"myTable{len(tables)}\")\n html_table_string += fuzz_html_helpers.html_create_table_head(\n tables[-1],\n [\n (\"Amount of callsites blocked\",\n \"Total amount of callsites blocked\"),\n (\"Calltree index\",\n \"Index in call tree where the fuzz blocker is.\"),\n (\"Parent function\",\n \"Function in which the call site that blocks resides.\"),\n (\"Callsite\",\n \"\"),\n (\"Largest blocked function\",\n \"This is the function with highest cyclomatiic complexity amongst\"\n \"all of the functions that are blocked. As such, it's a way of \"\n \"highlighting a potentially important function being blocked\")\n ],\n sort_by_column=0,\n sort_order=\"desc\"\n )\n for node in fuzz_blockers:\n link_prefix = \"0\" * (5 - len(str(node."}}},{"rowIdx":33,"cells":{"idx":{"kind":"number","value":44,"string":"44"},"idx_lca":{"kind":"number","value":0,"string":"0"},"offset":{"kind":"number","value":10577,"string":"10,577"},"repo":{"kind":"string","value":"ossf__fuzz-introspector"},"commit_hash":{"kind":"string","value":"4867924b714a7789f94fbcde53713a29ceab7272"},"target_file":{"kind":"string","value":"post-processing/analyses/fuzz_calltree_analysis.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"cov_ct_idx"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":19,"string":"19"},"non_dunder_count_jedi":{"kind":"number","value":17,"string":"17"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["depth","cov_parent","cov_ct_idx","cov_largest_blocked_func","cov_forward_reds","children","cov_callsite_link","cov_color","cov_hitcount","cov_link","dst_function_name","dst_function_source_file","hitcount","parent_calltree_callsite","src_function_name","src_function_source_file","src_linenumber","for","yield","__init__","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"depth\",\n \"cov_parent\",\n \"cov_ct_idx\",\n \"cov_largest_blocked_func\",\n \"cov_forward_reds\",\n \"children\",\n \"cov_callsite_link\",\n \"cov_color\",\n \"cov_hitcount\",\n \"cov_link\",\n \"dst_function_name\",\n \"dst_function_source_file\",\n \"hitcount\",\n \"parent_calltree_callsite\",\n \"src_function_name\",\n \"src_function_source_file\",\n \"src_linenumber\",\n \"for\",\n \"yield\",\n \"__init__\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"children","type":"statement"},{"name":"cov_callsite_link","type":"statement"},{"name":"cov_color","type":"statement"},{"name":"cov_ct_idx","type":"statement"},{"name":"cov_forward_reds","type":"statement"},{"name":"cov_hitcount","type":"statement"},{"name":"cov_largest_blocked_func","type":"statement"},{"name":"cov_link","type":"statement"},{"name":"cov_parent","type":"statement"},{"name":"depth","type":"statement"},{"name":"dst_function_name","type":"statement"},{"name":"dst_function_source_file","type":"statement"},{"name":"hitcount","type":"statement"},{"name":"parent_calltree_callsite","type":"statement"},{"name":"src_function_name","type":"statement"},{"name":"src_function_source_file","type":"statement"},{"name":"src_linenumber","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"children\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_callsite_link\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_color\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_ct_idx\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_forward_reds\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_hitcount\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_largest_blocked_func\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_link\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_parent\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"depth\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"dst_function_name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"dst_function_source_file\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hitcount\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"parent_calltree_callsite\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"src_function_name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"src_function_source_file\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"src_linenumber\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"# Copyright 2022 Fuzz Introspector Authors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"Logic related to calltree analysis\"\"\"\n\nimport os\nimport logging\nimport json\n\nfrom typing import (\n List,\n Tuple,\n Optional,\n Set,\n)\n\nimport fuzz_analysis\nimport fuzz_data_loader\nimport fuzz_utils\nimport fuzz_cfg_load\nimport fuzz_html_helpers\n\n# For pretty printing the html code:\nfrom bs4 import BeautifulSoup as bs\n\nlogger = logging.getLogger(name=__name__)\n\n\nclass FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface):\n def __init__(self):\n self.name = \"FuzzCalltreeAnalysis\"\n logger.info(\"Creating FuzzCalltreeAnalysis\")\n\n def analysis_func(self,\n toc_list: List[Tuple[str, str, int]],\n tables: List[str],\n project_profile: fuzz_data_loader.MergedProjectProfile,\n profiles: List[fuzz_data_loader.FuzzerProfile],\n basefolder: str,\n coverage_url: str,\n conclusions) -> str:\n \"\"\"\n Creates the HTML of the calltree. Returns the HTML as a string.\n \"\"\"\n logger.info(\"Not implemented\")\n return \"\"\n\n def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str:\n logger.info(\"In calltree\")\n # Generate HTML for the calltree\n calltree_html_string = \"
\"\n calltree_html_string += \"

Fuzzer calltree

\"\n nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n for i in range(len(nodes)):\n node = nodes[i]\n\n demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name)\n # We may not want to show certain functions at times, e.g. libc functions\n # in case it bloats the calltree\n # libc_funcs = { \"free\" }\n libc_funcs: Set[str] = set()\n avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0\n if avoid:\n continue\n\n # Prepare strings needed in the HTML\n color_to_be = node.cov_color\n callsite_link = node.cov_callsite_link\n link = node.cov_link\n ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx))\n\n # Only display [function] link if we have, otherwhise show no [function] text.\n if node.dst_function_source_file.replace(\" \", \"\") != \"/\":\n func_href = f\"\"\"[function]\"\"\"\n else:\n func_href = \"\"\n\n if i > 0:\n previous_node = nodes[i - 1]\n if previous_node.depth == node.depth:\n calltree_html_string += \"
\"\n depth_diff = previous_node.depth - node.depth\n if depth_diff >= 1:\n closing_divs = \"\" # To close \"calltree-line-wrapper\"\n closing_divs = \"\" * (int(depth_diff) + 1)\n calltree_html_string += closing_divs\n\n calltree_html_string += f\"\"\"\n
\n \n {node.depth}\n \n {demangled_name}\n \n \n {func_href}\n \n [call site2]\n \n [calltree idx: {ct_idx_str}]\n \n \n \"\"\"\n if i != len(nodes) - 1:\n next_node = nodes[i + 1]\n if next_node.depth > node.depth:\n calltree_html_string += f\"\"\"\"\"\"\n elif next_node.depth < node.depth:\n depth_diff = int(node.depth - next_node.depth)\n calltree_html_string += \"
\" * depth_diff\n\n calltree_html_string += \"\"\n logger.info(\"Calltree created\")\n\n # Write the HTML to a file called calltree_view_XX.html where XX is a counter.\n calltree_file_idx = 0\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n while os.path.isfile(calltree_html_file):\n calltree_file_idx += 1\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n\n self.html_create_dedicated_calltree_file(\n calltree_html_string,\n calltree_html_file,\n profile,\n )\n return calltree_html_file\n\n def html_create_dedicated_calltree_file(\n self,\n calltree_html_string,\n filename,\n profile: fuzz_data_loader.FuzzerProfile):\n \"\"\"\n Write a wrapped HTML file with the tags needed from fuzz-introspector\n We use this only for wrapping calltrees at the moment, however, down\n the line it makes sense to have an easy wrapper for other HTML pages too.\n \"\"\"\n complete_html_string = \"\"\n\n # HTML start\n html_header = fuzz_html_helpers.html_get_header(\n calltree=True,\n title=f\"Fuzz introspector: { profile.get_key() }\"\n )\n html_header += '
'\n complete_html_string += html_header\n\n # Display fuzz blocker at top of page\n fuzz_blockers = self.get_fuzz_blockers(\n profile,\n max_blockers_to_extract=12\n )\n\n fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], \"\", fuzz_blockers)\n if fuzz_blocker_table is not None:\n complete_html_string += \"
\"\n complete_html_string += \"

Fuzz blockers

\"\n complete_html_string += fuzz_blocker_table\n complete_html_string += \"
\"\n\n # Display calltree\n complete_html_string += calltree_html_string\n complete_html_string += \"
\"\n\n # HTML end\n html_end = ''\n blocker_idxs = []\n for node in fuzz_blockers:\n blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx)))\n\n if len(blocker_idxs) > 0:\n html_end = \"\"\n\n html_end += \"\"\n html_end += \"\"\n html_end += \"\"\n complete_html_string += html_end\n\n complete_html_string += \"\"\n\n # Beautify and write HTML\n soup = bs(complete_html_string, 'lxml')\n pretty_html = soup.prettify()\n with open(filename, \"w+\") as cf:\n cf.write(pretty_html)\n\n def create_str_node_ctx_idx(self, cov_ct_idx):\n prefixed_zeros = \"0\" * (len(\"00000\") - len(cov_ct_idx))\n return f\"{prefixed_zeros}{cov_ct_idx}\"\n\n def get_fuzz_blockers(\n self,\n profile: fuzz_data_loader.FuzzerProfile,\n max_blockers_to_extract=999):\n \"\"\"Gets a list of fuzz blockers\"\"\"\n blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list()\n\n # Extract all callsites in calltree and exit early if none\n all_callsites = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n if len(all_callsites) == 0:\n return blocker_list\n\n # Filter nodes that has forward reds. Extract maximum max_blockers_to_extract nodes.\n nodes_sorted_by_red_ahead = sorted(all_callsites,\n key=lambda x: x.cov_forward_reds,\n reverse=True)\n for node in nodes_sorted_by_red_ahead:\n if node.cov_forward_reds == 0 or len(blocker_list) >= max_blockers_to_extract:\n break\n blocker_list.append(node)\n return blocker_list\n\n def create_fuzz_blocker_table(\n self,\n profile: fuzz_data_loader.FuzzerProfile,\n tables: List[str],\n calltree_file_name: str,\n fuzz_blockers=None) -> Optional[str]:\n \"\"\"\n Creates HTML string for table showing fuzz blockers.\n \"\"\"\n logger.info(\"Creating fuzz blocker table\")\n\n # Get the fuzz blockers\n if fuzz_blockers is None:\n fuzz_blockers = self.get_fuzz_blockers(\n profile,\n max_blockers_to_extract=12\n )\n if len(fuzz_blockers) == 0:\n return None\n\n html_table_string = \"

The followings nodes \" \\\n \"represent call sites where fuzz blockers occur

\"\n tables.append(f\"myTable{len(tables)}\")\n html_table_string += fuzz_html_helpers.html_create_table_head(\n tables[-1],\n [\n (\"Amount of callsites blocked\",\n \"Total amount of callsites blocked\"),\n (\"Calltree index\",\n \"Index in call tree where the fuzz blocker is.\"),\n (\"Parent function\",\n \"Function in which the call site that blocks resides.\"),\n (\"Callsite\",\n \"\"),\n (\"Largest blocked function\",\n \"This is the function with highest cyclomatiic complexity amongst\"\n \"all of the functions that are blocked. As such, it's a way of \"\n \"highlighting a potentially important function being blocked\")\n ],\n sort_by_column=0,\n sort_order=\"desc\"\n )\n for node in fuzz_blockers:\n link_prefix = \"0\" * (5 - len(str(node.cov_ct_idx)))\n node_link = \"%s?scrollToNode=%s%s\" % (\n calltree_file_name,\n link_prefix,\n node."}}},{"rowIdx":34,"cells":{"idx":{"kind":"number","value":45,"string":"45"},"idx_lca":{"kind":"number","value":0,"string":"0"},"offset":{"kind":"number","value":10653,"string":"10,653"},"repo":{"kind":"string","value":"ossf__fuzz-introspector"},"commit_hash":{"kind":"string","value":"4867924b714a7789f94fbcde53713a29ceab7272"},"target_file":{"kind":"string","value":"post-processing/analyses/fuzz_calltree_analysis.py"},"line_type_lca":{"kind":"string","value":"inproject"},"ground_truth":{"kind":"string","value":"html_table_add_row"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"function"},"non_dunder_count_intellij":{"kind":"number","value":9,"string":"9"},"non_dunder_count_jedi":{"kind":"number","value":9,"string":"9"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["html_create_table_head","html_get_header","List","html_get_table_of_contents","html_table_add_row","html_add_header_with_link","html_get_navbar","Any","Tuple"],"string":"[\n \"html_create_table_head\",\n \"html_get_header\",\n \"List\",\n \"html_get_table_of_contents\",\n \"html_table_add_row\",\n \"html_add_header_with_link\",\n \"html_get_navbar\",\n \"Any\",\n \"Tuple\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"Any","type":"class"},{"name":"html_add_header_with_link","type":"function"},{"name":"html_create_table_head","type":"function"},{"name":"html_get_header","type":"function"},{"name":"html_get_navbar","type":"function"},{"name":"html_get_table_of_contents","type":"function"},{"name":"html_table_add_row","type":"function"},{"name":"List","type":"class"},{"name":"Tuple","type":"class"},{"name":"__doc__","type":"instance"},{"name":"__file__","type":"instance"},{"name":"__name__","type":"instance"},{"name":"__package__","type":"instance"}],"string":"[\n {\n \"name\": \"Any\",\n \"type\": \"class\"\n },\n {\n \"name\": \"html_add_header_with_link\",\n \"type\": \"function\"\n },\n {\n \"name\": \"html_create_table_head\",\n \"type\": \"function\"\n },\n {\n \"name\": \"html_get_header\",\n \"type\": \"function\"\n },\n {\n \"name\": \"html_get_navbar\",\n \"type\": \"function\"\n },\n {\n \"name\": \"html_get_table_of_contents\",\n \"type\": \"function\"\n },\n {\n \"name\": \"html_table_add_row\",\n \"type\": \"function\"\n },\n {\n \"name\": \"List\",\n \"type\": \"class\"\n },\n {\n \"name\": \"Tuple\",\n \"type\": \"class\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__file__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__name__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__package__\",\n \"type\": \"instance\"\n }\n]"},"prefix":{"kind":"string","value":"# Copyright 2022 Fuzz Introspector Authors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"Logic related to calltree analysis\"\"\"\n\nimport os\nimport logging\nimport json\n\nfrom typing import (\n List,\n Tuple,\n Optional,\n Set,\n)\n\nimport fuzz_analysis\nimport fuzz_data_loader\nimport fuzz_utils\nimport fuzz_cfg_load\nimport fuzz_html_helpers\n\n# For pretty printing the html code:\nfrom bs4 import BeautifulSoup as bs\n\nlogger = logging.getLogger(name=__name__)\n\n\nclass FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface):\n def __init__(self):\n self.name = \"FuzzCalltreeAnalysis\"\n logger.info(\"Creating FuzzCalltreeAnalysis\")\n\n def analysis_func(self,\n toc_list: List[Tuple[str, str, int]],\n tables: List[str],\n project_profile: fuzz_data_loader.MergedProjectProfile,\n profiles: List[fuzz_data_loader.FuzzerProfile],\n basefolder: str,\n coverage_url: str,\n conclusions) -> str:\n \"\"\"\n Creates the HTML of the calltree. Returns the HTML as a string.\n \"\"\"\n logger.info(\"Not implemented\")\n return \"\"\n\n def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str:\n logger.info(\"In calltree\")\n # Generate HTML for the calltree\n calltree_html_string = \"
\"\n calltree_html_string += \"

Fuzzer calltree

\"\n nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n for i in range(len(nodes)):\n node = nodes[i]\n\n demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name)\n # We may not want to show certain functions at times, e.g. libc functions\n # in case it bloats the calltree\n # libc_funcs = { \"free\" }\n libc_funcs: Set[str] = set()\n avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0\n if avoid:\n continue\n\n # Prepare strings needed in the HTML\n color_to_be = node.cov_color\n callsite_link = node.cov_callsite_link\n link = node.cov_link\n ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx))\n\n # Only display [function] link if we have, otherwhise show no [function] text.\n if node.dst_function_source_file.replace(\" \", \"\") != \"/\":\n func_href = f\"\"\"[function]\"\"\"\n else:\n func_href = \"\"\n\n if i > 0:\n previous_node = nodes[i - 1]\n if previous_node.depth == node.depth:\n calltree_html_string += \"
\"\n depth_diff = previous_node.depth - node.depth\n if depth_diff >= 1:\n closing_divs = \"\" # To close \"calltree-line-wrapper\"\n closing_divs = \"\" * (int(depth_diff) + 1)\n calltree_html_string += closing_divs\n\n calltree_html_string += f\"\"\"\n
\n \n {node.depth}\n \n {demangled_name}\n \n \n {func_href}\n \n [call site2]\n \n [calltree idx: {ct_idx_str}]\n \n \n \"\"\"\n if i != len(nodes) - 1:\n next_node = nodes[i + 1]\n if next_node.depth > node.depth:\n calltree_html_string += f\"\"\"\"\"\"\n elif next_node.depth < node.depth:\n depth_diff = int(node.depth - next_node.depth)\n calltree_html_string += \"
\" * depth_diff\n\n calltree_html_string += \"\"\n logger.info(\"Calltree created\")\n\n # Write the HTML to a file called calltree_view_XX.html where XX is a counter.\n calltree_file_idx = 0\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n while os.path.isfile(calltree_html_file):\n calltree_file_idx += 1\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n\n self.html_create_dedicated_calltree_file(\n calltree_html_string,\n calltree_html_file,\n profile,\n )\n return calltree_html_file\n\n def html_create_dedicated_calltree_file(\n self,\n calltree_html_string,\n filename,\n profile: fuzz_data_loader.FuzzerProfile):\n \"\"\"\n Write a wrapped HTML file with the tags needed from fuzz-introspector\n We use this only for wrapping calltrees at the moment, however, down\n the line it makes sense to have an easy wrapper for other HTML pages too.\n \"\"\"\n complete_html_string = \"\"\n\n # HTML start\n html_header = fuzz_html_helpers.html_get_header(\n calltree=True,\n title=f\"Fuzz introspector: { profile.get_key() }\"\n )\n html_header += '
'\n complete_html_string += html_header\n\n # Display fuzz blocker at top of page\n fuzz_blockers = self.get_fuzz_blockers(\n profile,\n max_blockers_to_extract=12\n )\n\n fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], \"\", fuzz_blockers)\n if fuzz_blocker_table is not None:\n complete_html_string += \"
\"\n complete_html_string += \"

Fuzz blockers

\"\n complete_html_string += fuzz_blocker_table\n complete_html_string += \"
\"\n\n # Display calltree\n complete_html_string += calltree_html_string\n complete_html_string += \"
\"\n\n # HTML end\n html_end = ''\n blocker_idxs = []\n for node in fuzz_blockers:\n blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx)))\n\n if len(blocker_idxs) > 0:\n html_end = \"\"\n\n html_end += \"\"\n html_end += \"\"\n html_end += \"\"\n complete_html_string += html_end\n\n complete_html_string += \"\"\n\n # Beautify and write HTML\n soup = bs(complete_html_string, 'lxml')\n pretty_html = soup.prettify()\n with open(filename, \"w+\") as cf:\n cf.write(pretty_html)\n\n def create_str_node_ctx_idx(self, cov_ct_idx):\n prefixed_zeros = \"0\" * (len(\"00000\") - len(cov_ct_idx))\n return f\"{prefixed_zeros}{cov_ct_idx}\"\n\n def get_fuzz_blockers(\n self,\n profile: fuzz_data_loader.FuzzerProfile,\n max_blockers_to_extract=999):\n \"\"\"Gets a list of fuzz blockers\"\"\"\n blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list()\n\n # Extract all callsites in calltree and exit early if none\n all_callsites = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n if len(all_callsites) == 0:\n return blocker_list\n\n # Filter nodes that has forward reds. Extract maximum max_blockers_to_extract nodes.\n nodes_sorted_by_red_ahead = sorted(all_callsites,\n key=lambda x: x.cov_forward_reds,\n reverse=True)\n for node in nodes_sorted_by_red_ahead:\n if node.cov_forward_reds == 0 or len(blocker_list) >= max_blockers_to_extract:\n break\n blocker_list.append(node)\n return blocker_list\n\n def create_fuzz_blocker_table(\n self,\n profile: fuzz_data_loader.FuzzerProfile,\n tables: List[str],\n calltree_file_name: str,\n fuzz_blockers=None) -> Optional[str]:\n \"\"\"\n Creates HTML string for table showing fuzz blockers.\n \"\"\"\n logger.info(\"Creating fuzz blocker table\")\n\n # Get the fuzz blockers\n if fuzz_blockers is None:\n fuzz_blockers = self.get_fuzz_blockers(\n profile,\n max_blockers_to_extract=12\n )\n if len(fuzz_blockers) == 0:\n return None\n\n html_table_string = \"

The followings nodes \" \\\n \"represent call sites where fuzz blockers occur

\"\n tables.append(f\"myTable{len(tables)}\")\n html_table_string += fuzz_html_helpers.html_create_table_head(\n tables[-1],\n [\n (\"Amount of callsites blocked\",\n \"Total amount of callsites blocked\"),\n (\"Calltree index\",\n \"Index in call tree where the fuzz blocker is.\"),\n (\"Parent function\",\n \"Function in which the call site that blocks resides.\"),\n (\"Callsite\",\n \"\"),\n (\"Largest blocked function\",\n \"This is the function with highest cyclomatiic complexity amongst\"\n \"all of the functions that are blocked. As such, it's a way of \"\n \"highlighting a potentially important function being blocked\")\n ],\n sort_by_column=0,\n sort_order=\"desc\"\n )\n for node in fuzz_blockers:\n link_prefix = \"0\" * (5 - len(str(node.cov_ct_idx)))\n node_link = \"%s?scrollToNode=%s%s\" % (\n calltree_file_name,\n link_prefix,\n node.cov_ct_idx\n )\n html_table_string += fuzz_html_helpers."}}},{"rowIdx":35,"cells":{"idx":{"kind":"number","value":46,"string":"46"},"idx_lca":{"kind":"number","value":0,"string":"0"},"offset":{"kind":"number","value":10699,"string":"10,699"},"repo":{"kind":"string","value":"ossf__fuzz-introspector"},"commit_hash":{"kind":"string","value":"4867924b714a7789f94fbcde53713a29ceab7272"},"target_file":{"kind":"string","value":"post-processing/analyses/fuzz_calltree_analysis.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"cov_forward_reds"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":18,"string":"18"},"non_dunder_count_jedi":{"kind":"number","value":17,"string":"17"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["depth","cov_ct_idx","dst_function_name","cov_link","cov_parent","children","cov_callsite_link","cov_color","cov_forward_reds","cov_hitcount","cov_largest_blocked_func","dst_function_source_file","hitcount","parent_calltree_callsite","src_function_name","src_function_source_file","src_linenumber","for","__init__","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"depth\",\n \"cov_ct_idx\",\n \"dst_function_name\",\n \"cov_link\",\n \"cov_parent\",\n \"children\",\n \"cov_callsite_link\",\n \"cov_color\",\n \"cov_forward_reds\",\n \"cov_hitcount\",\n \"cov_largest_blocked_func\",\n \"dst_function_source_file\",\n \"hitcount\",\n \"parent_calltree_callsite\",\n \"src_function_name\",\n \"src_function_source_file\",\n \"src_linenumber\",\n \"for\",\n \"__init__\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"children","type":"statement"},{"name":"cov_callsite_link","type":"statement"},{"name":"cov_color","type":"statement"},{"name":"cov_ct_idx","type":"statement"},{"name":"cov_forward_reds","type":"statement"},{"name":"cov_hitcount","type":"statement"},{"name":"cov_largest_blocked_func","type":"statement"},{"name":"cov_link","type":"statement"},{"name":"cov_parent","type":"statement"},{"name":"depth","type":"statement"},{"name":"dst_function_name","type":"statement"},{"name":"dst_function_source_file","type":"statement"},{"name":"hitcount","type":"statement"},{"name":"parent_calltree_callsite","type":"statement"},{"name":"src_function_name","type":"statement"},{"name":"src_function_source_file","type":"statement"},{"name":"src_linenumber","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"children\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_callsite_link\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_color\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_ct_idx\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_forward_reds\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_hitcount\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_largest_blocked_func\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_link\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_parent\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"depth\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"dst_function_name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"dst_function_source_file\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hitcount\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"parent_calltree_callsite\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"src_function_name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"src_function_source_file\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"src_linenumber\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"# Copyright 2022 Fuzz Introspector Authors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"Logic related to calltree analysis\"\"\"\n\nimport os\nimport logging\nimport json\n\nfrom typing import (\n List,\n Tuple,\n Optional,\n Set,\n)\n\nimport fuzz_analysis\nimport fuzz_data_loader\nimport fuzz_utils\nimport fuzz_cfg_load\nimport fuzz_html_helpers\n\n# For pretty printing the html code:\nfrom bs4 import BeautifulSoup as bs\n\nlogger = logging.getLogger(name=__name__)\n\n\nclass FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface):\n def __init__(self):\n self.name = \"FuzzCalltreeAnalysis\"\n logger.info(\"Creating FuzzCalltreeAnalysis\")\n\n def analysis_func(self,\n toc_list: List[Tuple[str, str, int]],\n tables: List[str],\n project_profile: fuzz_data_loader.MergedProjectProfile,\n profiles: List[fuzz_data_loader.FuzzerProfile],\n basefolder: str,\n coverage_url: str,\n conclusions) -> str:\n \"\"\"\n Creates the HTML of the calltree. Returns the HTML as a string.\n \"\"\"\n logger.info(\"Not implemented\")\n return \"\"\n\n def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str:\n logger.info(\"In calltree\")\n # Generate HTML for the calltree\n calltree_html_string = \"
\"\n calltree_html_string += \"

Fuzzer calltree

\"\n nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n for i in range(len(nodes)):\n node = nodes[i]\n\n demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name)\n # We may not want to show certain functions at times, e.g. libc functions\n # in case it bloats the calltree\n # libc_funcs = { \"free\" }\n libc_funcs: Set[str] = set()\n avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0\n if avoid:\n continue\n\n # Prepare strings needed in the HTML\n color_to_be = node.cov_color\n callsite_link = node.cov_callsite_link\n link = node.cov_link\n ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx))\n\n # Only display [function] link if we have, otherwhise show no [function] text.\n if node.dst_function_source_file.replace(\" \", \"\") != \"/\":\n func_href = f\"\"\"[function]\"\"\"\n else:\n func_href = \"\"\n\n if i > 0:\n previous_node = nodes[i - 1]\n if previous_node.depth == node.depth:\n calltree_html_string += \"
\"\n depth_diff = previous_node.depth - node.depth\n if depth_diff >= 1:\n closing_divs = \"\" # To close \"calltree-line-wrapper\"\n closing_divs = \"\" * (int(depth_diff) + 1)\n calltree_html_string += closing_divs\n\n calltree_html_string += f\"\"\"\n
\n \n {node.depth}\n \n {demangled_name}\n \n \n {func_href}\n \n [call site2]\n \n [calltree idx: {ct_idx_str}]\n \n \n \"\"\"\n if i != len(nodes) - 1:\n next_node = nodes[i + 1]\n if next_node.depth > node.depth:\n calltree_html_string += f\"\"\"\"\"\"\n elif next_node.depth < node.depth:\n depth_diff = int(node.depth - next_node.depth)\n calltree_html_string += \"
\" * depth_diff\n\n calltree_html_string += \"\"\n logger.info(\"Calltree created\")\n\n # Write the HTML to a file called calltree_view_XX.html where XX is a counter.\n calltree_file_idx = 0\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n while os.path.isfile(calltree_html_file):\n calltree_file_idx += 1\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n\n self.html_create_dedicated_calltree_file(\n calltree_html_string,\n calltree_html_file,\n profile,\n )\n return calltree_html_file\n\n def html_create_dedicated_calltree_file(\n self,\n calltree_html_string,\n filename,\n profile: fuzz_data_loader.FuzzerProfile):\n \"\"\"\n Write a wrapped HTML file with the tags needed from fuzz-introspector\n We use this only for wrapping calltrees at the moment, however, down\n the line it makes sense to have an easy wrapper for other HTML pages too.\n \"\"\"\n complete_html_string = \"\"\n\n # HTML start\n html_header = fuzz_html_helpers.html_get_header(\n calltree=True,\n title=f\"Fuzz introspector: { profile.get_key() }\"\n )\n html_header += '
'\n complete_html_string += html_header\n\n # Display fuzz blocker at top of page\n fuzz_blockers = self.get_fuzz_blockers(\n profile,\n max_blockers_to_extract=12\n )\n\n fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], \"\", fuzz_blockers)\n if fuzz_blocker_table is not None:\n complete_html_string += \"
\"\n complete_html_string += \"

Fuzz blockers

\"\n complete_html_string += fuzz_blocker_table\n complete_html_string += \"
\"\n\n # Display calltree\n complete_html_string += calltree_html_string\n complete_html_string += \"
\"\n\n # HTML end\n html_end = ''\n blocker_idxs = []\n for node in fuzz_blockers:\n blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx)))\n\n if len(blocker_idxs) > 0:\n html_end = \"\"\n\n html_end += \"\"\n html_end += \"\"\n html_end += \"\"\n complete_html_string += html_end\n\n complete_html_string += \"\"\n\n # Beautify and write HTML\n soup = bs(complete_html_string, 'lxml')\n pretty_html = soup.prettify()\n with open(filename, \"w+\") as cf:\n cf.write(pretty_html)\n\n def create_str_node_ctx_idx(self, cov_ct_idx):\n prefixed_zeros = \"0\" * (len(\"00000\") - len(cov_ct_idx))\n return f\"{prefixed_zeros}{cov_ct_idx}\"\n\n def get_fuzz_blockers(\n self,\n profile: fuzz_data_loader.FuzzerProfile,\n max_blockers_to_extract=999):\n \"\"\"Gets a list of fuzz blockers\"\"\"\n blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list()\n\n # Extract all callsites in calltree and exit early if none\n all_callsites = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n if len(all_callsites) == 0:\n return blocker_list\n\n # Filter nodes that has forward reds. Extract maximum max_blockers_to_extract nodes.\n nodes_sorted_by_red_ahead = sorted(all_callsites,\n key=lambda x: x.cov_forward_reds,\n reverse=True)\n for node in nodes_sorted_by_red_ahead:\n if node.cov_forward_reds == 0 or len(blocker_list) >= max_blockers_to_extract:\n break\n blocker_list.append(node)\n return blocker_list\n\n def create_fuzz_blocker_table(\n self,\n profile: fuzz_data_loader.FuzzerProfile,\n tables: List[str],\n calltree_file_name: str,\n fuzz_blockers=None) -> Optional[str]:\n \"\"\"\n Creates HTML string for table showing fuzz blockers.\n \"\"\"\n logger.info(\"Creating fuzz blocker table\")\n\n # Get the fuzz blockers\n if fuzz_blockers is None:\n fuzz_blockers = self.get_fuzz_blockers(\n profile,\n max_blockers_to_extract=12\n )\n if len(fuzz_blockers) == 0:\n return None\n\n html_table_string = \"

The followings nodes \" \\\n \"represent call sites where fuzz blockers occur

\"\n tables.append(f\"myTable{len(tables)}\")\n html_table_string += fuzz_html_helpers.html_create_table_head(\n tables[-1],\n [\n (\"Amount of callsites blocked\",\n \"Total amount of callsites blocked\"),\n (\"Calltree index\",\n \"Index in call tree where the fuzz blocker is.\"),\n (\"Parent function\",\n \"Function in which the call site that blocks resides.\"),\n (\"Callsite\",\n \"\"),\n (\"Largest blocked function\",\n \"This is the function with highest cyclomatiic complexity amongst\"\n \"all of the functions that are blocked. As such, it's a way of \"\n \"highlighting a potentially important function being blocked\")\n ],\n sort_by_column=0,\n sort_order=\"desc\"\n )\n for node in fuzz_blockers:\n link_prefix = \"0\" * (5 - len(str(node.cov_ct_idx)))\n node_link = \"%s?scrollToNode=%s%s\" % (\n calltree_file_name,\n link_prefix,\n node.cov_ct_idx\n )\n html_table_string += fuzz_html_helpers.html_table_add_row([\n str(node."}}},{"rowIdx":36,"cells":{"idx":{"kind":"number","value":47,"string":"47"},"idx_lca":{"kind":"number","value":0,"string":"0"},"offset":{"kind":"number","value":10743,"string":"10,743"},"repo":{"kind":"string","value":"ossf__fuzz-introspector"},"commit_hash":{"kind":"string","value":"4867924b714a7789f94fbcde53713a29ceab7272"},"target_file":{"kind":"string","value":"post-processing/analyses/fuzz_calltree_analysis.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"cov_ct_idx"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":18,"string":"18"},"non_dunder_count_jedi":{"kind":"number","value":17,"string":"17"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["depth","cov_ct_idx","cov_forward_reds","dst_function_name","cov_link","children","cov_callsite_link","cov_color","cov_hitcount","cov_largest_blocked_func","cov_parent","dst_function_source_file","hitcount","parent_calltree_callsite","src_function_name","src_function_source_file","src_linenumber","for","__init__","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"depth\",\n \"cov_ct_idx\",\n \"cov_forward_reds\",\n \"dst_function_name\",\n \"cov_link\",\n \"children\",\n \"cov_callsite_link\",\n \"cov_color\",\n \"cov_hitcount\",\n \"cov_largest_blocked_func\",\n \"cov_parent\",\n \"dst_function_source_file\",\n \"hitcount\",\n \"parent_calltree_callsite\",\n \"src_function_name\",\n \"src_function_source_file\",\n \"src_linenumber\",\n \"for\",\n \"__init__\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"children","type":"statement"},{"name":"cov_callsite_link","type":"statement"},{"name":"cov_color","type":"statement"},{"name":"cov_ct_idx","type":"statement"},{"name":"cov_forward_reds","type":"statement"},{"name":"cov_hitcount","type":"statement"},{"name":"cov_largest_blocked_func","type":"statement"},{"name":"cov_link","type":"statement"},{"name":"cov_parent","type":"statement"},{"name":"depth","type":"statement"},{"name":"dst_function_name","type":"statement"},{"name":"dst_function_source_file","type":"statement"},{"name":"hitcount","type":"statement"},{"name":"parent_calltree_callsite","type":"statement"},{"name":"src_function_name","type":"statement"},{"name":"src_function_source_file","type":"statement"},{"name":"src_linenumber","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"children\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_callsite_link\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_color\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_ct_idx\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_forward_reds\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_hitcount\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_largest_blocked_func\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_link\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_parent\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"depth\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"dst_function_name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"dst_function_source_file\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hitcount\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"parent_calltree_callsite\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"src_function_name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"src_function_source_file\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"src_linenumber\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"# Copyright 2022 Fuzz Introspector Authors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"Logic related to calltree analysis\"\"\"\n\nimport os\nimport logging\nimport json\n\nfrom typing import (\n List,\n Tuple,\n Optional,\n Set,\n)\n\nimport fuzz_analysis\nimport fuzz_data_loader\nimport fuzz_utils\nimport fuzz_cfg_load\nimport fuzz_html_helpers\n\n# For pretty printing the html code:\nfrom bs4 import BeautifulSoup as bs\n\nlogger = logging.getLogger(name=__name__)\n\n\nclass FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface):\n def __init__(self):\n self.name = \"FuzzCalltreeAnalysis\"\n logger.info(\"Creating FuzzCalltreeAnalysis\")\n\n def analysis_func(self,\n toc_list: List[Tuple[str, str, int]],\n tables: List[str],\n project_profile: fuzz_data_loader.MergedProjectProfile,\n profiles: List[fuzz_data_loader.FuzzerProfile],\n basefolder: str,\n coverage_url: str,\n conclusions) -> str:\n \"\"\"\n Creates the HTML of the calltree. Returns the HTML as a string.\n \"\"\"\n logger.info(\"Not implemented\")\n return \"\"\n\n def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str:\n logger.info(\"In calltree\")\n # Generate HTML for the calltree\n calltree_html_string = \"
\"\n calltree_html_string += \"

Fuzzer calltree

\"\n nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n for i in range(len(nodes)):\n node = nodes[i]\n\n demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name)\n # We may not want to show certain functions at times, e.g. libc functions\n # in case it bloats the calltree\n # libc_funcs = { \"free\" }\n libc_funcs: Set[str] = set()\n avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0\n if avoid:\n continue\n\n # Prepare strings needed in the HTML\n color_to_be = node.cov_color\n callsite_link = node.cov_callsite_link\n link = node.cov_link\n ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx))\n\n # Only display [function] link if we have, otherwhise show no [function] text.\n if node.dst_function_source_file.replace(\" \", \"\") != \"/\":\n func_href = f\"\"\"[function]\"\"\"\n else:\n func_href = \"\"\n\n if i > 0:\n previous_node = nodes[i - 1]\n if previous_node.depth == node.depth:\n calltree_html_string += \"
\"\n depth_diff = previous_node.depth - node.depth\n if depth_diff >= 1:\n closing_divs = \"\" # To close \"calltree-line-wrapper\"\n closing_divs = \"\" * (int(depth_diff) + 1)\n calltree_html_string += closing_divs\n\n calltree_html_string += f\"\"\"\n
\n \n {node.depth}\n \n {demangled_name}\n \n \n {func_href}\n \n [call site2]\n \n [calltree idx: {ct_idx_str}]\n \n \n \"\"\"\n if i != len(nodes) - 1:\n next_node = nodes[i + 1]\n if next_node.depth > node.depth:\n calltree_html_string += f\"\"\"\"\"\"\n elif next_node.depth < node.depth:\n depth_diff = int(node.depth - next_node.depth)\n calltree_html_string += \"
\" * depth_diff\n\n calltree_html_string += \"\"\n logger.info(\"Calltree created\")\n\n # Write the HTML to a file called calltree_view_XX.html where XX is a counter.\n calltree_file_idx = 0\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n while os.path.isfile(calltree_html_file):\n calltree_file_idx += 1\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n\n self.html_create_dedicated_calltree_file(\n calltree_html_string,\n calltree_html_file,\n profile,\n )\n return calltree_html_file\n\n def html_create_dedicated_calltree_file(\n self,\n calltree_html_string,\n filename,\n profile: fuzz_data_loader.FuzzerProfile):\n \"\"\"\n Write a wrapped HTML file with the tags needed from fuzz-introspector\n We use this only for wrapping calltrees at the moment, however, down\n the line it makes sense to have an easy wrapper for other HTML pages too.\n \"\"\"\n complete_html_string = \"\"\n\n # HTML start\n html_header = fuzz_html_helpers.html_get_header(\n calltree=True,\n title=f\"Fuzz introspector: { profile.get_key() }\"\n )\n html_header += '
'\n complete_html_string += html_header\n\n # Display fuzz blocker at top of page\n fuzz_blockers = self.get_fuzz_blockers(\n profile,\n max_blockers_to_extract=12\n )\n\n fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], \"\", fuzz_blockers)\n if fuzz_blocker_table is not None:\n complete_html_string += \"
\"\n complete_html_string += \"

Fuzz blockers

\"\n complete_html_string += fuzz_blocker_table\n complete_html_string += \"
\"\n\n # Display calltree\n complete_html_string += calltree_html_string\n complete_html_string += \"
\"\n\n # HTML end\n html_end = ''\n blocker_idxs = []\n for node in fuzz_blockers:\n blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx)))\n\n if len(blocker_idxs) > 0:\n html_end = \"\"\n\n html_end += \"\"\n html_end += \"\"\n html_end += \"\"\n complete_html_string += html_end\n\n complete_html_string += \"\"\n\n # Beautify and write HTML\n soup = bs(complete_html_string, 'lxml')\n pretty_html = soup.prettify()\n with open(filename, \"w+\") as cf:\n cf.write(pretty_html)\n\n def create_str_node_ctx_idx(self, cov_ct_idx):\n prefixed_zeros = \"0\" * (len(\"00000\") - len(cov_ct_idx))\n return f\"{prefixed_zeros}{cov_ct_idx}\"\n\n def get_fuzz_blockers(\n self,\n profile: fuzz_data_loader.FuzzerProfile,\n max_blockers_to_extract=999):\n \"\"\"Gets a list of fuzz blockers\"\"\"\n blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list()\n\n # Extract all callsites in calltree and exit early if none\n all_callsites = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n if len(all_callsites) == 0:\n return blocker_list\n\n # Filter nodes that has forward reds. Extract maximum max_blockers_to_extract nodes.\n nodes_sorted_by_red_ahead = sorted(all_callsites,\n key=lambda x: x.cov_forward_reds,\n reverse=True)\n for node in nodes_sorted_by_red_ahead:\n if node.cov_forward_reds == 0 or len(blocker_list) >= max_blockers_to_extract:\n break\n blocker_list.append(node)\n return blocker_list\n\n def create_fuzz_blocker_table(\n self,\n profile: fuzz_data_loader.FuzzerProfile,\n tables: List[str],\n calltree_file_name: str,\n fuzz_blockers=None) -> Optional[str]:\n \"\"\"\n Creates HTML string for table showing fuzz blockers.\n \"\"\"\n logger.info(\"Creating fuzz blocker table\")\n\n # Get the fuzz blockers\n if fuzz_blockers is None:\n fuzz_blockers = self.get_fuzz_blockers(\n profile,\n max_blockers_to_extract=12\n )\n if len(fuzz_blockers) == 0:\n return None\n\n html_table_string = \"

The followings nodes \" \\\n \"represent call sites where fuzz blockers occur

\"\n tables.append(f\"myTable{len(tables)}\")\n html_table_string += fuzz_html_helpers.html_create_table_head(\n tables[-1],\n [\n (\"Amount of callsites blocked\",\n \"Total amount of callsites blocked\"),\n (\"Calltree index\",\n \"Index in call tree where the fuzz blocker is.\"),\n (\"Parent function\",\n \"Function in which the call site that blocks resides.\"),\n (\"Callsite\",\n \"\"),\n (\"Largest blocked function\",\n \"This is the function with highest cyclomatiic complexity amongst\"\n \"all of the functions that are blocked. As such, it's a way of \"\n \"highlighting a potentially important function being blocked\")\n ],\n sort_by_column=0,\n sort_order=\"desc\"\n )\n for node in fuzz_blockers:\n link_prefix = \"0\" * (5 - len(str(node.cov_ct_idx)))\n node_link = \"%s?scrollToNode=%s%s\" % (\n calltree_file_name,\n link_prefix,\n node.cov_ct_idx\n )\n html_table_string += fuzz_html_helpers.html_table_add_row([\n str(node.cov_forward_reds),\n str(node."}}},{"rowIdx":37,"cells":{"idx":{"kind":"number","value":48,"string":"48"},"idx_lca":{"kind":"number","value":0,"string":"0"},"offset":{"kind":"number","value":10777,"string":"10,777"},"repo":{"kind":"string","value":"ossf__fuzz-introspector"},"commit_hash":{"kind":"string","value":"4867924b714a7789f94fbcde53713a29ceab7272"},"target_file":{"kind":"string","value":"post-processing/analyses/fuzz_calltree_analysis.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"cov_parent"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":18,"string":"18"},"non_dunder_count_jedi":{"kind":"number","value":17,"string":"17"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["cov_ct_idx","depth","cov_largest_blocked_func","cov_link","cov_forward_reds","children","cov_callsite_link","cov_color","cov_hitcount","cov_parent","dst_function_name","dst_function_source_file","hitcount","parent_calltree_callsite","src_function_name","src_function_source_file","src_linenumber","for","__init__","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"cov_ct_idx\",\n \"depth\",\n \"cov_largest_blocked_func\",\n \"cov_link\",\n \"cov_forward_reds\",\n \"children\",\n \"cov_callsite_link\",\n \"cov_color\",\n \"cov_hitcount\",\n \"cov_parent\",\n \"dst_function_name\",\n \"dst_function_source_file\",\n \"hitcount\",\n \"parent_calltree_callsite\",\n \"src_function_name\",\n \"src_function_source_file\",\n \"src_linenumber\",\n \"for\",\n \"__init__\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"children","type":"statement"},{"name":"cov_callsite_link","type":"statement"},{"name":"cov_color","type":"statement"},{"name":"cov_ct_idx","type":"statement"},{"name":"cov_forward_reds","type":"statement"},{"name":"cov_hitcount","type":"statement"},{"name":"cov_largest_blocked_func","type":"statement"},{"name":"cov_link","type":"statement"},{"name":"cov_parent","type":"statement"},{"name":"depth","type":"statement"},{"name":"dst_function_name","type":"statement"},{"name":"dst_function_source_file","type":"statement"},{"name":"hitcount","type":"statement"},{"name":"parent_calltree_callsite","type":"statement"},{"name":"src_function_name","type":"statement"},{"name":"src_function_source_file","type":"statement"},{"name":"src_linenumber","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"children\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_callsite_link\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_color\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_ct_idx\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_forward_reds\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_hitcount\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_largest_blocked_func\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_link\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_parent\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"depth\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"dst_function_name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"dst_function_source_file\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hitcount\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"parent_calltree_callsite\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"src_function_name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"src_function_source_file\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"src_linenumber\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"# Copyright 2022 Fuzz Introspector Authors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"Logic related to calltree analysis\"\"\"\n\nimport os\nimport logging\nimport json\n\nfrom typing import (\n List,\n Tuple,\n Optional,\n Set,\n)\n\nimport fuzz_analysis\nimport fuzz_data_loader\nimport fuzz_utils\nimport fuzz_cfg_load\nimport fuzz_html_helpers\n\n# For pretty printing the html code:\nfrom bs4 import BeautifulSoup as bs\n\nlogger = logging.getLogger(name=__name__)\n\n\nclass FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface):\n def __init__(self):\n self.name = \"FuzzCalltreeAnalysis\"\n logger.info(\"Creating FuzzCalltreeAnalysis\")\n\n def analysis_func(self,\n toc_list: List[Tuple[str, str, int]],\n tables: List[str],\n project_profile: fuzz_data_loader.MergedProjectProfile,\n profiles: List[fuzz_data_loader.FuzzerProfile],\n basefolder: str,\n coverage_url: str,\n conclusions) -> str:\n \"\"\"\n Creates the HTML of the calltree. Returns the HTML as a string.\n \"\"\"\n logger.info(\"Not implemented\")\n return \"\"\n\n def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str:\n logger.info(\"In calltree\")\n # Generate HTML for the calltree\n calltree_html_string = \"
\"\n calltree_html_string += \"

Fuzzer calltree

\"\n nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n for i in range(len(nodes)):\n node = nodes[i]\n\n demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name)\n # We may not want to show certain functions at times, e.g. libc functions\n # in case it bloats the calltree\n # libc_funcs = { \"free\" }\n libc_funcs: Set[str] = set()\n avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0\n if avoid:\n continue\n\n # Prepare strings needed in the HTML\n color_to_be = node.cov_color\n callsite_link = node.cov_callsite_link\n link = node.cov_link\n ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx))\n\n # Only display [function] link if we have, otherwhise show no [function] text.\n if node.dst_function_source_file.replace(\" \", \"\") != \"/\":\n func_href = f\"\"\"[function]\"\"\"\n else:\n func_href = \"\"\n\n if i > 0:\n previous_node = nodes[i - 1]\n if previous_node.depth == node.depth:\n calltree_html_string += \"
\"\n depth_diff = previous_node.depth - node.depth\n if depth_diff >= 1:\n closing_divs = \"\" # To close \"calltree-line-wrapper\"\n closing_divs = \"\" * (int(depth_diff) + 1)\n calltree_html_string += closing_divs\n\n calltree_html_string += f\"\"\"\n
\n \n {node.depth}\n \n {demangled_name}\n \n \n {func_href}\n \n [call site2]\n \n [calltree idx: {ct_idx_str}]\n \n \n \"\"\"\n if i != len(nodes) - 1:\n next_node = nodes[i + 1]\n if next_node.depth > node.depth:\n calltree_html_string += f\"\"\"\"\"\"\n elif next_node.depth < node.depth:\n depth_diff = int(node.depth - next_node.depth)\n calltree_html_string += \"
\" * depth_diff\n\n calltree_html_string += \"\"\n logger.info(\"Calltree created\")\n\n # Write the HTML to a file called calltree_view_XX.html where XX is a counter.\n calltree_file_idx = 0\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n while os.path.isfile(calltree_html_file):\n calltree_file_idx += 1\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n\n self.html_create_dedicated_calltree_file(\n calltree_html_string,\n calltree_html_file,\n profile,\n )\n return calltree_html_file\n\n def html_create_dedicated_calltree_file(\n self,\n calltree_html_string,\n filename,\n profile: fuzz_data_loader.FuzzerProfile):\n \"\"\"\n Write a wrapped HTML file with the tags needed from fuzz-introspector\n We use this only for wrapping calltrees at the moment, however, down\n the line it makes sense to have an easy wrapper for other HTML pages too.\n \"\"\"\n complete_html_string = \"\"\n\n # HTML start\n html_header = fuzz_html_helpers.html_get_header(\n calltree=True,\n title=f\"Fuzz introspector: { profile.get_key() }\"\n )\n html_header += '
'\n complete_html_string += html_header\n\n # Display fuzz blocker at top of page\n fuzz_blockers = self.get_fuzz_blockers(\n profile,\n max_blockers_to_extract=12\n )\n\n fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], \"\", fuzz_blockers)\n if fuzz_blocker_table is not None:\n complete_html_string += \"
\"\n complete_html_string += \"

Fuzz blockers

\"\n complete_html_string += fuzz_blocker_table\n complete_html_string += \"
\"\n\n # Display calltree\n complete_html_string += calltree_html_string\n complete_html_string += \"
\"\n\n # HTML end\n html_end = ''\n blocker_idxs = []\n for node in fuzz_blockers:\n blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx)))\n\n if len(blocker_idxs) > 0:\n html_end = \"\"\n\n html_end += \"\"\n html_end += \"\"\n html_end += \"\"\n complete_html_string += html_end\n\n complete_html_string += \"\"\n\n # Beautify and write HTML\n soup = bs(complete_html_string, 'lxml')\n pretty_html = soup.prettify()\n with open(filename, \"w+\") as cf:\n cf.write(pretty_html)\n\n def create_str_node_ctx_idx(self, cov_ct_idx):\n prefixed_zeros = \"0\" * (len(\"00000\") - len(cov_ct_idx))\n return f\"{prefixed_zeros}{cov_ct_idx}\"\n\n def get_fuzz_blockers(\n self,\n profile: fuzz_data_loader.FuzzerProfile,\n max_blockers_to_extract=999):\n \"\"\"Gets a list of fuzz blockers\"\"\"\n blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list()\n\n # Extract all callsites in calltree and exit early if none\n all_callsites = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n if len(all_callsites) == 0:\n return blocker_list\n\n # Filter nodes that has forward reds. Extract maximum max_blockers_to_extract nodes.\n nodes_sorted_by_red_ahead = sorted(all_callsites,\n key=lambda x: x.cov_forward_reds,\n reverse=True)\n for node in nodes_sorted_by_red_ahead:\n if node.cov_forward_reds == 0 or len(blocker_list) >= max_blockers_to_extract:\n break\n blocker_list.append(node)\n return blocker_list\n\n def create_fuzz_blocker_table(\n self,\n profile: fuzz_data_loader.FuzzerProfile,\n tables: List[str],\n calltree_file_name: str,\n fuzz_blockers=None) -> Optional[str]:\n \"\"\"\n Creates HTML string for table showing fuzz blockers.\n \"\"\"\n logger.info(\"Creating fuzz blocker table\")\n\n # Get the fuzz blockers\n if fuzz_blockers is None:\n fuzz_blockers = self.get_fuzz_blockers(\n profile,\n max_blockers_to_extract=12\n )\n if len(fuzz_blockers) == 0:\n return None\n\n html_table_string = \"

The followings nodes \" \\\n \"represent call sites where fuzz blockers occur

\"\n tables.append(f\"myTable{len(tables)}\")\n html_table_string += fuzz_html_helpers.html_create_table_head(\n tables[-1],\n [\n (\"Amount of callsites blocked\",\n \"Total amount of callsites blocked\"),\n (\"Calltree index\",\n \"Index in call tree where the fuzz blocker is.\"),\n (\"Parent function\",\n \"Function in which the call site that blocks resides.\"),\n (\"Callsite\",\n \"\"),\n (\"Largest blocked function\",\n \"This is the function with highest cyclomatiic complexity amongst\"\n \"all of the functions that are blocked. As such, it's a way of \"\n \"highlighting a potentially important function being blocked\")\n ],\n sort_by_column=0,\n sort_order=\"desc\"\n )\n for node in fuzz_blockers:\n link_prefix = \"0\" * (5 - len(str(node.cov_ct_idx)))\n node_link = \"%s?scrollToNode=%s%s\" % (\n calltree_file_name,\n link_prefix,\n node.cov_ct_idx\n )\n html_table_string += fuzz_html_helpers.html_table_add_row([\n str(node.cov_forward_reds),\n str(node.cov_ct_idx),\n node."}}},{"rowIdx":38,"cells":{"idx":{"kind":"number","value":49,"string":"49"},"idx_lca":{"kind":"number","value":0,"string":"0"},"offset":{"kind":"number","value":10864,"string":"10,864"},"repo":{"kind":"string","value":"ossf__fuzz-introspector"},"commit_hash":{"kind":"string","value":"4867924b714a7789f94fbcde53713a29ceab7272"},"target_file":{"kind":"string","value":"post-processing/analyses/fuzz_calltree_analysis.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"cov_largest_blocked_func"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":18,"string":"18"},"non_dunder_count_jedi":{"kind":"number","value":17,"string":"17"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["cov_ct_idx","depth","cov_parent","cov_link","cov_forward_reds","children","cov_callsite_link","cov_color","cov_hitcount","cov_largest_blocked_func","dst_function_name","dst_function_source_file","hitcount","parent_calltree_callsite","src_function_name","src_function_source_file","src_linenumber","for","__init__","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"cov_ct_idx\",\n \"depth\",\n \"cov_parent\",\n \"cov_link\",\n \"cov_forward_reds\",\n \"children\",\n \"cov_callsite_link\",\n \"cov_color\",\n \"cov_hitcount\",\n \"cov_largest_blocked_func\",\n \"dst_function_name\",\n \"dst_function_source_file\",\n \"hitcount\",\n \"parent_calltree_callsite\",\n \"src_function_name\",\n \"src_function_source_file\",\n \"src_linenumber\",\n \"for\",\n \"__init__\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"children","type":"statement"},{"name":"cov_callsite_link","type":"statement"},{"name":"cov_color","type":"statement"},{"name":"cov_ct_idx","type":"statement"},{"name":"cov_forward_reds","type":"statement"},{"name":"cov_hitcount","type":"statement"},{"name":"cov_largest_blocked_func","type":"statement"},{"name":"cov_link","type":"statement"},{"name":"cov_parent","type":"statement"},{"name":"depth","type":"statement"},{"name":"dst_function_name","type":"statement"},{"name":"dst_function_source_file","type":"statement"},{"name":"hitcount","type":"statement"},{"name":"parent_calltree_callsite","type":"statement"},{"name":"src_function_name","type":"statement"},{"name":"src_function_source_file","type":"statement"},{"name":"src_linenumber","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"children\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_callsite_link\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_color\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_ct_idx\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_forward_reds\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_hitcount\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_largest_blocked_func\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_link\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"cov_parent\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"depth\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"dst_function_name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"dst_function_source_file\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hitcount\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"parent_calltree_callsite\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"src_function_name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"src_function_source_file\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"src_linenumber\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"# Copyright 2022 Fuzz Introspector Authors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"Logic related to calltree analysis\"\"\"\n\nimport os\nimport logging\nimport json\n\nfrom typing import (\n List,\n Tuple,\n Optional,\n Set,\n)\n\nimport fuzz_analysis\nimport fuzz_data_loader\nimport fuzz_utils\nimport fuzz_cfg_load\nimport fuzz_html_helpers\n\n# For pretty printing the html code:\nfrom bs4 import BeautifulSoup as bs\n\nlogger = logging.getLogger(name=__name__)\n\n\nclass FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface):\n def __init__(self):\n self.name = \"FuzzCalltreeAnalysis\"\n logger.info(\"Creating FuzzCalltreeAnalysis\")\n\n def analysis_func(self,\n toc_list: List[Tuple[str, str, int]],\n tables: List[str],\n project_profile: fuzz_data_loader.MergedProjectProfile,\n profiles: List[fuzz_data_loader.FuzzerProfile],\n basefolder: str,\n coverage_url: str,\n conclusions) -> str:\n \"\"\"\n Creates the HTML of the calltree. Returns the HTML as a string.\n \"\"\"\n logger.info(\"Not implemented\")\n return \"\"\n\n def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str:\n logger.info(\"In calltree\")\n # Generate HTML for the calltree\n calltree_html_string = \"
\"\n calltree_html_string += \"

Fuzzer calltree

\"\n nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n for i in range(len(nodes)):\n node = nodes[i]\n\n demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name)\n # We may not want to show certain functions at times, e.g. libc functions\n # in case it bloats the calltree\n # libc_funcs = { \"free\" }\n libc_funcs: Set[str] = set()\n avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0\n if avoid:\n continue\n\n # Prepare strings needed in the HTML\n color_to_be = node.cov_color\n callsite_link = node.cov_callsite_link\n link = node.cov_link\n ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx))\n\n # Only display [function] link if we have, otherwhise show no [function] text.\n if node.dst_function_source_file.replace(\" \", \"\") != \"/\":\n func_href = f\"\"\"[function]\"\"\"\n else:\n func_href = \"\"\n\n if i > 0:\n previous_node = nodes[i - 1]\n if previous_node.depth == node.depth:\n calltree_html_string += \"
\"\n depth_diff = previous_node.depth - node.depth\n if depth_diff >= 1:\n closing_divs = \"\" # To close \"calltree-line-wrapper\"\n closing_divs = \"\" * (int(depth_diff) + 1)\n calltree_html_string += closing_divs\n\n calltree_html_string += f\"\"\"\n
\n \n {node.depth}\n \n {demangled_name}\n \n \n {func_href}\n \n [call site2]\n \n [calltree idx: {ct_idx_str}]\n \n \n \"\"\"\n if i != len(nodes) - 1:\n next_node = nodes[i + 1]\n if next_node.depth > node.depth:\n calltree_html_string += f\"\"\"\"\"\"\n elif next_node.depth < node.depth:\n depth_diff = int(node.depth - next_node.depth)\n calltree_html_string += \"
\" * depth_diff\n\n calltree_html_string += \"\"\n logger.info(\"Calltree created\")\n\n # Write the HTML to a file called calltree_view_XX.html where XX is a counter.\n calltree_file_idx = 0\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n while os.path.isfile(calltree_html_file):\n calltree_file_idx += 1\n calltree_html_file = f\"calltree_view_{calltree_file_idx}.html\"\n\n self.html_create_dedicated_calltree_file(\n calltree_html_string,\n calltree_html_file,\n profile,\n )\n return calltree_html_file\n\n def html_create_dedicated_calltree_file(\n self,\n calltree_html_string,\n filename,\n profile: fuzz_data_loader.FuzzerProfile):\n \"\"\"\n Write a wrapped HTML file with the tags needed from fuzz-introspector\n We use this only for wrapping calltrees at the moment, however, down\n the line it makes sense to have an easy wrapper for other HTML pages too.\n \"\"\"\n complete_html_string = \"\"\n\n # HTML start\n html_header = fuzz_html_helpers.html_get_header(\n calltree=True,\n title=f\"Fuzz introspector: { profile.get_key() }\"\n )\n html_header += '
'\n complete_html_string += html_header\n\n # Display fuzz blocker at top of page\n fuzz_blockers = self.get_fuzz_blockers(\n profile,\n max_blockers_to_extract=12\n )\n\n fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], \"\", fuzz_blockers)\n if fuzz_blocker_table is not None:\n complete_html_string += \"
\"\n complete_html_string += \"

Fuzz blockers

\"\n complete_html_string += fuzz_blocker_table\n complete_html_string += \"
\"\n\n # Display calltree\n complete_html_string += calltree_html_string\n complete_html_string += \"
\"\n\n # HTML end\n html_end = ''\n blocker_idxs = []\n for node in fuzz_blockers:\n blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx)))\n\n if len(blocker_idxs) > 0:\n html_end = \"\"\n\n html_end += \"\"\n html_end += \"\"\n html_end += \"\"\n complete_html_string += html_end\n\n complete_html_string += \"\"\n\n # Beautify and write HTML\n soup = bs(complete_html_string, 'lxml')\n pretty_html = soup.prettify()\n with open(filename, \"w+\") as cf:\n cf.write(pretty_html)\n\n def create_str_node_ctx_idx(self, cov_ct_idx):\n prefixed_zeros = \"0\" * (len(\"00000\") - len(cov_ct_idx))\n return f\"{prefixed_zeros}{cov_ct_idx}\"\n\n def get_fuzz_blockers(\n self,\n profile: fuzz_data_loader.FuzzerProfile,\n max_blockers_to_extract=999):\n \"\"\"Gets a list of fuzz blockers\"\"\"\n blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list()\n\n # Extract all callsites in calltree and exit early if none\n all_callsites = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths)\n if len(all_callsites) == 0:\n return blocker_list\n\n # Filter nodes that has forward reds. Extract maximum max_blockers_to_extract nodes.\n nodes_sorted_by_red_ahead = sorted(all_callsites,\n key=lambda x: x.cov_forward_reds,\n reverse=True)\n for node in nodes_sorted_by_red_ahead:\n if node.cov_forward_reds == 0 or len(blocker_list) >= max_blockers_to_extract:\n break\n blocker_list.append(node)\n return blocker_list\n\n def create_fuzz_blocker_table(\n self,\n profile: fuzz_data_loader.FuzzerProfile,\n tables: List[str],\n calltree_file_name: str,\n fuzz_blockers=None) -> Optional[str]:\n \"\"\"\n Creates HTML string for table showing fuzz blockers.\n \"\"\"\n logger.info(\"Creating fuzz blocker table\")\n\n # Get the fuzz blockers\n if fuzz_blockers is None:\n fuzz_blockers = self.get_fuzz_blockers(\n profile,\n max_blockers_to_extract=12\n )\n if len(fuzz_blockers) == 0:\n return None\n\n html_table_string = \"

The followings nodes \" \\\n \"represent call sites where fuzz blockers occur

\"\n tables.append(f\"myTable{len(tables)}\")\n html_table_string += fuzz_html_helpers.html_create_table_head(\n tables[-1],\n [\n (\"Amount of callsites blocked\",\n \"Total amount of callsites blocked\"),\n (\"Calltree index\",\n \"Index in call tree where the fuzz blocker is.\"),\n (\"Parent function\",\n \"Function in which the call site that blocks resides.\"),\n (\"Callsite\",\n \"\"),\n (\"Largest blocked function\",\n \"This is the function with highest cyclomatiic complexity amongst\"\n \"all of the functions that are blocked. As such, it's a way of \"\n \"highlighting a potentially important function being blocked\")\n ],\n sort_by_column=0,\n sort_order=\"desc\"\n )\n for node in fuzz_blockers:\n link_prefix = \"0\" * (5 - len(str(node.cov_ct_idx)))\n node_link = \"%s?scrollToNode=%s%s\" % (\n calltree_file_name,\n link_prefix,\n node.cov_ct_idx\n )\n html_table_string += fuzz_html_helpers.html_table_add_row([\n str(node.cov_forward_reds),\n str(node.cov_ct_idx),\n node.cov_parent,\n f\"call site\",\n node."}}},{"rowIdx":39,"cells":{"idx":{"kind":"number","value":58,"string":"58"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":3201,"string":"3,201"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"edges"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["edges","nodes","name","type","edge_style","__init__","_get_node_id","_order_edges","color_node","graph_style","hide_node","label2id","node_style","remove_edge","remove_node","transitive_reduction","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"edges\",\n \"nodes\",\n \"name\",\n \"type\",\n \"edge_style\",\n \"__init__\",\n \"_get_node_id\",\n \"_order_edges\",\n \"color_node\",\n \"graph_style\",\n \"hide_node\",\n \"label2id\",\n \"node_style\",\n \"remove_edge\",\n \"remove_node\",\n \"transitive_reduction\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self."}}},{"rowIdx":40,"cells":{"idx":{"kind":"number","value":59,"string":"59"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":3496,"string":"3,496"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"nodes"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["nodes","edges","edge_style","node_style","graph_style","__init__","_get_node_id","_order_edges","color_node","hide_node","label2id","name","remove_edge","remove_node","transitive_reduction","type","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"nodes\",\n \"edges\",\n \"edge_style\",\n \"node_style\",\n \"graph_style\",\n \"__init__\",\n \"_get_node_id\",\n \"_order_edges\",\n \"color_node\",\n \"hide_node\",\n \"label2id\",\n \"name\",\n \"remove_edge\",\n \"remove_node\",\n \"transitive_reduction\",\n \"type\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self."}}},{"rowIdx":41,"cells":{"idx":{"kind":"number","value":60,"string":"60"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":3662,"string":"3,662"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"label2id"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["edges","nodes","name","type","label2id","__init__","_get_node_id","_order_edges","color_node","edge_style","graph_style","hide_node","node_style","remove_edge","remove_node","transitive_reduction","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"edges\",\n \"nodes\",\n \"name\",\n \"type\",\n \"label2id\",\n \"__init__\",\n \"_get_node_id\",\n \"_order_edges\",\n \"color_node\",\n \"edge_style\",\n \"graph_style\",\n \"hide_node\",\n \"node_style\",\n \"remove_edge\",\n \"remove_node\",\n \"transitive_reduction\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self."}}},{"rowIdx":42,"cells":{"idx":{"kind":"number","value":61,"string":"61"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":3921,"string":"3,921"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"edges"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["edges","edge_style","node_style","graph_style","nodes","__init__","_get_node_id","_order_edges","color_node","hide_node","label2id","name","remove_edge","remove_node","transitive_reduction","type","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"edges\",\n \"edge_style\",\n \"node_style\",\n \"graph_style\",\n \"nodes\",\n \"__init__\",\n \"_get_node_id\",\n \"_order_edges\",\n \"color_node\",\n \"hide_node\",\n \"label2id\",\n \"name\",\n \"remove_edge\",\n \"remove_node\",\n \"transitive_reduction\",\n \"type\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self."}}},{"rowIdx":43,"cells":{"idx":{"kind":"number","value":62,"string":"62"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":4002,"string":"4,002"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"edges"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["edges","edge_style","node_style","graph_style","nodes","__init__","_get_node_id","_order_edges","color_node","hide_node","label2id","name","remove_edge","remove_node","transitive_reduction","type","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"edges\",\n \"edge_style\",\n \"node_style\",\n \"graph_style\",\n \"nodes\",\n \"__init__\",\n \"_get_node_id\",\n \"_order_edges\",\n \"color_node\",\n \"hide_node\",\n \"label2id\",\n \"name\",\n \"remove_edge\",\n \"remove_node\",\n \"transitive_reduction\",\n \"type\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True)\n targets = sorted(set(int(e[1]) for e in list(self."}}},{"rowIdx":44,"cells":{"idx":{"kind":"number","value":63,"string":"63"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":4159,"string":"4,159"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"edges"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["edges","edge_style","nodes","label2id","_order_edges","__init__","_get_node_id","color_node","graph_style","hide_node","name","node_style","remove_edge","remove_node","transitive_reduction","type","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"edges\",\n \"edge_style\",\n \"nodes\",\n \"label2id\",\n \"_order_edges\",\n \"__init__\",\n \"_get_node_id\",\n \"color_node\",\n \"graph_style\",\n \"hide_node\",\n \"name\",\n \"node_style\",\n \"remove_edge\",\n \"remove_node\",\n \"transitive_reduction\",\n \"type\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True)\n targets = sorted(set(int(e[1]) for e in list(self.edges)))\n for target in targets:\n for source in sources:\n edge = (str(source), str(target))\n if edge in self."}}},{"rowIdx":45,"cells":{"idx":{"kind":"number","value":64,"string":"64"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":4330,"string":"4,330"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"infile"},"ground_truth":{"kind":"string","value":"type"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":17,"string":"17"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["edges","nodes","label2id","name","type","__init__","_get_node_id","_order_edges","color_node","edge_style","graph_style","hide_node","node_style","remove_edge","remove_node","transitive_reduction","write","for","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"edges\",\n \"nodes\",\n \"label2id\",\n \"name\",\n \"type\",\n \"__init__\",\n \"_get_node_id\",\n \"_order_edges\",\n \"color_node\",\n \"edge_style\",\n \"graph_style\",\n \"hide_node\",\n \"node_style\",\n \"remove_edge\",\n \"remove_node\",\n \"transitive_reduction\",\n \"write\",\n \"for\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True)\n targets = sorted(set(int(e[1]) for e in list(self.edges)))\n for target in targets:\n for source in sources:\n edge = (str(source), str(target))\n if edge in self.edges:\n ordered.append(edge)\n return ordered\n\n def write(self, fname):\n with open(fname, \"w\") as f:\n f.write(\" \".join([self."}}},{"rowIdx":46,"cells":{"idx":{"kind":"number","value":65,"string":"65"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":4341,"string":"4,341"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"infile"},"ground_truth":{"kind":"string","value":"name"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":17,"string":"17"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["name","type","edges","nodes","label2id","__init__","_get_node_id","_order_edges","color_node","edge_style","graph_style","hide_node","node_style","remove_edge","remove_node","transitive_reduction","write","for","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"name\",\n \"type\",\n \"edges\",\n \"nodes\",\n \"label2id\",\n \"__init__\",\n \"_get_node_id\",\n \"_order_edges\",\n \"color_node\",\n \"edge_style\",\n \"graph_style\",\n \"hide_node\",\n \"node_style\",\n \"remove_edge\",\n \"remove_node\",\n \"transitive_reduction\",\n \"write\",\n \"for\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True)\n targets = sorted(set(int(e[1]) for e in list(self.edges)))\n for target in targets:\n for source in sources:\n edge = (str(source), str(target))\n if edge in self.edges:\n ordered.append(edge)\n return ordered\n\n def write(self, fname):\n with open(fname, \"w\") as f:\n f.write(\" \".join([self.type, self."}}},{"rowIdx":47,"cells":{"idx":{"kind":"number","value":66,"string":"66"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":4381,"string":"4,381"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"infile"},"ground_truth":{"kind":"string","value":"graph_style"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["edges","nodes","label2id","edge_style","node_style","__init__","_get_node_id","_order_edges","color_node","graph_style","hide_node","name","remove_edge","remove_node","transitive_reduction","type","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"edges\",\n \"nodes\",\n \"label2id\",\n \"edge_style\",\n \"node_style\",\n \"__init__\",\n \"_get_node_id\",\n \"_order_edges\",\n \"color_node\",\n \"graph_style\",\n \"hide_node\",\n \"name\",\n \"remove_edge\",\n \"remove_node\",\n \"transitive_reduction\",\n \"type\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True)\n targets = sorted(set(int(e[1]) for e in list(self.edges)))\n for target in targets:\n for source in sources:\n edge = (str(source), str(target))\n if edge in self.edges:\n ordered.append(edge)\n return ordered\n\n def write(self, fname):\n with open(fname, \"w\") as f:\n f.write(\" \".join([self.type, self.name, \"{\\n\"]))\n f.write(self."}}},{"rowIdx":48,"cells":{"idx":{"kind":"number","value":67,"string":"67"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":4419,"string":"4,419"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"infile"},"ground_truth":{"kind":"string","value":"node_style"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["edges","nodes","label2id","edge_style","graph_style","__init__","_get_node_id","_order_edges","color_node","hide_node","name","node_style","remove_edge","remove_node","transitive_reduction","type","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"edges\",\n \"nodes\",\n \"label2id\",\n \"edge_style\",\n \"graph_style\",\n \"__init__\",\n \"_get_node_id\",\n \"_order_edges\",\n \"color_node\",\n \"hide_node\",\n \"name\",\n \"node_style\",\n \"remove_edge\",\n \"remove_node\",\n \"transitive_reduction\",\n \"type\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True)\n targets = sorted(set(int(e[1]) for e in list(self.edges)))\n for target in targets:\n for source in sources:\n edge = (str(source), str(target))\n if edge in self.edges:\n ordered.append(edge)\n return ordered\n\n def write(self, fname):\n with open(fname, \"w\") as f:\n f.write(\" \".join([self.type, self.name, \"{\\n\"]))\n f.write(self.graph_style)\n f.write(self."}}},{"rowIdx":49,"cells":{"idx":{"kind":"number","value":68,"string":"68"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":4456,"string":"4,456"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"infile"},"ground_truth":{"kind":"string","value":"edge_style"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["edges","nodes","label2id","node_style","graph_style","__init__","_get_node_id","_order_edges","color_node","edge_style","hide_node","name","remove_edge","remove_node","transitive_reduction","type","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"edges\",\n \"nodes\",\n \"label2id\",\n \"node_style\",\n \"graph_style\",\n \"__init__\",\n \"_get_node_id\",\n \"_order_edges\",\n \"color_node\",\n \"edge_style\",\n \"hide_node\",\n \"name\",\n \"remove_edge\",\n \"remove_node\",\n \"transitive_reduction\",\n \"type\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True)\n targets = sorted(set(int(e[1]) for e in list(self.edges)))\n for target in targets:\n for source in sources:\n edge = (str(source), str(target))\n if edge in self.edges:\n ordered.append(edge)\n return ordered\n\n def write(self, fname):\n with open(fname, \"w\") as f:\n f.write(\" \".join([self.type, self.name, \"{\\n\"]))\n f.write(self.graph_style)\n f.write(self.node_style)\n f.write(self."}}},{"rowIdx":50,"cells":{"idx":{"kind":"number","value":69,"string":"69"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":4497,"string":"4,497"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"nodes"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["edges","nodes","name","type","label2id","__init__","_get_node_id","_order_edges","color_node","edge_style","graph_style","hide_node","node_style","remove_edge","remove_node","transitive_reduction","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"edges\",\n \"nodes\",\n \"name\",\n \"type\",\n \"label2id\",\n \"__init__\",\n \"_get_node_id\",\n \"_order_edges\",\n \"color_node\",\n \"edge_style\",\n \"graph_style\",\n \"hide_node\",\n \"node_style\",\n \"remove_edge\",\n \"remove_node\",\n \"transitive_reduction\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True)\n targets = sorted(set(int(e[1]) for e in list(self.edges)))\n for target in targets:\n for source in sources:\n edge = (str(source), str(target))\n if edge in self.edges:\n ordered.append(edge)\n return ordered\n\n def write(self, fname):\n with open(fname, \"w\") as f:\n f.write(\" \".join([self.type, self.name, \"{\\n\"]))\n f.write(self.graph_style)\n f.write(self.node_style)\n f.write(self.edge_style)\n for k, v in self."}}},{"rowIdx":51,"cells":{"idx":{"kind":"number","value":70,"string":"70"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":4744,"string":"4,744"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"infile"},"ground_truth":{"kind":"string","value":"_order_edges"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"function"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":true,"string":"true"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["edges","nodes","label2id","name","type","__init__","_get_node_id","_order_edges","color_node","edge_style","graph_style","hide_node","node_style","remove_edge","remove_node","transitive_reduction","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"edges\",\n \"nodes\",\n \"label2id\",\n \"name\",\n \"type\",\n \"__init__\",\n \"_get_node_id\",\n \"_order_edges\",\n \"color_node\",\n \"edge_style\",\n \"graph_style\",\n \"hide_node\",\n \"node_style\",\n \"remove_edge\",\n \"remove_node\",\n \"transitive_reduction\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True)\n targets = sorted(set(int(e[1]) for e in list(self.edges)))\n for target in targets:\n for source in sources:\n edge = (str(source), str(target))\n if edge in self.edges:\n ordered.append(edge)\n return ordered\n\n def write(self, fname):\n with open(fname, \"w\") as f:\n f.write(\" \".join([self.type, self.name, \"{\\n\"]))\n f.write(self.graph_style)\n f.write(self.node_style)\n f.write(self.edge_style)\n for k, v in self.nodes.items():\n l = v[\"label\"]\n c = v[\"color\"]\n s = v[\"style\"]\n line = f' {k}[label = \"{l}\", color = \"{c}\", style=\"{s}\"];\\n'\n f.write(line)\n for a, b in self."}}},{"rowIdx":52,"cells":{"idx":{"kind":"number","value":71,"string":"71"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":4963,"string":"4,963"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"nodes"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["nodes","node_style","edges","remove_node","_get_node_id","__init__","_order_edges","color_node","edge_style","graph_style","hide_node","label2id","name","remove_edge","transitive_reduction","type","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"nodes\",\n \"node_style\",\n \"edges\",\n \"remove_node\",\n \"_get_node_id\",\n \"__init__\",\n \"_order_edges\",\n \"color_node\",\n \"edge_style\",\n \"graph_style\",\n \"hide_node\",\n \"label2id\",\n \"name\",\n \"remove_edge\",\n \"transitive_reduction\",\n \"type\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True)\n targets = sorted(set(int(e[1]) for e in list(self.edges)))\n for target in targets:\n for source in sources:\n edge = (str(source), str(target))\n if edge in self.edges:\n ordered.append(edge)\n return ordered\n\n def write(self, fname):\n with open(fname, \"w\") as f:\n f.write(\" \".join([self.type, self.name, \"{\\n\"]))\n f.write(self.graph_style)\n f.write(self.node_style)\n f.write(self.edge_style)\n for k, v in self.nodes.items():\n l = v[\"label\"]\n c = v[\"color\"]\n s = v[\"style\"]\n line = f' {k}[label = \"{l}\", color = \"{c}\", style=\"{s}\"];\\n'\n f.write(line)\n for a, b in self._order_edges():\n line = f\" {a} -> {b}\\n\"\n f.write(line)\n f.write(\"}\\n\")\n\n def _get_node_id(self, node):\n node = str(node)\n if node.isdigit() and node in self."}}},{"rowIdx":53,"cells":{"idx":{"kind":"number","value":72,"string":"72"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":5014,"string":"5,014"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"common"},"ground_truth":{"kind":"string","value":"label2id"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["nodes","edges","node_style","name","type","__init__","_get_node_id","_order_edges","color_node","edge_style","graph_style","hide_node","label2id","remove_edge","remove_node","transitive_reduction","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"nodes\",\n \"edges\",\n \"node_style\",\n \"name\",\n \"type\",\n \"__init__\",\n \"_get_node_id\",\n \"_order_edges\",\n \"color_node\",\n \"edge_style\",\n \"graph_style\",\n \"hide_node\",\n \"label2id\",\n \"remove_edge\",\n \"remove_node\",\n \"transitive_reduction\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True)\n targets = sorted(set(int(e[1]) for e in list(self.edges)))\n for target in targets:\n for source in sources:\n edge = (str(source), str(target))\n if edge in self.edges:\n ordered.append(edge)\n return ordered\n\n def write(self, fname):\n with open(fname, \"w\") as f:\n f.write(\" \".join([self.type, self.name, \"{\\n\"]))\n f.write(self.graph_style)\n f.write(self.node_style)\n f.write(self.edge_style)\n for k, v in self.nodes.items():\n l = v[\"label\"]\n c = v[\"color\"]\n s = v[\"style\"]\n line = f' {k}[label = \"{l}\", color = \"{c}\", style=\"{s}\"];\\n'\n f.write(line)\n for a, b in self._order_edges():\n line = f\" {a} -> {b}\\n\"\n f.write(line)\n f.write(\"}\\n\")\n\n def _get_node_id(self, node):\n node = str(node)\n if node.isdigit() and node in self.nodes:\n return node\n return self."}}},{"rowIdx":54,"cells":{"idx":{"kind":"number","value":73,"string":"73"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":5096,"string":"5,096"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"_get_node_id"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"function"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":true,"string":"true"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["_get_node_id","nodes","node_style","remove_node","edges","__init__","_order_edges","color_node","edge_style","graph_style","hide_node","label2id","name","remove_edge","transitive_reduction","type","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"_get_node_id\",\n \"nodes\",\n \"node_style\",\n \"remove_node\",\n \"edges\",\n \"__init__\",\n \"_order_edges\",\n \"color_node\",\n \"edge_style\",\n \"graph_style\",\n \"hide_node\",\n \"label2id\",\n \"name\",\n \"remove_edge\",\n \"transitive_reduction\",\n \"type\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True)\n targets = sorted(set(int(e[1]) for e in list(self.edges)))\n for target in targets:\n for source in sources:\n edge = (str(source), str(target))\n if edge in self.edges:\n ordered.append(edge)\n return ordered\n\n def write(self, fname):\n with open(fname, \"w\") as f:\n f.write(\" \".join([self.type, self.name, \"{\\n\"]))\n f.write(self.graph_style)\n f.write(self.node_style)\n f.write(self.edge_style)\n for k, v in self.nodes.items():\n l = v[\"label\"]\n c = v[\"color\"]\n s = v[\"style\"]\n line = f' {k}[label = \"{l}\", color = \"{c}\", style=\"{s}\"];\\n'\n f.write(line)\n for a, b in self._order_edges():\n line = f\" {a} -> {b}\\n\"\n f.write(line)\n f.write(\"}\\n\")\n\n def _get_node_id(self, node):\n node = str(node)\n if node.isdigit() and node in self.nodes:\n return node\n return self.label2id.get(node)\n\n def color_node(self, node, color):\n node_id = self."}}},{"rowIdx":55,"cells":{"idx":{"kind":"number","value":74,"string":"74"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":5176,"string":"5,176"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"nodes"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["nodes","label2id","edges","node_style","_get_node_id","__init__","_order_edges","color_node","edge_style","graph_style","hide_node","name","remove_edge","remove_node","transitive_reduction","type","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"nodes\",\n \"label2id\",\n \"edges\",\n \"node_style\",\n \"_get_node_id\",\n \"__init__\",\n \"_order_edges\",\n \"color_node\",\n \"edge_style\",\n \"graph_style\",\n \"hide_node\",\n \"name\",\n \"remove_edge\",\n \"remove_node\",\n \"transitive_reduction\",\n \"type\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True)\n targets = sorted(set(int(e[1]) for e in list(self.edges)))\n for target in targets:\n for source in sources:\n edge = (str(source), str(target))\n if edge in self.edges:\n ordered.append(edge)\n return ordered\n\n def write(self, fname):\n with open(fname, \"w\") as f:\n f.write(\" \".join([self.type, self.name, \"{\\n\"]))\n f.write(self.graph_style)\n f.write(self.node_style)\n f.write(self.edge_style)\n for k, v in self.nodes.items():\n l = v[\"label\"]\n c = v[\"color\"]\n s = v[\"style\"]\n line = f' {k}[label = \"{l}\", color = \"{c}\", style=\"{s}\"];\\n'\n f.write(line)\n for a, b in self._order_edges():\n line = f\" {a} -> {b}\\n\"\n f.write(line)\n f.write(\"}\\n\")\n\n def _get_node_id(self, node):\n node = str(node)\n if node.isdigit() and node in self.nodes:\n return node\n return self.label2id.get(node)\n\n def color_node(self, node, color):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n self."}}},{"rowIdx":56,"cells":{"idx":{"kind":"number","value":75,"string":"75"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":5265,"string":"5,265"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"infile"},"ground_truth":{"kind":"string","value":"_get_node_id"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"function"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":true,"string":"true"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["_get_node_id","nodes","node_style","edges","remove_node","__init__","_order_edges","color_node","edge_style","graph_style","hide_node","label2id","name","remove_edge","transitive_reduction","type","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"_get_node_id\",\n \"nodes\",\n \"node_style\",\n \"edges\",\n \"remove_node\",\n \"__init__\",\n \"_order_edges\",\n \"color_node\",\n \"edge_style\",\n \"graph_style\",\n \"hide_node\",\n \"label2id\",\n \"name\",\n \"remove_edge\",\n \"transitive_reduction\",\n \"type\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True)\n targets = sorted(set(int(e[1]) for e in list(self.edges)))\n for target in targets:\n for source in sources:\n edge = (str(source), str(target))\n if edge in self.edges:\n ordered.append(edge)\n return ordered\n\n def write(self, fname):\n with open(fname, \"w\") as f:\n f.write(\" \".join([self.type, self.name, \"{\\n\"]))\n f.write(self.graph_style)\n f.write(self.node_style)\n f.write(self.edge_style)\n for k, v in self.nodes.items():\n l = v[\"label\"]\n c = v[\"color\"]\n s = v[\"style\"]\n line = f' {k}[label = \"{l}\", color = \"{c}\", style=\"{s}\"];\\n'\n f.write(line)\n for a, b in self._order_edges():\n line = f\" {a} -> {b}\\n\"\n f.write(line)\n f.write(\"}\\n\")\n\n def _get_node_id(self, node):\n node = str(node)\n if node.isdigit() and node in self.nodes:\n return node\n return self.label2id.get(node)\n\n def color_node(self, node, color):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n self.nodes[node_id][\"color\"] = color\n\n def remove_node(self, node):\n node_id = self."}}},{"rowIdx":57,"cells":{"idx":{"kind":"number","value":76,"string":"76"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":5379,"string":"5,379"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"nodes"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["label2id","_get_node_id","nodes","edges","node_style","__init__","_order_edges","color_node","edge_style","graph_style","hide_node","name","remove_edge","remove_node","transitive_reduction","type","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"label2id\",\n \"_get_node_id\",\n \"nodes\",\n \"edges\",\n \"node_style\",\n \"__init__\",\n \"_order_edges\",\n \"color_node\",\n \"edge_style\",\n \"graph_style\",\n \"hide_node\",\n \"name\",\n \"remove_edge\",\n \"remove_node\",\n \"transitive_reduction\",\n \"type\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True)\n targets = sorted(set(int(e[1]) for e in list(self.edges)))\n for target in targets:\n for source in sources:\n edge = (str(source), str(target))\n if edge in self.edges:\n ordered.append(edge)\n return ordered\n\n def write(self, fname):\n with open(fname, \"w\") as f:\n f.write(\" \".join([self.type, self.name, \"{\\n\"]))\n f.write(self.graph_style)\n f.write(self.node_style)\n f.write(self.edge_style)\n for k, v in self.nodes.items():\n l = v[\"label\"]\n c = v[\"color\"]\n s = v[\"style\"]\n line = f' {k}[label = \"{l}\", color = \"{c}\", style=\"{s}\"];\\n'\n f.write(line)\n for a, b in self._order_edges():\n line = f\" {a} -> {b}\\n\"\n f.write(line)\n f.write(\"}\\n\")\n\n def _get_node_id(self, node):\n node = str(node)\n if node.isdigit() and node in self.nodes:\n return node\n return self.label2id.get(node)\n\n def color_node(self, node, color):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n self.nodes[node_id][\"color\"] = color\n\n def remove_node(self, node):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n # remove the node\n label = self."}}},{"rowIdx":58,"cells":{"idx":{"kind":"number","value":77,"string":"77"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":5420,"string":"5,420"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"nodes"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["nodes","label2id","edges","node_style","_get_node_id","__init__","_order_edges","color_node","edge_style","graph_style","hide_node","name","remove_edge","remove_node","transitive_reduction","type","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"nodes\",\n \"label2id\",\n \"edges\",\n \"node_style\",\n \"_get_node_id\",\n \"__init__\",\n \"_order_edges\",\n \"color_node\",\n \"edge_style\",\n \"graph_style\",\n \"hide_node\",\n \"name\",\n \"remove_edge\",\n \"remove_node\",\n \"transitive_reduction\",\n \"type\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True)\n targets = sorted(set(int(e[1]) for e in list(self.edges)))\n for target in targets:\n for source in sources:\n edge = (str(source), str(target))\n if edge in self.edges:\n ordered.append(edge)\n return ordered\n\n def write(self, fname):\n with open(fname, \"w\") as f:\n f.write(\" \".join([self.type, self.name, \"{\\n\"]))\n f.write(self.graph_style)\n f.write(self.node_style)\n f.write(self.edge_style)\n for k, v in self.nodes.items():\n l = v[\"label\"]\n c = v[\"color\"]\n s = v[\"style\"]\n line = f' {k}[label = \"{l}\", color = \"{c}\", style=\"{s}\"];\\n'\n f.write(line)\n for a, b in self._order_edges():\n line = f\" {a} -> {b}\\n\"\n f.write(line)\n f.write(\"}\\n\")\n\n def _get_node_id(self, node):\n node = str(node)\n if node.isdigit() and node in self.nodes:\n return node\n return self.label2id.get(node)\n\n def color_node(self, node, color):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n self.nodes[node_id][\"color\"] = color\n\n def remove_node(self, node):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n # remove the node\n label = self.nodes[node_id][\"label\"]\n del self."}}},{"rowIdx":59,"cells":{"idx":{"kind":"number","value":78,"string":"78"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":5452,"string":"5,452"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"label2id"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["nodes","edges","node_style","_get_node_id","name","__init__","_order_edges","color_node","edge_style","graph_style","hide_node","label2id","remove_edge","remove_node","transitive_reduction","type","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"nodes\",\n \"edges\",\n \"node_style\",\n \"_get_node_id\",\n \"name\",\n \"__init__\",\n \"_order_edges\",\n \"color_node\",\n \"edge_style\",\n \"graph_style\",\n \"hide_node\",\n \"label2id\",\n \"remove_edge\",\n \"remove_node\",\n \"transitive_reduction\",\n \"type\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True)\n targets = sorted(set(int(e[1]) for e in list(self.edges)))\n for target in targets:\n for source in sources:\n edge = (str(source), str(target))\n if edge in self.edges:\n ordered.append(edge)\n return ordered\n\n def write(self, fname):\n with open(fname, \"w\") as f:\n f.write(\" \".join([self.type, self.name, \"{\\n\"]))\n f.write(self.graph_style)\n f.write(self.node_style)\n f.write(self.edge_style)\n for k, v in self.nodes.items():\n l = v[\"label\"]\n c = v[\"color\"]\n s = v[\"style\"]\n line = f' {k}[label = \"{l}\", color = \"{c}\", style=\"{s}\"];\\n'\n f.write(line)\n for a, b in self._order_edges():\n line = f\" {a} -> {b}\\n\"\n f.write(line)\n f.write(\"}\\n\")\n\n def _get_node_id(self, node):\n node = str(node)\n if node.isdigit() and node in self.nodes:\n return node\n return self.label2id.get(node)\n\n def color_node(self, node, color):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n self.nodes[node_id][\"color\"] = color\n\n def remove_node(self, node):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n # remove the node\n label = self.nodes[node_id][\"label\"]\n del self.nodes[node_id]\n del self."}}},{"rowIdx":60,"cells":{"idx":{"kind":"number","value":79,"string":"79"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":5535,"string":"5,535"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"edges"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["edges","edge_style","nodes","remove_edge","node_style","__init__","_get_node_id","_order_edges","color_node","graph_style","hide_node","label2id","name","remove_node","transitive_reduction","type","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"edges\",\n \"edge_style\",\n \"nodes\",\n \"remove_edge\",\n \"node_style\",\n \"__init__\",\n \"_get_node_id\",\n \"_order_edges\",\n \"color_node\",\n \"graph_style\",\n \"hide_node\",\n \"label2id\",\n \"name\",\n \"remove_node\",\n \"transitive_reduction\",\n \"type\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True)\n targets = sorted(set(int(e[1]) for e in list(self.edges)))\n for target in targets:\n for source in sources:\n edge = (str(source), str(target))\n if edge in self.edges:\n ordered.append(edge)\n return ordered\n\n def write(self, fname):\n with open(fname, \"w\") as f:\n f.write(\" \".join([self.type, self.name, \"{\\n\"]))\n f.write(self.graph_style)\n f.write(self.node_style)\n f.write(self.edge_style)\n for k, v in self.nodes.items():\n l = v[\"label\"]\n c = v[\"color\"]\n s = v[\"style\"]\n line = f' {k}[label = \"{l}\", color = \"{c}\", style=\"{s}\"];\\n'\n f.write(line)\n for a, b in self._order_edges():\n line = f\" {a} -> {b}\\n\"\n f.write(line)\n f.write(\"}\\n\")\n\n def _get_node_id(self, node):\n node = str(node)\n if node.isdigit() and node in self.nodes:\n return node\n return self.label2id.get(node)\n\n def color_node(self, node, color):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n self.nodes[node_id][\"color\"] = color\n\n def remove_node(self, node):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n # remove the node\n label = self.nodes[node_id][\"label\"]\n del self.nodes[node_id]\n del self.label2id[label]\n # remove all edges with this node\n for edge in self."}}},{"rowIdx":61,"cells":{"idx":{"kind":"number","value":80,"string":"80"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":5602,"string":"5,602"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"edges"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["nodes","edges","node_style","name","type","__init__","_get_node_id","_order_edges","color_node","edge_style","graph_style","hide_node","label2id","remove_edge","remove_node","transitive_reduction","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"nodes\",\n \"edges\",\n \"node_style\",\n \"name\",\n \"type\",\n \"__init__\",\n \"_get_node_id\",\n \"_order_edges\",\n \"color_node\",\n \"edge_style\",\n \"graph_style\",\n \"hide_node\",\n \"label2id\",\n \"remove_edge\",\n \"remove_node\",\n \"transitive_reduction\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True)\n targets = sorted(set(int(e[1]) for e in list(self.edges)))\n for target in targets:\n for source in sources:\n edge = (str(source), str(target))\n if edge in self.edges:\n ordered.append(edge)\n return ordered\n\n def write(self, fname):\n with open(fname, \"w\") as f:\n f.write(\" \".join([self.type, self.name, \"{\\n\"]))\n f.write(self.graph_style)\n f.write(self.node_style)\n f.write(self.edge_style)\n for k, v in self.nodes.items():\n l = v[\"label\"]\n c = v[\"color\"]\n s = v[\"style\"]\n line = f' {k}[label = \"{l}\", color = \"{c}\", style=\"{s}\"];\\n'\n f.write(line)\n for a, b in self._order_edges():\n line = f\" {a} -> {b}\\n\"\n f.write(line)\n f.write(\"}\\n\")\n\n def _get_node_id(self, node):\n node = str(node)\n if node.isdigit() and node in self.nodes:\n return node\n return self.label2id.get(node)\n\n def color_node(self, node, color):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n self.nodes[node_id][\"color\"] = color\n\n def remove_node(self, node):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n # remove the node\n label = self.nodes[node_id][\"label\"]\n del self.nodes[node_id]\n del self.label2id[label]\n # remove all edges with this node\n for edge in self.edges.copy():\n if node_id in edge:\n self."}}},{"rowIdx":62,"cells":{"idx":{"kind":"number","value":81,"string":"81"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":5690,"string":"5,690"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"infile"},"ground_truth":{"kind":"string","value":"_get_node_id"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"function"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":true,"string":"true"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["edges","_get_node_id","nodes","edge_style","label2id","__init__","_order_edges","color_node","graph_style","hide_node","name","node_style","remove_edge","remove_node","transitive_reduction","type","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"edges\",\n \"_get_node_id\",\n \"nodes\",\n \"edge_style\",\n \"label2id\",\n \"__init__\",\n \"_order_edges\",\n \"color_node\",\n \"graph_style\",\n \"hide_node\",\n \"name\",\n \"node_style\",\n \"remove_edge\",\n \"remove_node\",\n \"transitive_reduction\",\n \"type\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True)\n targets = sorted(set(int(e[1]) for e in list(self.edges)))\n for target in targets:\n for source in sources:\n edge = (str(source), str(target))\n if edge in self.edges:\n ordered.append(edge)\n return ordered\n\n def write(self, fname):\n with open(fname, \"w\") as f:\n f.write(\" \".join([self.type, self.name, \"{\\n\"]))\n f.write(self.graph_style)\n f.write(self.node_style)\n f.write(self.edge_style)\n for k, v in self.nodes.items():\n l = v[\"label\"]\n c = v[\"color\"]\n s = v[\"style\"]\n line = f' {k}[label = \"{l}\", color = \"{c}\", style=\"{s}\"];\\n'\n f.write(line)\n for a, b in self._order_edges():\n line = f\" {a} -> {b}\\n\"\n f.write(line)\n f.write(\"}\\n\")\n\n def _get_node_id(self, node):\n node = str(node)\n if node.isdigit() and node in self.nodes:\n return node\n return self.label2id.get(node)\n\n def color_node(self, node, color):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n self.nodes[node_id][\"color\"] = color\n\n def remove_node(self, node):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n # remove the node\n label = self.nodes[node_id][\"label\"]\n del self.nodes[node_id]\n del self.label2id[label]\n # remove all edges with this node\n for edge in self.edges.copy():\n if node_id in edge:\n self.edges.remove(edge)\n\n def remove_edge(self, source, target):\n source_id = self."}}},{"rowIdx":63,"cells":{"idx":{"kind":"number","value":82,"string":"82"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":5736,"string":"5,736"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"infile"},"ground_truth":{"kind":"string","value":"_get_node_id"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"function"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":true,"string":"true"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["edges","_get_node_id","nodes","edge_style","label2id","__init__","_order_edges","color_node","graph_style","hide_node","name","node_style","remove_edge","remove_node","transitive_reduction","type","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"edges\",\n \"_get_node_id\",\n \"nodes\",\n \"edge_style\",\n \"label2id\",\n \"__init__\",\n \"_order_edges\",\n \"color_node\",\n \"graph_style\",\n \"hide_node\",\n \"name\",\n \"node_style\",\n \"remove_edge\",\n \"remove_node\",\n \"transitive_reduction\",\n \"type\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True)\n targets = sorted(set(int(e[1]) for e in list(self.edges)))\n for target in targets:\n for source in sources:\n edge = (str(source), str(target))\n if edge in self.edges:\n ordered.append(edge)\n return ordered\n\n def write(self, fname):\n with open(fname, \"w\") as f:\n f.write(\" \".join([self.type, self.name, \"{\\n\"]))\n f.write(self.graph_style)\n f.write(self.node_style)\n f.write(self.edge_style)\n for k, v in self.nodes.items():\n l = v[\"label\"]\n c = v[\"color\"]\n s = v[\"style\"]\n line = f' {k}[label = \"{l}\", color = \"{c}\", style=\"{s}\"];\\n'\n f.write(line)\n for a, b in self._order_edges():\n line = f\" {a} -> {b}\\n\"\n f.write(line)\n f.write(\"}\\n\")\n\n def _get_node_id(self, node):\n node = str(node)\n if node.isdigit() and node in self.nodes:\n return node\n return self.label2id.get(node)\n\n def color_node(self, node, color):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n self.nodes[node_id][\"color\"] = color\n\n def remove_node(self, node):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n # remove the node\n label = self.nodes[node_id][\"label\"]\n del self.nodes[node_id]\n del self.label2id[label]\n # remove all edges with this node\n for edge in self.edges.copy():\n if node_id in edge:\n self.edges.remove(edge)\n\n def remove_edge(self, source, target):\n source_id = self._get_node_id(source)\n target_id = self."}}},{"rowIdx":64,"cells":{"idx":{"kind":"number","value":83,"string":"83"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":5819,"string":"5,819"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"edges"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["edges","edge_style","_order_edges","nodes","label2id","__init__","_get_node_id","color_node","graph_style","hide_node","name","node_style","remove_edge","remove_node","transitive_reduction","type","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"edges\",\n \"edge_style\",\n \"_order_edges\",\n \"nodes\",\n \"label2id\",\n \"__init__\",\n \"_get_node_id\",\n \"color_node\",\n \"graph_style\",\n \"hide_node\",\n \"name\",\n \"node_style\",\n \"remove_edge\",\n \"remove_node\",\n \"transitive_reduction\",\n \"type\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True)\n targets = sorted(set(int(e[1]) for e in list(self.edges)))\n for target in targets:\n for source in sources:\n edge = (str(source), str(target))\n if edge in self.edges:\n ordered.append(edge)\n return ordered\n\n def write(self, fname):\n with open(fname, \"w\") as f:\n f.write(\" \".join([self.type, self.name, \"{\\n\"]))\n f.write(self.graph_style)\n f.write(self.node_style)\n f.write(self.edge_style)\n for k, v in self.nodes.items():\n l = v[\"label\"]\n c = v[\"color\"]\n s = v[\"style\"]\n line = f' {k}[label = \"{l}\", color = \"{c}\", style=\"{s}\"];\\n'\n f.write(line)\n for a, b in self._order_edges():\n line = f\" {a} -> {b}\\n\"\n f.write(line)\n f.write(\"}\\n\")\n\n def _get_node_id(self, node):\n node = str(node)\n if node.isdigit() and node in self.nodes:\n return node\n return self.label2id.get(node)\n\n def color_node(self, node, color):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n self.nodes[node_id][\"color\"] = color\n\n def remove_node(self, node):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n # remove the node\n label = self.nodes[node_id][\"label\"]\n del self.nodes[node_id]\n del self.label2id[label]\n # remove all edges with this node\n for edge in self.edges.copy():\n if node_id in edge:\n self.edges.remove(edge)\n\n def remove_edge(self, source, target):\n source_id = self._get_node_id(source)\n target_id = self._get_node_id(target)\n edge = (source_id, target_id)\n if edge in self."}}},{"rowIdx":65,"cells":{"idx":{"kind":"number","value":84,"string":"84"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":5843,"string":"5,843"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"edges"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["edges","edge_style","nodes","write","name","__init__","_get_node_id","_order_edges","color_node","graph_style","hide_node","label2id","node_style","remove_edge","remove_node","transitive_reduction","type","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"edges\",\n \"edge_style\",\n \"nodes\",\n \"write\",\n \"name\",\n \"__init__\",\n \"_get_node_id\",\n \"_order_edges\",\n \"color_node\",\n \"graph_style\",\n \"hide_node\",\n \"label2id\",\n \"node_style\",\n \"remove_edge\",\n \"remove_node\",\n \"transitive_reduction\",\n \"type\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True)\n targets = sorted(set(int(e[1]) for e in list(self.edges)))\n for target in targets:\n for source in sources:\n edge = (str(source), str(target))\n if edge in self.edges:\n ordered.append(edge)\n return ordered\n\n def write(self, fname):\n with open(fname, \"w\") as f:\n f.write(\" \".join([self.type, self.name, \"{\\n\"]))\n f.write(self.graph_style)\n f.write(self.node_style)\n f.write(self.edge_style)\n for k, v in self.nodes.items():\n l = v[\"label\"]\n c = v[\"color\"]\n s = v[\"style\"]\n line = f' {k}[label = \"{l}\", color = \"{c}\", style=\"{s}\"];\\n'\n f.write(line)\n for a, b in self._order_edges():\n line = f\" {a} -> {b}\\n\"\n f.write(line)\n f.write(\"}\\n\")\n\n def _get_node_id(self, node):\n node = str(node)\n if node.isdigit() and node in self.nodes:\n return node\n return self.label2id.get(node)\n\n def color_node(self, node, color):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n self.nodes[node_id][\"color\"] = color\n\n def remove_node(self, node):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n # remove the node\n label = self.nodes[node_id][\"label\"]\n del self.nodes[node_id]\n del self.label2id[label]\n # remove all edges with this node\n for edge in self.edges.copy():\n if node_id in edge:\n self.edges.remove(edge)\n\n def remove_edge(self, source, target):\n source_id = self._get_node_id(source)\n target_id = self._get_node_id(target)\n edge = (source_id, target_id)\n if edge in self.edges:\n self."}}},{"rowIdx":66,"cells":{"idx":{"kind":"number","value":85,"string":"85"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":5992,"string":"5,992"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"_get_node_id"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"function"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":true,"string":"true"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["_get_node_id","nodes","node_style","remove_node","edges","__init__","_order_edges","color_node","edge_style","graph_style","hide_node","label2id","name","remove_edge","transitive_reduction","type","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"_get_node_id\",\n \"nodes\",\n \"node_style\",\n \"remove_node\",\n \"edges\",\n \"__init__\",\n \"_order_edges\",\n \"color_node\",\n \"edge_style\",\n \"graph_style\",\n \"hide_node\",\n \"label2id\",\n \"name\",\n \"remove_edge\",\n \"transitive_reduction\",\n \"type\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True)\n targets = sorted(set(int(e[1]) for e in list(self.edges)))\n for target in targets:\n for source in sources:\n edge = (str(source), str(target))\n if edge in self.edges:\n ordered.append(edge)\n return ordered\n\n def write(self, fname):\n with open(fname, \"w\") as f:\n f.write(\" \".join([self.type, self.name, \"{\\n\"]))\n f.write(self.graph_style)\n f.write(self.node_style)\n f.write(self.edge_style)\n for k, v in self.nodes.items():\n l = v[\"label\"]\n c = v[\"color\"]\n s = v[\"style\"]\n line = f' {k}[label = \"{l}\", color = \"{c}\", style=\"{s}\"];\\n'\n f.write(line)\n for a, b in self._order_edges():\n line = f\" {a} -> {b}\\n\"\n f.write(line)\n f.write(\"}\\n\")\n\n def _get_node_id(self, node):\n node = str(node)\n if node.isdigit() and node in self.nodes:\n return node\n return self.label2id.get(node)\n\n def color_node(self, node, color):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n self.nodes[node_id][\"color\"] = color\n\n def remove_node(self, node):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n # remove the node\n label = self.nodes[node_id][\"label\"]\n del self.nodes[node_id]\n del self.label2id[label]\n # remove all edges with this node\n for edge in self.edges.copy():\n if node_id in edge:\n self.edges.remove(edge)\n\n def remove_edge(self, source, target):\n source_id = self._get_node_id(source)\n target_id = self._get_node_id(target)\n edge = (source_id, target_id)\n if edge in self.edges:\n self.edges.remove(edge)\n\n def hide_node(self, node):\n \"\"\"remove a node, and connect incoming edges and outgoing edges\"\"\"\n node_id = self."}}},{"rowIdx":67,"cells":{"idx":{"kind":"number","value":86,"string":"86"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":6173,"string":"6,173"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"edges"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["edges","nodes","edge_style","_order_edges","node_style","__init__","_get_node_id","color_node","graph_style","hide_node","label2id","name","remove_edge","remove_node","transitive_reduction","type","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"edges\",\n \"nodes\",\n \"edge_style\",\n \"_order_edges\",\n \"node_style\",\n \"__init__\",\n \"_get_node_id\",\n \"color_node\",\n \"graph_style\",\n \"hide_node\",\n \"label2id\",\n \"name\",\n \"remove_edge\",\n \"remove_node\",\n \"transitive_reduction\",\n \"type\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True)\n targets = sorted(set(int(e[1]) for e in list(self.edges)))\n for target in targets:\n for source in sources:\n edge = (str(source), str(target))\n if edge in self.edges:\n ordered.append(edge)\n return ordered\n\n def write(self, fname):\n with open(fname, \"w\") as f:\n f.write(\" \".join([self.type, self.name, \"{\\n\"]))\n f.write(self.graph_style)\n f.write(self.node_style)\n f.write(self.edge_style)\n for k, v in self.nodes.items():\n l = v[\"label\"]\n c = v[\"color\"]\n s = v[\"style\"]\n line = f' {k}[label = \"{l}\", color = \"{c}\", style=\"{s}\"];\\n'\n f.write(line)\n for a, b in self._order_edges():\n line = f\" {a} -> {b}\\n\"\n f.write(line)\n f.write(\"}\\n\")\n\n def _get_node_id(self, node):\n node = str(node)\n if node.isdigit() and node in self.nodes:\n return node\n return self.label2id.get(node)\n\n def color_node(self, node, color):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n self.nodes[node_id][\"color\"] = color\n\n def remove_node(self, node):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n # remove the node\n label = self.nodes[node_id][\"label\"]\n del self.nodes[node_id]\n del self.label2id[label]\n # remove all edges with this node\n for edge in self.edges.copy():\n if node_id in edge:\n self.edges.remove(edge)\n\n def remove_edge(self, source, target):\n source_id = self._get_node_id(source)\n target_id = self._get_node_id(target)\n edge = (source_id, target_id)\n if edge in self.edges:\n self.edges.remove(edge)\n\n def hide_node(self, node):\n \"\"\"remove a node, and connect incoming edges and outgoing edges\"\"\"\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n # identify parent and daughter nodes\n parents = []\n daughters = []\n for edge in self."}}},{"rowIdx":68,"cells":{"idx":{"kind":"number","value":87,"string":"87"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":6374,"string":"6,374"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"infile"},"ground_truth":{"kind":"string","value":"remove_node"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"function"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["edges","nodes","type","label2id","node_style","__init__","_get_node_id","_order_edges","color_node","edge_style","graph_style","hide_node","name","remove_edge","remove_node","transitive_reduction","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"edges\",\n \"nodes\",\n \"type\",\n \"label2id\",\n \"node_style\",\n \"__init__\",\n \"_get_node_id\",\n \"_order_edges\",\n \"color_node\",\n \"edge_style\",\n \"graph_style\",\n \"hide_node\",\n \"name\",\n \"remove_edge\",\n \"remove_node\",\n \"transitive_reduction\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True)\n targets = sorted(set(int(e[1]) for e in list(self.edges)))\n for target in targets:\n for source in sources:\n edge = (str(source), str(target))\n if edge in self.edges:\n ordered.append(edge)\n return ordered\n\n def write(self, fname):\n with open(fname, \"w\") as f:\n f.write(\" \".join([self.type, self.name, \"{\\n\"]))\n f.write(self.graph_style)\n f.write(self.node_style)\n f.write(self.edge_style)\n for k, v in self.nodes.items():\n l = v[\"label\"]\n c = v[\"color\"]\n s = v[\"style\"]\n line = f' {k}[label = \"{l}\", color = \"{c}\", style=\"{s}\"];\\n'\n f.write(line)\n for a, b in self._order_edges():\n line = f\" {a} -> {b}\\n\"\n f.write(line)\n f.write(\"}\\n\")\n\n def _get_node_id(self, node):\n node = str(node)\n if node.isdigit() and node in self.nodes:\n return node\n return self.label2id.get(node)\n\n def color_node(self, node, color):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n self.nodes[node_id][\"color\"] = color\n\n def remove_node(self, node):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n # remove the node\n label = self.nodes[node_id][\"label\"]\n del self.nodes[node_id]\n del self.label2id[label]\n # remove all edges with this node\n for edge in self.edges.copy():\n if node_id in edge:\n self.edges.remove(edge)\n\n def remove_edge(self, source, target):\n source_id = self._get_node_id(source)\n target_id = self._get_node_id(target)\n edge = (source_id, target_id)\n if edge in self.edges:\n self.edges.remove(edge)\n\n def hide_node(self, node):\n \"\"\"remove a node, and connect incoming edges and outgoing edges\"\"\"\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n # identify parent and daughter nodes\n parents = []\n daughters = []\n for edge in self.edges:\n if node_id == edge[0]:\n daughters.append(edge[1])\n elif node_id == edge[1]:\n parents.append(edge[0])\n\n # remove the node\n self."}}},{"rowIdx":69,"cells":{"idx":{"kind":"number","value":88,"string":"88"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":6565,"string":"6,565"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"edges"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["nodes","edges","node_style","edge_style","name","__init__","_get_node_id","_order_edges","color_node","graph_style","hide_node","label2id","remove_edge","remove_node","transitive_reduction","type","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"nodes\",\n \"edges\",\n \"node_style\",\n \"edge_style\",\n \"name\",\n \"__init__\",\n \"_get_node_id\",\n \"_order_edges\",\n \"color_node\",\n \"graph_style\",\n \"hide_node\",\n \"label2id\",\n \"remove_edge\",\n \"remove_node\",\n \"transitive_reduction\",\n \"type\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True)\n targets = sorted(set(int(e[1]) for e in list(self.edges)))\n for target in targets:\n for source in sources:\n edge = (str(source), str(target))\n if edge in self.edges:\n ordered.append(edge)\n return ordered\n\n def write(self, fname):\n with open(fname, \"w\") as f:\n f.write(\" \".join([self.type, self.name, \"{\\n\"]))\n f.write(self.graph_style)\n f.write(self.node_style)\n f.write(self.edge_style)\n for k, v in self.nodes.items():\n l = v[\"label\"]\n c = v[\"color\"]\n s = v[\"style\"]\n line = f' {k}[label = \"{l}\", color = \"{c}\", style=\"{s}\"];\\n'\n f.write(line)\n for a, b in self._order_edges():\n line = f\" {a} -> {b}\\n\"\n f.write(line)\n f.write(\"}\\n\")\n\n def _get_node_id(self, node):\n node = str(node)\n if node.isdigit() and node in self.nodes:\n return node\n return self.label2id.get(node)\n\n def color_node(self, node, color):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n self.nodes[node_id][\"color\"] = color\n\n def remove_node(self, node):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n # remove the node\n label = self.nodes[node_id][\"label\"]\n del self.nodes[node_id]\n del self.label2id[label]\n # remove all edges with this node\n for edge in self.edges.copy():\n if node_id in edge:\n self.edges.remove(edge)\n\n def remove_edge(self, source, target):\n source_id = self._get_node_id(source)\n target_id = self._get_node_id(target)\n edge = (source_id, target_id)\n if edge in self.edges:\n self.edges.remove(edge)\n\n def hide_node(self, node):\n \"\"\"remove a node, and connect incoming edges and outgoing edges\"\"\"\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n # identify parent and daughter nodes\n parents = []\n daughters = []\n for edge in self.edges:\n if node_id == edge[0]:\n daughters.append(edge[1])\n elif node_id == edge[1]:\n parents.append(edge[0])\n\n # remove the node\n self.remove_node(node)\n # connect the neighboring nodes\n for parent in parents:\n for daughter in daughters:\n edge = (parent, daughter)\n self."}}},{"rowIdx":70,"cells":{"idx":{"kind":"number","value":89,"string":"89"},"idx_lca":{"kind":"number","value":1,"string":"1"},"offset":{"kind":"number","value":6646,"string":"6,646"},"repo":{"kind":"string","value":"vanheeringen-lab__seq2science"},"commit_hash":{"kind":"string","value":"d5ff9782c8f6c4cd989f74684154c508b7c65127"},"target_file":{"kind":"string","value":"docs/scripts/clean_dags.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"edges"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":16,"string":"16"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["graph_style","edges","edge_style","nodes","node_style","__init__","_get_node_id","_order_edges","color_node","hide_node","label2id","name","remove_edge","remove_node","transitive_reduction","type","write","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"graph_style\",\n \"edges\",\n \"edge_style\",\n \"nodes\",\n \"node_style\",\n \"__init__\",\n \"_get_node_id\",\n \"_order_edges\",\n \"color_node\",\n \"hide_node\",\n \"label2id\",\n \"name\",\n \"remove_edge\",\n \"remove_node\",\n \"transitive_reduction\",\n \"type\",\n \"write\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"color_node","type":"function"},{"name":"edge_style","type":"statement"},{"name":"edges","type":"statement"},{"name":"graph_style","type":"statement"},{"name":"hide_node","type":"function"},{"name":"label2id","type":"statement"},{"name":"name","type":"statement"},{"name":"node_style","type":"statement"},{"name":"nodes","type":"statement"},{"name":"remove_edge","type":"function"},{"name":"remove_node","type":"function"},{"name":"transitive_reduction","type":"function"},{"name":"type","type":"statement"},{"name":"write","type":"function"},{"name":"_get_node_id","type":"function"},{"name":"_order_edges","type":"function"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"color_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"edge_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"edges\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"graph_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"hide_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"label2id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"name\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"node_style\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"nodes\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"remove_edge\",\n \"type\": \"function\"\n },\n {\n \"name\": \"remove_node\",\n \"type\": \"function\"\n },\n {\n \"name\": \"transitive_reduction\",\n \"type\": \"function\"\n },\n {\n \"name\": \"type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"write\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_get_node_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"_order_edges\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"import re\nimport networkx as nx\n\nrules_to_keep = {\n # \"0.13 0.6 0.85\", # yellow\n # \"0.09 0.6 0.85\", # brown\n # \"0.28 0.6 0.85\", # green\n # \"0.04 0.6 0.85\", # red\n # \"0.00 0.6 0.85\", # cherry\n # \"0.63 0.6 0.85\", # purple\n # \"0.59 0.6 0.85\", # dark blue\n # \"0.58 0.6 0.85\", # blue\n # \"0.49 0.6 0.85\", # teal\n # input\n \"get_genome\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"ena2fastq_PE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_SE\": \"0.49 0.6 0.85\", # teal\n \"sra2fastq_PE\": \"0.49 0.6 0.85\", # teal\n # fastq\n \"fastp_SE\": \"0.13 0.6 0.85\", # yellow\n \"fastp_PE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_SE\": \"0.13 0.6 0.85\", # yellow\n \"trimgalore_PE\": \"0.13 0.6 0.85\", # yellow\n \"merge_replicates\": \"0.13 0.6 0.85\", # yellow\n # align\n \"bowtie2_align\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem\": \"0.13 0.6 0.85\", # yellow\n \"bwa_mem2\": \"0.13 0.6 0.85\", # yellow\n \"hisat2_align\": \"0.13 0.6 0.85\", # yellow\n \"minimap2_align\": \"0.13 0.6 0.85\", # yellow\n \"star_align\": \"0.13 0.6 0.85\", # yellow\n \"mark_duplicates\": \"0.13 0.6 0.85\", # yellow\n \"sieve_bam\": \"0.13 0.6 0.85\", # yellow\n # peak counting\n \"macs2_callpeak\": \"0.13 0.6 0.85\", # yellow\n \"call_peak_genrich\": \"0.13 0.6 0.85\", # yellow\n \"hmmratac\": \"0.13 0.6 0.85\", # yellow\n \"create_SNAP_object\": \"0.13 0.6 0.85\", # yellow\n # gene counting/quantification\n \"htseq_count\": \"0.13 0.6 0.85\", # yellow\n \"featurecounts\": \"0.13 0.6 0.85\", # yellow\n \"salmon_quant\": \"0.13 0.6 0.85\", # yellow\n # trackhub\n \"bam_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"peak_bigpeak\": \"0.00 0.6 0.85\", # cherry\n \"bedgraph_bigwig\": \"0.00 0.6 0.85\", # cherry\n \"trackhub\": \"0.00 0.6 0.85\", # cherry\n # multiqc\n \"multiqc\": \"0.63 0.6 0.85\", # purple\n # peak files\n \"coverage_table\": \"0.28 0.6 0.85\", # green\n \"onehot_peaks\": \"0.28 0.6 0.85\", # green\n \"create_bins_SNAP_object\": \"0.28 0.6 0.85\", # green\n # gene files\n \"gene_id2name\": \"0.28 0.6 0.85\", # green\n \"tpm_matrix\": \"0.28 0.6 0.85\", # green\n \"count_matrix\": \"0.28 0.6 0.85\", # green\n \"txi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"pytxi_count_matrix\": \"0.28 0.6 0.85\", # green\n \"citeseqcount\": \"0.28 0.6 0.85\", # green\n \"kallistobus_count\": \"0.28 0.6 0.85\", # green\n # other\n \"gimme_maelstrom\": \"0.28 0.6 0.85\", # green\n \"deseq2\": \"0.28 0.6 0.85\", # green\n \"dexseq_count_matrix\": \"0.28 0.6 0.85\", # green\n}\n\n\nclass Digraph:\n def __init__(self, infile):\n with open(infile) as f:\n lines = f.readlines()\n self.type, self.name = lines[0].split()[0:2]\n self.graph_style = lines[1]\n self.node_style = lines[2]\n self.edge_style = lines[3]\n\n self.nodes = dict()\n self.edges = set()\n self.label2id = dict()\n l = re.compile(r'label = \"(.*?)\"')\n c = re.compile(r'color = \"(.*?)\"')\n s = re.compile(r'style=\"(.*?)\"')\n for line in lines[4:]:\n line = line.strip()\n\n # read edges\n edge = tuple(line.split(\" -> \"))\n if len(edge) == 2:\n self.edges.add(edge)\n\n # read nodes\n elif \"[\" in line[:5]:\n node_id = line.split(\"[\")[0]\n label = l.search(line).groups()[0]\n color = c.search(line).groups()[0]\n style = s.search(line).groups()[0]\n self.nodes[node_id] = {\n \"label\": label,\n \"color\": color,\n \"style\": style,\n }\n self.label2id[label] = node_id\n\n def _order_edges(self):\n \"\"\"\n edges are sorted by\n 1) ascending target nodes and\n 2) descending source nodes\n \"\"\"\n ordered = []\n sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True)\n targets = sorted(set(int(e[1]) for e in list(self.edges)))\n for target in targets:\n for source in sources:\n edge = (str(source), str(target))\n if edge in self.edges:\n ordered.append(edge)\n return ordered\n\n def write(self, fname):\n with open(fname, \"w\") as f:\n f.write(\" \".join([self.type, self.name, \"{\\n\"]))\n f.write(self.graph_style)\n f.write(self.node_style)\n f.write(self.edge_style)\n for k, v in self.nodes.items():\n l = v[\"label\"]\n c = v[\"color\"]\n s = v[\"style\"]\n line = f' {k}[label = \"{l}\", color = \"{c}\", style=\"{s}\"];\\n'\n f.write(line)\n for a, b in self._order_edges():\n line = f\" {a} -> {b}\\n\"\n f.write(line)\n f.write(\"}\\n\")\n\n def _get_node_id(self, node):\n node = str(node)\n if node.isdigit() and node in self.nodes:\n return node\n return self.label2id.get(node)\n\n def color_node(self, node, color):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n self.nodes[node_id][\"color\"] = color\n\n def remove_node(self, node):\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n # remove the node\n label = self.nodes[node_id][\"label\"]\n del self.nodes[node_id]\n del self.label2id[label]\n # remove all edges with this node\n for edge in self.edges.copy():\n if node_id in edge:\n self.edges.remove(edge)\n\n def remove_edge(self, source, target):\n source_id = self._get_node_id(source)\n target_id = self._get_node_id(target)\n edge = (source_id, target_id)\n if edge in self.edges:\n self.edges.remove(edge)\n\n def hide_node(self, node):\n \"\"\"remove a node, and connect incoming edges and outgoing edges\"\"\"\n node_id = self._get_node_id(node)\n if node_id is None:\n return\n\n # identify parent and daughter nodes\n parents = []\n daughters = []\n for edge in self.edges:\n if node_id == edge[0]:\n daughters.append(edge[1])\n elif node_id == edge[1]:\n parents.append(edge[0])\n\n # remove the node\n self.remove_node(node)\n # connect the neighboring nodes\n for parent in parents:\n for daughter in daughters:\n edge = (parent, daughter)\n self.edges.add(edge)\n\n def transitive_reduction(self):\n g = nx.DiGraph(self."}}},{"rowIdx":71,"cells":{"idx":{"kind":"number","value":96,"string":"96"},"idx_lca":{"kind":"number","value":4,"string":"4"},"offset":{"kind":"number","value":1958,"string":"1,958"},"repo":{"kind":"string","value":"Significant-Gravitas__Auto-GPT"},"commit_hash":{"kind":"string","value":"0569d6652fbffa665de6e42403a48783fbede8ce"},"target_file":{"kind":"string","value":"autogpt/commands.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"google_api_key"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":63,"string":"63"},"non_dunder_count_jedi":{"kind":"number","value":63,"string":"63"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["speak_mode","google_api_key","execute_local_commands","custom_search_engine_id","fast_llm_model","ai_settings_file","AZURE_CONFIG_FILE","azure_model_to_deployment_id_map","browse_chunk_max_length","browse_summary_max_token","continuous_limit","continuous_mode","debug_mode","elevenlabs_api_key","elevenlabs_voice_1_id","elevenlabs_voice_2_id","fast_token_limit","get_azure_deployment_id_for_model","github_api_key","github_username","huggingface_api_token","image_provider","load_azure_config","memory_backend","memory_index","milvus_addr","milvus_collection","openai_api_base","openai_api_key","openai_api_type","openai_api_version","pinecone_api_key","pinecone_region","redis_host","redis_password","redis_port","set_browse_chunk_max_length","set_browse_summary_max_token","set_continuous_limit","set_continuous_mode","set_custom_search_engine_id","set_debug_mode","set_elevenlabs_api_key","set_elevenlabs_voice_1_id","set_elevenlabs_voice_2_id","set_fast_llm_model","set_fast_token_limit","set_google_api_key","set_openai_api_key","set_pinecone_api_key","set_pinecone_region","set_smart_llm_model","set_smart_token_limit","set_speak_mode","skip_reprompt","smart_llm_model","smart_token_limit","temperature","use_azure","use_brian_tts","use_mac_os_tts","user_agent","wipe_redis_on_start","__init__","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"speak_mode\",\n \"google_api_key\",\n \"execute_local_commands\",\n \"custom_search_engine_id\",\n \"fast_llm_model\",\n \"ai_settings_file\",\n \"AZURE_CONFIG_FILE\",\n \"azure_model_to_deployment_id_map\",\n \"browse_chunk_max_length\",\n \"browse_summary_max_token\",\n \"continuous_limit\",\n \"continuous_mode\",\n \"debug_mode\",\n \"elevenlabs_api_key\",\n \"elevenlabs_voice_1_id\",\n \"elevenlabs_voice_2_id\",\n \"fast_token_limit\",\n \"get_azure_deployment_id_for_model\",\n \"github_api_key\",\n \"github_username\",\n \"huggingface_api_token\",\n \"image_provider\",\n \"load_azure_config\",\n \"memory_backend\",\n \"memory_index\",\n \"milvus_addr\",\n \"milvus_collection\",\n \"openai_api_base\",\n \"openai_api_key\",\n \"openai_api_type\",\n \"openai_api_version\",\n \"pinecone_api_key\",\n \"pinecone_region\",\n \"redis_host\",\n \"redis_password\",\n \"redis_port\",\n \"set_browse_chunk_max_length\",\n \"set_browse_summary_max_token\",\n \"set_continuous_limit\",\n \"set_continuous_mode\",\n \"set_custom_search_engine_id\",\n \"set_debug_mode\",\n \"set_elevenlabs_api_key\",\n \"set_elevenlabs_voice_1_id\",\n \"set_elevenlabs_voice_2_id\",\n \"set_fast_llm_model\",\n \"set_fast_token_limit\",\n \"set_google_api_key\",\n \"set_openai_api_key\",\n \"set_pinecone_api_key\",\n \"set_pinecone_region\",\n \"set_smart_llm_model\",\n \"set_smart_token_limit\",\n \"set_speak_mode\",\n \"skip_reprompt\",\n \"smart_llm_model\",\n \"smart_token_limit\",\n \"temperature\",\n \"use_azure\",\n \"use_brian_tts\",\n \"use_mac_os_tts\",\n \"user_agent\",\n \"wipe_redis_on_start\",\n \"__init__\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"ai_settings_file","type":"statement"},{"name":"AZURE_CONFIG_FILE","type":"statement"},{"name":"azure_model_to_deployment_id_map","type":"statement"},{"name":"browse_chunk_max_length","type":"statement"},{"name":"browse_summary_max_token","type":"statement"},{"name":"continuous_limit","type":"statement"},{"name":"continuous_mode","type":"statement"},{"name":"custom_search_engine_id","type":"statement"},{"name":"debug_mode","type":"statement"},{"name":"elevenlabs_api_key","type":"statement"},{"name":"elevenlabs_voice_1_id","type":"statement"},{"name":"elevenlabs_voice_2_id","type":"statement"},{"name":"execute_local_commands","type":"statement"},{"name":"fast_llm_model","type":"statement"},{"name":"fast_token_limit","type":"statement"},{"name":"get_azure_deployment_id_for_model","type":"function"},{"name":"github_api_key","type":"statement"},{"name":"github_username","type":"statement"},{"name":"google_api_key","type":"statement"},{"name":"huggingface_api_token","type":"statement"},{"name":"image_provider","type":"statement"},{"name":"load_azure_config","type":"function"},{"name":"memory_backend","type":"statement"},{"name":"memory_index","type":"statement"},{"name":"milvus_addr","type":"statement"},{"name":"milvus_collection","type":"statement"},{"name":"openai_api_base","type":"statement"},{"name":"openai_api_key","type":"statement"},{"name":"openai_api_type","type":"statement"},{"name":"openai_api_version","type":"statement"},{"name":"pinecone_api_key","type":"statement"},{"name":"pinecone_region","type":"statement"},{"name":"redis_host","type":"statement"},{"name":"redis_password","type":"statement"},{"name":"redis_port","type":"statement"},{"name":"set_browse_chunk_max_length","type":"function"},{"name":"set_browse_summary_max_token","type":"function"},{"name":"set_continuous_limit","type":"function"},{"name":"set_continuous_mode","type":"function"},{"name":"set_custom_search_engine_id","type":"function"},{"name":"set_debug_mode","type":"function"},{"name":"set_elevenlabs_api_key","type":"function"},{"name":"set_elevenlabs_voice_1_id","type":"function"},{"name":"set_elevenlabs_voice_2_id","type":"function"},{"name":"set_fast_llm_model","type":"function"},{"name":"set_fast_token_limit","type":"function"},{"name":"set_google_api_key","type":"function"},{"name":"set_openai_api_key","type":"function"},{"name":"set_pinecone_api_key","type":"function"},{"name":"set_pinecone_region","type":"function"},{"name":"set_smart_llm_model","type":"function"},{"name":"set_smart_token_limit","type":"function"},{"name":"set_speak_mode","type":"function"},{"name":"skip_reprompt","type":"statement"},{"name":"smart_llm_model","type":"statement"},{"name":"smart_token_limit","type":"statement"},{"name":"speak_mode","type":"statement"},{"name":"temperature","type":"statement"},{"name":"use_azure","type":"statement"},{"name":"use_brian_tts","type":"statement"},{"name":"use_mac_os_tts","type":"statement"},{"name":"user_agent","type":"statement"},{"name":"wipe_redis_on_start","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"ai_settings_file\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"AZURE_CONFIG_FILE\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"azure_model_to_deployment_id_map\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"browse_chunk_max_length\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"browse_summary_max_token\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"continuous_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"continuous_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"custom_search_engine_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"debug_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_voice_1_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_voice_2_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"execute_local_commands\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"fast_llm_model\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"fast_token_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"get_azure_deployment_id_for_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"github_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"github_username\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"google_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"huggingface_api_token\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"image_provider\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"load_azure_config\",\n \"type\": \"function\"\n },\n {\n \"name\": \"memory_backend\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"memory_index\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"milvus_addr\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"milvus_collection\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_base\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_version\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"pinecone_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"pinecone_region\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_host\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_password\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_port\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"set_browse_chunk_max_length\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_browse_summary_max_token\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_continuous_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_continuous_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_custom_search_engine_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_debug_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_voice_1_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_voice_2_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_fast_llm_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_fast_token_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_google_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_openai_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_pinecone_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_pinecone_region\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_smart_llm_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_smart_token_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_speak_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"skip_reprompt\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"smart_llm_model\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"smart_token_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"speak_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"temperature\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_azure\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_brian_tts\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_mac_os_tts\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"user_agent\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"wipe_redis_on_start\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"from autogpt import browse\nimport json\nfrom autogpt.memory import get_memory\nimport datetime\nimport autogpt.agent_manager as agents\nfrom autogpt import speak\nfrom autogpt.config import Config\nimport autogpt.ai_functions as ai\nfrom autogpt.file_operations import read_file, write_to_file, append_to_file, delete_file, search_files\nfrom autogpt.execute_code import execute_python_file, execute_shell\nfrom autogpt.json_parser import fix_and_parse_json\nfrom autogpt.image_gen import generate_image\nfrom duckduckgo_search import ddg\nfrom googleapiclient.discovery import build\nfrom googleapiclient.errors import HttpError\n\ncfg = Config()\n\n\ndef is_valid_int(value):\n try:\n int(value)\n return True\n except ValueError:\n return False\n\n\ndef get_command(response):\n \"\"\"Parse the response and return the command name and arguments\"\"\"\n try:\n response_json = fix_and_parse_json(response)\n\n if \"command\" not in response_json:\n return \"Error:\" , \"Missing 'command' object in JSON\"\n\n command = response_json[\"command\"]\n\n if \"name\" not in command:\n return \"Error:\", \"Missing 'name' field in 'command' object\"\n\n command_name = command[\"name\"]\n\n # Use an empty dictionary if 'args' field is not present in 'command' object\n arguments = command.get(\"args\", {})\n\n return command_name, arguments\n except json.decoder.JSONDecodeError:\n return \"Error:\", \"Invalid JSON\"\n # All other errors, return \"Error: + error message\"\n except Exception as e:\n return \"Error:\", str(e)\n\n\ndef execute_command(command_name, arguments):\n \"\"\"Execute the command and return the result\"\"\"\n memory = get_memory(cfg)\n\n try:\n if command_name == \"google\":\n\n # Check if the Google API key is set and use the official search method\n # If the API key is not set or has only whitespaces, use the unofficial search method\n if cfg."}}},{"rowIdx":72,"cells":{"idx":{"kind":"number","value":97,"string":"97"},"idx_lca":{"kind":"number","value":4,"string":"4"},"offset":{"kind":"number","value":1982,"string":"1,982"},"repo":{"kind":"string","value":"Significant-Gravitas__Auto-GPT"},"commit_hash":{"kind":"string","value":"0569d6652fbffa665de6e42403a48783fbede8ce"},"target_file":{"kind":"string","value":"autogpt/commands.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"google_api_key"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":64,"string":"64"},"non_dunder_count_jedi":{"kind":"number","value":63,"string":"63"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["google_api_key","set_google_api_key","execute_local_commands","github_api_key","openai_api_key","ai_settings_file","AZURE_CONFIG_FILE","azure_model_to_deployment_id_map","browse_chunk_max_length","browse_summary_max_token","continuous_limit","continuous_mode","custom_search_engine_id","debug_mode","elevenlabs_api_key","elevenlabs_voice_1_id","elevenlabs_voice_2_id","fast_llm_model","fast_token_limit","get_azure_deployment_id_for_model","github_username","huggingface_api_token","image_provider","load_azure_config","memory_backend","memory_index","milvus_addr","milvus_collection","openai_api_base","openai_api_type","openai_api_version","pinecone_api_key","pinecone_region","redis_host","redis_password","redis_port","set_browse_chunk_max_length","set_browse_summary_max_token","set_continuous_limit","set_continuous_mode","set_custom_search_engine_id","set_debug_mode","set_elevenlabs_api_key","set_elevenlabs_voice_1_id","set_elevenlabs_voice_2_id","set_fast_llm_model","set_fast_token_limit","set_openai_api_key","set_pinecone_api_key","set_pinecone_region","set_smart_llm_model","set_smart_token_limit","set_speak_mode","skip_reprompt","smart_llm_model","smart_token_limit","speak_mode","temperature","use_azure","use_brian_tts","use_mac_os_tts","user_agent","wipe_redis_on_start","yield","__init__","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"google_api_key\",\n \"set_google_api_key\",\n \"execute_local_commands\",\n \"github_api_key\",\n \"openai_api_key\",\n \"ai_settings_file\",\n \"AZURE_CONFIG_FILE\",\n \"azure_model_to_deployment_id_map\",\n \"browse_chunk_max_length\",\n \"browse_summary_max_token\",\n \"continuous_limit\",\n \"continuous_mode\",\n \"custom_search_engine_id\",\n \"debug_mode\",\n \"elevenlabs_api_key\",\n \"elevenlabs_voice_1_id\",\n \"elevenlabs_voice_2_id\",\n \"fast_llm_model\",\n \"fast_token_limit\",\n \"get_azure_deployment_id_for_model\",\n \"github_username\",\n \"huggingface_api_token\",\n \"image_provider\",\n \"load_azure_config\",\n \"memory_backend\",\n \"memory_index\",\n \"milvus_addr\",\n \"milvus_collection\",\n \"openai_api_base\",\n \"openai_api_type\",\n \"openai_api_version\",\n \"pinecone_api_key\",\n \"pinecone_region\",\n \"redis_host\",\n \"redis_password\",\n \"redis_port\",\n \"set_browse_chunk_max_length\",\n \"set_browse_summary_max_token\",\n \"set_continuous_limit\",\n \"set_continuous_mode\",\n \"set_custom_search_engine_id\",\n \"set_debug_mode\",\n \"set_elevenlabs_api_key\",\n \"set_elevenlabs_voice_1_id\",\n \"set_elevenlabs_voice_2_id\",\n \"set_fast_llm_model\",\n \"set_fast_token_limit\",\n \"set_openai_api_key\",\n \"set_pinecone_api_key\",\n \"set_pinecone_region\",\n \"set_smart_llm_model\",\n \"set_smart_token_limit\",\n \"set_speak_mode\",\n \"skip_reprompt\",\n \"smart_llm_model\",\n \"smart_token_limit\",\n \"speak_mode\",\n \"temperature\",\n \"use_azure\",\n \"use_brian_tts\",\n \"use_mac_os_tts\",\n \"user_agent\",\n \"wipe_redis_on_start\",\n \"yield\",\n \"__init__\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"ai_settings_file","type":"statement"},{"name":"AZURE_CONFIG_FILE","type":"statement"},{"name":"azure_model_to_deployment_id_map","type":"statement"},{"name":"browse_chunk_max_length","type":"statement"},{"name":"browse_summary_max_token","type":"statement"},{"name":"continuous_limit","type":"statement"},{"name":"continuous_mode","type":"statement"},{"name":"custom_search_engine_id","type":"statement"},{"name":"debug_mode","type":"statement"},{"name":"elevenlabs_api_key","type":"statement"},{"name":"elevenlabs_voice_1_id","type":"statement"},{"name":"elevenlabs_voice_2_id","type":"statement"},{"name":"execute_local_commands","type":"statement"},{"name":"fast_llm_model","type":"statement"},{"name":"fast_token_limit","type":"statement"},{"name":"get_azure_deployment_id_for_model","type":"function"},{"name":"github_api_key","type":"statement"},{"name":"github_username","type":"statement"},{"name":"google_api_key","type":"statement"},{"name":"huggingface_api_token","type":"statement"},{"name":"image_provider","type":"statement"},{"name":"load_azure_config","type":"function"},{"name":"memory_backend","type":"statement"},{"name":"memory_index","type":"statement"},{"name":"milvus_addr","type":"statement"},{"name":"milvus_collection","type":"statement"},{"name":"openai_api_base","type":"statement"},{"name":"openai_api_key","type":"statement"},{"name":"openai_api_type","type":"statement"},{"name":"openai_api_version","type":"statement"},{"name":"pinecone_api_key","type":"statement"},{"name":"pinecone_region","type":"statement"},{"name":"redis_host","type":"statement"},{"name":"redis_password","type":"statement"},{"name":"redis_port","type":"statement"},{"name":"set_browse_chunk_max_length","type":"function"},{"name":"set_browse_summary_max_token","type":"function"},{"name":"set_continuous_limit","type":"function"},{"name":"set_continuous_mode","type":"function"},{"name":"set_custom_search_engine_id","type":"function"},{"name":"set_debug_mode","type":"function"},{"name":"set_elevenlabs_api_key","type":"function"},{"name":"set_elevenlabs_voice_1_id","type":"function"},{"name":"set_elevenlabs_voice_2_id","type":"function"},{"name":"set_fast_llm_model","type":"function"},{"name":"set_fast_token_limit","type":"function"},{"name":"set_google_api_key","type":"function"},{"name":"set_openai_api_key","type":"function"},{"name":"set_pinecone_api_key","type":"function"},{"name":"set_pinecone_region","type":"function"},{"name":"set_smart_llm_model","type":"function"},{"name":"set_smart_token_limit","type":"function"},{"name":"set_speak_mode","type":"function"},{"name":"skip_reprompt","type":"statement"},{"name":"smart_llm_model","type":"statement"},{"name":"smart_token_limit","type":"statement"},{"name":"speak_mode","type":"statement"},{"name":"temperature","type":"statement"},{"name":"use_azure","type":"statement"},{"name":"use_brian_tts","type":"statement"},{"name":"use_mac_os_tts","type":"statement"},{"name":"user_agent","type":"statement"},{"name":"wipe_redis_on_start","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"ai_settings_file\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"AZURE_CONFIG_FILE\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"azure_model_to_deployment_id_map\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"browse_chunk_max_length\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"browse_summary_max_token\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"continuous_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"continuous_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"custom_search_engine_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"debug_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_voice_1_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_voice_2_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"execute_local_commands\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"fast_llm_model\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"fast_token_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"get_azure_deployment_id_for_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"github_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"github_username\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"google_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"huggingface_api_token\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"image_provider\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"load_azure_config\",\n \"type\": \"function\"\n },\n {\n \"name\": \"memory_backend\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"memory_index\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"milvus_addr\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"milvus_collection\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_base\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_version\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"pinecone_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"pinecone_region\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_host\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_password\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_port\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"set_browse_chunk_max_length\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_browse_summary_max_token\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_continuous_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_continuous_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_custom_search_engine_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_debug_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_voice_1_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_voice_2_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_fast_llm_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_fast_token_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_google_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_openai_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_pinecone_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_pinecone_region\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_smart_llm_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_smart_token_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_speak_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"skip_reprompt\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"smart_llm_model\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"smart_token_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"speak_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"temperature\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_azure\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_brian_tts\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_mac_os_tts\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"user_agent\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"wipe_redis_on_start\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"from autogpt import browse\nimport json\nfrom autogpt.memory import get_memory\nimport datetime\nimport autogpt.agent_manager as agents\nfrom autogpt import speak\nfrom autogpt.config import Config\nimport autogpt.ai_functions as ai\nfrom autogpt.file_operations import read_file, write_to_file, append_to_file, delete_file, search_files\nfrom autogpt.execute_code import execute_python_file, execute_shell\nfrom autogpt.json_parser import fix_and_parse_json\nfrom autogpt.image_gen import generate_image\nfrom duckduckgo_search import ddg\nfrom googleapiclient.discovery import build\nfrom googleapiclient.errors import HttpError\n\ncfg = Config()\n\n\ndef is_valid_int(value):\n try:\n int(value)\n return True\n except ValueError:\n return False\n\n\ndef get_command(response):\n \"\"\"Parse the response and return the command name and arguments\"\"\"\n try:\n response_json = fix_and_parse_json(response)\n\n if \"command\" not in response_json:\n return \"Error:\" , \"Missing 'command' object in JSON\"\n\n command = response_json[\"command\"]\n\n if \"name\" not in command:\n return \"Error:\", \"Missing 'name' field in 'command' object\"\n\n command_name = command[\"name\"]\n\n # Use an empty dictionary if 'args' field is not present in 'command' object\n arguments = command.get(\"args\", {})\n\n return command_name, arguments\n except json.decoder.JSONDecodeError:\n return \"Error:\", \"Invalid JSON\"\n # All other errors, return \"Error: + error message\"\n except Exception as e:\n return \"Error:\", str(e)\n\n\ndef execute_command(command_name, arguments):\n \"\"\"Execute the command and return the result\"\"\"\n memory = get_memory(cfg)\n\n try:\n if command_name == \"google\":\n\n # Check if the Google API key is set and use the official search method\n # If the API key is not set or has only whitespaces, use the unofficial search method\n if cfg.google_api_key and (cfg."}}},{"rowIdx":73,"cells":{"idx":{"kind":"number","value":98,"string":"98"},"idx_lca":{"kind":"number","value":4,"string":"4"},"offset":{"kind":"number","value":2012,"string":"2,012"},"repo":{"kind":"string","value":"Significant-Gravitas__Auto-GPT"},"commit_hash":{"kind":"string","value":"0569d6652fbffa665de6e42403a48783fbede8ce"},"target_file":{"kind":"string","value":"autogpt/commands.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"google_api_key"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":64,"string":"64"},"non_dunder_count_jedi":{"kind":"number","value":63,"string":"63"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["google_api_key","speak_mode","execute_local_commands","custom_search_engine_id","fast_llm_model","ai_settings_file","AZURE_CONFIG_FILE","azure_model_to_deployment_id_map","browse_chunk_max_length","browse_summary_max_token","continuous_limit","continuous_mode","debug_mode","elevenlabs_api_key","elevenlabs_voice_1_id","elevenlabs_voice_2_id","fast_token_limit","get_azure_deployment_id_for_model","github_api_key","github_username","huggingface_api_token","image_provider","load_azure_config","memory_backend","memory_index","milvus_addr","milvus_collection","openai_api_base","openai_api_key","openai_api_type","openai_api_version","pinecone_api_key","pinecone_region","redis_host","redis_password","redis_port","set_browse_chunk_max_length","set_browse_summary_max_token","set_continuous_limit","set_continuous_mode","set_custom_search_engine_id","set_debug_mode","set_elevenlabs_api_key","set_elevenlabs_voice_1_id","set_elevenlabs_voice_2_id","set_fast_llm_model","set_fast_token_limit","set_google_api_key","set_openai_api_key","set_pinecone_api_key","set_pinecone_region","set_smart_llm_model","set_smart_token_limit","set_speak_mode","skip_reprompt","smart_llm_model","smart_token_limit","temperature","use_azure","use_brian_tts","use_mac_os_tts","user_agent","wipe_redis_on_start","yield","__init__","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"google_api_key\",\n \"speak_mode\",\n \"execute_local_commands\",\n \"custom_search_engine_id\",\n \"fast_llm_model\",\n \"ai_settings_file\",\n \"AZURE_CONFIG_FILE\",\n \"azure_model_to_deployment_id_map\",\n \"browse_chunk_max_length\",\n \"browse_summary_max_token\",\n \"continuous_limit\",\n \"continuous_mode\",\n \"debug_mode\",\n \"elevenlabs_api_key\",\n \"elevenlabs_voice_1_id\",\n \"elevenlabs_voice_2_id\",\n \"fast_token_limit\",\n \"get_azure_deployment_id_for_model\",\n \"github_api_key\",\n \"github_username\",\n \"huggingface_api_token\",\n \"image_provider\",\n \"load_azure_config\",\n \"memory_backend\",\n \"memory_index\",\n \"milvus_addr\",\n \"milvus_collection\",\n \"openai_api_base\",\n \"openai_api_key\",\n \"openai_api_type\",\n \"openai_api_version\",\n \"pinecone_api_key\",\n \"pinecone_region\",\n \"redis_host\",\n \"redis_password\",\n \"redis_port\",\n \"set_browse_chunk_max_length\",\n \"set_browse_summary_max_token\",\n \"set_continuous_limit\",\n \"set_continuous_mode\",\n \"set_custom_search_engine_id\",\n \"set_debug_mode\",\n \"set_elevenlabs_api_key\",\n \"set_elevenlabs_voice_1_id\",\n \"set_elevenlabs_voice_2_id\",\n \"set_fast_llm_model\",\n \"set_fast_token_limit\",\n \"set_google_api_key\",\n \"set_openai_api_key\",\n \"set_pinecone_api_key\",\n \"set_pinecone_region\",\n \"set_smart_llm_model\",\n \"set_smart_token_limit\",\n \"set_speak_mode\",\n \"skip_reprompt\",\n \"smart_llm_model\",\n \"smart_token_limit\",\n \"temperature\",\n \"use_azure\",\n \"use_brian_tts\",\n \"use_mac_os_tts\",\n \"user_agent\",\n \"wipe_redis_on_start\",\n \"yield\",\n \"__init__\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"ai_settings_file","type":"statement"},{"name":"AZURE_CONFIG_FILE","type":"statement"},{"name":"azure_model_to_deployment_id_map","type":"statement"},{"name":"browse_chunk_max_length","type":"statement"},{"name":"browse_summary_max_token","type":"statement"},{"name":"continuous_limit","type":"statement"},{"name":"continuous_mode","type":"statement"},{"name":"custom_search_engine_id","type":"statement"},{"name":"debug_mode","type":"statement"},{"name":"elevenlabs_api_key","type":"statement"},{"name":"elevenlabs_voice_1_id","type":"statement"},{"name":"elevenlabs_voice_2_id","type":"statement"},{"name":"execute_local_commands","type":"statement"},{"name":"fast_llm_model","type":"statement"},{"name":"fast_token_limit","type":"statement"},{"name":"get_azure_deployment_id_for_model","type":"function"},{"name":"github_api_key","type":"statement"},{"name":"github_username","type":"statement"},{"name":"google_api_key","type":"statement"},{"name":"huggingface_api_token","type":"statement"},{"name":"image_provider","type":"statement"},{"name":"load_azure_config","type":"function"},{"name":"memory_backend","type":"statement"},{"name":"memory_index","type":"statement"},{"name":"milvus_addr","type":"statement"},{"name":"milvus_collection","type":"statement"},{"name":"openai_api_base","type":"statement"},{"name":"openai_api_key","type":"statement"},{"name":"openai_api_type","type":"statement"},{"name":"openai_api_version","type":"statement"},{"name":"pinecone_api_key","type":"statement"},{"name":"pinecone_region","type":"statement"},{"name":"redis_host","type":"statement"},{"name":"redis_password","type":"statement"},{"name":"redis_port","type":"statement"},{"name":"set_browse_chunk_max_length","type":"function"},{"name":"set_browse_summary_max_token","type":"function"},{"name":"set_continuous_limit","type":"function"},{"name":"set_continuous_mode","type":"function"},{"name":"set_custom_search_engine_id","type":"function"},{"name":"set_debug_mode","type":"function"},{"name":"set_elevenlabs_api_key","type":"function"},{"name":"set_elevenlabs_voice_1_id","type":"function"},{"name":"set_elevenlabs_voice_2_id","type":"function"},{"name":"set_fast_llm_model","type":"function"},{"name":"set_fast_token_limit","type":"function"},{"name":"set_google_api_key","type":"function"},{"name":"set_openai_api_key","type":"function"},{"name":"set_pinecone_api_key","type":"function"},{"name":"set_pinecone_region","type":"function"},{"name":"set_smart_llm_model","type":"function"},{"name":"set_smart_token_limit","type":"function"},{"name":"set_speak_mode","type":"function"},{"name":"skip_reprompt","type":"statement"},{"name":"smart_llm_model","type":"statement"},{"name":"smart_token_limit","type":"statement"},{"name":"speak_mode","type":"statement"},{"name":"temperature","type":"statement"},{"name":"use_azure","type":"statement"},{"name":"use_brian_tts","type":"statement"},{"name":"use_mac_os_tts","type":"statement"},{"name":"user_agent","type":"statement"},{"name":"wipe_redis_on_start","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"ai_settings_file\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"AZURE_CONFIG_FILE\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"azure_model_to_deployment_id_map\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"browse_chunk_max_length\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"browse_summary_max_token\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"continuous_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"continuous_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"custom_search_engine_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"debug_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_voice_1_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_voice_2_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"execute_local_commands\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"fast_llm_model\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"fast_token_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"get_azure_deployment_id_for_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"github_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"github_username\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"google_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"huggingface_api_token\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"image_provider\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"load_azure_config\",\n \"type\": \"function\"\n },\n {\n \"name\": \"memory_backend\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"memory_index\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"milvus_addr\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"milvus_collection\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_base\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_version\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"pinecone_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"pinecone_region\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_host\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_password\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_port\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"set_browse_chunk_max_length\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_browse_summary_max_token\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_continuous_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_continuous_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_custom_search_engine_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_debug_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_voice_1_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_voice_2_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_fast_llm_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_fast_token_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_google_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_openai_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_pinecone_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_pinecone_region\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_smart_llm_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_smart_token_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_speak_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"skip_reprompt\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"smart_llm_model\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"smart_token_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"speak_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"temperature\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_azure\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_brian_tts\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_mac_os_tts\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"user_agent\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"wipe_redis_on_start\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"from autogpt import browse\nimport json\nfrom autogpt.memory import get_memory\nimport datetime\nimport autogpt.agent_manager as agents\nfrom autogpt import speak\nfrom autogpt.config import Config\nimport autogpt.ai_functions as ai\nfrom autogpt.file_operations import read_file, write_to_file, append_to_file, delete_file, search_files\nfrom autogpt.execute_code import execute_python_file, execute_shell\nfrom autogpt.json_parser import fix_and_parse_json\nfrom autogpt.image_gen import generate_image\nfrom duckduckgo_search import ddg\nfrom googleapiclient.discovery import build\nfrom googleapiclient.errors import HttpError\n\ncfg = Config()\n\n\ndef is_valid_int(value):\n try:\n int(value)\n return True\n except ValueError:\n return False\n\n\ndef get_command(response):\n \"\"\"Parse the response and return the command name and arguments\"\"\"\n try:\n response_json = fix_and_parse_json(response)\n\n if \"command\" not in response_json:\n return \"Error:\" , \"Missing 'command' object in JSON\"\n\n command = response_json[\"command\"]\n\n if \"name\" not in command:\n return \"Error:\", \"Missing 'name' field in 'command' object\"\n\n command_name = command[\"name\"]\n\n # Use an empty dictionary if 'args' field is not present in 'command' object\n arguments = command.get(\"args\", {})\n\n return command_name, arguments\n except json.decoder.JSONDecodeError:\n return \"Error:\", \"Invalid JSON\"\n # All other errors, return \"Error: + error message\"\n except Exception as e:\n return \"Error:\", str(e)\n\n\ndef execute_command(command_name, arguments):\n \"\"\"Execute the command and return the result\"\"\"\n memory = get_memory(cfg)\n\n try:\n if command_name == \"google\":\n\n # Check if the Google API key is set and use the official search method\n # If the API key is not set or has only whitespaces, use the unofficial search method\n if cfg.google_api_key and (cfg.google_api_key.strip() if cfg."}}},{"rowIdx":74,"cells":{"idx":{"kind":"number","value":99,"string":"99"},"idx_lca":{"kind":"number","value":4,"string":"4"},"offset":{"kind":"number","value":2249,"string":"2,249"},"repo":{"kind":"string","value":"Significant-Gravitas__Auto-GPT"},"commit_hash":{"kind":"string","value":"0569d6652fbffa665de6e42403a48783fbede8ce"},"target_file":{"kind":"string","value":"autogpt/commands.py"},"line_type_lca":{"kind":"string","value":"inproject"},"ground_truth":{"kind":"string","value":"add"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"function"},"non_dunder_count_intellij":{"kind":"number","value":12,"string":"12"},"non_dunder_count_jedi":{"kind":"number","value":12,"string":"12"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["get","cfg","get_stats","data","index","add","clear","dimension","filename","get_relevant","redis","vec_num","__init__","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__slots__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"get\",\n \"cfg\",\n \"get_stats\",\n \"data\",\n \"index\",\n \"add\",\n \"clear\",\n \"dimension\",\n \"filename\",\n \"get_relevant\",\n \"redis\",\n \"vec_num\",\n \"__init__\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__slots__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"add","type":"function"},{"name":"cfg","type":"statement"},{"name":"clear","type":"function"},{"name":"data","type":"statement"},{"name":"dimension","type":"statement"},{"name":"filename","type":"statement"},{"name":"get","type":"function"},{"name":"get_relevant","type":"function"},{"name":"get_stats","type":"function"},{"name":"index","type":"statement"},{"name":"redis","type":"statement"},{"name":"vec_num","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__bool__","type":"instance"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__ge__","type":"instance"},{"name":"__getattribute__","type":"function"},{"name":"__gt__","type":"instance"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__le__","type":"instance"},{"name":"__lt__","type":"instance"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"},{"name":"__subclasshook__","type":"function"}],"string":"[\n {\n \"name\": \"add\",\n \"type\": \"function\"\n },\n {\n \"name\": \"cfg\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"clear\",\n \"type\": \"function\"\n },\n {\n \"name\": \"data\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"dimension\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"filename\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"get\",\n \"type\": \"function\"\n },\n {\n \"name\": \"get_relevant\",\n \"type\": \"function\"\n },\n {\n \"name\": \"get_stats\",\n \"type\": \"function\"\n },\n {\n \"name\": \"index\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"vec_num\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__bool__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__ge__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__gt__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__le__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__lt__\",\n \"type\": \"instance\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__subclasshook__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"from autogpt import browse\nimport json\nfrom autogpt.memory import get_memory\nimport datetime\nimport autogpt.agent_manager as agents\nfrom autogpt import speak\nfrom autogpt.config import Config\nimport autogpt.ai_functions as ai\nfrom autogpt.file_operations import read_file, write_to_file, append_to_file, delete_file, search_files\nfrom autogpt.execute_code import execute_python_file, execute_shell\nfrom autogpt.json_parser import fix_and_parse_json\nfrom autogpt.image_gen import generate_image\nfrom duckduckgo_search import ddg\nfrom googleapiclient.discovery import build\nfrom googleapiclient.errors import HttpError\n\ncfg = Config()\n\n\ndef is_valid_int(value):\n try:\n int(value)\n return True\n except ValueError:\n return False\n\n\ndef get_command(response):\n \"\"\"Parse the response and return the command name and arguments\"\"\"\n try:\n response_json = fix_and_parse_json(response)\n\n if \"command\" not in response_json:\n return \"Error:\" , \"Missing 'command' object in JSON\"\n\n command = response_json[\"command\"]\n\n if \"name\" not in command:\n return \"Error:\", \"Missing 'name' field in 'command' object\"\n\n command_name = command[\"name\"]\n\n # Use an empty dictionary if 'args' field is not present in 'command' object\n arguments = command.get(\"args\", {})\n\n return command_name, arguments\n except json.decoder.JSONDecodeError:\n return \"Error:\", \"Invalid JSON\"\n # All other errors, return \"Error: + error message\"\n except Exception as e:\n return \"Error:\", str(e)\n\n\ndef execute_command(command_name, arguments):\n \"\"\"Execute the command and return the result\"\"\"\n memory = get_memory(cfg)\n\n try:\n if command_name == \"google\":\n\n # Check if the Google API key is set and use the official search method\n # If the API key is not set or has only whitespaces, use the unofficial search method\n if cfg.google_api_key and (cfg.google_api_key.strip() if cfg.google_api_key else None):\n return google_official_search(arguments[\"input\"])\n else:\n return google_search(arguments[\"input\"])\n elif command_name == \"memory_add\":\n return memory."}}},{"rowIdx":75,"cells":{"idx":{"kind":"number","value":100,"string":"100"},"idx_lca":{"kind":"number","value":4,"string":"4"},"offset":{"kind":"number","value":4500,"string":"4,500"},"repo":{"kind":"string","value":"Significant-Gravitas__Auto-GPT"},"commit_hash":{"kind":"string","value":"0569d6652fbffa665de6e42403a48783fbede8ce"},"target_file":{"kind":"string","value":"autogpt/commands.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"execute_local_commands"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":63,"string":"63"},"non_dunder_count_jedi":{"kind":"number","value":63,"string":"63"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["speak_mode","google_api_key","custom_search_engine_id","fast_llm_model","execute_local_commands","ai_settings_file","AZURE_CONFIG_FILE","azure_model_to_deployment_id_map","browse_chunk_max_length","browse_summary_max_token","continuous_limit","continuous_mode","debug_mode","elevenlabs_api_key","elevenlabs_voice_1_id","elevenlabs_voice_2_id","fast_token_limit","get_azure_deployment_id_for_model","github_api_key","github_username","huggingface_api_token","image_provider","load_azure_config","memory_backend","memory_index","milvus_addr","milvus_collection","openai_api_base","openai_api_key","openai_api_type","openai_api_version","pinecone_api_key","pinecone_region","redis_host","redis_password","redis_port","set_browse_chunk_max_length","set_browse_summary_max_token","set_continuous_limit","set_continuous_mode","set_custom_search_engine_id","set_debug_mode","set_elevenlabs_api_key","set_elevenlabs_voice_1_id","set_elevenlabs_voice_2_id","set_fast_llm_model","set_fast_token_limit","set_google_api_key","set_openai_api_key","set_pinecone_api_key","set_pinecone_region","set_smart_llm_model","set_smart_token_limit","set_speak_mode","skip_reprompt","smart_llm_model","smart_token_limit","temperature","use_azure","use_brian_tts","use_mac_os_tts","user_agent","wipe_redis_on_start","__init__","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"speak_mode\",\n \"google_api_key\",\n \"custom_search_engine_id\",\n \"fast_llm_model\",\n \"execute_local_commands\",\n \"ai_settings_file\",\n \"AZURE_CONFIG_FILE\",\n \"azure_model_to_deployment_id_map\",\n \"browse_chunk_max_length\",\n \"browse_summary_max_token\",\n \"continuous_limit\",\n \"continuous_mode\",\n \"debug_mode\",\n \"elevenlabs_api_key\",\n \"elevenlabs_voice_1_id\",\n \"elevenlabs_voice_2_id\",\n \"fast_token_limit\",\n \"get_azure_deployment_id_for_model\",\n \"github_api_key\",\n \"github_username\",\n \"huggingface_api_token\",\n \"image_provider\",\n \"load_azure_config\",\n \"memory_backend\",\n \"memory_index\",\n \"milvus_addr\",\n \"milvus_collection\",\n \"openai_api_base\",\n \"openai_api_key\",\n \"openai_api_type\",\n \"openai_api_version\",\n \"pinecone_api_key\",\n \"pinecone_region\",\n \"redis_host\",\n \"redis_password\",\n \"redis_port\",\n \"set_browse_chunk_max_length\",\n \"set_browse_summary_max_token\",\n \"set_continuous_limit\",\n \"set_continuous_mode\",\n \"set_custom_search_engine_id\",\n \"set_debug_mode\",\n \"set_elevenlabs_api_key\",\n \"set_elevenlabs_voice_1_id\",\n \"set_elevenlabs_voice_2_id\",\n \"set_fast_llm_model\",\n \"set_fast_token_limit\",\n \"set_google_api_key\",\n \"set_openai_api_key\",\n \"set_pinecone_api_key\",\n \"set_pinecone_region\",\n \"set_smart_llm_model\",\n \"set_smart_token_limit\",\n \"set_speak_mode\",\n \"skip_reprompt\",\n \"smart_llm_model\",\n \"smart_token_limit\",\n \"temperature\",\n \"use_azure\",\n \"use_brian_tts\",\n \"use_mac_os_tts\",\n \"user_agent\",\n \"wipe_redis_on_start\",\n \"__init__\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"ai_settings_file","type":"statement"},{"name":"AZURE_CONFIG_FILE","type":"statement"},{"name":"azure_model_to_deployment_id_map","type":"statement"},{"name":"browse_chunk_max_length","type":"statement"},{"name":"browse_summary_max_token","type":"statement"},{"name":"continuous_limit","type":"statement"},{"name":"continuous_mode","type":"statement"},{"name":"custom_search_engine_id","type":"statement"},{"name":"debug_mode","type":"statement"},{"name":"elevenlabs_api_key","type":"statement"},{"name":"elevenlabs_voice_1_id","type":"statement"},{"name":"elevenlabs_voice_2_id","type":"statement"},{"name":"execute_local_commands","type":"statement"},{"name":"fast_llm_model","type":"statement"},{"name":"fast_token_limit","type":"statement"},{"name":"get_azure_deployment_id_for_model","type":"function"},{"name":"github_api_key","type":"statement"},{"name":"github_username","type":"statement"},{"name":"google_api_key","type":"statement"},{"name":"huggingface_api_token","type":"statement"},{"name":"image_provider","type":"statement"},{"name":"load_azure_config","type":"function"},{"name":"memory_backend","type":"statement"},{"name":"memory_index","type":"statement"},{"name":"milvus_addr","type":"statement"},{"name":"milvus_collection","type":"statement"},{"name":"openai_api_base","type":"statement"},{"name":"openai_api_key","type":"statement"},{"name":"openai_api_type","type":"statement"},{"name":"openai_api_version","type":"statement"},{"name":"pinecone_api_key","type":"statement"},{"name":"pinecone_region","type":"statement"},{"name":"redis_host","type":"statement"},{"name":"redis_password","type":"statement"},{"name":"redis_port","type":"statement"},{"name":"set_browse_chunk_max_length","type":"function"},{"name":"set_browse_summary_max_token","type":"function"},{"name":"set_continuous_limit","type":"function"},{"name":"set_continuous_mode","type":"function"},{"name":"set_custom_search_engine_id","type":"function"},{"name":"set_debug_mode","type":"function"},{"name":"set_elevenlabs_api_key","type":"function"},{"name":"set_elevenlabs_voice_1_id","type":"function"},{"name":"set_elevenlabs_voice_2_id","type":"function"},{"name":"set_fast_llm_model","type":"function"},{"name":"set_fast_token_limit","type":"function"},{"name":"set_google_api_key","type":"function"},{"name":"set_openai_api_key","type":"function"},{"name":"set_pinecone_api_key","type":"function"},{"name":"set_pinecone_region","type":"function"},{"name":"set_smart_llm_model","type":"function"},{"name":"set_smart_token_limit","type":"function"},{"name":"set_speak_mode","type":"function"},{"name":"skip_reprompt","type":"statement"},{"name":"smart_llm_model","type":"statement"},{"name":"smart_token_limit","type":"statement"},{"name":"speak_mode","type":"statement"},{"name":"temperature","type":"statement"},{"name":"use_azure","type":"statement"},{"name":"use_brian_tts","type":"statement"},{"name":"use_mac_os_tts","type":"statement"},{"name":"user_agent","type":"statement"},{"name":"wipe_redis_on_start","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"ai_settings_file\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"AZURE_CONFIG_FILE\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"azure_model_to_deployment_id_map\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"browse_chunk_max_length\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"browse_summary_max_token\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"continuous_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"continuous_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"custom_search_engine_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"debug_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_voice_1_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_voice_2_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"execute_local_commands\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"fast_llm_model\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"fast_token_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"get_azure_deployment_id_for_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"github_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"github_username\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"google_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"huggingface_api_token\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"image_provider\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"load_azure_config\",\n \"type\": \"function\"\n },\n {\n \"name\": \"memory_backend\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"memory_index\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"milvus_addr\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"milvus_collection\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_base\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_version\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"pinecone_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"pinecone_region\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_host\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_password\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_port\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"set_browse_chunk_max_length\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_browse_summary_max_token\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_continuous_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_continuous_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_custom_search_engine_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_debug_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_voice_1_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_voice_2_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_fast_llm_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_fast_token_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_google_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_openai_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_pinecone_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_pinecone_region\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_smart_llm_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_smart_token_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_speak_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"skip_reprompt\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"smart_llm_model\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"smart_token_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"speak_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"temperature\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_azure\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_brian_tts\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_mac_os_tts\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"user_agent\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"wipe_redis_on_start\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"from autogpt import browse\nimport json\nfrom autogpt.memory import get_memory\nimport datetime\nimport autogpt.agent_manager as agents\nfrom autogpt import speak\nfrom autogpt.config import Config\nimport autogpt.ai_functions as ai\nfrom autogpt.file_operations import read_file, write_to_file, append_to_file, delete_file, search_files\nfrom autogpt.execute_code import execute_python_file, execute_shell\nfrom autogpt.json_parser import fix_and_parse_json\nfrom autogpt.image_gen import generate_image\nfrom duckduckgo_search import ddg\nfrom googleapiclient.discovery import build\nfrom googleapiclient.errors import HttpError\n\ncfg = Config()\n\n\ndef is_valid_int(value):\n try:\n int(value)\n return True\n except ValueError:\n return False\n\n\ndef get_command(response):\n \"\"\"Parse the response and return the command name and arguments\"\"\"\n try:\n response_json = fix_and_parse_json(response)\n\n if \"command\" not in response_json:\n return \"Error:\" , \"Missing 'command' object in JSON\"\n\n command = response_json[\"command\"]\n\n if \"name\" not in command:\n return \"Error:\", \"Missing 'name' field in 'command' object\"\n\n command_name = command[\"name\"]\n\n # Use an empty dictionary if 'args' field is not present in 'command' object\n arguments = command.get(\"args\", {})\n\n return command_name, arguments\n except json.decoder.JSONDecodeError:\n return \"Error:\", \"Invalid JSON\"\n # All other errors, return \"Error: + error message\"\n except Exception as e:\n return \"Error:\", str(e)\n\n\ndef execute_command(command_name, arguments):\n \"\"\"Execute the command and return the result\"\"\"\n memory = get_memory(cfg)\n\n try:\n if command_name == \"google\":\n\n # Check if the Google API key is set and use the official search method\n # If the API key is not set or has only whitespaces, use the unofficial search method\n if cfg.google_api_key and (cfg.google_api_key.strip() if cfg.google_api_key else None):\n return google_official_search(arguments[\"input\"])\n else:\n return google_search(arguments[\"input\"])\n elif command_name == \"memory_add\":\n return memory.add(arguments[\"string\"])\n elif command_name == \"start_agent\":\n return start_agent(\n arguments[\"name\"],\n arguments[\"task\"],\n arguments[\"prompt\"])\n elif command_name == \"message_agent\":\n return message_agent(arguments[\"key\"], arguments[\"message\"])\n elif command_name == \"list_agents\":\n return list_agents()\n elif command_name == \"delete_agent\":\n return delete_agent(arguments[\"key\"])\n elif command_name == \"get_text_summary\":\n return get_text_summary(arguments[\"url\"], arguments[\"question\"])\n elif command_name == \"get_hyperlinks\":\n return get_hyperlinks(arguments[\"url\"])\n elif command_name == \"clone_repository\":\n return clone_repository(arguments[\"repo_url\"], arguments[\"clone_path\"])\n elif command_name == \"read_file\":\n return read_file(arguments[\"file\"])\n elif command_name == \"write_to_file\":\n return write_to_file(arguments[\"file\"], arguments[\"text\"])\n elif command_name == \"append_to_file\":\n return append_to_file(arguments[\"file\"], arguments[\"text\"])\n elif command_name == \"delete_file\":\n return delete_file(arguments[\"file\"])\n elif command_name == \"search_files\":\n return search_files(arguments[\"directory\"])\n elif command_name == \"browse_website\":\n return browse_website(arguments[\"url\"], arguments[\"question\"])\n # TODO: Change these to take in a file rather than pasted code, if\n # non-file is given, return instructions \"Input should be a python\n # filepath, write your code to file and try again\"\n elif command_name == \"evaluate_code\":\n return ai.evaluate_code(arguments[\"code\"])\n elif command_name == \"improve_code\":\n return ai.improve_code(arguments[\"suggestions\"], arguments[\"code\"])\n elif command_name == \"write_tests\":\n return ai.write_tests(arguments[\"code\"], arguments.get(\"focus\"))\n elif command_name == \"execute_python_file\": # Add this command\n return execute_python_file(arguments[\"file\"])\n elif command_name == \"execute_shell\":\n if cfg."}}},{"rowIdx":76,"cells":{"idx":{"kind":"number","value":101,"string":"101"},"idx_lca":{"kind":"number","value":4,"string":"4"},"offset":{"kind":"number","value":6145,"string":"6,145"},"repo":{"kind":"string","value":"Significant-Gravitas__Auto-GPT"},"commit_hash":{"kind":"string","value":"0569d6652fbffa665de6e42403a48783fbede8ce"},"target_file":{"kind":"string","value":"autogpt/commands.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"google_api_key"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":63,"string":"63"},"non_dunder_count_jedi":{"kind":"number","value":63,"string":"63"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["google_api_key","custom_search_engine_id","set_google_api_key","fast_llm_model","github_api_key","ai_settings_file","AZURE_CONFIG_FILE","azure_model_to_deployment_id_map","browse_chunk_max_length","browse_summary_max_token","continuous_limit","continuous_mode","debug_mode","elevenlabs_api_key","elevenlabs_voice_1_id","elevenlabs_voice_2_id","execute_local_commands","fast_token_limit","get_azure_deployment_id_for_model","github_username","huggingface_api_token","image_provider","load_azure_config","memory_backend","memory_index","milvus_addr","milvus_collection","openai_api_base","openai_api_key","openai_api_type","openai_api_version","pinecone_api_key","pinecone_region","redis_host","redis_password","redis_port","set_browse_chunk_max_length","set_browse_summary_max_token","set_continuous_limit","set_continuous_mode","set_custom_search_engine_id","set_debug_mode","set_elevenlabs_api_key","set_elevenlabs_voice_1_id","set_elevenlabs_voice_2_id","set_fast_llm_model","set_fast_token_limit","set_openai_api_key","set_pinecone_api_key","set_pinecone_region","set_smart_llm_model","set_smart_token_limit","set_speak_mode","skip_reprompt","smart_llm_model","smart_token_limit","speak_mode","temperature","use_azure","use_brian_tts","use_mac_os_tts","user_agent","wipe_redis_on_start","__init__","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"google_api_key\",\n \"custom_search_engine_id\",\n \"set_google_api_key\",\n \"fast_llm_model\",\n \"github_api_key\",\n \"ai_settings_file\",\n \"AZURE_CONFIG_FILE\",\n \"azure_model_to_deployment_id_map\",\n \"browse_chunk_max_length\",\n \"browse_summary_max_token\",\n \"continuous_limit\",\n \"continuous_mode\",\n \"debug_mode\",\n \"elevenlabs_api_key\",\n \"elevenlabs_voice_1_id\",\n \"elevenlabs_voice_2_id\",\n \"execute_local_commands\",\n \"fast_token_limit\",\n \"get_azure_deployment_id_for_model\",\n \"github_username\",\n \"huggingface_api_token\",\n \"image_provider\",\n \"load_azure_config\",\n \"memory_backend\",\n \"memory_index\",\n \"milvus_addr\",\n \"milvus_collection\",\n \"openai_api_base\",\n \"openai_api_key\",\n \"openai_api_type\",\n \"openai_api_version\",\n \"pinecone_api_key\",\n \"pinecone_region\",\n \"redis_host\",\n \"redis_password\",\n \"redis_port\",\n \"set_browse_chunk_max_length\",\n \"set_browse_summary_max_token\",\n \"set_continuous_limit\",\n \"set_continuous_mode\",\n \"set_custom_search_engine_id\",\n \"set_debug_mode\",\n \"set_elevenlabs_api_key\",\n \"set_elevenlabs_voice_1_id\",\n \"set_elevenlabs_voice_2_id\",\n \"set_fast_llm_model\",\n \"set_fast_token_limit\",\n \"set_openai_api_key\",\n \"set_pinecone_api_key\",\n \"set_pinecone_region\",\n \"set_smart_llm_model\",\n \"set_smart_token_limit\",\n \"set_speak_mode\",\n \"skip_reprompt\",\n \"smart_llm_model\",\n \"smart_token_limit\",\n \"speak_mode\",\n \"temperature\",\n \"use_azure\",\n \"use_brian_tts\",\n \"use_mac_os_tts\",\n \"user_agent\",\n \"wipe_redis_on_start\",\n \"__init__\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"ai_settings_file","type":"statement"},{"name":"AZURE_CONFIG_FILE","type":"statement"},{"name":"azure_model_to_deployment_id_map","type":"statement"},{"name":"browse_chunk_max_length","type":"statement"},{"name":"browse_summary_max_token","type":"statement"},{"name":"continuous_limit","type":"statement"},{"name":"continuous_mode","type":"statement"},{"name":"custom_search_engine_id","type":"statement"},{"name":"debug_mode","type":"statement"},{"name":"elevenlabs_api_key","type":"statement"},{"name":"elevenlabs_voice_1_id","type":"statement"},{"name":"elevenlabs_voice_2_id","type":"statement"},{"name":"execute_local_commands","type":"statement"},{"name":"fast_llm_model","type":"statement"},{"name":"fast_token_limit","type":"statement"},{"name":"get_azure_deployment_id_for_model","type":"function"},{"name":"github_api_key","type":"statement"},{"name":"github_username","type":"statement"},{"name":"google_api_key","type":"statement"},{"name":"huggingface_api_token","type":"statement"},{"name":"image_provider","type":"statement"},{"name":"load_azure_config","type":"function"},{"name":"memory_backend","type":"statement"},{"name":"memory_index","type":"statement"},{"name":"milvus_addr","type":"statement"},{"name":"milvus_collection","type":"statement"},{"name":"openai_api_base","type":"statement"},{"name":"openai_api_key","type":"statement"},{"name":"openai_api_type","type":"statement"},{"name":"openai_api_version","type":"statement"},{"name":"pinecone_api_key","type":"statement"},{"name":"pinecone_region","type":"statement"},{"name":"redis_host","type":"statement"},{"name":"redis_password","type":"statement"},{"name":"redis_port","type":"statement"},{"name":"set_browse_chunk_max_length","type":"function"},{"name":"set_browse_summary_max_token","type":"function"},{"name":"set_continuous_limit","type":"function"},{"name":"set_continuous_mode","type":"function"},{"name":"set_custom_search_engine_id","type":"function"},{"name":"set_debug_mode","type":"function"},{"name":"set_elevenlabs_api_key","type":"function"},{"name":"set_elevenlabs_voice_1_id","type":"function"},{"name":"set_elevenlabs_voice_2_id","type":"function"},{"name":"set_fast_llm_model","type":"function"},{"name":"set_fast_token_limit","type":"function"},{"name":"set_google_api_key","type":"function"},{"name":"set_openai_api_key","type":"function"},{"name":"set_pinecone_api_key","type":"function"},{"name":"set_pinecone_region","type":"function"},{"name":"set_smart_llm_model","type":"function"},{"name":"set_smart_token_limit","type":"function"},{"name":"set_speak_mode","type":"function"},{"name":"skip_reprompt","type":"statement"},{"name":"smart_llm_model","type":"statement"},{"name":"smart_token_limit","type":"statement"},{"name":"speak_mode","type":"statement"},{"name":"temperature","type":"statement"},{"name":"use_azure","type":"statement"},{"name":"use_brian_tts","type":"statement"},{"name":"use_mac_os_tts","type":"statement"},{"name":"user_agent","type":"statement"},{"name":"wipe_redis_on_start","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"ai_settings_file\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"AZURE_CONFIG_FILE\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"azure_model_to_deployment_id_map\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"browse_chunk_max_length\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"browse_summary_max_token\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"continuous_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"continuous_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"custom_search_engine_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"debug_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_voice_1_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_voice_2_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"execute_local_commands\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"fast_llm_model\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"fast_token_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"get_azure_deployment_id_for_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"github_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"github_username\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"google_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"huggingface_api_token\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"image_provider\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"load_azure_config\",\n \"type\": \"function\"\n },\n {\n \"name\": \"memory_backend\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"memory_index\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"milvus_addr\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"milvus_collection\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_base\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_version\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"pinecone_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"pinecone_region\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_host\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_password\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_port\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"set_browse_chunk_max_length\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_browse_summary_max_token\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_continuous_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_continuous_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_custom_search_engine_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_debug_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_voice_1_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_voice_2_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_fast_llm_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_fast_token_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_google_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_openai_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_pinecone_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_pinecone_region\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_smart_llm_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_smart_token_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_speak_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"skip_reprompt\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"smart_llm_model\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"smart_token_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"speak_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"temperature\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_azure\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_brian_tts\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_mac_os_tts\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"user_agent\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"wipe_redis_on_start\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"from autogpt import browse\nimport json\nfrom autogpt.memory import get_memory\nimport datetime\nimport autogpt.agent_manager as agents\nfrom autogpt import speak\nfrom autogpt.config import Config\nimport autogpt.ai_functions as ai\nfrom autogpt.file_operations import read_file, write_to_file, append_to_file, delete_file, search_files\nfrom autogpt.execute_code import execute_python_file, execute_shell\nfrom autogpt.json_parser import fix_and_parse_json\nfrom autogpt.image_gen import generate_image\nfrom duckduckgo_search import ddg\nfrom googleapiclient.discovery import build\nfrom googleapiclient.errors import HttpError\n\ncfg = Config()\n\n\ndef is_valid_int(value):\n try:\n int(value)\n return True\n except ValueError:\n return False\n\n\ndef get_command(response):\n \"\"\"Parse the response and return the command name and arguments\"\"\"\n try:\n response_json = fix_and_parse_json(response)\n\n if \"command\" not in response_json:\n return \"Error:\" , \"Missing 'command' object in JSON\"\n\n command = response_json[\"command\"]\n\n if \"name\" not in command:\n return \"Error:\", \"Missing 'name' field in 'command' object\"\n\n command_name = command[\"name\"]\n\n # Use an empty dictionary if 'args' field is not present in 'command' object\n arguments = command.get(\"args\", {})\n\n return command_name, arguments\n except json.decoder.JSONDecodeError:\n return \"Error:\", \"Invalid JSON\"\n # All other errors, return \"Error: + error message\"\n except Exception as e:\n return \"Error:\", str(e)\n\n\ndef execute_command(command_name, arguments):\n \"\"\"Execute the command and return the result\"\"\"\n memory = get_memory(cfg)\n\n try:\n if command_name == \"google\":\n\n # Check if the Google API key is set and use the official search method\n # If the API key is not set or has only whitespaces, use the unofficial search method\n if cfg.google_api_key and (cfg.google_api_key.strip() if cfg.google_api_key else None):\n return google_official_search(arguments[\"input\"])\n else:\n return google_search(arguments[\"input\"])\n elif command_name == \"memory_add\":\n return memory.add(arguments[\"string\"])\n elif command_name == \"start_agent\":\n return start_agent(\n arguments[\"name\"],\n arguments[\"task\"],\n arguments[\"prompt\"])\n elif command_name == \"message_agent\":\n return message_agent(arguments[\"key\"], arguments[\"message\"])\n elif command_name == \"list_agents\":\n return list_agents()\n elif command_name == \"delete_agent\":\n return delete_agent(arguments[\"key\"])\n elif command_name == \"get_text_summary\":\n return get_text_summary(arguments[\"url\"], arguments[\"question\"])\n elif command_name == \"get_hyperlinks\":\n return get_hyperlinks(arguments[\"url\"])\n elif command_name == \"clone_repository\":\n return clone_repository(arguments[\"repo_url\"], arguments[\"clone_path\"])\n elif command_name == \"read_file\":\n return read_file(arguments[\"file\"])\n elif command_name == \"write_to_file\":\n return write_to_file(arguments[\"file\"], arguments[\"text\"])\n elif command_name == \"append_to_file\":\n return append_to_file(arguments[\"file\"], arguments[\"text\"])\n elif command_name == \"delete_file\":\n return delete_file(arguments[\"file\"])\n elif command_name == \"search_files\":\n return search_files(arguments[\"directory\"])\n elif command_name == \"browse_website\":\n return browse_website(arguments[\"url\"], arguments[\"question\"])\n # TODO: Change these to take in a file rather than pasted code, if\n # non-file is given, return instructions \"Input should be a python\n # filepath, write your code to file and try again\"\n elif command_name == \"evaluate_code\":\n return ai.evaluate_code(arguments[\"code\"])\n elif command_name == \"improve_code\":\n return ai.improve_code(arguments[\"suggestions\"], arguments[\"code\"])\n elif command_name == \"write_tests\":\n return ai.write_tests(arguments[\"code\"], arguments.get(\"focus\"))\n elif command_name == \"execute_python_file\": # Add this command\n return execute_python_file(arguments[\"file\"])\n elif command_name == \"execute_shell\":\n if cfg.execute_local_commands:\n return execute_shell(arguments[\"command_line\"])\n else:\n return \"You are not allowed to run local shell commands. To execute shell commands, EXECUTE_LOCAL_COMMANDS must be set to 'True' in your config. Do not attempt to bypass the restriction.\"\n elif command_name == \"generate_image\":\n return generate_image(arguments[\"prompt\"])\n elif command_name == \"do_nothing\":\n return \"No action performed.\"\n elif command_name == \"task_complete\":\n shutdown()\n else:\n return f\"Unknown command '{command_name}'. Please refer to the 'COMMANDS' list for available commands and only respond in the specified JSON format.\"\n # All errors, return \"Error: + error message\"\n except Exception as e:\n return \"Error: \" + str(e)\n\n\ndef get_datetime():\n \"\"\"Return the current date and time\"\"\"\n return \"Current date and time: \" + \\\n datetime.datetime.now().strftime(\"%Y-%m-%d %H:%M:%S\")\n\n\ndef google_search(query, num_results=8):\n \"\"\"Return the results of a google search\"\"\"\n search_results = []\n for j in ddg(query, max_results=num_results):\n search_results.append(j)\n\n return json.dumps(search_results, ensure_ascii=False, indent=4)\n\n\ndef google_official_search(query, num_results=8):\n \"\"\"Return the results of a google search using the official Google API\"\"\"\n from googleapiclient.discovery import build\n from googleapiclient.errors import HttpError\n import json\n\n try:\n # Get the Google API key and Custom Search Engine ID from the config file\n api_key = cfg."}}},{"rowIdx":77,"cells":{"idx":{"kind":"number","value":102,"string":"102"},"idx_lca":{"kind":"number","value":4,"string":"4"},"offset":{"kind":"number","value":6198,"string":"6,198"},"repo":{"kind":"string","value":"Significant-Gravitas__Auto-GPT"},"commit_hash":{"kind":"string","value":"0569d6652fbffa665de6e42403a48783fbede8ce"},"target_file":{"kind":"string","value":"autogpt/commands.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"custom_search_engine_id"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":63,"string":"63"},"non_dunder_count_jedi":{"kind":"number","value":63,"string":"63"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["custom_search_engine_id","google_api_key","set_custom_search_engine_id","fast_llm_model","speak_mode","ai_settings_file","AZURE_CONFIG_FILE","azure_model_to_deployment_id_map","browse_chunk_max_length","browse_summary_max_token","continuous_limit","continuous_mode","debug_mode","elevenlabs_api_key","elevenlabs_voice_1_id","elevenlabs_voice_2_id","execute_local_commands","fast_token_limit","get_azure_deployment_id_for_model","github_api_key","github_username","huggingface_api_token","image_provider","load_azure_config","memory_backend","memory_index","milvus_addr","milvus_collection","openai_api_base","openai_api_key","openai_api_type","openai_api_version","pinecone_api_key","pinecone_region","redis_host","redis_password","redis_port","set_browse_chunk_max_length","set_browse_summary_max_token","set_continuous_limit","set_continuous_mode","set_debug_mode","set_elevenlabs_api_key","set_elevenlabs_voice_1_id","set_elevenlabs_voice_2_id","set_fast_llm_model","set_fast_token_limit","set_google_api_key","set_openai_api_key","set_pinecone_api_key","set_pinecone_region","set_smart_llm_model","set_smart_token_limit","set_speak_mode","skip_reprompt","smart_llm_model","smart_token_limit","temperature","use_azure","use_brian_tts","use_mac_os_tts","user_agent","wipe_redis_on_start","__init__","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"custom_search_engine_id\",\n \"google_api_key\",\n \"set_custom_search_engine_id\",\n \"fast_llm_model\",\n \"speak_mode\",\n \"ai_settings_file\",\n \"AZURE_CONFIG_FILE\",\n \"azure_model_to_deployment_id_map\",\n \"browse_chunk_max_length\",\n \"browse_summary_max_token\",\n \"continuous_limit\",\n \"continuous_mode\",\n \"debug_mode\",\n \"elevenlabs_api_key\",\n \"elevenlabs_voice_1_id\",\n \"elevenlabs_voice_2_id\",\n \"execute_local_commands\",\n \"fast_token_limit\",\n \"get_azure_deployment_id_for_model\",\n \"github_api_key\",\n \"github_username\",\n \"huggingface_api_token\",\n \"image_provider\",\n \"load_azure_config\",\n \"memory_backend\",\n \"memory_index\",\n \"milvus_addr\",\n \"milvus_collection\",\n \"openai_api_base\",\n \"openai_api_key\",\n \"openai_api_type\",\n \"openai_api_version\",\n \"pinecone_api_key\",\n \"pinecone_region\",\n \"redis_host\",\n \"redis_password\",\n \"redis_port\",\n \"set_browse_chunk_max_length\",\n \"set_browse_summary_max_token\",\n \"set_continuous_limit\",\n \"set_continuous_mode\",\n \"set_debug_mode\",\n \"set_elevenlabs_api_key\",\n \"set_elevenlabs_voice_1_id\",\n \"set_elevenlabs_voice_2_id\",\n \"set_fast_llm_model\",\n \"set_fast_token_limit\",\n \"set_google_api_key\",\n \"set_openai_api_key\",\n \"set_pinecone_api_key\",\n \"set_pinecone_region\",\n \"set_smart_llm_model\",\n \"set_smart_token_limit\",\n \"set_speak_mode\",\n \"skip_reprompt\",\n \"smart_llm_model\",\n \"smart_token_limit\",\n \"temperature\",\n \"use_azure\",\n \"use_brian_tts\",\n \"use_mac_os_tts\",\n \"user_agent\",\n \"wipe_redis_on_start\",\n \"__init__\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"ai_settings_file","type":"statement"},{"name":"AZURE_CONFIG_FILE","type":"statement"},{"name":"azure_model_to_deployment_id_map","type":"statement"},{"name":"browse_chunk_max_length","type":"statement"},{"name":"browse_summary_max_token","type":"statement"},{"name":"continuous_limit","type":"statement"},{"name":"continuous_mode","type":"statement"},{"name":"custom_search_engine_id","type":"statement"},{"name":"debug_mode","type":"statement"},{"name":"elevenlabs_api_key","type":"statement"},{"name":"elevenlabs_voice_1_id","type":"statement"},{"name":"elevenlabs_voice_2_id","type":"statement"},{"name":"execute_local_commands","type":"statement"},{"name":"fast_llm_model","type":"statement"},{"name":"fast_token_limit","type":"statement"},{"name":"get_azure_deployment_id_for_model","type":"function"},{"name":"github_api_key","type":"statement"},{"name":"github_username","type":"statement"},{"name":"google_api_key","type":"statement"},{"name":"huggingface_api_token","type":"statement"},{"name":"image_provider","type":"statement"},{"name":"load_azure_config","type":"function"},{"name":"memory_backend","type":"statement"},{"name":"memory_index","type":"statement"},{"name":"milvus_addr","type":"statement"},{"name":"milvus_collection","type":"statement"},{"name":"openai_api_base","type":"statement"},{"name":"openai_api_key","type":"statement"},{"name":"openai_api_type","type":"statement"},{"name":"openai_api_version","type":"statement"},{"name":"pinecone_api_key","type":"statement"},{"name":"pinecone_region","type":"statement"},{"name":"redis_host","type":"statement"},{"name":"redis_password","type":"statement"},{"name":"redis_port","type":"statement"},{"name":"set_browse_chunk_max_length","type":"function"},{"name":"set_browse_summary_max_token","type":"function"},{"name":"set_continuous_limit","type":"function"},{"name":"set_continuous_mode","type":"function"},{"name":"set_custom_search_engine_id","type":"function"},{"name":"set_debug_mode","type":"function"},{"name":"set_elevenlabs_api_key","type":"function"},{"name":"set_elevenlabs_voice_1_id","type":"function"},{"name":"set_elevenlabs_voice_2_id","type":"function"},{"name":"set_fast_llm_model","type":"function"},{"name":"set_fast_token_limit","type":"function"},{"name":"set_google_api_key","type":"function"},{"name":"set_openai_api_key","type":"function"},{"name":"set_pinecone_api_key","type":"function"},{"name":"set_pinecone_region","type":"function"},{"name":"set_smart_llm_model","type":"function"},{"name":"set_smart_token_limit","type":"function"},{"name":"set_speak_mode","type":"function"},{"name":"skip_reprompt","type":"statement"},{"name":"smart_llm_model","type":"statement"},{"name":"smart_token_limit","type":"statement"},{"name":"speak_mode","type":"statement"},{"name":"temperature","type":"statement"},{"name":"use_azure","type":"statement"},{"name":"use_brian_tts","type":"statement"},{"name":"use_mac_os_tts","type":"statement"},{"name":"user_agent","type":"statement"},{"name":"wipe_redis_on_start","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"ai_settings_file\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"AZURE_CONFIG_FILE\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"azure_model_to_deployment_id_map\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"browse_chunk_max_length\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"browse_summary_max_token\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"continuous_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"continuous_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"custom_search_engine_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"debug_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_voice_1_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_voice_2_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"execute_local_commands\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"fast_llm_model\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"fast_token_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"get_azure_deployment_id_for_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"github_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"github_username\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"google_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"huggingface_api_token\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"image_provider\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"load_azure_config\",\n \"type\": \"function\"\n },\n {\n \"name\": \"memory_backend\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"memory_index\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"milvus_addr\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"milvus_collection\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_base\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_version\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"pinecone_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"pinecone_region\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_host\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_password\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_port\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"set_browse_chunk_max_length\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_browse_summary_max_token\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_continuous_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_continuous_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_custom_search_engine_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_debug_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_voice_1_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_voice_2_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_fast_llm_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_fast_token_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_google_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_openai_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_pinecone_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_pinecone_region\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_smart_llm_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_smart_token_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_speak_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"skip_reprompt\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"smart_llm_model\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"smart_token_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"speak_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"temperature\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_azure\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_brian_tts\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_mac_os_tts\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"user_agent\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"wipe_redis_on_start\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"from autogpt import browse\nimport json\nfrom autogpt.memory import get_memory\nimport datetime\nimport autogpt.agent_manager as agents\nfrom autogpt import speak\nfrom autogpt.config import Config\nimport autogpt.ai_functions as ai\nfrom autogpt.file_operations import read_file, write_to_file, append_to_file, delete_file, search_files\nfrom autogpt.execute_code import execute_python_file, execute_shell\nfrom autogpt.json_parser import fix_and_parse_json\nfrom autogpt.image_gen import generate_image\nfrom duckduckgo_search import ddg\nfrom googleapiclient.discovery import build\nfrom googleapiclient.errors import HttpError\n\ncfg = Config()\n\n\ndef is_valid_int(value):\n try:\n int(value)\n return True\n except ValueError:\n return False\n\n\ndef get_command(response):\n \"\"\"Parse the response and return the command name and arguments\"\"\"\n try:\n response_json = fix_and_parse_json(response)\n\n if \"command\" not in response_json:\n return \"Error:\" , \"Missing 'command' object in JSON\"\n\n command = response_json[\"command\"]\n\n if \"name\" not in command:\n return \"Error:\", \"Missing 'name' field in 'command' object\"\n\n command_name = command[\"name\"]\n\n # Use an empty dictionary if 'args' field is not present in 'command' object\n arguments = command.get(\"args\", {})\n\n return command_name, arguments\n except json.decoder.JSONDecodeError:\n return \"Error:\", \"Invalid JSON\"\n # All other errors, return \"Error: + error message\"\n except Exception as e:\n return \"Error:\", str(e)\n\n\ndef execute_command(command_name, arguments):\n \"\"\"Execute the command and return the result\"\"\"\n memory = get_memory(cfg)\n\n try:\n if command_name == \"google\":\n\n # Check if the Google API key is set and use the official search method\n # If the API key is not set or has only whitespaces, use the unofficial search method\n if cfg.google_api_key and (cfg.google_api_key.strip() if cfg.google_api_key else None):\n return google_official_search(arguments[\"input\"])\n else:\n return google_search(arguments[\"input\"])\n elif command_name == \"memory_add\":\n return memory.add(arguments[\"string\"])\n elif command_name == \"start_agent\":\n return start_agent(\n arguments[\"name\"],\n arguments[\"task\"],\n arguments[\"prompt\"])\n elif command_name == \"message_agent\":\n return message_agent(arguments[\"key\"], arguments[\"message\"])\n elif command_name == \"list_agents\":\n return list_agents()\n elif command_name == \"delete_agent\":\n return delete_agent(arguments[\"key\"])\n elif command_name == \"get_text_summary\":\n return get_text_summary(arguments[\"url\"], arguments[\"question\"])\n elif command_name == \"get_hyperlinks\":\n return get_hyperlinks(arguments[\"url\"])\n elif command_name == \"clone_repository\":\n return clone_repository(arguments[\"repo_url\"], arguments[\"clone_path\"])\n elif command_name == \"read_file\":\n return read_file(arguments[\"file\"])\n elif command_name == \"write_to_file\":\n return write_to_file(arguments[\"file\"], arguments[\"text\"])\n elif command_name == \"append_to_file\":\n return append_to_file(arguments[\"file\"], arguments[\"text\"])\n elif command_name == \"delete_file\":\n return delete_file(arguments[\"file\"])\n elif command_name == \"search_files\":\n return search_files(arguments[\"directory\"])\n elif command_name == \"browse_website\":\n return browse_website(arguments[\"url\"], arguments[\"question\"])\n # TODO: Change these to take in a file rather than pasted code, if\n # non-file is given, return instructions \"Input should be a python\n # filepath, write your code to file and try again\"\n elif command_name == \"evaluate_code\":\n return ai.evaluate_code(arguments[\"code\"])\n elif command_name == \"improve_code\":\n return ai.improve_code(arguments[\"suggestions\"], arguments[\"code\"])\n elif command_name == \"write_tests\":\n return ai.write_tests(arguments[\"code\"], arguments.get(\"focus\"))\n elif command_name == \"execute_python_file\": # Add this command\n return execute_python_file(arguments[\"file\"])\n elif command_name == \"execute_shell\":\n if cfg.execute_local_commands:\n return execute_shell(arguments[\"command_line\"])\n else:\n return \"You are not allowed to run local shell commands. To execute shell commands, EXECUTE_LOCAL_COMMANDS must be set to 'True' in your config. Do not attempt to bypass the restriction.\"\n elif command_name == \"generate_image\":\n return generate_image(arguments[\"prompt\"])\n elif command_name == \"do_nothing\":\n return \"No action performed.\"\n elif command_name == \"task_complete\":\n shutdown()\n else:\n return f\"Unknown command '{command_name}'. Please refer to the 'COMMANDS' list for available commands and only respond in the specified JSON format.\"\n # All errors, return \"Error: + error message\"\n except Exception as e:\n return \"Error: \" + str(e)\n\n\ndef get_datetime():\n \"\"\"Return the current date and time\"\"\"\n return \"Current date and time: \" + \\\n datetime.datetime.now().strftime(\"%Y-%m-%d %H:%M:%S\")\n\n\ndef google_search(query, num_results=8):\n \"\"\"Return the results of a google search\"\"\"\n search_results = []\n for j in ddg(query, max_results=num_results):\n search_results.append(j)\n\n return json.dumps(search_results, ensure_ascii=False, indent=4)\n\n\ndef google_official_search(query, num_results=8):\n \"\"\"Return the results of a google search using the official Google API\"\"\"\n from googleapiclient.discovery import build\n from googleapiclient.errors import HttpError\n import json\n\n try:\n # Get the Google API key and Custom Search Engine ID from the config file\n api_key = cfg.google_api_key\n custom_search_engine_id = cfg."}}},{"rowIdx":78,"cells":{"idx":{"kind":"number","value":103,"string":"103"},"idx_lca":{"kind":"number","value":4,"string":"4"},"offset":{"kind":"number","value":9742,"string":"9,742"},"repo":{"kind":"string","value":"Significant-Gravitas__Auto-GPT"},"commit_hash":{"kind":"string","value":"0569d6652fbffa665de6e42403a48783fbede8ce"},"target_file":{"kind":"string","value":"autogpt/commands.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"fast_llm_model"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":63,"string":"63"},"non_dunder_count_jedi":{"kind":"number","value":63,"string":"63"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["google_api_key","speak_mode","custom_search_engine_id","execute_local_commands","user_agent","ai_settings_file","AZURE_CONFIG_FILE","azure_model_to_deployment_id_map","browse_chunk_max_length","browse_summary_max_token","continuous_limit","continuous_mode","debug_mode","elevenlabs_api_key","elevenlabs_voice_1_id","elevenlabs_voice_2_id","fast_llm_model","fast_token_limit","get_azure_deployment_id_for_model","github_api_key","github_username","huggingface_api_token","image_provider","load_azure_config","memory_backend","memory_index","milvus_addr","milvus_collection","openai_api_base","openai_api_key","openai_api_type","openai_api_version","pinecone_api_key","pinecone_region","redis_host","redis_password","redis_port","set_browse_chunk_max_length","set_browse_summary_max_token","set_continuous_limit","set_continuous_mode","set_custom_search_engine_id","set_debug_mode","set_elevenlabs_api_key","set_elevenlabs_voice_1_id","set_elevenlabs_voice_2_id","set_fast_llm_model","set_fast_token_limit","set_google_api_key","set_openai_api_key","set_pinecone_api_key","set_pinecone_region","set_smart_llm_model","set_smart_token_limit","set_speak_mode","skip_reprompt","smart_llm_model","smart_token_limit","temperature","use_azure","use_brian_tts","use_mac_os_tts","wipe_redis_on_start","__init__","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"google_api_key\",\n \"speak_mode\",\n \"custom_search_engine_id\",\n \"execute_local_commands\",\n \"user_agent\",\n \"ai_settings_file\",\n \"AZURE_CONFIG_FILE\",\n \"azure_model_to_deployment_id_map\",\n \"browse_chunk_max_length\",\n \"browse_summary_max_token\",\n \"continuous_limit\",\n \"continuous_mode\",\n \"debug_mode\",\n \"elevenlabs_api_key\",\n \"elevenlabs_voice_1_id\",\n \"elevenlabs_voice_2_id\",\n \"fast_llm_model\",\n \"fast_token_limit\",\n \"get_azure_deployment_id_for_model\",\n \"github_api_key\",\n \"github_username\",\n \"huggingface_api_token\",\n \"image_provider\",\n \"load_azure_config\",\n \"memory_backend\",\n \"memory_index\",\n \"milvus_addr\",\n \"milvus_collection\",\n \"openai_api_base\",\n \"openai_api_key\",\n \"openai_api_type\",\n \"openai_api_version\",\n \"pinecone_api_key\",\n \"pinecone_region\",\n \"redis_host\",\n \"redis_password\",\n \"redis_port\",\n \"set_browse_chunk_max_length\",\n \"set_browse_summary_max_token\",\n \"set_continuous_limit\",\n \"set_continuous_mode\",\n \"set_custom_search_engine_id\",\n \"set_debug_mode\",\n \"set_elevenlabs_api_key\",\n \"set_elevenlabs_voice_1_id\",\n \"set_elevenlabs_voice_2_id\",\n \"set_fast_llm_model\",\n \"set_fast_token_limit\",\n \"set_google_api_key\",\n \"set_openai_api_key\",\n \"set_pinecone_api_key\",\n \"set_pinecone_region\",\n \"set_smart_llm_model\",\n \"set_smart_token_limit\",\n \"set_speak_mode\",\n \"skip_reprompt\",\n \"smart_llm_model\",\n \"smart_token_limit\",\n \"temperature\",\n \"use_azure\",\n \"use_brian_tts\",\n \"use_mac_os_tts\",\n \"wipe_redis_on_start\",\n \"__init__\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"ai_settings_file","type":"statement"},{"name":"AZURE_CONFIG_FILE","type":"statement"},{"name":"azure_model_to_deployment_id_map","type":"statement"},{"name":"browse_chunk_max_length","type":"statement"},{"name":"browse_summary_max_token","type":"statement"},{"name":"continuous_limit","type":"statement"},{"name":"continuous_mode","type":"statement"},{"name":"custom_search_engine_id","type":"statement"},{"name":"debug_mode","type":"statement"},{"name":"elevenlabs_api_key","type":"statement"},{"name":"elevenlabs_voice_1_id","type":"statement"},{"name":"elevenlabs_voice_2_id","type":"statement"},{"name":"execute_local_commands","type":"statement"},{"name":"fast_llm_model","type":"statement"},{"name":"fast_token_limit","type":"statement"},{"name":"get_azure_deployment_id_for_model","type":"function"},{"name":"github_api_key","type":"statement"},{"name":"github_username","type":"statement"},{"name":"google_api_key","type":"statement"},{"name":"huggingface_api_token","type":"statement"},{"name":"image_provider","type":"statement"},{"name":"load_azure_config","type":"function"},{"name":"memory_backend","type":"statement"},{"name":"memory_index","type":"statement"},{"name":"milvus_addr","type":"statement"},{"name":"milvus_collection","type":"statement"},{"name":"openai_api_base","type":"statement"},{"name":"openai_api_key","type":"statement"},{"name":"openai_api_type","type":"statement"},{"name":"openai_api_version","type":"statement"},{"name":"pinecone_api_key","type":"statement"},{"name":"pinecone_region","type":"statement"},{"name":"redis_host","type":"statement"},{"name":"redis_password","type":"statement"},{"name":"redis_port","type":"statement"},{"name":"set_browse_chunk_max_length","type":"function"},{"name":"set_browse_summary_max_token","type":"function"},{"name":"set_continuous_limit","type":"function"},{"name":"set_continuous_mode","type":"function"},{"name":"set_custom_search_engine_id","type":"function"},{"name":"set_debug_mode","type":"function"},{"name":"set_elevenlabs_api_key","type":"function"},{"name":"set_elevenlabs_voice_1_id","type":"function"},{"name":"set_elevenlabs_voice_2_id","type":"function"},{"name":"set_fast_llm_model","type":"function"},{"name":"set_fast_token_limit","type":"function"},{"name":"set_google_api_key","type":"function"},{"name":"set_openai_api_key","type":"function"},{"name":"set_pinecone_api_key","type":"function"},{"name":"set_pinecone_region","type":"function"},{"name":"set_smart_llm_model","type":"function"},{"name":"set_smart_token_limit","type":"function"},{"name":"set_speak_mode","type":"function"},{"name":"skip_reprompt","type":"statement"},{"name":"smart_llm_model","type":"statement"},{"name":"smart_token_limit","type":"statement"},{"name":"speak_mode","type":"statement"},{"name":"temperature","type":"statement"},{"name":"use_azure","type":"statement"},{"name":"use_brian_tts","type":"statement"},{"name":"use_mac_os_tts","type":"statement"},{"name":"user_agent","type":"statement"},{"name":"wipe_redis_on_start","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"ai_settings_file\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"AZURE_CONFIG_FILE\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"azure_model_to_deployment_id_map\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"browse_chunk_max_length\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"browse_summary_max_token\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"continuous_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"continuous_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"custom_search_engine_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"debug_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_voice_1_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_voice_2_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"execute_local_commands\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"fast_llm_model\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"fast_token_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"get_azure_deployment_id_for_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"github_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"github_username\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"google_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"huggingface_api_token\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"image_provider\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"load_azure_config\",\n \"type\": \"function\"\n },\n {\n \"name\": \"memory_backend\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"memory_index\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"milvus_addr\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"milvus_collection\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_base\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_version\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"pinecone_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"pinecone_region\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_host\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_password\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_port\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"set_browse_chunk_max_length\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_browse_summary_max_token\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_continuous_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_continuous_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_custom_search_engine_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_debug_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_voice_1_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_voice_2_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_fast_llm_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_fast_token_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_google_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_openai_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_pinecone_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_pinecone_region\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_smart_llm_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_smart_token_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_speak_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"skip_reprompt\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"smart_llm_model\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"smart_token_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"speak_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"temperature\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_azure\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_brian_tts\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_mac_os_tts\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"user_agent\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"wipe_redis_on_start\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"from autogpt import browse\nimport json\nfrom autogpt.memory import get_memory\nimport datetime\nimport autogpt.agent_manager as agents\nfrom autogpt import speak\nfrom autogpt.config import Config\nimport autogpt.ai_functions as ai\nfrom autogpt.file_operations import read_file, write_to_file, append_to_file, delete_file, search_files\nfrom autogpt.execute_code import execute_python_file, execute_shell\nfrom autogpt.json_parser import fix_and_parse_json\nfrom autogpt.image_gen import generate_image\nfrom duckduckgo_search import ddg\nfrom googleapiclient.discovery import build\nfrom googleapiclient.errors import HttpError\n\ncfg = Config()\n\n\ndef is_valid_int(value):\n try:\n int(value)\n return True\n except ValueError:\n return False\n\n\ndef get_command(response):\n \"\"\"Parse the response and return the command name and arguments\"\"\"\n try:\n response_json = fix_and_parse_json(response)\n\n if \"command\" not in response_json:\n return \"Error:\" , \"Missing 'command' object in JSON\"\n\n command = response_json[\"command\"]\n\n if \"name\" not in command:\n return \"Error:\", \"Missing 'name' field in 'command' object\"\n\n command_name = command[\"name\"]\n\n # Use an empty dictionary if 'args' field is not present in 'command' object\n arguments = command.get(\"args\", {})\n\n return command_name, arguments\n except json.decoder.JSONDecodeError:\n return \"Error:\", \"Invalid JSON\"\n # All other errors, return \"Error: + error message\"\n except Exception as e:\n return \"Error:\", str(e)\n\n\ndef execute_command(command_name, arguments):\n \"\"\"Execute the command and return the result\"\"\"\n memory = get_memory(cfg)\n\n try:\n if command_name == \"google\":\n\n # Check if the Google API key is set and use the official search method\n # If the API key is not set or has only whitespaces, use the unofficial search method\n if cfg.google_api_key and (cfg.google_api_key.strip() if cfg.google_api_key else None):\n return google_official_search(arguments[\"input\"])\n else:\n return google_search(arguments[\"input\"])\n elif command_name == \"memory_add\":\n return memory.add(arguments[\"string\"])\n elif command_name == \"start_agent\":\n return start_agent(\n arguments[\"name\"],\n arguments[\"task\"],\n arguments[\"prompt\"])\n elif command_name == \"message_agent\":\n return message_agent(arguments[\"key\"], arguments[\"message\"])\n elif command_name == \"list_agents\":\n return list_agents()\n elif command_name == \"delete_agent\":\n return delete_agent(arguments[\"key\"])\n elif command_name == \"get_text_summary\":\n return get_text_summary(arguments[\"url\"], arguments[\"question\"])\n elif command_name == \"get_hyperlinks\":\n return get_hyperlinks(arguments[\"url\"])\n elif command_name == \"clone_repository\":\n return clone_repository(arguments[\"repo_url\"], arguments[\"clone_path\"])\n elif command_name == \"read_file\":\n return read_file(arguments[\"file\"])\n elif command_name == \"write_to_file\":\n return write_to_file(arguments[\"file\"], arguments[\"text\"])\n elif command_name == \"append_to_file\":\n return append_to_file(arguments[\"file\"], arguments[\"text\"])\n elif command_name == \"delete_file\":\n return delete_file(arguments[\"file\"])\n elif command_name == \"search_files\":\n return search_files(arguments[\"directory\"])\n elif command_name == \"browse_website\":\n return browse_website(arguments[\"url\"], arguments[\"question\"])\n # TODO: Change these to take in a file rather than pasted code, if\n # non-file is given, return instructions \"Input should be a python\n # filepath, write your code to file and try again\"\n elif command_name == \"evaluate_code\":\n return ai.evaluate_code(arguments[\"code\"])\n elif command_name == \"improve_code\":\n return ai.improve_code(arguments[\"suggestions\"], arguments[\"code\"])\n elif command_name == \"write_tests\":\n return ai.write_tests(arguments[\"code\"], arguments.get(\"focus\"))\n elif command_name == \"execute_python_file\": # Add this command\n return execute_python_file(arguments[\"file\"])\n elif command_name == \"execute_shell\":\n if cfg.execute_local_commands:\n return execute_shell(arguments[\"command_line\"])\n else:\n return \"You are not allowed to run local shell commands. To execute shell commands, EXECUTE_LOCAL_COMMANDS must be set to 'True' in your config. Do not attempt to bypass the restriction.\"\n elif command_name == \"generate_image\":\n return generate_image(arguments[\"prompt\"])\n elif command_name == \"do_nothing\":\n return \"No action performed.\"\n elif command_name == \"task_complete\":\n shutdown()\n else:\n return f\"Unknown command '{command_name}'. Please refer to the 'COMMANDS' list for available commands and only respond in the specified JSON format.\"\n # All errors, return \"Error: + error message\"\n except Exception as e:\n return \"Error: \" + str(e)\n\n\ndef get_datetime():\n \"\"\"Return the current date and time\"\"\"\n return \"Current date and time: \" + \\\n datetime.datetime.now().strftime(\"%Y-%m-%d %H:%M:%S\")\n\n\ndef google_search(query, num_results=8):\n \"\"\"Return the results of a google search\"\"\"\n search_results = []\n for j in ddg(query, max_results=num_results):\n search_results.append(j)\n\n return json.dumps(search_results, ensure_ascii=False, indent=4)\n\n\ndef google_official_search(query, num_results=8):\n \"\"\"Return the results of a google search using the official Google API\"\"\"\n from googleapiclient.discovery import build\n from googleapiclient.errors import HttpError\n import json\n\n try:\n # Get the Google API key and Custom Search Engine ID from the config file\n api_key = cfg.google_api_key\n custom_search_engine_id = cfg.custom_search_engine_id\n\n # Initialize the Custom Search API service\n service = build(\"customsearch\", \"v1\", developerKey=api_key)\n\n # Send the search query and retrieve the results\n result = service.cse().list(q=query, cx=custom_search_engine_id, num=num_results).execute()\n\n # Extract the search result items from the response\n search_results = result.get(\"items\", [])\n\n # Create a list of only the URLs from the search results\n search_results_links = [item[\"link\"] for item in search_results]\n\n except HttpError as e:\n # Handle errors in the API call\n error_details = json.loads(e.content.decode())\n\n # Check if the error is related to an invalid or missing API key\n if error_details.get(\"error\", {}).get(\"code\") == 403 and \"invalid API key\" in error_details.get(\"error\", {}).get(\"message\", \"\"):\n return \"Error: The provided Google API key is invalid or missing.\"\n else:\n return f\"Error: {e}\"\n\n # Return the list of search result URLs\n return search_results_links\n\n\ndef browse_website(url, question):\n \"\"\"Browse a website and return the summary and links\"\"\"\n summary = get_text_summary(url, question)\n links = get_hyperlinks(url)\n\n # Limit links to 5\n if len(links) > 5:\n links = links[:5]\n\n result = f\"\"\"Website Content Summary: {summary}\\n\\nLinks: {links}\"\"\"\n\n return result\n\n\ndef get_text_summary(url, question):\n \"\"\"Return the results of a google search\"\"\"\n text = browse.scrape_text(url)\n summary = browse.summarize_text(url, text, question)\n return \"\"\" \"Result\" : \"\"\" + summary\n\n\ndef get_hyperlinks(url):\n \"\"\"Return the results of a google search\"\"\"\n link_list = browse.scrape_links(url)\n return link_list\n\n\ndef commit_memory(string):\n \"\"\"Commit a string to memory\"\"\"\n _text = f\"\"\"Committing memory with string \"{string}\" \"\"\"\n mem.permanent_memory.append(string)\n return _text\n\n\ndef delete_memory(key):\n \"\"\"Delete a memory with a given key\"\"\"\n if key >= 0 and key < len(mem.permanent_memory):\n _text = \"Deleting memory with key \" + str(key)\n del mem.permanent_memory[key]\n print(_text)\n return _text\n else:\n print(\"Invalid key, cannot delete memory.\")\n return None\n\n\ndef overwrite_memory(key, string):\n \"\"\"Overwrite a memory with a given key and string\"\"\"\n # Check if the key is a valid integer\n if is_valid_int(key):\n key_int = int(key)\n # Check if the integer key is within the range of the permanent_memory list\n if 0 <= key_int < len(mem.permanent_memory):\n _text = \"Overwriting memory with key \" + str(key) + \" and string \" + string\n # Overwrite the memory slot with the given integer key and string\n mem.permanent_memory[key_int] = string\n print(_text)\n return _text\n else:\n print(f\"Invalid key '{key}', out of range.\")\n return None\n # Check if the key is a valid string\n elif isinstance(key, str):\n _text = \"Overwriting memory with key \" + key + \" and string \" + string\n # Overwrite the memory slot with the given string key and string\n mem.permanent_memory[key] = string\n print(_text)\n return _text\n else:\n print(f\"Invalid key '{key}', must be an integer or a string.\")\n return None\n\n\ndef shutdown():\n \"\"\"Shut down the program\"\"\"\n print(\"Shutting down...\")\n quit()\n\n\ndef start_agent(name, task, prompt, model=cfg."}}},{"rowIdx":79,"cells":{"idx":{"kind":"number","value":104,"string":"104"},"idx_lca":{"kind":"number","value":4,"string":"4"},"offset":{"kind":"number","value":10077,"string":"10,077"},"repo":{"kind":"string","value":"Significant-Gravitas__Auto-GPT"},"commit_hash":{"kind":"string","value":"0569d6652fbffa665de6e42403a48783fbede8ce"},"target_file":{"kind":"string","value":"autogpt/commands.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"speak_mode"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":63,"string":"63"},"non_dunder_count_jedi":{"kind":"number","value":63,"string":"63"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["speak_mode","google_api_key","fast_llm_model","execute_local_commands","custom_search_engine_id","ai_settings_file","AZURE_CONFIG_FILE","azure_model_to_deployment_id_map","browse_chunk_max_length","browse_summary_max_token","continuous_limit","continuous_mode","debug_mode","elevenlabs_api_key","elevenlabs_voice_1_id","elevenlabs_voice_2_id","fast_token_limit","get_azure_deployment_id_for_model","github_api_key","github_username","huggingface_api_token","image_provider","load_azure_config","memory_backend","memory_index","milvus_addr","milvus_collection","openai_api_base","openai_api_key","openai_api_type","openai_api_version","pinecone_api_key","pinecone_region","redis_host","redis_password","redis_port","set_browse_chunk_max_length","set_browse_summary_max_token","set_continuous_limit","set_continuous_mode","set_custom_search_engine_id","set_debug_mode","set_elevenlabs_api_key","set_elevenlabs_voice_1_id","set_elevenlabs_voice_2_id","set_fast_llm_model","set_fast_token_limit","set_google_api_key","set_openai_api_key","set_pinecone_api_key","set_pinecone_region","set_smart_llm_model","set_smart_token_limit","set_speak_mode","skip_reprompt","smart_llm_model","smart_token_limit","temperature","use_azure","use_brian_tts","use_mac_os_tts","user_agent","wipe_redis_on_start","__init__","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"speak_mode\",\n \"google_api_key\",\n \"fast_llm_model\",\n \"execute_local_commands\",\n \"custom_search_engine_id\",\n \"ai_settings_file\",\n \"AZURE_CONFIG_FILE\",\n \"azure_model_to_deployment_id_map\",\n \"browse_chunk_max_length\",\n \"browse_summary_max_token\",\n \"continuous_limit\",\n \"continuous_mode\",\n \"debug_mode\",\n \"elevenlabs_api_key\",\n \"elevenlabs_voice_1_id\",\n \"elevenlabs_voice_2_id\",\n \"fast_token_limit\",\n \"get_azure_deployment_id_for_model\",\n \"github_api_key\",\n \"github_username\",\n \"huggingface_api_token\",\n \"image_provider\",\n \"load_azure_config\",\n \"memory_backend\",\n \"memory_index\",\n \"milvus_addr\",\n \"milvus_collection\",\n \"openai_api_base\",\n \"openai_api_key\",\n \"openai_api_type\",\n \"openai_api_version\",\n \"pinecone_api_key\",\n \"pinecone_region\",\n \"redis_host\",\n \"redis_password\",\n \"redis_port\",\n \"set_browse_chunk_max_length\",\n \"set_browse_summary_max_token\",\n \"set_continuous_limit\",\n \"set_continuous_mode\",\n \"set_custom_search_engine_id\",\n \"set_debug_mode\",\n \"set_elevenlabs_api_key\",\n \"set_elevenlabs_voice_1_id\",\n \"set_elevenlabs_voice_2_id\",\n \"set_fast_llm_model\",\n \"set_fast_token_limit\",\n \"set_google_api_key\",\n \"set_openai_api_key\",\n \"set_pinecone_api_key\",\n \"set_pinecone_region\",\n \"set_smart_llm_model\",\n \"set_smart_token_limit\",\n \"set_speak_mode\",\n \"skip_reprompt\",\n \"smart_llm_model\",\n \"smart_token_limit\",\n \"temperature\",\n \"use_azure\",\n \"use_brian_tts\",\n \"use_mac_os_tts\",\n \"user_agent\",\n \"wipe_redis_on_start\",\n \"__init__\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"ai_settings_file","type":"statement"},{"name":"AZURE_CONFIG_FILE","type":"statement"},{"name":"azure_model_to_deployment_id_map","type":"statement"},{"name":"browse_chunk_max_length","type":"statement"},{"name":"browse_summary_max_token","type":"statement"},{"name":"continuous_limit","type":"statement"},{"name":"continuous_mode","type":"statement"},{"name":"custom_search_engine_id","type":"statement"},{"name":"debug_mode","type":"statement"},{"name":"elevenlabs_api_key","type":"statement"},{"name":"elevenlabs_voice_1_id","type":"statement"},{"name":"elevenlabs_voice_2_id","type":"statement"},{"name":"execute_local_commands","type":"statement"},{"name":"fast_llm_model","type":"statement"},{"name":"fast_token_limit","type":"statement"},{"name":"get_azure_deployment_id_for_model","type":"function"},{"name":"github_api_key","type":"statement"},{"name":"github_username","type":"statement"},{"name":"google_api_key","type":"statement"},{"name":"huggingface_api_token","type":"statement"},{"name":"image_provider","type":"statement"},{"name":"load_azure_config","type":"function"},{"name":"memory_backend","type":"statement"},{"name":"memory_index","type":"statement"},{"name":"milvus_addr","type":"statement"},{"name":"milvus_collection","type":"statement"},{"name":"openai_api_base","type":"statement"},{"name":"openai_api_key","type":"statement"},{"name":"openai_api_type","type":"statement"},{"name":"openai_api_version","type":"statement"},{"name":"pinecone_api_key","type":"statement"},{"name":"pinecone_region","type":"statement"},{"name":"redis_host","type":"statement"},{"name":"redis_password","type":"statement"},{"name":"redis_port","type":"statement"},{"name":"set_browse_chunk_max_length","type":"function"},{"name":"set_browse_summary_max_token","type":"function"},{"name":"set_continuous_limit","type":"function"},{"name":"set_continuous_mode","type":"function"},{"name":"set_custom_search_engine_id","type":"function"},{"name":"set_debug_mode","type":"function"},{"name":"set_elevenlabs_api_key","type":"function"},{"name":"set_elevenlabs_voice_1_id","type":"function"},{"name":"set_elevenlabs_voice_2_id","type":"function"},{"name":"set_fast_llm_model","type":"function"},{"name":"set_fast_token_limit","type":"function"},{"name":"set_google_api_key","type":"function"},{"name":"set_openai_api_key","type":"function"},{"name":"set_pinecone_api_key","type":"function"},{"name":"set_pinecone_region","type":"function"},{"name":"set_smart_llm_model","type":"function"},{"name":"set_smart_token_limit","type":"function"},{"name":"set_speak_mode","type":"function"},{"name":"skip_reprompt","type":"statement"},{"name":"smart_llm_model","type":"statement"},{"name":"smart_token_limit","type":"statement"},{"name":"speak_mode","type":"statement"},{"name":"temperature","type":"statement"},{"name":"use_azure","type":"statement"},{"name":"use_brian_tts","type":"statement"},{"name":"use_mac_os_tts","type":"statement"},{"name":"user_agent","type":"statement"},{"name":"wipe_redis_on_start","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"ai_settings_file\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"AZURE_CONFIG_FILE\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"azure_model_to_deployment_id_map\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"browse_chunk_max_length\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"browse_summary_max_token\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"continuous_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"continuous_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"custom_search_engine_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"debug_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_voice_1_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_voice_2_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"execute_local_commands\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"fast_llm_model\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"fast_token_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"get_azure_deployment_id_for_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"github_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"github_username\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"google_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"huggingface_api_token\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"image_provider\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"load_azure_config\",\n \"type\": \"function\"\n },\n {\n \"name\": \"memory_backend\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"memory_index\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"milvus_addr\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"milvus_collection\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_base\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_version\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"pinecone_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"pinecone_region\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_host\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_password\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_port\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"set_browse_chunk_max_length\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_browse_summary_max_token\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_continuous_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_continuous_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_custom_search_engine_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_debug_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_voice_1_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_voice_2_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_fast_llm_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_fast_token_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_google_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_openai_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_pinecone_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_pinecone_region\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_smart_llm_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_smart_token_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_speak_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"skip_reprompt\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"smart_llm_model\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"smart_token_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"speak_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"temperature\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_azure\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_brian_tts\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_mac_os_tts\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"user_agent\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"wipe_redis_on_start\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"from autogpt import browse\nimport json\nfrom autogpt.memory import get_memory\nimport datetime\nimport autogpt.agent_manager as agents\nfrom autogpt import speak\nfrom autogpt.config import Config\nimport autogpt.ai_functions as ai\nfrom autogpt.file_operations import read_file, write_to_file, append_to_file, delete_file, search_files\nfrom autogpt.execute_code import execute_python_file, execute_shell\nfrom autogpt.json_parser import fix_and_parse_json\nfrom autogpt.image_gen import generate_image\nfrom duckduckgo_search import ddg\nfrom googleapiclient.discovery import build\nfrom googleapiclient.errors import HttpError\n\ncfg = Config()\n\n\ndef is_valid_int(value):\n try:\n int(value)\n return True\n except ValueError:\n return False\n\n\ndef get_command(response):\n \"\"\"Parse the response and return the command name and arguments\"\"\"\n try:\n response_json = fix_and_parse_json(response)\n\n if \"command\" not in response_json:\n return \"Error:\" , \"Missing 'command' object in JSON\"\n\n command = response_json[\"command\"]\n\n if \"name\" not in command:\n return \"Error:\", \"Missing 'name' field in 'command' object\"\n\n command_name = command[\"name\"]\n\n # Use an empty dictionary if 'args' field is not present in 'command' object\n arguments = command.get(\"args\", {})\n\n return command_name, arguments\n except json.decoder.JSONDecodeError:\n return \"Error:\", \"Invalid JSON\"\n # All other errors, return \"Error: + error message\"\n except Exception as e:\n return \"Error:\", str(e)\n\n\ndef execute_command(command_name, arguments):\n \"\"\"Execute the command and return the result\"\"\"\n memory = get_memory(cfg)\n\n try:\n if command_name == \"google\":\n\n # Check if the Google API key is set and use the official search method\n # If the API key is not set or has only whitespaces, use the unofficial search method\n if cfg.google_api_key and (cfg.google_api_key.strip() if cfg.google_api_key else None):\n return google_official_search(arguments[\"input\"])\n else:\n return google_search(arguments[\"input\"])\n elif command_name == \"memory_add\":\n return memory.add(arguments[\"string\"])\n elif command_name == \"start_agent\":\n return start_agent(\n arguments[\"name\"],\n arguments[\"task\"],\n arguments[\"prompt\"])\n elif command_name == \"message_agent\":\n return message_agent(arguments[\"key\"], arguments[\"message\"])\n elif command_name == \"list_agents\":\n return list_agents()\n elif command_name == \"delete_agent\":\n return delete_agent(arguments[\"key\"])\n elif command_name == \"get_text_summary\":\n return get_text_summary(arguments[\"url\"], arguments[\"question\"])\n elif command_name == \"get_hyperlinks\":\n return get_hyperlinks(arguments[\"url\"])\n elif command_name == \"clone_repository\":\n return clone_repository(arguments[\"repo_url\"], arguments[\"clone_path\"])\n elif command_name == \"read_file\":\n return read_file(arguments[\"file\"])\n elif command_name == \"write_to_file\":\n return write_to_file(arguments[\"file\"], arguments[\"text\"])\n elif command_name == \"append_to_file\":\n return append_to_file(arguments[\"file\"], arguments[\"text\"])\n elif command_name == \"delete_file\":\n return delete_file(arguments[\"file\"])\n elif command_name == \"search_files\":\n return search_files(arguments[\"directory\"])\n elif command_name == \"browse_website\":\n return browse_website(arguments[\"url\"], arguments[\"question\"])\n # TODO: Change these to take in a file rather than pasted code, if\n # non-file is given, return instructions \"Input should be a python\n # filepath, write your code to file and try again\"\n elif command_name == \"evaluate_code\":\n return ai.evaluate_code(arguments[\"code\"])\n elif command_name == \"improve_code\":\n return ai.improve_code(arguments[\"suggestions\"], arguments[\"code\"])\n elif command_name == \"write_tests\":\n return ai.write_tests(arguments[\"code\"], arguments.get(\"focus\"))\n elif command_name == \"execute_python_file\": # Add this command\n return execute_python_file(arguments[\"file\"])\n elif command_name == \"execute_shell\":\n if cfg.execute_local_commands:\n return execute_shell(arguments[\"command_line\"])\n else:\n return \"You are not allowed to run local shell commands. To execute shell commands, EXECUTE_LOCAL_COMMANDS must be set to 'True' in your config. Do not attempt to bypass the restriction.\"\n elif command_name == \"generate_image\":\n return generate_image(arguments[\"prompt\"])\n elif command_name == \"do_nothing\":\n return \"No action performed.\"\n elif command_name == \"task_complete\":\n shutdown()\n else:\n return f\"Unknown command '{command_name}'. Please refer to the 'COMMANDS' list for available commands and only respond in the specified JSON format.\"\n # All errors, return \"Error: + error message\"\n except Exception as e:\n return \"Error: \" + str(e)\n\n\ndef get_datetime():\n \"\"\"Return the current date and time\"\"\"\n return \"Current date and time: \" + \\\n datetime.datetime.now().strftime(\"%Y-%m-%d %H:%M:%S\")\n\n\ndef google_search(query, num_results=8):\n \"\"\"Return the results of a google search\"\"\"\n search_results = []\n for j in ddg(query, max_results=num_results):\n search_results.append(j)\n\n return json.dumps(search_results, ensure_ascii=False, indent=4)\n\n\ndef google_official_search(query, num_results=8):\n \"\"\"Return the results of a google search using the official Google API\"\"\"\n from googleapiclient.discovery import build\n from googleapiclient.errors import HttpError\n import json\n\n try:\n # Get the Google API key and Custom Search Engine ID from the config file\n api_key = cfg.google_api_key\n custom_search_engine_id = cfg.custom_search_engine_id\n\n # Initialize the Custom Search API service\n service = build(\"customsearch\", \"v1\", developerKey=api_key)\n\n # Send the search query and retrieve the results\n result = service.cse().list(q=query, cx=custom_search_engine_id, num=num_results).execute()\n\n # Extract the search result items from the response\n search_results = result.get(\"items\", [])\n\n # Create a list of only the URLs from the search results\n search_results_links = [item[\"link\"] for item in search_results]\n\n except HttpError as e:\n # Handle errors in the API call\n error_details = json.loads(e.content.decode())\n\n # Check if the error is related to an invalid or missing API key\n if error_details.get(\"error\", {}).get(\"code\") == 403 and \"invalid API key\" in error_details.get(\"error\", {}).get(\"message\", \"\"):\n return \"Error: The provided Google API key is invalid or missing.\"\n else:\n return f\"Error: {e}\"\n\n # Return the list of search result URLs\n return search_results_links\n\n\ndef browse_website(url, question):\n \"\"\"Browse a website and return the summary and links\"\"\"\n summary = get_text_summary(url, question)\n links = get_hyperlinks(url)\n\n # Limit links to 5\n if len(links) > 5:\n links = links[:5]\n\n result = f\"\"\"Website Content Summary: {summary}\\n\\nLinks: {links}\"\"\"\n\n return result\n\n\ndef get_text_summary(url, question):\n \"\"\"Return the results of a google search\"\"\"\n text = browse.scrape_text(url)\n summary = browse.summarize_text(url, text, question)\n return \"\"\" \"Result\" : \"\"\" + summary\n\n\ndef get_hyperlinks(url):\n \"\"\"Return the results of a google search\"\"\"\n link_list = browse.scrape_links(url)\n return link_list\n\n\ndef commit_memory(string):\n \"\"\"Commit a string to memory\"\"\"\n _text = f\"\"\"Committing memory with string \"{string}\" \"\"\"\n mem.permanent_memory.append(string)\n return _text\n\n\ndef delete_memory(key):\n \"\"\"Delete a memory with a given key\"\"\"\n if key >= 0 and key < len(mem.permanent_memory):\n _text = \"Deleting memory with key \" + str(key)\n del mem.permanent_memory[key]\n print(_text)\n return _text\n else:\n print(\"Invalid key, cannot delete memory.\")\n return None\n\n\ndef overwrite_memory(key, string):\n \"\"\"Overwrite a memory with a given key and string\"\"\"\n # Check if the key is a valid integer\n if is_valid_int(key):\n key_int = int(key)\n # Check if the integer key is within the range of the permanent_memory list\n if 0 <= key_int < len(mem.permanent_memory):\n _text = \"Overwriting memory with key \" + str(key) + \" and string \" + string\n # Overwrite the memory slot with the given integer key and string\n mem.permanent_memory[key_int] = string\n print(_text)\n return _text\n else:\n print(f\"Invalid key '{key}', out of range.\")\n return None\n # Check if the key is a valid string\n elif isinstance(key, str):\n _text = \"Overwriting memory with key \" + key + \" and string \" + string\n # Overwrite the memory slot with the given string key and string\n mem.permanent_memory[key] = string\n print(_text)\n return _text\n else:\n print(f\"Invalid key '{key}', must be an integer or a string.\")\n return None\n\n\ndef shutdown():\n \"\"\"Shut down the program\"\"\"\n print(\"Shutting down...\")\n quit()\n\n\ndef start_agent(name, task, prompt, model=cfg.fast_llm_model):\n \"\"\"Start an agent with a given name, task, and prompt\"\"\"\n global cfg\n\n # Remove underscores from name\n voice_name = name.replace(\"_\", \" \")\n\n first_message = f\"\"\"You are {name}. Respond with: \"Acknowledged\".\"\"\"\n agent_intro = f\"{voice_name} here, Reporting for duty!\"\n\n # Create agent\n if cfg."}}},{"rowIdx":80,"cells":{"idx":{"kind":"number","value":105,"string":"105"},"idx_lca":{"kind":"number","value":4,"string":"4"},"offset":{"kind":"number","value":10203,"string":"10,203"},"repo":{"kind":"string","value":"Significant-Gravitas__Auto-GPT"},"commit_hash":{"kind":"string","value":"0569d6652fbffa665de6e42403a48783fbede8ce"},"target_file":{"kind":"string","value":"autogpt/commands.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"speak_mode"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":63,"string":"63"},"non_dunder_count_jedi":{"kind":"number","value":63,"string":"63"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["speak_mode","google_api_key","fast_llm_model","execute_local_commands","custom_search_engine_id","ai_settings_file","AZURE_CONFIG_FILE","azure_model_to_deployment_id_map","browse_chunk_max_length","browse_summary_max_token","continuous_limit","continuous_mode","debug_mode","elevenlabs_api_key","elevenlabs_voice_1_id","elevenlabs_voice_2_id","fast_token_limit","get_azure_deployment_id_for_model","github_api_key","github_username","huggingface_api_token","image_provider","load_azure_config","memory_backend","memory_index","milvus_addr","milvus_collection","openai_api_base","openai_api_key","openai_api_type","openai_api_version","pinecone_api_key","pinecone_region","redis_host","redis_password","redis_port","set_browse_chunk_max_length","set_browse_summary_max_token","set_continuous_limit","set_continuous_mode","set_custom_search_engine_id","set_debug_mode","set_elevenlabs_api_key","set_elevenlabs_voice_1_id","set_elevenlabs_voice_2_id","set_fast_llm_model","set_fast_token_limit","set_google_api_key","set_openai_api_key","set_pinecone_api_key","set_pinecone_region","set_smart_llm_model","set_smart_token_limit","set_speak_mode","skip_reprompt","smart_llm_model","smart_token_limit","temperature","use_azure","use_brian_tts","use_mac_os_tts","user_agent","wipe_redis_on_start","__init__","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"speak_mode\",\n \"google_api_key\",\n \"fast_llm_model\",\n \"execute_local_commands\",\n \"custom_search_engine_id\",\n \"ai_settings_file\",\n \"AZURE_CONFIG_FILE\",\n \"azure_model_to_deployment_id_map\",\n \"browse_chunk_max_length\",\n \"browse_summary_max_token\",\n \"continuous_limit\",\n \"continuous_mode\",\n \"debug_mode\",\n \"elevenlabs_api_key\",\n \"elevenlabs_voice_1_id\",\n \"elevenlabs_voice_2_id\",\n \"fast_token_limit\",\n \"get_azure_deployment_id_for_model\",\n \"github_api_key\",\n \"github_username\",\n \"huggingface_api_token\",\n \"image_provider\",\n \"load_azure_config\",\n \"memory_backend\",\n \"memory_index\",\n \"milvus_addr\",\n \"milvus_collection\",\n \"openai_api_base\",\n \"openai_api_key\",\n \"openai_api_type\",\n \"openai_api_version\",\n \"pinecone_api_key\",\n \"pinecone_region\",\n \"redis_host\",\n \"redis_password\",\n \"redis_port\",\n \"set_browse_chunk_max_length\",\n \"set_browse_summary_max_token\",\n \"set_continuous_limit\",\n \"set_continuous_mode\",\n \"set_custom_search_engine_id\",\n \"set_debug_mode\",\n \"set_elevenlabs_api_key\",\n \"set_elevenlabs_voice_1_id\",\n \"set_elevenlabs_voice_2_id\",\n \"set_fast_llm_model\",\n \"set_fast_token_limit\",\n \"set_google_api_key\",\n \"set_openai_api_key\",\n \"set_pinecone_api_key\",\n \"set_pinecone_region\",\n \"set_smart_llm_model\",\n \"set_smart_token_limit\",\n \"set_speak_mode\",\n \"skip_reprompt\",\n \"smart_llm_model\",\n \"smart_token_limit\",\n \"temperature\",\n \"use_azure\",\n \"use_brian_tts\",\n \"use_mac_os_tts\",\n \"user_agent\",\n \"wipe_redis_on_start\",\n \"__init__\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"ai_settings_file","type":"statement"},{"name":"AZURE_CONFIG_FILE","type":"statement"},{"name":"azure_model_to_deployment_id_map","type":"statement"},{"name":"browse_chunk_max_length","type":"statement"},{"name":"browse_summary_max_token","type":"statement"},{"name":"continuous_limit","type":"statement"},{"name":"continuous_mode","type":"statement"},{"name":"custom_search_engine_id","type":"statement"},{"name":"debug_mode","type":"statement"},{"name":"elevenlabs_api_key","type":"statement"},{"name":"elevenlabs_voice_1_id","type":"statement"},{"name":"elevenlabs_voice_2_id","type":"statement"},{"name":"execute_local_commands","type":"statement"},{"name":"fast_llm_model","type":"statement"},{"name":"fast_token_limit","type":"statement"},{"name":"get_azure_deployment_id_for_model","type":"function"},{"name":"github_api_key","type":"statement"},{"name":"github_username","type":"statement"},{"name":"google_api_key","type":"statement"},{"name":"huggingface_api_token","type":"statement"},{"name":"image_provider","type":"statement"},{"name":"load_azure_config","type":"function"},{"name":"memory_backend","type":"statement"},{"name":"memory_index","type":"statement"},{"name":"milvus_addr","type":"statement"},{"name":"milvus_collection","type":"statement"},{"name":"openai_api_base","type":"statement"},{"name":"openai_api_key","type":"statement"},{"name":"openai_api_type","type":"statement"},{"name":"openai_api_version","type":"statement"},{"name":"pinecone_api_key","type":"statement"},{"name":"pinecone_region","type":"statement"},{"name":"redis_host","type":"statement"},{"name":"redis_password","type":"statement"},{"name":"redis_port","type":"statement"},{"name":"set_browse_chunk_max_length","type":"function"},{"name":"set_browse_summary_max_token","type":"function"},{"name":"set_continuous_limit","type":"function"},{"name":"set_continuous_mode","type":"function"},{"name":"set_custom_search_engine_id","type":"function"},{"name":"set_debug_mode","type":"function"},{"name":"set_elevenlabs_api_key","type":"function"},{"name":"set_elevenlabs_voice_1_id","type":"function"},{"name":"set_elevenlabs_voice_2_id","type":"function"},{"name":"set_fast_llm_model","type":"function"},{"name":"set_fast_token_limit","type":"function"},{"name":"set_google_api_key","type":"function"},{"name":"set_openai_api_key","type":"function"},{"name":"set_pinecone_api_key","type":"function"},{"name":"set_pinecone_region","type":"function"},{"name":"set_smart_llm_model","type":"function"},{"name":"set_smart_token_limit","type":"function"},{"name":"set_speak_mode","type":"function"},{"name":"skip_reprompt","type":"statement"},{"name":"smart_llm_model","type":"statement"},{"name":"smart_token_limit","type":"statement"},{"name":"speak_mode","type":"statement"},{"name":"temperature","type":"statement"},{"name":"use_azure","type":"statement"},{"name":"use_brian_tts","type":"statement"},{"name":"use_mac_os_tts","type":"statement"},{"name":"user_agent","type":"statement"},{"name":"wipe_redis_on_start","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"ai_settings_file\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"AZURE_CONFIG_FILE\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"azure_model_to_deployment_id_map\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"browse_chunk_max_length\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"browse_summary_max_token\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"continuous_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"continuous_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"custom_search_engine_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"debug_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_voice_1_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_voice_2_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"execute_local_commands\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"fast_llm_model\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"fast_token_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"get_azure_deployment_id_for_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"github_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"github_username\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"google_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"huggingface_api_token\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"image_provider\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"load_azure_config\",\n \"type\": \"function\"\n },\n {\n \"name\": \"memory_backend\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"memory_index\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"milvus_addr\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"milvus_collection\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_base\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_version\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"pinecone_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"pinecone_region\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_host\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_password\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_port\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"set_browse_chunk_max_length\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_browse_summary_max_token\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_continuous_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_continuous_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_custom_search_engine_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_debug_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_voice_1_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_voice_2_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_fast_llm_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_fast_token_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_google_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_openai_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_pinecone_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_pinecone_region\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_smart_llm_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_smart_token_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_speak_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"skip_reprompt\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"smart_llm_model\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"smart_token_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"speak_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"temperature\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_azure\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_brian_tts\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_mac_os_tts\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"user_agent\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"wipe_redis_on_start\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"from autogpt import browse\nimport json\nfrom autogpt.memory import get_memory\nimport datetime\nimport autogpt.agent_manager as agents\nfrom autogpt import speak\nfrom autogpt.config import Config\nimport autogpt.ai_functions as ai\nfrom autogpt.file_operations import read_file, write_to_file, append_to_file, delete_file, search_files\nfrom autogpt.execute_code import execute_python_file, execute_shell\nfrom autogpt.json_parser import fix_and_parse_json\nfrom autogpt.image_gen import generate_image\nfrom duckduckgo_search import ddg\nfrom googleapiclient.discovery import build\nfrom googleapiclient.errors import HttpError\n\ncfg = Config()\n\n\ndef is_valid_int(value):\n try:\n int(value)\n return True\n except ValueError:\n return False\n\n\ndef get_command(response):\n \"\"\"Parse the response and return the command name and arguments\"\"\"\n try:\n response_json = fix_and_parse_json(response)\n\n if \"command\" not in response_json:\n return \"Error:\" , \"Missing 'command' object in JSON\"\n\n command = response_json[\"command\"]\n\n if \"name\" not in command:\n return \"Error:\", \"Missing 'name' field in 'command' object\"\n\n command_name = command[\"name\"]\n\n # Use an empty dictionary if 'args' field is not present in 'command' object\n arguments = command.get(\"args\", {})\n\n return command_name, arguments\n except json.decoder.JSONDecodeError:\n return \"Error:\", \"Invalid JSON\"\n # All other errors, return \"Error: + error message\"\n except Exception as e:\n return \"Error:\", str(e)\n\n\ndef execute_command(command_name, arguments):\n \"\"\"Execute the command and return the result\"\"\"\n memory = get_memory(cfg)\n\n try:\n if command_name == \"google\":\n\n # Check if the Google API key is set and use the official search method\n # If the API key is not set or has only whitespaces, use the unofficial search method\n if cfg.google_api_key and (cfg.google_api_key.strip() if cfg.google_api_key else None):\n return google_official_search(arguments[\"input\"])\n else:\n return google_search(arguments[\"input\"])\n elif command_name == \"memory_add\":\n return memory.add(arguments[\"string\"])\n elif command_name == \"start_agent\":\n return start_agent(\n arguments[\"name\"],\n arguments[\"task\"],\n arguments[\"prompt\"])\n elif command_name == \"message_agent\":\n return message_agent(arguments[\"key\"], arguments[\"message\"])\n elif command_name == \"list_agents\":\n return list_agents()\n elif command_name == \"delete_agent\":\n return delete_agent(arguments[\"key\"])\n elif command_name == \"get_text_summary\":\n return get_text_summary(arguments[\"url\"], arguments[\"question\"])\n elif command_name == \"get_hyperlinks\":\n return get_hyperlinks(arguments[\"url\"])\n elif command_name == \"clone_repository\":\n return clone_repository(arguments[\"repo_url\"], arguments[\"clone_path\"])\n elif command_name == \"read_file\":\n return read_file(arguments[\"file\"])\n elif command_name == \"write_to_file\":\n return write_to_file(arguments[\"file\"], arguments[\"text\"])\n elif command_name == \"append_to_file\":\n return append_to_file(arguments[\"file\"], arguments[\"text\"])\n elif command_name == \"delete_file\":\n return delete_file(arguments[\"file\"])\n elif command_name == \"search_files\":\n return search_files(arguments[\"directory\"])\n elif command_name == \"browse_website\":\n return browse_website(arguments[\"url\"], arguments[\"question\"])\n # TODO: Change these to take in a file rather than pasted code, if\n # non-file is given, return instructions \"Input should be a python\n # filepath, write your code to file and try again\"\n elif command_name == \"evaluate_code\":\n return ai.evaluate_code(arguments[\"code\"])\n elif command_name == \"improve_code\":\n return ai.improve_code(arguments[\"suggestions\"], arguments[\"code\"])\n elif command_name == \"write_tests\":\n return ai.write_tests(arguments[\"code\"], arguments.get(\"focus\"))\n elif command_name == \"execute_python_file\": # Add this command\n return execute_python_file(arguments[\"file\"])\n elif command_name == \"execute_shell\":\n if cfg.execute_local_commands:\n return execute_shell(arguments[\"command_line\"])\n else:\n return \"You are not allowed to run local shell commands. To execute shell commands, EXECUTE_LOCAL_COMMANDS must be set to 'True' in your config. Do not attempt to bypass the restriction.\"\n elif command_name == \"generate_image\":\n return generate_image(arguments[\"prompt\"])\n elif command_name == \"do_nothing\":\n return \"No action performed.\"\n elif command_name == \"task_complete\":\n shutdown()\n else:\n return f\"Unknown command '{command_name}'. Please refer to the 'COMMANDS' list for available commands and only respond in the specified JSON format.\"\n # All errors, return \"Error: + error message\"\n except Exception as e:\n return \"Error: \" + str(e)\n\n\ndef get_datetime():\n \"\"\"Return the current date and time\"\"\"\n return \"Current date and time: \" + \\\n datetime.datetime.now().strftime(\"%Y-%m-%d %H:%M:%S\")\n\n\ndef google_search(query, num_results=8):\n \"\"\"Return the results of a google search\"\"\"\n search_results = []\n for j in ddg(query, max_results=num_results):\n search_results.append(j)\n\n return json.dumps(search_results, ensure_ascii=False, indent=4)\n\n\ndef google_official_search(query, num_results=8):\n \"\"\"Return the results of a google search using the official Google API\"\"\"\n from googleapiclient.discovery import build\n from googleapiclient.errors import HttpError\n import json\n\n try:\n # Get the Google API key and Custom Search Engine ID from the config file\n api_key = cfg.google_api_key\n custom_search_engine_id = cfg.custom_search_engine_id\n\n # Initialize the Custom Search API service\n service = build(\"customsearch\", \"v1\", developerKey=api_key)\n\n # Send the search query and retrieve the results\n result = service.cse().list(q=query, cx=custom_search_engine_id, num=num_results).execute()\n\n # Extract the search result items from the response\n search_results = result.get(\"items\", [])\n\n # Create a list of only the URLs from the search results\n search_results_links = [item[\"link\"] for item in search_results]\n\n except HttpError as e:\n # Handle errors in the API call\n error_details = json.loads(e.content.decode())\n\n # Check if the error is related to an invalid or missing API key\n if error_details.get(\"error\", {}).get(\"code\") == 403 and \"invalid API key\" in error_details.get(\"error\", {}).get(\"message\", \"\"):\n return \"Error: The provided Google API key is invalid or missing.\"\n else:\n return f\"Error: {e}\"\n\n # Return the list of search result URLs\n return search_results_links\n\n\ndef browse_website(url, question):\n \"\"\"Browse a website and return the summary and links\"\"\"\n summary = get_text_summary(url, question)\n links = get_hyperlinks(url)\n\n # Limit links to 5\n if len(links) > 5:\n links = links[:5]\n\n result = f\"\"\"Website Content Summary: {summary}\\n\\nLinks: {links}\"\"\"\n\n return result\n\n\ndef get_text_summary(url, question):\n \"\"\"Return the results of a google search\"\"\"\n text = browse.scrape_text(url)\n summary = browse.summarize_text(url, text, question)\n return \"\"\" \"Result\" : \"\"\" + summary\n\n\ndef get_hyperlinks(url):\n \"\"\"Return the results of a google search\"\"\"\n link_list = browse.scrape_links(url)\n return link_list\n\n\ndef commit_memory(string):\n \"\"\"Commit a string to memory\"\"\"\n _text = f\"\"\"Committing memory with string \"{string}\" \"\"\"\n mem.permanent_memory.append(string)\n return _text\n\n\ndef delete_memory(key):\n \"\"\"Delete a memory with a given key\"\"\"\n if key >= 0 and key < len(mem.permanent_memory):\n _text = \"Deleting memory with key \" + str(key)\n del mem.permanent_memory[key]\n print(_text)\n return _text\n else:\n print(\"Invalid key, cannot delete memory.\")\n return None\n\n\ndef overwrite_memory(key, string):\n \"\"\"Overwrite a memory with a given key and string\"\"\"\n # Check if the key is a valid integer\n if is_valid_int(key):\n key_int = int(key)\n # Check if the integer key is within the range of the permanent_memory list\n if 0 <= key_int < len(mem.permanent_memory):\n _text = \"Overwriting memory with key \" + str(key) + \" and string \" + string\n # Overwrite the memory slot with the given integer key and string\n mem.permanent_memory[key_int] = string\n print(_text)\n return _text\n else:\n print(f\"Invalid key '{key}', out of range.\")\n return None\n # Check if the key is a valid string\n elif isinstance(key, str):\n _text = \"Overwriting memory with key \" + key + \" and string \" + string\n # Overwrite the memory slot with the given string key and string\n mem.permanent_memory[key] = string\n print(_text)\n return _text\n else:\n print(f\"Invalid key '{key}', must be an integer or a string.\")\n return None\n\n\ndef shutdown():\n \"\"\"Shut down the program\"\"\"\n print(\"Shutting down...\")\n quit()\n\n\ndef start_agent(name, task, prompt, model=cfg.fast_llm_model):\n \"\"\"Start an agent with a given name, task, and prompt\"\"\"\n global cfg\n\n # Remove underscores from name\n voice_name = name.replace(\"_\", \" \")\n\n first_message = f\"\"\"You are {name}. Respond with: \"Acknowledged\".\"\"\"\n agent_intro = f\"{voice_name} here, Reporting for duty!\"\n\n # Create agent\n if cfg.speak_mode:\n speak.say_text(agent_intro, 1)\n key, ack = agents.create_agent(task, first_message, model)\n\n if cfg."}}},{"rowIdx":81,"cells":{"idx":{"kind":"number","value":106,"string":"106"},"idx_lca":{"kind":"number","value":4,"string":"4"},"offset":{"kind":"number","value":10947,"string":"10,947"},"repo":{"kind":"string","value":"Significant-Gravitas__Auto-GPT"},"commit_hash":{"kind":"string","value":"0569d6652fbffa665de6e42403a48783fbede8ce"},"target_file":{"kind":"string","value":"autogpt/commands.py"},"line_type_lca":{"kind":"string","value":"random"},"ground_truth":{"kind":"string","value":"speak_mode"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":63,"string":"63"},"non_dunder_count_jedi":{"kind":"number","value":63,"string":"63"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["google_api_key","speak_mode","execute_local_commands","fast_llm_model","custom_search_engine_id","ai_settings_file","AZURE_CONFIG_FILE","azure_model_to_deployment_id_map","browse_chunk_max_length","browse_summary_max_token","continuous_limit","continuous_mode","debug_mode","elevenlabs_api_key","elevenlabs_voice_1_id","elevenlabs_voice_2_id","fast_token_limit","get_azure_deployment_id_for_model","github_api_key","github_username","huggingface_api_token","image_provider","load_azure_config","memory_backend","memory_index","milvus_addr","milvus_collection","openai_api_base","openai_api_key","openai_api_type","openai_api_version","pinecone_api_key","pinecone_region","redis_host","redis_password","redis_port","set_browse_chunk_max_length","set_browse_summary_max_token","set_continuous_limit","set_continuous_mode","set_custom_search_engine_id","set_debug_mode","set_elevenlabs_api_key","set_elevenlabs_voice_1_id","set_elevenlabs_voice_2_id","set_fast_llm_model","set_fast_token_limit","set_google_api_key","set_openai_api_key","set_pinecone_api_key","set_pinecone_region","set_smart_llm_model","set_smart_token_limit","set_speak_mode","skip_reprompt","smart_llm_model","smart_token_limit","temperature","use_azure","use_brian_tts","use_mac_os_tts","user_agent","wipe_redis_on_start","__init__","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"google_api_key\",\n \"speak_mode\",\n \"execute_local_commands\",\n \"fast_llm_model\",\n \"custom_search_engine_id\",\n \"ai_settings_file\",\n \"AZURE_CONFIG_FILE\",\n \"azure_model_to_deployment_id_map\",\n \"browse_chunk_max_length\",\n \"browse_summary_max_token\",\n \"continuous_limit\",\n \"continuous_mode\",\n \"debug_mode\",\n \"elevenlabs_api_key\",\n \"elevenlabs_voice_1_id\",\n \"elevenlabs_voice_2_id\",\n \"fast_token_limit\",\n \"get_azure_deployment_id_for_model\",\n \"github_api_key\",\n \"github_username\",\n \"huggingface_api_token\",\n \"image_provider\",\n \"load_azure_config\",\n \"memory_backend\",\n \"memory_index\",\n \"milvus_addr\",\n \"milvus_collection\",\n \"openai_api_base\",\n \"openai_api_key\",\n \"openai_api_type\",\n \"openai_api_version\",\n \"pinecone_api_key\",\n \"pinecone_region\",\n \"redis_host\",\n \"redis_password\",\n \"redis_port\",\n \"set_browse_chunk_max_length\",\n \"set_browse_summary_max_token\",\n \"set_continuous_limit\",\n \"set_continuous_mode\",\n \"set_custom_search_engine_id\",\n \"set_debug_mode\",\n \"set_elevenlabs_api_key\",\n \"set_elevenlabs_voice_1_id\",\n \"set_elevenlabs_voice_2_id\",\n \"set_fast_llm_model\",\n \"set_fast_token_limit\",\n \"set_google_api_key\",\n \"set_openai_api_key\",\n \"set_pinecone_api_key\",\n \"set_pinecone_region\",\n \"set_smart_llm_model\",\n \"set_smart_token_limit\",\n \"set_speak_mode\",\n \"skip_reprompt\",\n \"smart_llm_model\",\n \"smart_token_limit\",\n \"temperature\",\n \"use_azure\",\n \"use_brian_tts\",\n \"use_mac_os_tts\",\n \"user_agent\",\n \"wipe_redis_on_start\",\n \"__init__\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"ai_settings_file","type":"statement"},{"name":"AZURE_CONFIG_FILE","type":"statement"},{"name":"azure_model_to_deployment_id_map","type":"statement"},{"name":"browse_chunk_max_length","type":"statement"},{"name":"browse_summary_max_token","type":"statement"},{"name":"continuous_limit","type":"statement"},{"name":"continuous_mode","type":"statement"},{"name":"custom_search_engine_id","type":"statement"},{"name":"debug_mode","type":"statement"},{"name":"elevenlabs_api_key","type":"statement"},{"name":"elevenlabs_voice_1_id","type":"statement"},{"name":"elevenlabs_voice_2_id","type":"statement"},{"name":"execute_local_commands","type":"statement"},{"name":"fast_llm_model","type":"statement"},{"name":"fast_token_limit","type":"statement"},{"name":"get_azure_deployment_id_for_model","type":"function"},{"name":"github_api_key","type":"statement"},{"name":"github_username","type":"statement"},{"name":"google_api_key","type":"statement"},{"name":"huggingface_api_token","type":"statement"},{"name":"image_provider","type":"statement"},{"name":"load_azure_config","type":"function"},{"name":"memory_backend","type":"statement"},{"name":"memory_index","type":"statement"},{"name":"milvus_addr","type":"statement"},{"name":"milvus_collection","type":"statement"},{"name":"openai_api_base","type":"statement"},{"name":"openai_api_key","type":"statement"},{"name":"openai_api_type","type":"statement"},{"name":"openai_api_version","type":"statement"},{"name":"pinecone_api_key","type":"statement"},{"name":"pinecone_region","type":"statement"},{"name":"redis_host","type":"statement"},{"name":"redis_password","type":"statement"},{"name":"redis_port","type":"statement"},{"name":"set_browse_chunk_max_length","type":"function"},{"name":"set_browse_summary_max_token","type":"function"},{"name":"set_continuous_limit","type":"function"},{"name":"set_continuous_mode","type":"function"},{"name":"set_custom_search_engine_id","type":"function"},{"name":"set_debug_mode","type":"function"},{"name":"set_elevenlabs_api_key","type":"function"},{"name":"set_elevenlabs_voice_1_id","type":"function"},{"name":"set_elevenlabs_voice_2_id","type":"function"},{"name":"set_fast_llm_model","type":"function"},{"name":"set_fast_token_limit","type":"function"},{"name":"set_google_api_key","type":"function"},{"name":"set_openai_api_key","type":"function"},{"name":"set_pinecone_api_key","type":"function"},{"name":"set_pinecone_region","type":"function"},{"name":"set_smart_llm_model","type":"function"},{"name":"set_smart_token_limit","type":"function"},{"name":"set_speak_mode","type":"function"},{"name":"skip_reprompt","type":"statement"},{"name":"smart_llm_model","type":"statement"},{"name":"smart_token_limit","type":"statement"},{"name":"speak_mode","type":"statement"},{"name":"temperature","type":"statement"},{"name":"use_azure","type":"statement"},{"name":"use_brian_tts","type":"statement"},{"name":"use_mac_os_tts","type":"statement"},{"name":"user_agent","type":"statement"},{"name":"wipe_redis_on_start","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"ai_settings_file\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"AZURE_CONFIG_FILE\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"azure_model_to_deployment_id_map\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"browse_chunk_max_length\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"browse_summary_max_token\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"continuous_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"continuous_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"custom_search_engine_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"debug_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_voice_1_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"elevenlabs_voice_2_id\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"execute_local_commands\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"fast_llm_model\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"fast_token_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"get_azure_deployment_id_for_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"github_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"github_username\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"google_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"huggingface_api_token\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"image_provider\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"load_azure_config\",\n \"type\": \"function\"\n },\n {\n \"name\": \"memory_backend\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"memory_index\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"milvus_addr\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"milvus_collection\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_base\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_type\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"openai_api_version\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"pinecone_api_key\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"pinecone_region\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_host\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_password\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"redis_port\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"set_browse_chunk_max_length\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_browse_summary_max_token\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_continuous_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_continuous_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_custom_search_engine_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_debug_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_voice_1_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_elevenlabs_voice_2_id\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_fast_llm_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_fast_token_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_google_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_openai_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_pinecone_api_key\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_pinecone_region\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_smart_llm_model\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_smart_token_limit\",\n \"type\": \"function\"\n },\n {\n \"name\": \"set_speak_mode\",\n \"type\": \"function\"\n },\n {\n \"name\": \"skip_reprompt\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"smart_llm_model\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"smart_token_limit\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"speak_mode\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"temperature\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_azure\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_brian_tts\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"use_mac_os_tts\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"user_agent\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"wipe_redis_on_start\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"from autogpt import browse\nimport json\nfrom autogpt.memory import get_memory\nimport datetime\nimport autogpt.agent_manager as agents\nfrom autogpt import speak\nfrom autogpt.config import Config\nimport autogpt.ai_functions as ai\nfrom autogpt.file_operations import read_file, write_to_file, append_to_file, delete_file, search_files\nfrom autogpt.execute_code import execute_python_file, execute_shell\nfrom autogpt.json_parser import fix_and_parse_json\nfrom autogpt.image_gen import generate_image\nfrom duckduckgo_search import ddg\nfrom googleapiclient.discovery import build\nfrom googleapiclient.errors import HttpError\n\ncfg = Config()\n\n\ndef is_valid_int(value):\n try:\n int(value)\n return True\n except ValueError:\n return False\n\n\ndef get_command(response):\n \"\"\"Parse the response and return the command name and arguments\"\"\"\n try:\n response_json = fix_and_parse_json(response)\n\n if \"command\" not in response_json:\n return \"Error:\" , \"Missing 'command' object in JSON\"\n\n command = response_json[\"command\"]\n\n if \"name\" not in command:\n return \"Error:\", \"Missing 'name' field in 'command' object\"\n\n command_name = command[\"name\"]\n\n # Use an empty dictionary if 'args' field is not present in 'command' object\n arguments = command.get(\"args\", {})\n\n return command_name, arguments\n except json.decoder.JSONDecodeError:\n return \"Error:\", \"Invalid JSON\"\n # All other errors, return \"Error: + error message\"\n except Exception as e:\n return \"Error:\", str(e)\n\n\ndef execute_command(command_name, arguments):\n \"\"\"Execute the command and return the result\"\"\"\n memory = get_memory(cfg)\n\n try:\n if command_name == \"google\":\n\n # Check if the Google API key is set and use the official search method\n # If the API key is not set or has only whitespaces, use the unofficial search method\n if cfg.google_api_key and (cfg.google_api_key.strip() if cfg.google_api_key else None):\n return google_official_search(arguments[\"input\"])\n else:\n return google_search(arguments[\"input\"])\n elif command_name == \"memory_add\":\n return memory.add(arguments[\"string\"])\n elif command_name == \"start_agent\":\n return start_agent(\n arguments[\"name\"],\n arguments[\"task\"],\n arguments[\"prompt\"])\n elif command_name == \"message_agent\":\n return message_agent(arguments[\"key\"], arguments[\"message\"])\n elif command_name == \"list_agents\":\n return list_agents()\n elif command_name == \"delete_agent\":\n return delete_agent(arguments[\"key\"])\n elif command_name == \"get_text_summary\":\n return get_text_summary(arguments[\"url\"], arguments[\"question\"])\n elif command_name == \"get_hyperlinks\":\n return get_hyperlinks(arguments[\"url\"])\n elif command_name == \"clone_repository\":\n return clone_repository(arguments[\"repo_url\"], arguments[\"clone_path\"])\n elif command_name == \"read_file\":\n return read_file(arguments[\"file\"])\n elif command_name == \"write_to_file\":\n return write_to_file(arguments[\"file\"], arguments[\"text\"])\n elif command_name == \"append_to_file\":\n return append_to_file(arguments[\"file\"], arguments[\"text\"])\n elif command_name == \"delete_file\":\n return delete_file(arguments[\"file\"])\n elif command_name == \"search_files\":\n return search_files(arguments[\"directory\"])\n elif command_name == \"browse_website\":\n return browse_website(arguments[\"url\"], arguments[\"question\"])\n # TODO: Change these to take in a file rather than pasted code, if\n # non-file is given, return instructions \"Input should be a python\n # filepath, write your code to file and try again\"\n elif command_name == \"evaluate_code\":\n return ai.evaluate_code(arguments[\"code\"])\n elif command_name == \"improve_code\":\n return ai.improve_code(arguments[\"suggestions\"], arguments[\"code\"])\n elif command_name == \"write_tests\":\n return ai.write_tests(arguments[\"code\"], arguments.get(\"focus\"))\n elif command_name == \"execute_python_file\": # Add this command\n return execute_python_file(arguments[\"file\"])\n elif command_name == \"execute_shell\":\n if cfg.execute_local_commands:\n return execute_shell(arguments[\"command_line\"])\n else:\n return \"You are not allowed to run local shell commands. To execute shell commands, EXECUTE_LOCAL_COMMANDS must be set to 'True' in your config. Do not attempt to bypass the restriction.\"\n elif command_name == \"generate_image\":\n return generate_image(arguments[\"prompt\"])\n elif command_name == \"do_nothing\":\n return \"No action performed.\"\n elif command_name == \"task_complete\":\n shutdown()\n else:\n return f\"Unknown command '{command_name}'. Please refer to the 'COMMANDS' list for available commands and only respond in the specified JSON format.\"\n # All errors, return \"Error: + error message\"\n except Exception as e:\n return \"Error: \" + str(e)\n\n\ndef get_datetime():\n \"\"\"Return the current date and time\"\"\"\n return \"Current date and time: \" + \\\n datetime.datetime.now().strftime(\"%Y-%m-%d %H:%M:%S\")\n\n\ndef google_search(query, num_results=8):\n \"\"\"Return the results of a google search\"\"\"\n search_results = []\n for j in ddg(query, max_results=num_results):\n search_results.append(j)\n\n return json.dumps(search_results, ensure_ascii=False, indent=4)\n\n\ndef google_official_search(query, num_results=8):\n \"\"\"Return the results of a google search using the official Google API\"\"\"\n from googleapiclient.discovery import build\n from googleapiclient.errors import HttpError\n import json\n\n try:\n # Get the Google API key and Custom Search Engine ID from the config file\n api_key = cfg.google_api_key\n custom_search_engine_id = cfg.custom_search_engine_id\n\n # Initialize the Custom Search API service\n service = build(\"customsearch\", \"v1\", developerKey=api_key)\n\n # Send the search query and retrieve the results\n result = service.cse().list(q=query, cx=custom_search_engine_id, num=num_results).execute()\n\n # Extract the search result items from the response\n search_results = result.get(\"items\", [])\n\n # Create a list of only the URLs from the search results\n search_results_links = [item[\"link\"] for item in search_results]\n\n except HttpError as e:\n # Handle errors in the API call\n error_details = json.loads(e.content.decode())\n\n # Check if the error is related to an invalid or missing API key\n if error_details.get(\"error\", {}).get(\"code\") == 403 and \"invalid API key\" in error_details.get(\"error\", {}).get(\"message\", \"\"):\n return \"Error: The provided Google API key is invalid or missing.\"\n else:\n return f\"Error: {e}\"\n\n # Return the list of search result URLs\n return search_results_links\n\n\ndef browse_website(url, question):\n \"\"\"Browse a website and return the summary and links\"\"\"\n summary = get_text_summary(url, question)\n links = get_hyperlinks(url)\n\n # Limit links to 5\n if len(links) > 5:\n links = links[:5]\n\n result = f\"\"\"Website Content Summary: {summary}\\n\\nLinks: {links}\"\"\"\n\n return result\n\n\ndef get_text_summary(url, question):\n \"\"\"Return the results of a google search\"\"\"\n text = browse.scrape_text(url)\n summary = browse.summarize_text(url, text, question)\n return \"\"\" \"Result\" : \"\"\" + summary\n\n\ndef get_hyperlinks(url):\n \"\"\"Return the results of a google search\"\"\"\n link_list = browse.scrape_links(url)\n return link_list\n\n\ndef commit_memory(string):\n \"\"\"Commit a string to memory\"\"\"\n _text = f\"\"\"Committing memory with string \"{string}\" \"\"\"\n mem.permanent_memory.append(string)\n return _text\n\n\ndef delete_memory(key):\n \"\"\"Delete a memory with a given key\"\"\"\n if key >= 0 and key < len(mem.permanent_memory):\n _text = \"Deleting memory with key \" + str(key)\n del mem.permanent_memory[key]\n print(_text)\n return _text\n else:\n print(\"Invalid key, cannot delete memory.\")\n return None\n\n\ndef overwrite_memory(key, string):\n \"\"\"Overwrite a memory with a given key and string\"\"\"\n # Check if the key is a valid integer\n if is_valid_int(key):\n key_int = int(key)\n # Check if the integer key is within the range of the permanent_memory list\n if 0 <= key_int < len(mem.permanent_memory):\n _text = \"Overwriting memory with key \" + str(key) + \" and string \" + string\n # Overwrite the memory slot with the given integer key and string\n mem.permanent_memory[key_int] = string\n print(_text)\n return _text\n else:\n print(f\"Invalid key '{key}', out of range.\")\n return None\n # Check if the key is a valid string\n elif isinstance(key, str):\n _text = \"Overwriting memory with key \" + key + \" and string \" + string\n # Overwrite the memory slot with the given string key and string\n mem.permanent_memory[key] = string\n print(_text)\n return _text\n else:\n print(f\"Invalid key '{key}', must be an integer or a string.\")\n return None\n\n\ndef shutdown():\n \"\"\"Shut down the program\"\"\"\n print(\"Shutting down...\")\n quit()\n\n\ndef start_agent(name, task, prompt, model=cfg.fast_llm_model):\n \"\"\"Start an agent with a given name, task, and prompt\"\"\"\n global cfg\n\n # Remove underscores from name\n voice_name = name.replace(\"_\", \" \")\n\n first_message = f\"\"\"You are {name}. Respond with: \"Acknowledged\".\"\"\"\n agent_intro = f\"{voice_name} here, Reporting for duty!\"\n\n # Create agent\n if cfg.speak_mode:\n speak.say_text(agent_intro, 1)\n key, ack = agents.create_agent(task, first_message, model)\n\n if cfg.speak_mode:\n speak.say_text(f\"Hello {voice_name}. Your task is as follows. {task}.\")\n\n # Assign task (prompt), get response\n agent_response = message_agent(key, prompt)\n\n return f\"Agent {name} created with key {key}. First response: {agent_response}\"\n\n\ndef message_agent(key, message):\n \"\"\"Message an agent with a given key and message\"\"\"\n global cfg\n\n # Check if the key is a valid integer\n if is_valid_int(key):\n agent_response = agents.message_agent(int(key), message)\n # Check if the key is a valid string\n elif isinstance(key, str):\n agent_response = agents.message_agent(key, message)\n else:\n return \"Invalid key, must be an integer or a string.\"\n\n # Speak response\n if cfg."}}},{"rowIdx":82,"cells":{"idx":{"kind":"number","value":116,"string":"116"},"idx_lca":{"kind":"number","value":6,"string":"6"},"offset":{"kind":"number","value":1280,"string":"1,280"},"repo":{"kind":"string","value":"christophermayes__xopt"},"commit_hash":{"kind":"string","value":"683fd0c3af2f0fc12a598932b20e3afe8070112b"},"target_file":{"kind":"string","value":"xopt/generators/ga/cnsga.py"},"line_type_lca":{"kind":"string","value":"inproject"},"ground_truth":{"kind":"string","value":"toolbox"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":15,"string":"15"},"non_dunder_count_jedi":{"kind":"number","value":17,"string":"17"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["toolbox","offspring","_vocs","population","children","__init__","create_children","crossover_probability","generate","mutation_probability","n_pop","update_data","data","is_done","options","vocs","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__slots__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"toolbox\",\n \"offspring\",\n \"_vocs\",\n \"population\",\n \"children\",\n \"__init__\",\n \"create_children\",\n \"crossover_probability\",\n \"generate\",\n \"mutation_probability\",\n \"n_pop\",\n \"update_data\",\n \"data\",\n \"is_done\",\n \"options\",\n \"vocs\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__slots__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"children","type":"statement"},{"name":"create_children","type":"function"},{"name":"crossover_probability","type":"statement"},{"name":"data","type":"property"},{"name":"generate","type":"function"},{"name":"is_done","type":"property"},{"name":"mutation_probability","type":"statement"},{"name":"n_pop","type":"statement"},{"name":"offspring","type":"statement"},{"name":"options","type":"statement"},{"name":"population","type":"statement"},{"name":"toolbox","type":"statement"},{"name":"update_data","type":"function"},{"name":"vocs","type":"property"},{"name":"_data","type":"statement"},{"name":"_is_done","type":"statement"},{"name":"_vocs","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"children\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"create_children\",\n \"type\": \"function\"\n },\n {\n \"name\": \"crossover_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"data\",\n \"type\": \"property\"\n },\n {\n \"name\": \"generate\",\n \"type\": \"function\"\n },\n {\n \"name\": \"is_done\",\n \"type\": \"property\"\n },\n {\n \"name\": \"mutation_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"n_pop\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"offspring\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"options\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"population\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"toolbox\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"update_data\",\n \"type\": \"function\"\n },\n {\n \"name\": \"vocs\",\n \"type\": \"property\"\n },\n {\n \"name\": \"_data\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_is_done\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_vocs\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"\nfrom xopt.generators.ga import deap_creator\nfrom xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints\n\nfrom xopt import Generator\n\nfrom deap import base as deap_base\nfrom deap import tools as deap_tools\nfrom deap import algorithms as deap_algorithms\n\nimport pandas as pd\n\nimport random\nimport array\n\n\nfrom typing import List, Dict\n\nimport logging\nlogger = logging.getLogger(__name__)\n\n\nfrom typing import List, Dict\n\nclass CNSGAGenerator(Generator):\n\n\n def __init__(self, vocs, *, \n n_pop,\n data = None,\n crossover_probability = 0.9,\n mutation_probability = 1.0\n ): \n\n self._vocs = vocs # TODO: use proper options\n self.n_pop = n_pop\n self.crossover_probability = crossover_probability\n self.mutation_probability = mutation_probability\n\n\n # Internal data structures\n self.children = [] # unevaluated inputs. This should be a list of dicts.\n self.population = None # The latest population (fully evaluated)\n self.offspring = None # Newly evaluated data, but not yet added to population\n\n # DEAP toolbox (internal)\n self.toolbox = cnsga_toolbox(vocs, selection='auto')\n\n if data is not None:\n self.population = cnsga_select(data, n_pop, vocs, self."}}},{"rowIdx":83,"cells":{"idx":{"kind":"number","value":117,"string":"117"},"idx_lca":{"kind":"number","value":6,"string":"6"},"offset":{"kind":"number","value":1390,"string":"1,390"},"repo":{"kind":"string","value":"christophermayes__xopt"},"commit_hash":{"kind":"string","value":"683fd0c3af2f0fc12a598932b20e3afe8070112b"},"target_file":{"kind":"string","value":"xopt/generators/ga/cnsga.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"population"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":15,"string":"15"},"non_dunder_count_jedi":{"kind":"number","value":17,"string":"17"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["population","children","n_pop","offspring","toolbox","__init__","_vocs","create_children","crossover_probability","generate","mutation_probability","update_data","data","is_done","options","vocs","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__slots__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"population\",\n \"children\",\n \"n_pop\",\n \"offspring\",\n \"toolbox\",\n \"__init__\",\n \"_vocs\",\n \"create_children\",\n \"crossover_probability\",\n \"generate\",\n \"mutation_probability\",\n \"update_data\",\n \"data\",\n \"is_done\",\n \"options\",\n \"vocs\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__slots__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"children","type":"statement"},{"name":"create_children","type":"function"},{"name":"crossover_probability","type":"statement"},{"name":"data","type":"property"},{"name":"generate","type":"function"},{"name":"is_done","type":"property"},{"name":"mutation_probability","type":"statement"},{"name":"n_pop","type":"statement"},{"name":"offspring","type":"statement"},{"name":"options","type":"statement"},{"name":"population","type":"statement"},{"name":"toolbox","type":"statement"},{"name":"update_data","type":"function"},{"name":"vocs","type":"property"},{"name":"_data","type":"statement"},{"name":"_is_done","type":"statement"},{"name":"_vocs","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"children\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"create_children\",\n \"type\": \"function\"\n },\n {\n \"name\": \"crossover_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"data\",\n \"type\": \"property\"\n },\n {\n \"name\": \"generate\",\n \"type\": \"function\"\n },\n {\n \"name\": \"is_done\",\n \"type\": \"property\"\n },\n {\n \"name\": \"mutation_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"n_pop\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"offspring\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"options\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"population\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"toolbox\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"update_data\",\n \"type\": \"function\"\n },\n {\n \"name\": \"vocs\",\n \"type\": \"property\"\n },\n {\n \"name\": \"_data\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_is_done\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_vocs\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"\nfrom xopt.generators.ga import deap_creator\nfrom xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints\n\nfrom xopt import Generator\n\nfrom deap import base as deap_base\nfrom deap import tools as deap_tools\nfrom deap import algorithms as deap_algorithms\n\nimport pandas as pd\n\nimport random\nimport array\n\n\nfrom typing import List, Dict\n\nimport logging\nlogger = logging.getLogger(__name__)\n\n\nfrom typing import List, Dict\n\nclass CNSGAGenerator(Generator):\n\n\n def __init__(self, vocs, *, \n n_pop,\n data = None,\n crossover_probability = 0.9,\n mutation_probability = 1.0\n ): \n\n self._vocs = vocs # TODO: use proper options\n self.n_pop = n_pop\n self.crossover_probability = crossover_probability\n self.mutation_probability = mutation_probability\n\n\n # Internal data structures\n self.children = [] # unevaluated inputs. This should be a list of dicts.\n self.population = None # The latest population (fully evaluated)\n self.offspring = None # Newly evaluated data, but not yet added to population\n\n # DEAP toolbox (internal)\n self.toolbox = cnsga_toolbox(vocs, selection='auto')\n\n if data is not None:\n self.population = cnsga_select(data, n_pop, vocs, self.toolbox)\n\n\n def create_children(self):\n\n # No population, so create random children\n if self."}}},{"rowIdx":84,"cells":{"idx":{"kind":"number","value":118,"string":"118"},"idx_lca":{"kind":"number","value":6,"string":"6"},"offset":{"kind":"number","value":1435,"string":"1,435"},"repo":{"kind":"string","value":"christophermayes__xopt"},"commit_hash":{"kind":"string","value":"683fd0c3af2f0fc12a598932b20e3afe8070112b"},"target_file":{"kind":"string","value":"xopt/generators/ga/cnsga.py"},"line_type_lca":{"kind":"string","value":"inproject"},"ground_truth":{"kind":"string","value":"vocs"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"property"},"non_dunder_count_intellij":{"kind":"number","value":15,"string":"15"},"non_dunder_count_jedi":{"kind":"number","value":17,"string":"17"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["children","toolbox","n_pop","offspring","population","__init__","_vocs","create_children","crossover_probability","generate","mutation_probability","update_data","data","is_done","options","vocs","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__slots__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"children\",\n \"toolbox\",\n \"n_pop\",\n \"offspring\",\n \"population\",\n \"__init__\",\n \"_vocs\",\n \"create_children\",\n \"crossover_probability\",\n \"generate\",\n \"mutation_probability\",\n \"update_data\",\n \"data\",\n \"is_done\",\n \"options\",\n \"vocs\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__slots__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"children","type":"statement"},{"name":"create_children","type":"function"},{"name":"crossover_probability","type":"statement"},{"name":"data","type":"property"},{"name":"generate","type":"function"},{"name":"is_done","type":"property"},{"name":"mutation_probability","type":"statement"},{"name":"n_pop","type":"statement"},{"name":"offspring","type":"statement"},{"name":"options","type":"statement"},{"name":"population","type":"statement"},{"name":"toolbox","type":"statement"},{"name":"update_data","type":"function"},{"name":"vocs","type":"property"},{"name":"_data","type":"statement"},{"name":"_is_done","type":"statement"},{"name":"_vocs","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"children\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"create_children\",\n \"type\": \"function\"\n },\n {\n \"name\": \"crossover_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"data\",\n \"type\": \"property\"\n },\n {\n \"name\": \"generate\",\n \"type\": \"function\"\n },\n {\n \"name\": \"is_done\",\n \"type\": \"property\"\n },\n {\n \"name\": \"mutation_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"n_pop\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"offspring\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"options\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"population\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"toolbox\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"update_data\",\n \"type\": \"function\"\n },\n {\n \"name\": \"vocs\",\n \"type\": \"property\"\n },\n {\n \"name\": \"_data\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_is_done\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_vocs\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"\nfrom xopt.generators.ga import deap_creator\nfrom xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints\n\nfrom xopt import Generator\n\nfrom deap import base as deap_base\nfrom deap import tools as deap_tools\nfrom deap import algorithms as deap_algorithms\n\nimport pandas as pd\n\nimport random\nimport array\n\n\nfrom typing import List, Dict\n\nimport logging\nlogger = logging.getLogger(__name__)\n\n\nfrom typing import List, Dict\n\nclass CNSGAGenerator(Generator):\n\n\n def __init__(self, vocs, *, \n n_pop,\n data = None,\n crossover_probability = 0.9,\n mutation_probability = 1.0\n ): \n\n self._vocs = vocs # TODO: use proper options\n self.n_pop = n_pop\n self.crossover_probability = crossover_probability\n self.mutation_probability = mutation_probability\n\n\n # Internal data structures\n self.children = [] # unevaluated inputs. This should be a list of dicts.\n self.population = None # The latest population (fully evaluated)\n self.offspring = None # Newly evaluated data, but not yet added to population\n\n # DEAP toolbox (internal)\n self.toolbox = cnsga_toolbox(vocs, selection='auto')\n\n if data is not None:\n self.population = cnsga_select(data, n_pop, vocs, self.toolbox)\n\n\n def create_children(self):\n\n # No population, so create random children\n if self.population is None:\n return [self."}}},{"rowIdx":85,"cells":{"idx":{"kind":"number","value":119,"string":"119"},"idx_lca":{"kind":"number","value":6,"string":"6"},"offset":{"kind":"number","value":1476,"string":"1,476"},"repo":{"kind":"string","value":"christophermayes__xopt"},"commit_hash":{"kind":"string","value":"683fd0c3af2f0fc12a598932b20e3afe8070112b"},"target_file":{"kind":"string","value":"xopt/generators/ga/cnsga.py"},"line_type_lca":{"kind":"string","value":"inproject"},"ground_truth":{"kind":"string","value":"n_pop"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":15,"string":"15"},"non_dunder_count_jedi":{"kind":"number","value":17,"string":"17"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["children","offspring","population","_vocs","n_pop","__init__","create_children","crossover_probability","generate","mutation_probability","toolbox","update_data","data","is_done","options","vocs","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__slots__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"children\",\n \"offspring\",\n \"population\",\n \"_vocs\",\n \"n_pop\",\n \"__init__\",\n \"create_children\",\n \"crossover_probability\",\n \"generate\",\n \"mutation_probability\",\n \"toolbox\",\n \"update_data\",\n \"data\",\n \"is_done\",\n \"options\",\n \"vocs\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__slots__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"children","type":"statement"},{"name":"create_children","type":"function"},{"name":"crossover_probability","type":"statement"},{"name":"data","type":"property"},{"name":"generate","type":"function"},{"name":"is_done","type":"property"},{"name":"mutation_probability","type":"statement"},{"name":"n_pop","type":"statement"},{"name":"offspring","type":"statement"},{"name":"options","type":"statement"},{"name":"population","type":"statement"},{"name":"toolbox","type":"statement"},{"name":"update_data","type":"function"},{"name":"vocs","type":"property"},{"name":"_data","type":"statement"},{"name":"_is_done","type":"statement"},{"name":"_vocs","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"children\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"create_children\",\n \"type\": \"function\"\n },\n {\n \"name\": \"crossover_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"data\",\n \"type\": \"property\"\n },\n {\n \"name\": \"generate\",\n \"type\": \"function\"\n },\n {\n \"name\": \"is_done\",\n \"type\": \"property\"\n },\n {\n \"name\": \"mutation_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"n_pop\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"offspring\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"options\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"population\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"toolbox\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"update_data\",\n \"type\": \"function\"\n },\n {\n \"name\": \"vocs\",\n \"type\": \"property\"\n },\n {\n \"name\": \"_data\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_is_done\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_vocs\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"\nfrom xopt.generators.ga import deap_creator\nfrom xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints\n\nfrom xopt import Generator\n\nfrom deap import base as deap_base\nfrom deap import tools as deap_tools\nfrom deap import algorithms as deap_algorithms\n\nimport pandas as pd\n\nimport random\nimport array\n\n\nfrom typing import List, Dict\n\nimport logging\nlogger = logging.getLogger(__name__)\n\n\nfrom typing import List, Dict\n\nclass CNSGAGenerator(Generator):\n\n\n def __init__(self, vocs, *, \n n_pop,\n data = None,\n crossover_probability = 0.9,\n mutation_probability = 1.0\n ): \n\n self._vocs = vocs # TODO: use proper options\n self.n_pop = n_pop\n self.crossover_probability = crossover_probability\n self.mutation_probability = mutation_probability\n\n\n # Internal data structures\n self.children = [] # unevaluated inputs. This should be a list of dicts.\n self.population = None # The latest population (fully evaluated)\n self.offspring = None # Newly evaluated data, but not yet added to population\n\n # DEAP toolbox (internal)\n self.toolbox = cnsga_toolbox(vocs, selection='auto')\n\n if data is not None:\n self.population = cnsga_select(data, n_pop, vocs, self.toolbox)\n\n\n def create_children(self):\n\n # No population, so create random children\n if self.population is None:\n return [self.vocs.random_inputs() for _ in range(self."}}},{"rowIdx":86,"cells":{"idx":{"kind":"number","value":120,"string":"120"},"idx_lca":{"kind":"number","value":6,"string":"6"},"offset":{"kind":"number","value":1567,"string":"1,567"},"repo":{"kind":"string","value":"christophermayes__xopt"},"commit_hash":{"kind":"string","value":"683fd0c3af2f0fc12a598932b20e3afe8070112b"},"target_file":{"kind":"string","value":"xopt/generators/ga/cnsga.py"},"line_type_lca":{"kind":"string","value":"inproject"},"ground_truth":{"kind":"string","value":"population"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":15,"string":"15"},"non_dunder_count_jedi":{"kind":"number","value":17,"string":"17"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["children","data","offspring","n_pop","toolbox","__init__","_vocs","create_children","crossover_probability","generate","mutation_probability","population","update_data","is_done","options","vocs","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__slots__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"children\",\n \"data\",\n \"offspring\",\n \"n_pop\",\n \"toolbox\",\n \"__init__\",\n \"_vocs\",\n \"create_children\",\n \"crossover_probability\",\n \"generate\",\n \"mutation_probability\",\n \"population\",\n \"update_data\",\n \"is_done\",\n \"options\",\n \"vocs\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__slots__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"children","type":"statement"},{"name":"create_children","type":"function"},{"name":"crossover_probability","type":"statement"},{"name":"data","type":"property"},{"name":"generate","type":"function"},{"name":"is_done","type":"property"},{"name":"mutation_probability","type":"statement"},{"name":"n_pop","type":"statement"},{"name":"offspring","type":"statement"},{"name":"options","type":"statement"},{"name":"population","type":"statement"},{"name":"toolbox","type":"statement"},{"name":"update_data","type":"function"},{"name":"vocs","type":"property"},{"name":"_data","type":"statement"},{"name":"_is_done","type":"statement"},{"name":"_vocs","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"children\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"create_children\",\n \"type\": \"function\"\n },\n {\n \"name\": \"crossover_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"data\",\n \"type\": \"property\"\n },\n {\n \"name\": \"generate\",\n \"type\": \"function\"\n },\n {\n \"name\": \"is_done\",\n \"type\": \"property\"\n },\n {\n \"name\": \"mutation_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"n_pop\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"offspring\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"options\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"population\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"toolbox\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"update_data\",\n \"type\": \"function\"\n },\n {\n \"name\": \"vocs\",\n \"type\": \"property\"\n },\n {\n \"name\": \"_data\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_is_done\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_vocs\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"\nfrom xopt.generators.ga import deap_creator\nfrom xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints\n\nfrom xopt import Generator\n\nfrom deap import base as deap_base\nfrom deap import tools as deap_tools\nfrom deap import algorithms as deap_algorithms\n\nimport pandas as pd\n\nimport random\nimport array\n\n\nfrom typing import List, Dict\n\nimport logging\nlogger = logging.getLogger(__name__)\n\n\nfrom typing import List, Dict\n\nclass CNSGAGenerator(Generator):\n\n\n def __init__(self, vocs, *, \n n_pop,\n data = None,\n crossover_probability = 0.9,\n mutation_probability = 1.0\n ): \n\n self._vocs = vocs # TODO: use proper options\n self.n_pop = n_pop\n self.crossover_probability = crossover_probability\n self.mutation_probability = mutation_probability\n\n\n # Internal data structures\n self.children = [] # unevaluated inputs. This should be a list of dicts.\n self.population = None # The latest population (fully evaluated)\n self.offspring = None # Newly evaluated data, but not yet added to population\n\n # DEAP toolbox (internal)\n self.toolbox = cnsga_toolbox(vocs, selection='auto')\n\n if data is not None:\n self.population = cnsga_select(data, n_pop, vocs, self.toolbox)\n\n\n def create_children(self):\n\n # No population, so create random children\n if self.population is None:\n return [self.vocs.random_inputs() for _ in range(self.n_pop)]\n\n # Use population to create children\n inputs = cnsga_variation(self."}}},{"rowIdx":87,"cells":{"idx":{"kind":"number","value":121,"string":"121"},"idx_lca":{"kind":"number","value":6,"string":"6"},"offset":{"kind":"number","value":1584,"string":"1,584"},"repo":{"kind":"string","value":"christophermayes__xopt"},"commit_hash":{"kind":"string","value":"683fd0c3af2f0fc12a598932b20e3afe8070112b"},"target_file":{"kind":"string","value":"xopt/generators/ga/cnsga.py"},"line_type_lca":{"kind":"string","value":"inproject"},"ground_truth":{"kind":"string","value":"vocs"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"property"},"non_dunder_count_intellij":{"kind":"number","value":15,"string":"15"},"non_dunder_count_jedi":{"kind":"number","value":17,"string":"17"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["vocs","children","population","toolbox","offspring","__init__","_vocs","create_children","crossover_probability","generate","mutation_probability","n_pop","update_data","data","is_done","options","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__slots__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"vocs\",\n \"children\",\n \"population\",\n \"toolbox\",\n \"offspring\",\n \"__init__\",\n \"_vocs\",\n \"create_children\",\n \"crossover_probability\",\n \"generate\",\n \"mutation_probability\",\n \"n_pop\",\n \"update_data\",\n \"data\",\n \"is_done\",\n \"options\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__slots__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"children","type":"statement"},{"name":"create_children","type":"function"},{"name":"crossover_probability","type":"statement"},{"name":"data","type":"property"},{"name":"generate","type":"function"},{"name":"is_done","type":"property"},{"name":"mutation_probability","type":"statement"},{"name":"n_pop","type":"statement"},{"name":"offspring","type":"statement"},{"name":"options","type":"statement"},{"name":"population","type":"statement"},{"name":"toolbox","type":"statement"},{"name":"update_data","type":"function"},{"name":"vocs","type":"property"},{"name":"_data","type":"statement"},{"name":"_is_done","type":"statement"},{"name":"_vocs","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"children\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"create_children\",\n \"type\": \"function\"\n },\n {\n \"name\": \"crossover_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"data\",\n \"type\": \"property\"\n },\n {\n \"name\": \"generate\",\n \"type\": \"function\"\n },\n {\n \"name\": \"is_done\",\n \"type\": \"property\"\n },\n {\n \"name\": \"mutation_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"n_pop\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"offspring\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"options\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"population\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"toolbox\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"update_data\",\n \"type\": \"function\"\n },\n {\n \"name\": \"vocs\",\n \"type\": \"property\"\n },\n {\n \"name\": \"_data\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_is_done\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_vocs\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"\nfrom xopt.generators.ga import deap_creator\nfrom xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints\n\nfrom xopt import Generator\n\nfrom deap import base as deap_base\nfrom deap import tools as deap_tools\nfrom deap import algorithms as deap_algorithms\n\nimport pandas as pd\n\nimport random\nimport array\n\n\nfrom typing import List, Dict\n\nimport logging\nlogger = logging.getLogger(__name__)\n\n\nfrom typing import List, Dict\n\nclass CNSGAGenerator(Generator):\n\n\n def __init__(self, vocs, *, \n n_pop,\n data = None,\n crossover_probability = 0.9,\n mutation_probability = 1.0\n ): \n\n self._vocs = vocs # TODO: use proper options\n self.n_pop = n_pop\n self.crossover_probability = crossover_probability\n self.mutation_probability = mutation_probability\n\n\n # Internal data structures\n self.children = [] # unevaluated inputs. This should be a list of dicts.\n self.population = None # The latest population (fully evaluated)\n self.offspring = None # Newly evaluated data, but not yet added to population\n\n # DEAP toolbox (internal)\n self.toolbox = cnsga_toolbox(vocs, selection='auto')\n\n if data is not None:\n self.population = cnsga_select(data, n_pop, vocs, self.toolbox)\n\n\n def create_children(self):\n\n # No population, so create random children\n if self.population is None:\n return [self.vocs.random_inputs() for _ in range(self.n_pop)]\n\n # Use population to create children\n inputs = cnsga_variation(self.population, self."}}},{"rowIdx":88,"cells":{"idx":{"kind":"number","value":122,"string":"122"},"idx_lca":{"kind":"number","value":6,"string":"6"},"offset":{"kind":"number","value":1595,"string":"1,595"},"repo":{"kind":"string","value":"christophermayes__xopt"},"commit_hash":{"kind":"string","value":"683fd0c3af2f0fc12a598932b20e3afe8070112b"},"target_file":{"kind":"string","value":"xopt/generators/ga/cnsga.py"},"line_type_lca":{"kind":"string","value":"inproject"},"ground_truth":{"kind":"string","value":"toolbox"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":15,"string":"15"},"non_dunder_count_jedi":{"kind":"number","value":17,"string":"17"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["toolbox","children","population","offspring","n_pop","__init__","_vocs","create_children","crossover_probability","generate","mutation_probability","update_data","data","is_done","options","vocs","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__slots__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"toolbox\",\n \"children\",\n \"population\",\n \"offspring\",\n \"n_pop\",\n \"__init__\",\n \"_vocs\",\n \"create_children\",\n \"crossover_probability\",\n \"generate\",\n \"mutation_probability\",\n \"update_data\",\n \"data\",\n \"is_done\",\n \"options\",\n \"vocs\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__slots__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"children","type":"statement"},{"name":"create_children","type":"function"},{"name":"crossover_probability","type":"statement"},{"name":"data","type":"property"},{"name":"generate","type":"function"},{"name":"is_done","type":"property"},{"name":"mutation_probability","type":"statement"},{"name":"n_pop","type":"statement"},{"name":"offspring","type":"statement"},{"name":"options","type":"statement"},{"name":"population","type":"statement"},{"name":"toolbox","type":"statement"},{"name":"update_data","type":"function"},{"name":"vocs","type":"property"},{"name":"_data","type":"statement"},{"name":"_is_done","type":"statement"},{"name":"_vocs","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"children\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"create_children\",\n \"type\": \"function\"\n },\n {\n \"name\": \"crossover_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"data\",\n \"type\": \"property\"\n },\n {\n \"name\": \"generate\",\n \"type\": \"function\"\n },\n {\n \"name\": \"is_done\",\n \"type\": \"property\"\n },\n {\n \"name\": \"mutation_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"n_pop\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"offspring\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"options\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"population\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"toolbox\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"update_data\",\n \"type\": \"function\"\n },\n {\n \"name\": \"vocs\",\n \"type\": \"property\"\n },\n {\n \"name\": \"_data\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_is_done\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_vocs\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"\nfrom xopt.generators.ga import deap_creator\nfrom xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints\n\nfrom xopt import Generator\n\nfrom deap import base as deap_base\nfrom deap import tools as deap_tools\nfrom deap import algorithms as deap_algorithms\n\nimport pandas as pd\n\nimport random\nimport array\n\n\nfrom typing import List, Dict\n\nimport logging\nlogger = logging.getLogger(__name__)\n\n\nfrom typing import List, Dict\n\nclass CNSGAGenerator(Generator):\n\n\n def __init__(self, vocs, *, \n n_pop,\n data = None,\n crossover_probability = 0.9,\n mutation_probability = 1.0\n ): \n\n self._vocs = vocs # TODO: use proper options\n self.n_pop = n_pop\n self.crossover_probability = crossover_probability\n self.mutation_probability = mutation_probability\n\n\n # Internal data structures\n self.children = [] # unevaluated inputs. This should be a list of dicts.\n self.population = None # The latest population (fully evaluated)\n self.offspring = None # Newly evaluated data, but not yet added to population\n\n # DEAP toolbox (internal)\n self.toolbox = cnsga_toolbox(vocs, selection='auto')\n\n if data is not None:\n self.population = cnsga_select(data, n_pop, vocs, self.toolbox)\n\n\n def create_children(self):\n\n # No population, so create random children\n if self.population is None:\n return [self.vocs.random_inputs() for _ in range(self.n_pop)]\n\n # Use population to create children\n inputs = cnsga_variation(self.population, self.vocs, self."}}},{"rowIdx":89,"cells":{"idx":{"kind":"number","value":123,"string":"123"},"idx_lca":{"kind":"number","value":6,"string":"6"},"offset":{"kind":"number","value":1643,"string":"1,643"},"repo":{"kind":"string","value":"christophermayes__xopt"},"commit_hash":{"kind":"string","value":"683fd0c3af2f0fc12a598932b20e3afe8070112b"},"target_file":{"kind":"string","value":"xopt/generators/ga/cnsga.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"crossover_probability"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":15,"string":"15"},"non_dunder_count_jedi":{"kind":"number","value":17,"string":"17"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["crossover_probability","mutation_probability","offspring","children","n_pop","__init__","_vocs","create_children","generate","population","toolbox","update_data","data","is_done","options","vocs","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__slots__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"crossover_probability\",\n \"mutation_probability\",\n \"offspring\",\n \"children\",\n \"n_pop\",\n \"__init__\",\n \"_vocs\",\n \"create_children\",\n \"generate\",\n \"population\",\n \"toolbox\",\n \"update_data\",\n \"data\",\n \"is_done\",\n \"options\",\n \"vocs\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__slots__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"children","type":"statement"},{"name":"create_children","type":"function"},{"name":"crossover_probability","type":"statement"},{"name":"data","type":"property"},{"name":"generate","type":"function"},{"name":"is_done","type":"property"},{"name":"mutation_probability","type":"statement"},{"name":"n_pop","type":"statement"},{"name":"offspring","type":"statement"},{"name":"options","type":"statement"},{"name":"population","type":"statement"},{"name":"toolbox","type":"statement"},{"name":"update_data","type":"function"},{"name":"vocs","type":"property"},{"name":"_data","type":"statement"},{"name":"_is_done","type":"statement"},{"name":"_vocs","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"children\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"create_children\",\n \"type\": \"function\"\n },\n {\n \"name\": \"crossover_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"data\",\n \"type\": \"property\"\n },\n {\n \"name\": \"generate\",\n \"type\": \"function\"\n },\n {\n \"name\": \"is_done\",\n \"type\": \"property\"\n },\n {\n \"name\": \"mutation_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"n_pop\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"offspring\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"options\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"population\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"toolbox\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"update_data\",\n \"type\": \"function\"\n },\n {\n \"name\": \"vocs\",\n \"type\": \"property\"\n },\n {\n \"name\": \"_data\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_is_done\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_vocs\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"\nfrom xopt.generators.ga import deap_creator\nfrom xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints\n\nfrom xopt import Generator\n\nfrom deap import base as deap_base\nfrom deap import tools as deap_tools\nfrom deap import algorithms as deap_algorithms\n\nimport pandas as pd\n\nimport random\nimport array\n\n\nfrom typing import List, Dict\n\nimport logging\nlogger = logging.getLogger(__name__)\n\n\nfrom typing import List, Dict\n\nclass CNSGAGenerator(Generator):\n\n\n def __init__(self, vocs, *, \n n_pop,\n data = None,\n crossover_probability = 0.9,\n mutation_probability = 1.0\n ): \n\n self._vocs = vocs # TODO: use proper options\n self.n_pop = n_pop\n self.crossover_probability = crossover_probability\n self.mutation_probability = mutation_probability\n\n\n # Internal data structures\n self.children = [] # unevaluated inputs. This should be a list of dicts.\n self.population = None # The latest population (fully evaluated)\n self.offspring = None # Newly evaluated data, but not yet added to population\n\n # DEAP toolbox (internal)\n self.toolbox = cnsga_toolbox(vocs, selection='auto')\n\n if data is not None:\n self.population = cnsga_select(data, n_pop, vocs, self.toolbox)\n\n\n def create_children(self):\n\n # No population, so create random children\n if self.population is None:\n return [self.vocs.random_inputs() for _ in range(self.n_pop)]\n\n # Use population to create children\n inputs = cnsga_variation(self.population, self.vocs, self.toolbox,\n crossover_probability=self."}}},{"rowIdx":90,"cells":{"idx":{"kind":"number","value":124,"string":"124"},"idx_lca":{"kind":"number","value":6,"string":"6"},"offset":{"kind":"number","value":1692,"string":"1,692"},"repo":{"kind":"string","value":"christophermayes__xopt"},"commit_hash":{"kind":"string","value":"683fd0c3af2f0fc12a598932b20e3afe8070112b"},"target_file":{"kind":"string","value":"xopt/generators/ga/cnsga.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"mutation_probability"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":15,"string":"15"},"non_dunder_count_jedi":{"kind":"number","value":17,"string":"17"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["mutation_probability","crossover_probability","offspring","children","population","__init__","_vocs","create_children","generate","n_pop","toolbox","update_data","data","is_done","options","vocs","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__slots__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"mutation_probability\",\n \"crossover_probability\",\n \"offspring\",\n \"children\",\n \"population\",\n \"__init__\",\n \"_vocs\",\n \"create_children\",\n \"generate\",\n \"n_pop\",\n \"toolbox\",\n \"update_data\",\n \"data\",\n \"is_done\",\n \"options\",\n \"vocs\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__slots__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"children","type":"statement"},{"name":"create_children","type":"function"},{"name":"crossover_probability","type":"statement"},{"name":"data","type":"property"},{"name":"generate","type":"function"},{"name":"is_done","type":"property"},{"name":"mutation_probability","type":"statement"},{"name":"n_pop","type":"statement"},{"name":"offspring","type":"statement"},{"name":"options","type":"statement"},{"name":"population","type":"statement"},{"name":"toolbox","type":"statement"},{"name":"update_data","type":"function"},{"name":"vocs","type":"property"},{"name":"_data","type":"statement"},{"name":"_is_done","type":"statement"},{"name":"_vocs","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"children\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"create_children\",\n \"type\": \"function\"\n },\n {\n \"name\": \"crossover_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"data\",\n \"type\": \"property\"\n },\n {\n \"name\": \"generate\",\n \"type\": \"function\"\n },\n {\n \"name\": \"is_done\",\n \"type\": \"property\"\n },\n {\n \"name\": \"mutation_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"n_pop\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"offspring\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"options\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"population\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"toolbox\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"update_data\",\n \"type\": \"function\"\n },\n {\n \"name\": \"vocs\",\n \"type\": \"property\"\n },\n {\n \"name\": \"_data\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_is_done\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_vocs\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"\nfrom xopt.generators.ga import deap_creator\nfrom xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints\n\nfrom xopt import Generator\n\nfrom deap import base as deap_base\nfrom deap import tools as deap_tools\nfrom deap import algorithms as deap_algorithms\n\nimport pandas as pd\n\nimport random\nimport array\n\n\nfrom typing import List, Dict\n\nimport logging\nlogger = logging.getLogger(__name__)\n\n\nfrom typing import List, Dict\n\nclass CNSGAGenerator(Generator):\n\n\n def __init__(self, vocs, *, \n n_pop,\n data = None,\n crossover_probability = 0.9,\n mutation_probability = 1.0\n ): \n\n self._vocs = vocs # TODO: use proper options\n self.n_pop = n_pop\n self.crossover_probability = crossover_probability\n self.mutation_probability = mutation_probability\n\n\n # Internal data structures\n self.children = [] # unevaluated inputs. This should be a list of dicts.\n self.population = None # The latest population (fully evaluated)\n self.offspring = None # Newly evaluated data, but not yet added to population\n\n # DEAP toolbox (internal)\n self.toolbox = cnsga_toolbox(vocs, selection='auto')\n\n if data is not None:\n self.population = cnsga_select(data, n_pop, vocs, self.toolbox)\n\n\n def create_children(self):\n\n # No population, so create random children\n if self.population is None:\n return [self.vocs.random_inputs() for _ in range(self.n_pop)]\n\n # Use population to create children\n inputs = cnsga_variation(self.population, self.vocs, self.toolbox,\n crossover_probability=self.crossover_probability, mutation_probability=self."}}},{"rowIdx":91,"cells":{"idx":{"kind":"number","value":126,"string":"126"},"idx_lca":{"kind":"number","value":6,"string":"6"},"offset":{"kind":"number","value":1856,"string":"1,856"},"repo":{"kind":"string","value":"christophermayes__xopt"},"commit_hash":{"kind":"string","value":"683fd0c3af2f0fc12a598932b20e3afe8070112b"},"target_file":{"kind":"string","value":"xopt/generators/ga/cnsga.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"offspring"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":17,"string":"17"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":true,"string":"true"},"intellij_completions":{"kind":"list like","value":["offspring","children","n_pop","population","toolbox","__init__","_vocs","create_children","crossover_probability","generate","mutation_probability","update_data","data","is_done","options","vocs","for","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__slots__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"offspring\",\n \"children\",\n \"n_pop\",\n \"population\",\n \"toolbox\",\n \"__init__\",\n \"_vocs\",\n \"create_children\",\n \"crossover_probability\",\n \"generate\",\n \"mutation_probability\",\n \"update_data\",\n \"data\",\n \"is_done\",\n \"options\",\n \"vocs\",\n \"for\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__slots__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"children","type":"statement"},{"name":"create_children","type":"function"},{"name":"crossover_probability","type":"statement"},{"name":"data","type":"property"},{"name":"generate","type":"function"},{"name":"is_done","type":"property"},{"name":"mutation_probability","type":"statement"},{"name":"n_pop","type":"statement"},{"name":"offspring","type":"statement"},{"name":"options","type":"statement"},{"name":"population","type":"statement"},{"name":"toolbox","type":"statement"},{"name":"update_data","type":"function"},{"name":"vocs","type":"property"},{"name":"_data","type":"statement"},{"name":"_is_done","type":"statement"},{"name":"_vocs","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"children\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"create_children\",\n \"type\": \"function\"\n },\n {\n \"name\": \"crossover_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"data\",\n \"type\": \"property\"\n },\n {\n \"name\": \"generate\",\n \"type\": \"function\"\n },\n {\n \"name\": \"is_done\",\n \"type\": \"property\"\n },\n {\n \"name\": \"mutation_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"n_pop\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"offspring\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"options\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"population\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"toolbox\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"update_data\",\n \"type\": \"function\"\n },\n {\n \"name\": \"vocs\",\n \"type\": \"property\"\n },\n {\n \"name\": \"_data\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_is_done\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_vocs\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"\nfrom xopt.generators.ga import deap_creator\nfrom xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints\n\nfrom xopt import Generator\n\nfrom deap import base as deap_base\nfrom deap import tools as deap_tools\nfrom deap import algorithms as deap_algorithms\n\nimport pandas as pd\n\nimport random\nimport array\n\n\nfrom typing import List, Dict\n\nimport logging\nlogger = logging.getLogger(__name__)\n\n\nfrom typing import List, Dict\n\nclass CNSGAGenerator(Generator):\n\n\n def __init__(self, vocs, *, \n n_pop,\n data = None,\n crossover_probability = 0.9,\n mutation_probability = 1.0\n ): \n\n self._vocs = vocs # TODO: use proper options\n self.n_pop = n_pop\n self.crossover_probability = crossover_probability\n self.mutation_probability = mutation_probability\n\n\n # Internal data structures\n self.children = [] # unevaluated inputs. This should be a list of dicts.\n self.population = None # The latest population (fully evaluated)\n self.offspring = None # Newly evaluated data, but not yet added to population\n\n # DEAP toolbox (internal)\n self.toolbox = cnsga_toolbox(vocs, selection='auto')\n\n if data is not None:\n self.population = cnsga_select(data, n_pop, vocs, self.toolbox)\n\n\n def create_children(self):\n\n # No population, so create random children\n if self.population is None:\n return [self.vocs.random_inputs() for _ in range(self.n_pop)]\n\n # Use population to create children\n inputs = cnsga_variation(self.population, self.vocs, self.toolbox,\n crossover_probability=self.crossover_probability, mutation_probability=self.mutation_probability)\n return inputs.to_dict(orient='records')\n\n\n def update_data(self, new_data: pd.DataFrame):\n self.offspring = pd.concat([self."}}},{"rowIdx":92,"cells":{"idx":{"kind":"number","value":127,"string":"127"},"idx_lca":{"kind":"number","value":6,"string":"6"},"offset":{"kind":"number","value":1925,"string":"1,925"},"repo":{"kind":"string","value":"christophermayes__xopt"},"commit_hash":{"kind":"string","value":"683fd0c3af2f0fc12a598932b20e3afe8070112b"},"target_file":{"kind":"string","value":"xopt/generators/ga/cnsga.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"offspring"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":15,"string":"15"},"non_dunder_count_jedi":{"kind":"number","value":17,"string":"17"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["n_pop","children","population","toolbox","offspring","__init__","_vocs","create_children","crossover_probability","generate","mutation_probability","update_data","data","is_done","options","vocs","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__slots__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"n_pop\",\n \"children\",\n \"population\",\n \"toolbox\",\n \"offspring\",\n \"__init__\",\n \"_vocs\",\n \"create_children\",\n \"crossover_probability\",\n \"generate\",\n \"mutation_probability\",\n \"update_data\",\n \"data\",\n \"is_done\",\n \"options\",\n \"vocs\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__slots__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"children","type":"statement"},{"name":"create_children","type":"function"},{"name":"crossover_probability","type":"statement"},{"name":"data","type":"property"},{"name":"generate","type":"function"},{"name":"is_done","type":"property"},{"name":"mutation_probability","type":"statement"},{"name":"n_pop","type":"statement"},{"name":"offspring","type":"statement"},{"name":"options","type":"statement"},{"name":"population","type":"statement"},{"name":"toolbox","type":"statement"},{"name":"update_data","type":"function"},{"name":"vocs","type":"property"},{"name":"_data","type":"statement"},{"name":"_is_done","type":"statement"},{"name":"_vocs","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"children\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"create_children\",\n \"type\": \"function\"\n },\n {\n \"name\": \"crossover_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"data\",\n \"type\": \"property\"\n },\n {\n \"name\": \"generate\",\n \"type\": \"function\"\n },\n {\n \"name\": \"is_done\",\n \"type\": \"property\"\n },\n {\n \"name\": \"mutation_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"n_pop\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"offspring\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"options\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"population\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"toolbox\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"update_data\",\n \"type\": \"function\"\n },\n {\n \"name\": \"vocs\",\n \"type\": \"property\"\n },\n {\n \"name\": \"_data\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_is_done\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_vocs\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"\nfrom xopt.generators.ga import deap_creator\nfrom xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints\n\nfrom xopt import Generator\n\nfrom deap import base as deap_base\nfrom deap import tools as deap_tools\nfrom deap import algorithms as deap_algorithms\n\nimport pandas as pd\n\nimport random\nimport array\n\n\nfrom typing import List, Dict\n\nimport logging\nlogger = logging.getLogger(__name__)\n\n\nfrom typing import List, Dict\n\nclass CNSGAGenerator(Generator):\n\n\n def __init__(self, vocs, *, \n n_pop,\n data = None,\n crossover_probability = 0.9,\n mutation_probability = 1.0\n ): \n\n self._vocs = vocs # TODO: use proper options\n self.n_pop = n_pop\n self.crossover_probability = crossover_probability\n self.mutation_probability = mutation_probability\n\n\n # Internal data structures\n self.children = [] # unevaluated inputs. This should be a list of dicts.\n self.population = None # The latest population (fully evaluated)\n self.offspring = None # Newly evaluated data, but not yet added to population\n\n # DEAP toolbox (internal)\n self.toolbox = cnsga_toolbox(vocs, selection='auto')\n\n if data is not None:\n self.population = cnsga_select(data, n_pop, vocs, self.toolbox)\n\n\n def create_children(self):\n\n # No population, so create random children\n if self.population is None:\n return [self.vocs.random_inputs() for _ in range(self.n_pop)]\n\n # Use population to create children\n inputs = cnsga_variation(self.population, self.vocs, self.toolbox,\n crossover_probability=self.crossover_probability, mutation_probability=self.mutation_probability)\n return inputs.to_dict(orient='records')\n\n\n def update_data(self, new_data: pd.DataFrame):\n self.offspring = pd.concat([self.offspring, new_data])\n\n # Next generation\n if len(self."}}},{"rowIdx":93,"cells":{"idx":{"kind":"number","value":128,"string":"128"},"idx_lca":{"kind":"number","value":6,"string":"6"},"offset":{"kind":"number","value":1944,"string":"1,944"},"repo":{"kind":"string","value":"christophermayes__xopt"},"commit_hash":{"kind":"string","value":"683fd0c3af2f0fc12a598932b20e3afe8070112b"},"target_file":{"kind":"string","value":"xopt/generators/ga/cnsga.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"n_pop"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":15,"string":"15"},"non_dunder_count_jedi":{"kind":"number","value":17,"string":"17"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["offspring","children","n_pop","toolbox","population","__init__","_vocs","create_children","crossover_probability","generate","mutation_probability","update_data","data","is_done","options","vocs","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__slots__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"offspring\",\n \"children\",\n \"n_pop\",\n \"toolbox\",\n \"population\",\n \"__init__\",\n \"_vocs\",\n \"create_children\",\n \"crossover_probability\",\n \"generate\",\n \"mutation_probability\",\n \"update_data\",\n \"data\",\n \"is_done\",\n \"options\",\n \"vocs\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__slots__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"children","type":"statement"},{"name":"create_children","type":"function"},{"name":"crossover_probability","type":"statement"},{"name":"data","type":"property"},{"name":"generate","type":"function"},{"name":"is_done","type":"property"},{"name":"mutation_probability","type":"statement"},{"name":"n_pop","type":"statement"},{"name":"offspring","type":"statement"},{"name":"options","type":"statement"},{"name":"population","type":"statement"},{"name":"toolbox","type":"statement"},{"name":"update_data","type":"function"},{"name":"vocs","type":"property"},{"name":"_data","type":"statement"},{"name":"_is_done","type":"statement"},{"name":"_vocs","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"children\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"create_children\",\n \"type\": \"function\"\n },\n {\n \"name\": \"crossover_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"data\",\n \"type\": \"property\"\n },\n {\n \"name\": \"generate\",\n \"type\": \"function\"\n },\n {\n \"name\": \"is_done\",\n \"type\": \"property\"\n },\n {\n \"name\": \"mutation_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"n_pop\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"offspring\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"options\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"population\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"toolbox\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"update_data\",\n \"type\": \"function\"\n },\n {\n \"name\": \"vocs\",\n \"type\": \"property\"\n },\n {\n \"name\": \"_data\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_is_done\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_vocs\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"\nfrom xopt.generators.ga import deap_creator\nfrom xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints\n\nfrom xopt import Generator\n\nfrom deap import base as deap_base\nfrom deap import tools as deap_tools\nfrom deap import algorithms as deap_algorithms\n\nimport pandas as pd\n\nimport random\nimport array\n\n\nfrom typing import List, Dict\n\nimport logging\nlogger = logging.getLogger(__name__)\n\n\nfrom typing import List, Dict\n\nclass CNSGAGenerator(Generator):\n\n\n def __init__(self, vocs, *, \n n_pop,\n data = None,\n crossover_probability = 0.9,\n mutation_probability = 1.0\n ): \n\n self._vocs = vocs # TODO: use proper options\n self.n_pop = n_pop\n self.crossover_probability = crossover_probability\n self.mutation_probability = mutation_probability\n\n\n # Internal data structures\n self.children = [] # unevaluated inputs. This should be a list of dicts.\n self.population = None # The latest population (fully evaluated)\n self.offspring = None # Newly evaluated data, but not yet added to population\n\n # DEAP toolbox (internal)\n self.toolbox = cnsga_toolbox(vocs, selection='auto')\n\n if data is not None:\n self.population = cnsga_select(data, n_pop, vocs, self.toolbox)\n\n\n def create_children(self):\n\n # No population, so create random children\n if self.population is None:\n return [self.vocs.random_inputs() for _ in range(self.n_pop)]\n\n # Use population to create children\n inputs = cnsga_variation(self.population, self.vocs, self.toolbox,\n crossover_probability=self.crossover_probability, mutation_probability=self.mutation_probability)\n return inputs.to_dict(orient='records')\n\n\n def update_data(self, new_data: pd.DataFrame):\n self.offspring = pd.concat([self.offspring, new_data])\n\n # Next generation\n if len(self.offspring) >= self."}}},{"rowIdx":94,"cells":{"idx":{"kind":"number","value":129,"string":"129"},"idx_lca":{"kind":"number","value":6,"string":"6"},"offset":{"kind":"number","value":1971,"string":"1,971"},"repo":{"kind":"string","value":"christophermayes__xopt"},"commit_hash":{"kind":"string","value":"683fd0c3af2f0fc12a598932b20e3afe8070112b"},"target_file":{"kind":"string","value":"xopt/generators/ga/cnsga.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"population"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":15,"string":"15"},"non_dunder_count_jedi":{"kind":"number","value":17,"string":"17"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["population","children","offspring","n_pop","toolbox","__init__","_vocs","create_children","crossover_probability","generate","mutation_probability","update_data","data","is_done","options","vocs","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__slots__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"population\",\n \"children\",\n \"offspring\",\n \"n_pop\",\n \"toolbox\",\n \"__init__\",\n \"_vocs\",\n \"create_children\",\n \"crossover_probability\",\n \"generate\",\n \"mutation_probability\",\n \"update_data\",\n \"data\",\n \"is_done\",\n \"options\",\n \"vocs\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__slots__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"children","type":"statement"},{"name":"create_children","type":"function"},{"name":"crossover_probability","type":"statement"},{"name":"data","type":"property"},{"name":"generate","type":"function"},{"name":"is_done","type":"property"},{"name":"mutation_probability","type":"statement"},{"name":"n_pop","type":"statement"},{"name":"offspring","type":"statement"},{"name":"options","type":"statement"},{"name":"population","type":"statement"},{"name":"toolbox","type":"statement"},{"name":"update_data","type":"function"},{"name":"vocs","type":"property"},{"name":"_data","type":"statement"},{"name":"_is_done","type":"statement"},{"name":"_vocs","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"children\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"create_children\",\n \"type\": \"function\"\n },\n {\n \"name\": \"crossover_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"data\",\n \"type\": \"property\"\n },\n {\n \"name\": \"generate\",\n \"type\": \"function\"\n },\n {\n \"name\": \"is_done\",\n \"type\": \"property\"\n },\n {\n \"name\": \"mutation_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"n_pop\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"offspring\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"options\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"population\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"toolbox\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"update_data\",\n \"type\": \"function\"\n },\n {\n \"name\": \"vocs\",\n \"type\": \"property\"\n },\n {\n \"name\": \"_data\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_is_done\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_vocs\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"\nfrom xopt.generators.ga import deap_creator\nfrom xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints\n\nfrom xopt import Generator\n\nfrom deap import base as deap_base\nfrom deap import tools as deap_tools\nfrom deap import algorithms as deap_algorithms\n\nimport pandas as pd\n\nimport random\nimport array\n\n\nfrom typing import List, Dict\n\nimport logging\nlogger = logging.getLogger(__name__)\n\n\nfrom typing import List, Dict\n\nclass CNSGAGenerator(Generator):\n\n\n def __init__(self, vocs, *, \n n_pop,\n data = None,\n crossover_probability = 0.9,\n mutation_probability = 1.0\n ): \n\n self._vocs = vocs # TODO: use proper options\n self.n_pop = n_pop\n self.crossover_probability = crossover_probability\n self.mutation_probability = mutation_probability\n\n\n # Internal data structures\n self.children = [] # unevaluated inputs. This should be a list of dicts.\n self.population = None # The latest population (fully evaluated)\n self.offspring = None # Newly evaluated data, but not yet added to population\n\n # DEAP toolbox (internal)\n self.toolbox = cnsga_toolbox(vocs, selection='auto')\n\n if data is not None:\n self.population = cnsga_select(data, n_pop, vocs, self.toolbox)\n\n\n def create_children(self):\n\n # No population, so create random children\n if self.population is None:\n return [self.vocs.random_inputs() for _ in range(self.n_pop)]\n\n # Use population to create children\n inputs = cnsga_variation(self.population, self.vocs, self.toolbox,\n crossover_probability=self.crossover_probability, mutation_probability=self.mutation_probability)\n return inputs.to_dict(orient='records')\n\n\n def update_data(self, new_data: pd.DataFrame):\n self.offspring = pd.concat([self.offspring, new_data])\n\n # Next generation\n if len(self.offspring) >= self.n_pop:\n if self."}}},{"rowIdx":95,"cells":{"idx":{"kind":"number","value":131,"string":"131"},"idx_lca":{"kind":"number","value":6,"string":"6"},"offset":{"kind":"number","value":2033,"string":"2,033"},"repo":{"kind":"string","value":"christophermayes__xopt"},"commit_hash":{"kind":"string","value":"683fd0c3af2f0fc12a598932b20e3afe8070112b"},"target_file":{"kind":"string","value":"xopt/generators/ga/cnsga.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"offspring"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":15,"string":"15"},"non_dunder_count_jedi":{"kind":"number","value":17,"string":"17"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["population","children","toolbox","data","offspring","__init__","_vocs","create_children","crossover_probability","generate","mutation_probability","n_pop","update_data","is_done","options","vocs","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__slots__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"population\",\n \"children\",\n \"toolbox\",\n \"data\",\n \"offspring\",\n \"__init__\",\n \"_vocs\",\n \"create_children\",\n \"crossover_probability\",\n \"generate\",\n \"mutation_probability\",\n \"n_pop\",\n \"update_data\",\n \"is_done\",\n \"options\",\n \"vocs\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__slots__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"children","type":"statement"},{"name":"create_children","type":"function"},{"name":"crossover_probability","type":"statement"},{"name":"data","type":"property"},{"name":"generate","type":"function"},{"name":"is_done","type":"property"},{"name":"mutation_probability","type":"statement"},{"name":"n_pop","type":"statement"},{"name":"offspring","type":"statement"},{"name":"options","type":"statement"},{"name":"population","type":"statement"},{"name":"toolbox","type":"statement"},{"name":"update_data","type":"function"},{"name":"vocs","type":"property"},{"name":"_data","type":"statement"},{"name":"_is_done","type":"statement"},{"name":"_vocs","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"children\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"create_children\",\n \"type\": \"function\"\n },\n {\n \"name\": \"crossover_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"data\",\n \"type\": \"property\"\n },\n {\n \"name\": \"generate\",\n \"type\": \"function\"\n },\n {\n \"name\": \"is_done\",\n \"type\": \"property\"\n },\n {\n \"name\": \"mutation_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"n_pop\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"offspring\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"options\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"population\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"toolbox\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"update_data\",\n \"type\": \"function\"\n },\n {\n \"name\": \"vocs\",\n \"type\": \"property\"\n },\n {\n \"name\": \"_data\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_is_done\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_vocs\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"\nfrom xopt.generators.ga import deap_creator\nfrom xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints\n\nfrom xopt import Generator\n\nfrom deap import base as deap_base\nfrom deap import tools as deap_tools\nfrom deap import algorithms as deap_algorithms\n\nimport pandas as pd\n\nimport random\nimport array\n\n\nfrom typing import List, Dict\n\nimport logging\nlogger = logging.getLogger(__name__)\n\n\nfrom typing import List, Dict\n\nclass CNSGAGenerator(Generator):\n\n\n def __init__(self, vocs, *, \n n_pop,\n data = None,\n crossover_probability = 0.9,\n mutation_probability = 1.0\n ): \n\n self._vocs = vocs # TODO: use proper options\n self.n_pop = n_pop\n self.crossover_probability = crossover_probability\n self.mutation_probability = mutation_probability\n\n\n # Internal data structures\n self.children = [] # unevaluated inputs. This should be a list of dicts.\n self.population = None # The latest population (fully evaluated)\n self.offspring = None # Newly evaluated data, but not yet added to population\n\n # DEAP toolbox (internal)\n self.toolbox = cnsga_toolbox(vocs, selection='auto')\n\n if data is not None:\n self.population = cnsga_select(data, n_pop, vocs, self.toolbox)\n\n\n def create_children(self):\n\n # No population, so create random children\n if self.population is None:\n return [self.vocs.random_inputs() for _ in range(self.n_pop)]\n\n # Use population to create children\n inputs = cnsga_variation(self.population, self.vocs, self.toolbox,\n crossover_probability=self.crossover_probability, mutation_probability=self.mutation_probability)\n return inputs.to_dict(orient='records')\n\n\n def update_data(self, new_data: pd.DataFrame):\n self.offspring = pd.concat([self.offspring, new_data])\n\n # Next generation\n if len(self.offspring) >= self.n_pop:\n if self.population is None: \n self.population = self."}}},{"rowIdx":96,"cells":{"idx":{"kind":"number","value":132,"string":"132"},"idx_lca":{"kind":"number","value":6,"string":"6"},"offset":{"kind":"number","value":2054,"string":"2,054"},"repo":{"kind":"string","value":"christophermayes__xopt"},"commit_hash":{"kind":"string","value":"683fd0c3af2f0fc12a598932b20e3afe8070112b"},"target_file":{"kind":"string","value":"xopt/generators/ga/cnsga.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"n_pop"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":15,"string":"15"},"non_dunder_count_jedi":{"kind":"number","value":17,"string":"17"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["population","offspring","children","n_pop","_vocs","__init__","create_children","crossover_probability","generate","mutation_probability","toolbox","update_data","data","is_done","options","vocs","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__slots__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"population\",\n \"offspring\",\n \"children\",\n \"n_pop\",\n \"_vocs\",\n \"__init__\",\n \"create_children\",\n \"crossover_probability\",\n \"generate\",\n \"mutation_probability\",\n \"toolbox\",\n \"update_data\",\n \"data\",\n \"is_done\",\n \"options\",\n \"vocs\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__slots__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"children","type":"statement"},{"name":"create_children","type":"function"},{"name":"crossover_probability","type":"statement"},{"name":"data","type":"property"},{"name":"generate","type":"function"},{"name":"is_done","type":"property"},{"name":"mutation_probability","type":"statement"},{"name":"n_pop","type":"statement"},{"name":"offspring","type":"statement"},{"name":"options","type":"statement"},{"name":"population","type":"statement"},{"name":"toolbox","type":"statement"},{"name":"update_data","type":"function"},{"name":"vocs","type":"property"},{"name":"_data","type":"statement"},{"name":"_is_done","type":"statement"},{"name":"_vocs","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"children\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"create_children\",\n \"type\": \"function\"\n },\n {\n \"name\": \"crossover_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"data\",\n \"type\": \"property\"\n },\n {\n \"name\": \"generate\",\n \"type\": \"function\"\n },\n {\n \"name\": \"is_done\",\n \"type\": \"property\"\n },\n {\n \"name\": \"mutation_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"n_pop\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"offspring\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"options\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"population\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"toolbox\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"update_data\",\n \"type\": \"function\"\n },\n {\n \"name\": \"vocs\",\n \"type\": \"property\"\n },\n {\n \"name\": \"_data\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_is_done\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_vocs\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"\nfrom xopt.generators.ga import deap_creator\nfrom xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints\n\nfrom xopt import Generator\n\nfrom deap import base as deap_base\nfrom deap import tools as deap_tools\nfrom deap import algorithms as deap_algorithms\n\nimport pandas as pd\n\nimport random\nimport array\n\n\nfrom typing import List, Dict\n\nimport logging\nlogger = logging.getLogger(__name__)\n\n\nfrom typing import List, Dict\n\nclass CNSGAGenerator(Generator):\n\n\n def __init__(self, vocs, *, \n n_pop,\n data = None,\n crossover_probability = 0.9,\n mutation_probability = 1.0\n ): \n\n self._vocs = vocs # TODO: use proper options\n self.n_pop = n_pop\n self.crossover_probability = crossover_probability\n self.mutation_probability = mutation_probability\n\n\n # Internal data structures\n self.children = [] # unevaluated inputs. This should be a list of dicts.\n self.population = None # The latest population (fully evaluated)\n self.offspring = None # Newly evaluated data, but not yet added to population\n\n # DEAP toolbox (internal)\n self.toolbox = cnsga_toolbox(vocs, selection='auto')\n\n if data is not None:\n self.population = cnsga_select(data, n_pop, vocs, self.toolbox)\n\n\n def create_children(self):\n\n # No population, so create random children\n if self.population is None:\n return [self.vocs.random_inputs() for _ in range(self.n_pop)]\n\n # Use population to create children\n inputs = cnsga_variation(self.population, self.vocs, self.toolbox,\n crossover_probability=self.crossover_probability, mutation_probability=self.mutation_probability)\n return inputs.to_dict(orient='records')\n\n\n def update_data(self, new_data: pd.DataFrame):\n self.offspring = pd.concat([self.offspring, new_data])\n\n # Next generation\n if len(self.offspring) >= self.n_pop:\n if self.population is None: \n self.population = self.offspring.iloc[:self."}}},{"rowIdx":97,"cells":{"idx":{"kind":"number","value":134,"string":"134"},"idx_lca":{"kind":"number","value":6,"string":"6"},"offset":{"kind":"number","value":2099,"string":"2,099"},"repo":{"kind":"string","value":"christophermayes__xopt"},"commit_hash":{"kind":"string","value":"683fd0c3af2f0fc12a598932b20e3afe8070112b"},"target_file":{"kind":"string","value":"xopt/generators/ga/cnsga.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"offspring"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":15,"string":"15"},"non_dunder_count_jedi":{"kind":"number","value":17,"string":"17"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["offspring","children","toolbox","population","data","__init__","_vocs","create_children","crossover_probability","generate","mutation_probability","n_pop","update_data","is_done","options","vocs","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__slots__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"offspring\",\n \"children\",\n \"toolbox\",\n \"population\",\n \"data\",\n \"__init__\",\n \"_vocs\",\n \"create_children\",\n \"crossover_probability\",\n \"generate\",\n \"mutation_probability\",\n \"n_pop\",\n \"update_data\",\n \"is_done\",\n \"options\",\n \"vocs\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__slots__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"children","type":"statement"},{"name":"create_children","type":"function"},{"name":"crossover_probability","type":"statement"},{"name":"data","type":"property"},{"name":"generate","type":"function"},{"name":"is_done","type":"property"},{"name":"mutation_probability","type":"statement"},{"name":"n_pop","type":"statement"},{"name":"offspring","type":"statement"},{"name":"options","type":"statement"},{"name":"population","type":"statement"},{"name":"toolbox","type":"statement"},{"name":"update_data","type":"function"},{"name":"vocs","type":"property"},{"name":"_data","type":"statement"},{"name":"_is_done","type":"statement"},{"name":"_vocs","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"children\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"create_children\",\n \"type\": \"function\"\n },\n {\n \"name\": \"crossover_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"data\",\n \"type\": \"property\"\n },\n {\n \"name\": \"generate\",\n \"type\": \"function\"\n },\n {\n \"name\": \"is_done\",\n \"type\": \"property\"\n },\n {\n \"name\": \"mutation_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"n_pop\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"offspring\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"options\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"population\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"toolbox\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"update_data\",\n \"type\": \"function\"\n },\n {\n \"name\": \"vocs\",\n \"type\": \"property\"\n },\n {\n \"name\": \"_data\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_is_done\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_vocs\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"\nfrom xopt.generators.ga import deap_creator\nfrom xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints\n\nfrom xopt import Generator\n\nfrom deap import base as deap_base\nfrom deap import tools as deap_tools\nfrom deap import algorithms as deap_algorithms\n\nimport pandas as pd\n\nimport random\nimport array\n\n\nfrom typing import List, Dict\n\nimport logging\nlogger = logging.getLogger(__name__)\n\n\nfrom typing import List, Dict\n\nclass CNSGAGenerator(Generator):\n\n\n def __init__(self, vocs, *, \n n_pop,\n data = None,\n crossover_probability = 0.9,\n mutation_probability = 1.0\n ): \n\n self._vocs = vocs # TODO: use proper options\n self.n_pop = n_pop\n self.crossover_probability = crossover_probability\n self.mutation_probability = mutation_probability\n\n\n # Internal data structures\n self.children = [] # unevaluated inputs. This should be a list of dicts.\n self.population = None # The latest population (fully evaluated)\n self.offspring = None # Newly evaluated data, but not yet added to population\n\n # DEAP toolbox (internal)\n self.toolbox = cnsga_toolbox(vocs, selection='auto')\n\n if data is not None:\n self.population = cnsga_select(data, n_pop, vocs, self.toolbox)\n\n\n def create_children(self):\n\n # No population, so create random children\n if self.population is None:\n return [self.vocs.random_inputs() for _ in range(self.n_pop)]\n\n # Use population to create children\n inputs = cnsga_variation(self.population, self.vocs, self.toolbox,\n crossover_probability=self.crossover_probability, mutation_probability=self.mutation_probability)\n return inputs.to_dict(orient='records')\n\n\n def update_data(self, new_data: pd.DataFrame):\n self.offspring = pd.concat([self.offspring, new_data])\n\n # Next generation\n if len(self.offspring) >= self.n_pop:\n if self.population is None: \n self.population = self.offspring.iloc[:self.n_pop]\n self.offspring = self."}}},{"rowIdx":98,"cells":{"idx":{"kind":"number","value":135,"string":"135"},"idx_lca":{"kind":"number","value":6,"string":"6"},"offset":{"kind":"number","value":2119,"string":"2,119"},"repo":{"kind":"string","value":"christophermayes__xopt"},"commit_hash":{"kind":"string","value":"683fd0c3af2f0fc12a598932b20e3afe8070112b"},"target_file":{"kind":"string","value":"xopt/generators/ga/cnsga.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"n_pop"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":15,"string":"15"},"non_dunder_count_jedi":{"kind":"number","value":17,"string":"17"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["offspring","population","children","n_pop","toolbox","__init__","_vocs","create_children","crossover_probability","generate","mutation_probability","update_data","data","is_done","options","vocs","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__slots__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"offspring\",\n \"population\",\n \"children\",\n \"n_pop\",\n \"toolbox\",\n \"__init__\",\n \"_vocs\",\n \"create_children\",\n \"crossover_probability\",\n \"generate\",\n \"mutation_probability\",\n \"update_data\",\n \"data\",\n \"is_done\",\n \"options\",\n \"vocs\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__slots__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"children","type":"statement"},{"name":"create_children","type":"function"},{"name":"crossover_probability","type":"statement"},{"name":"data","type":"property"},{"name":"generate","type":"function"},{"name":"is_done","type":"property"},{"name":"mutation_probability","type":"statement"},{"name":"n_pop","type":"statement"},{"name":"offspring","type":"statement"},{"name":"options","type":"statement"},{"name":"population","type":"statement"},{"name":"toolbox","type":"statement"},{"name":"update_data","type":"function"},{"name":"vocs","type":"property"},{"name":"_data","type":"statement"},{"name":"_is_done","type":"statement"},{"name":"_vocs","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"children\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"create_children\",\n \"type\": \"function\"\n },\n {\n \"name\": \"crossover_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"data\",\n \"type\": \"property\"\n },\n {\n \"name\": \"generate\",\n \"type\": \"function\"\n },\n {\n \"name\": \"is_done\",\n \"type\": \"property\"\n },\n {\n \"name\": \"mutation_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"n_pop\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"offspring\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"options\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"population\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"toolbox\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"update_data\",\n \"type\": \"function\"\n },\n {\n \"name\": \"vocs\",\n \"type\": \"property\"\n },\n {\n \"name\": \"_data\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_is_done\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_vocs\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"\nfrom xopt.generators.ga import deap_creator\nfrom xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints\n\nfrom xopt import Generator\n\nfrom deap import base as deap_base\nfrom deap import tools as deap_tools\nfrom deap import algorithms as deap_algorithms\n\nimport pandas as pd\n\nimport random\nimport array\n\n\nfrom typing import List, Dict\n\nimport logging\nlogger = logging.getLogger(__name__)\n\n\nfrom typing import List, Dict\n\nclass CNSGAGenerator(Generator):\n\n\n def __init__(self, vocs, *, \n n_pop,\n data = None,\n crossover_probability = 0.9,\n mutation_probability = 1.0\n ): \n\n self._vocs = vocs # TODO: use proper options\n self.n_pop = n_pop\n self.crossover_probability = crossover_probability\n self.mutation_probability = mutation_probability\n\n\n # Internal data structures\n self.children = [] # unevaluated inputs. This should be a list of dicts.\n self.population = None # The latest population (fully evaluated)\n self.offspring = None # Newly evaluated data, but not yet added to population\n\n # DEAP toolbox (internal)\n self.toolbox = cnsga_toolbox(vocs, selection='auto')\n\n if data is not None:\n self.population = cnsga_select(data, n_pop, vocs, self.toolbox)\n\n\n def create_children(self):\n\n # No population, so create random children\n if self.population is None:\n return [self.vocs.random_inputs() for _ in range(self.n_pop)]\n\n # Use population to create children\n inputs = cnsga_variation(self.population, self.vocs, self.toolbox,\n crossover_probability=self.crossover_probability, mutation_probability=self.mutation_probability)\n return inputs.to_dict(orient='records')\n\n\n def update_data(self, new_data: pd.DataFrame):\n self.offspring = pd.concat([self.offspring, new_data])\n\n # Next generation\n if len(self.offspring) >= self.n_pop:\n if self.population is None: \n self.population = self.offspring.iloc[:self.n_pop]\n self.offspring = self.offspring.iloc[self."}}},{"rowIdx":99,"cells":{"idx":{"kind":"number","value":136,"string":"136"},"idx_lca":{"kind":"number","value":6,"string":"6"},"offset":{"kind":"number","value":2190,"string":"2,190"},"repo":{"kind":"string","value":"christophermayes__xopt"},"commit_hash":{"kind":"string","value":"683fd0c3af2f0fc12a598932b20e3afe8070112b"},"target_file":{"kind":"string","value":"xopt/generators/ga/cnsga.py"},"line_type_lca":{"kind":"string","value":"Unknown"},"ground_truth":{"kind":"string","value":"population"},"in_completions":{"kind":"bool","value":true,"string":"true"},"completion_type":{"kind":"string","value":"statement"},"non_dunder_count_intellij":{"kind":"number","value":16,"string":"16"},"non_dunder_count_jedi":{"kind":"number","value":17,"string":"17"},"start_with_":{"kind":"bool","value":false,"string":"false"},"first_occurrence":{"kind":"bool","value":false,"string":"false"},"intellij_completions":{"kind":"list like","value":["offspring","children","n_pop","population","toolbox","__init__","_vocs","create_children","crossover_probability","generate","mutation_probability","update_data","data","is_done","options","vocs","for","__annotations__","__class__","__delattr__","__dict__","__dir__","__eq__","__format__","__getattribute__","__hash__","__init_subclass__","__ne__","__new__","__reduce__","__reduce_ex__","__repr__","__setattr__","__sizeof__","__slots__","__str__","__subclasshook__","__doc__","__module__"],"string":"[\n \"offspring\",\n \"children\",\n \"n_pop\",\n \"population\",\n \"toolbox\",\n \"__init__\",\n \"_vocs\",\n \"create_children\",\n \"crossover_probability\",\n \"generate\",\n \"mutation_probability\",\n \"update_data\",\n \"data\",\n \"is_done\",\n \"options\",\n \"vocs\",\n \"for\",\n \"__annotations__\",\n \"__class__\",\n \"__delattr__\",\n \"__dict__\",\n \"__dir__\",\n \"__eq__\",\n \"__format__\",\n \"__getattribute__\",\n \"__hash__\",\n \"__init_subclass__\",\n \"__ne__\",\n \"__new__\",\n \"__reduce__\",\n \"__reduce_ex__\",\n \"__repr__\",\n \"__setattr__\",\n \"__sizeof__\",\n \"__slots__\",\n \"__str__\",\n \"__subclasshook__\",\n \"__doc__\",\n \"__module__\"\n]"},"jedi_completions":{"kind":"list like","value":[{"name":"children","type":"statement"},{"name":"create_children","type":"function"},{"name":"crossover_probability","type":"statement"},{"name":"data","type":"property"},{"name":"generate","type":"function"},{"name":"is_done","type":"property"},{"name":"mutation_probability","type":"statement"},{"name":"n_pop","type":"statement"},{"name":"offspring","type":"statement"},{"name":"options","type":"statement"},{"name":"population","type":"statement"},{"name":"toolbox","type":"statement"},{"name":"update_data","type":"function"},{"name":"vocs","type":"property"},{"name":"_data","type":"statement"},{"name":"_is_done","type":"statement"},{"name":"_vocs","type":"statement"},{"name":"__annotations__","type":"statement"},{"name":"__class__","type":"property"},{"name":"__delattr__","type":"function"},{"name":"__dict__","type":"statement"},{"name":"__dir__","type":"function"},{"name":"__doc__","type":"statement"},{"name":"__eq__","type":"function"},{"name":"__format__","type":"function"},{"name":"__getattribute__","type":"function"},{"name":"__hash__","type":"function"},{"name":"__init__","type":"function"},{"name":"__init_subclass__","type":"function"},{"name":"__module__","type":"statement"},{"name":"__ne__","type":"function"},{"name":"__new__","type":"function"},{"name":"__reduce__","type":"function"},{"name":"__reduce_ex__","type":"function"},{"name":"__repr__","type":"function"},{"name":"__setattr__","type":"function"},{"name":"__sizeof__","type":"function"},{"name":"__slots__","type":"statement"},{"name":"__str__","type":"function"}],"string":"[\n {\n \"name\": \"children\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"create_children\",\n \"type\": \"function\"\n },\n {\n \"name\": \"crossover_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"data\",\n \"type\": \"property\"\n },\n {\n \"name\": \"generate\",\n \"type\": \"function\"\n },\n {\n \"name\": \"is_done\",\n \"type\": \"property\"\n },\n {\n \"name\": \"mutation_probability\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"n_pop\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"offspring\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"options\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"population\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"toolbox\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"update_data\",\n \"type\": \"function\"\n },\n {\n \"name\": \"vocs\",\n \"type\": \"property\"\n },\n {\n \"name\": \"_data\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_is_done\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"_vocs\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__annotations__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__class__\",\n \"type\": \"property\"\n },\n {\n \"name\": \"__delattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__dict__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__dir__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__doc__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__eq__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__format__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__getattribute__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__hash__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__init_subclass__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__module__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__ne__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__new__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__reduce_ex__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__repr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__setattr__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__sizeof__\",\n \"type\": \"function\"\n },\n {\n \"name\": \"__slots__\",\n \"type\": \"statement\"\n },\n {\n \"name\": \"__str__\",\n \"type\": \"function\"\n }\n]"},"prefix":{"kind":"string","value":"\nfrom xopt.generators.ga import deap_creator\nfrom xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints\n\nfrom xopt import Generator\n\nfrom deap import base as deap_base\nfrom deap import tools as deap_tools\nfrom deap import algorithms as deap_algorithms\n\nimport pandas as pd\n\nimport random\nimport array\n\n\nfrom typing import List, Dict\n\nimport logging\nlogger = logging.getLogger(__name__)\n\n\nfrom typing import List, Dict\n\nclass CNSGAGenerator(Generator):\n\n\n def __init__(self, vocs, *, \n n_pop,\n data = None,\n crossover_probability = 0.9,\n mutation_probability = 1.0\n ): \n\n self._vocs = vocs # TODO: use proper options\n self.n_pop = n_pop\n self.crossover_probability = crossover_probability\n self.mutation_probability = mutation_probability\n\n\n # Internal data structures\n self.children = [] # unevaluated inputs. This should be a list of dicts.\n self.population = None # The latest population (fully evaluated)\n self.offspring = None # Newly evaluated data, but not yet added to population\n\n # DEAP toolbox (internal)\n self.toolbox = cnsga_toolbox(vocs, selection='auto')\n\n if data is not None:\n self.population = cnsga_select(data, n_pop, vocs, self.toolbox)\n\n\n def create_children(self):\n\n # No population, so create random children\n if self.population is None:\n return [self.vocs.random_inputs() for _ in range(self.n_pop)]\n\n # Use population to create children\n inputs = cnsga_variation(self.population, self.vocs, self.toolbox,\n crossover_probability=self.crossover_probability, mutation_probability=self.mutation_probability)\n return inputs.to_dict(orient='records')\n\n\n def update_data(self, new_data: pd.DataFrame):\n self.offspring = pd.concat([self.offspring, new_data])\n\n # Next generation\n if len(self.offspring) >= self.n_pop:\n if self.population is None: \n self.population = self.offspring.iloc[:self.n_pop]\n self.offspring = self.offspring.iloc[self.n_pop:]\n else:\n candidates = pd.concat([self."}}}],"truncated":false,"partial":false},"paginationData":{"pageIndex":0,"numItemsPerPage":100,"numTotalItems":5531,"offset":0,"length":100}},"jwt":"eyJhbGciOiJFZERTQSJ9.eyJyZWFkIjp0cnVlLCJwZXJtaXNzaW9ucyI6eyJyZXBvLmNvbnRlbnQucmVhZCI6dHJ1ZX0sImlhdCI6MTc1NzQ5MTQ0Niwic3ViIjoiL2RhdGFzZXRzL0RhbkNpcC9sY2EtU3RhcnRpbmdQb2ludHMtZXhwYW5kZWQiLCJleHAiOjE3NTc0OTUwNDYsImlzcyI6Imh0dHBzOi8vaHVnZ2luZ2ZhY2UuY28ifQ.gjkq1lZz9WSww13Oa7UcINP7kzxiLlpD_IrPi3Q3lVLuJlw8nzOvCAJ8FzZ-n8tTSEsMOaW54f7ILB8YdbvLCw","displayUrls":true},"discussionsStats":{"closed":0,"open":1,"total":1},"fullWidth":true,"hasGatedAccess":true,"hasFullAccess":true,"isEmbedded":false,"savedQueries":{"community":[],"user":[]}}">
idx
int64
0
7.85k
idx_lca
int64
0
223
offset
int64
162
55k
repo
stringclasses
62 values
commit_hash
stringclasses
113 values
target_file
stringclasses
134 values
line_type_lca
stringclasses
7 values
ground_truth
stringlengths
1
46
in_completions
bool
1 class
completion_type
stringclasses
6 values
non_dunder_count_intellij
int64
0
529
non_dunder_count_jedi
int64
0
128
start_with_
bool
2 classes
first_occurrence
bool
2 classes
intellij_completions
listlengths
1
532
jedi_completions
listlengths
3
148
prefix
stringlengths
162
55k
0
0
1,007
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
AnalysisInterface
true
class
8
13
false
true
[ "List", "AnalysisInterface", "analysis_coverage_runtime_analysis", "logger", "Tuple", "get_all_analyses", "overlay_calltree_with_coverage", "Dict" ]
[ { "name": "abc", "type": "module" }, { "name": "analysis_coverage_runtime_analysis", "type": "function" }, { "name": "AnalysisInterface", "type": "class" }, { "name": "Dict", "type": "class" }, { "name": "fuzz_cfg_load", "type": "module" }, { "name": "fuzz_data_loader", "type": "module" }, { "name": "fuzz_utils", "type": "module" }, { "name": "get_all_analyses", "type": "function" }, { "name": "List", "type": "class" }, { "name": "logger", "type": "statement" }, { "name": "logging", "type": "module" }, { "name": "overlay_calltree_with_coverage", "type": "function" }, { "name": "Tuple", "type": "class" }, { "name": "__doc__", "type": "instance" }, { "name": "__file__", "type": "instance" }, { "name": "__name__", "type": "instance" }, { "name": "__package__", "type": "instance" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.
2
0
1,333
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
inproject
MergedProjectProfile
true
class
14
19
false
true
[ "FuzzerProfile", "List", "MergedProjectProfile", "logger", "None", "add_func_to_reached_and_clone", "FunctionProfile", "load_all_profiles", "read_fuzzer_data_file_to_profile", "Any", "Dict", "Optional", "Set", "Tuple" ]
[ { "name": "add_func_to_reached_and_clone", "type": "function" }, { "name": "Any", "type": "class" }, { "name": "copy", "type": "module" }, { "name": "Dict", "type": "class" }, { "name": "FunctionProfile", "type": "class" }, { "name": "fuzz_cfg_load", "type": "module" }, { "name": "fuzz_cov_load", "type": "module" }, { "name": "fuzz_utils", "type": "module" }, { "name": "FuzzerProfile", "type": "class" }, { "name": "List", "type": "class" }, { "name": "load_all_profiles", "type": "function" }, { "name": "logger", "type": "statement" }, { "name": "logging", "type": "module" }, { "name": "MergedProjectProfile", "type": "class" }, { "name": "Optional", "type": "class" }, { "name": "os", "type": "module" }, { "name": "read_fuzzer_data_file_to_profile", "type": "function" }, { "name": "Set", "type": "class" }, { "name": "Tuple", "type": "class" }, { "name": "__doc__", "type": "instance" }, { "name": "__file__", "type": "instance" }, { "name": "__name__", "type": "instance" }, { "name": "__package__", "type": "instance" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.
3
0
1,409
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
inproject
FuzzerProfile
true
class
14
19
false
true
[ "FuzzerProfile", "MergedProjectProfile", "List", "logger", "None", "add_func_to_reached_and_clone", "FunctionProfile", "load_all_profiles", "read_fuzzer_data_file_to_profile", "Any", "Dict", "Optional", "Set", "Tuple" ]
[ { "name": "add_func_to_reached_and_clone", "type": "function" }, { "name": "Any", "type": "class" }, { "name": "copy", "type": "module" }, { "name": "Dict", "type": "class" }, { "name": "FunctionProfile", "type": "class" }, { "name": "fuzz_cfg_load", "type": "module" }, { "name": "fuzz_cov_load", "type": "module" }, { "name": "fuzz_utils", "type": "module" }, { "name": "FuzzerProfile", "type": "class" }, { "name": "List", "type": "class" }, { "name": "load_all_profiles", "type": "function" }, { "name": "logger", "type": "statement" }, { "name": "logging", "type": "module" }, { "name": "MergedProjectProfile", "type": "class" }, { "name": "Optional", "type": "class" }, { "name": "os", "type": "module" }, { "name": "read_fuzzer_data_file_to_profile", "type": "function" }, { "name": "Set", "type": "class" }, { "name": "Tuple", "type": "class" }, { "name": "__doc__", "type": "instance" }, { "name": "__file__", "type": "instance" }, { "name": "__name__", "type": "instance" }, { "name": "__package__", "type": "instance" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.
4
0
1,758
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
FuzzerProfile
true
class
14
19
false
false
[ "FuzzerProfile", "MergedProjectProfile", "None", "Set", "List", "add_func_to_reached_and_clone", "FunctionProfile", "load_all_profiles", "logger", "read_fuzzer_data_file_to_profile", "Any", "Dict", "Optional", "Tuple" ]
[ { "name": "add_func_to_reached_and_clone", "type": "function" }, { "name": "Any", "type": "class" }, { "name": "copy", "type": "module" }, { "name": "Dict", "type": "class" }, { "name": "FunctionProfile", "type": "class" }, { "name": "fuzz_cfg_load", "type": "module" }, { "name": "fuzz_cov_load", "type": "module" }, { "name": "fuzz_utils", "type": "module" }, { "name": "FuzzerProfile", "type": "class" }, { "name": "List", "type": "class" }, { "name": "load_all_profiles", "type": "function" }, { "name": "logger", "type": "statement" }, { "name": "logging", "type": "module" }, { "name": "MergedProjectProfile", "type": "class" }, { "name": "Optional", "type": "class" }, { "name": "os", "type": "module" }, { "name": "read_fuzzer_data_file_to_profile", "type": "function" }, { "name": "Set", "type": "class" }, { "name": "Tuple", "type": "class" }, { "name": "__doc__", "type": "instance" }, { "name": "__file__", "type": "instance" }, { "name": "__name__", "type": "instance" }, { "name": "__package__", "type": "instance" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.
5
0
2,009
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
inproject
extract_all_callsites
true
function
8
9
false
true
[ "extract_all_callsites", "CalltreeCallsite", "List", "logger", "Optional", "data_file_read_calltree", "extract_all_callsites_recursive", "print_ctcs_tree" ]
[ { "name": "CalltreeCallsite", "type": "class" }, { "name": "data_file_read_calltree", "type": "function" }, { "name": "extract_all_callsites", "type": "function" }, { "name": "extract_all_callsites_recursive", "type": "function" }, { "name": "List", "type": "class" }, { "name": "logger", "type": "statement" }, { "name": "logging", "type": "module" }, { "name": "Optional", "type": "class" }, { "name": "print_ctcs_tree", "type": "function" }, { "name": "__doc__", "type": "instance" }, { "name": "__file__", "type": "instance" }, { "name": "__name__", "type": "instance" }, { "name": "__package__", "type": "instance" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.
7
0
2,166
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
inproject
demangle_cpp_func
true
function
13
18
false
true
[ "List", "logger", "Optional", "demangle_cpp_func", "scan_executables_for_fuzz_introspector_logs", "data_file_read_yaml", "get_all_files_in_tree_with_regex", "get_target_coverage_url", "longest_common_prefix", "normalise_str", "safe_decode", "Any", "Dict" ]
[ { "name": "Any", "type": "class" }, { "name": "cxxfilt", "type": "module" }, { "name": "data_file_read_yaml", "type": "function" }, { "name": "demangle_cpp_func", "type": "function" }, { "name": "Dict", "type": "class" }, { "name": "get_all_files_in_tree_with_regex", "type": "function" }, { "name": "get_target_coverage_url", "type": "function" }, { "name": "List", "type": "class" }, { "name": "logger", "type": "statement" }, { "name": "logging", "type": "module" }, { "name": "longest_common_prefix", "type": "function" }, { "name": "normalise_str", "type": "function" }, { "name": "Optional", "type": "class" }, { "name": "os", "type": "module" }, { "name": "re", "type": "module" }, { "name": "safe_decode", "type": "function" }, { "name": "scan_executables_for_fuzz_introspector_logs", "type": "function" }, { "name": "yaml", "type": "module" }, { "name": "__doc__", "type": "instance" }, { "name": "__file__", "type": "instance" }, { "name": "__name__", "type": "instance" }, { "name": "__package__", "type": "instance" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.
8
0
2,189
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
inproject
dst_function_name
true
statement
17
17
false
true
[ "depth", "cov_ct_idx", "cov_forward_reds", "cov_largest_blocked_func", "cov_link", "children", "cov_callsite_link", "cov_color", "cov_hitcount", "cov_parent", "dst_function_name", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.
9
0
2,625
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
cov_color
true
statement
17
17
false
true
[ "depth", "cov_link", "cov_ct_idx", "cov_callsite_link", "cov_forward_reds", "children", "cov_color", "cov_hitcount", "cov_largest_blocked_func", "cov_parent", "dst_function_name", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.
10
0
2,668
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
random
cov_callsite_link
true
statement
17
17
false
true
[ "cov_link", "depth", "cov_color", "cov_ct_idx", "cov_callsite_link", "children", "cov_forward_reds", "cov_hitcount", "cov_largest_blocked_func", "cov_parent", "dst_function_name", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.
11
0
2,710
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
cov_link
true
statement
17
17
false
true
[ "cov_callsite_link", "depth", "cov_color", "cov_ct_idx", "cov_forward_reds", "children", "cov_hitcount", "cov_largest_blocked_func", "cov_link", "cov_parent", "dst_function_name", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.
12
0
2,749
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
infile
create_str_node_ctx_idx
true
function
7
7
false
true
[ "create_str_node_ctx_idx", "get_fuzz_blockers", "name", "create_fuzz_blocker_table", "html_create_dedicated_calltree_file", "__init__", "analysis_func", "create_calltree", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "analysis_func", "type": "function" }, { "name": "create_calltree", "type": "function" }, { "name": "create_fuzz_blocker_table", "type": "function" }, { "name": "create_str_node_ctx_idx", "type": "function" }, { "name": "get_fuzz_blockers", "type": "function" }, { "name": "html_create_dedicated_calltree_file", "type": "function" }, { "name": "name", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.
13
0
2,782
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
infile
cov_ct_idx
true
statement
17
17
false
true
[ "cov_ct_idx", "depth", "dst_function_name", "cov_forward_reds", "cov_link", "children", "cov_callsite_link", "cov_color", "cov_hitcount", "cov_largest_blocked_func", "cov_parent", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.
14
0
2,907
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
dst_function_source_file
true
statement
17
17
false
true
[ "depth", "cov_ct_idx", "cov_link", "cov_color", "cov_callsite_link", "children", "cov_forward_reds", "cov_hitcount", "cov_largest_blocked_func", "cov_parent", "dst_function_name", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.
15
0
3,174
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
depth
true
statement
17
17
false
true
[ "depth", "cov_ct_idx", "cov_link", "cov_color", "cov_forward_reds", "children", "cov_callsite_link", "cov_hitcount", "cov_largest_blocked_func", "cov_parent", "dst_function_name", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.
16
0
3,188
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
depth
true
statement
17
17
false
false
[ "depth", "cov_ct_idx", "cov_link", "cov_color", "cov_forward_reds", "children", "cov_callsite_link", "cov_hitcount", "cov_largest_blocked_func", "cov_parent", "dst_function_name", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.
17
0
3,291
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
depth
true
statement
17
17
false
false
[ "depth", "cov_ct_idx", "cov_link", "cov_color", "cov_callsite_link", "children", "cov_forward_reds", "cov_hitcount", "cov_largest_blocked_func", "cov_parent", "dst_function_name", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.
18
0
3,304
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
depth
true
statement
17
17
false
false
[ "depth", "cov_ct_idx", "cov_link", "cov_color", "cov_forward_reds", "children", "cov_callsite_link", "cov_hitcount", "cov_largest_blocked_func", "cov_parent", "dst_function_name", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.
19
0
3,744
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
depth
true
statement
17
17
false
false
[ "depth", "cov_ct_idx", "cov_link", "cov_color", "cov_forward_reds", "children", "cov_callsite_link", "cov_hitcount", "cov_largest_blocked_func", "cov_parent", "dst_function_name", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.
20
0
4,254
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
depth
true
statement
17
17
false
false
[ "depth", "cov_ct_idx", "cov_link", "cov_color", "cov_callsite_link", "children", "cov_forward_reds", "cov_hitcount", "cov_largest_blocked_func", "cov_parent", "dst_function_name", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.
28
0
5,388
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
inproject
FuzzerProfile
true
class
14
19
false
false
[ "FuzzerProfile", "MergedProjectProfile", "None", "List", "logger", "add_func_to_reached_and_clone", "FunctionProfile", "load_all_profiles", "read_fuzzer_data_file_to_profile", "Any", "Dict", "Optional", "Set", "Tuple" ]
[ { "name": "add_func_to_reached_and_clone", "type": "function" }, { "name": "Any", "type": "class" }, { "name": "copy", "type": "module" }, { "name": "Dict", "type": "class" }, { "name": "FunctionProfile", "type": "class" }, { "name": "fuzz_cfg_load", "type": "module" }, { "name": "fuzz_cov_load", "type": "module" }, { "name": "fuzz_utils", "type": "module" }, { "name": "FuzzerProfile", "type": "class" }, { "name": "List", "type": "class" }, { "name": "load_all_profiles", "type": "function" }, { "name": "logger", "type": "statement" }, { "name": "logging", "type": "module" }, { "name": "MergedProjectProfile", "type": "class" }, { "name": "Optional", "type": "class" }, { "name": "os", "type": "module" }, { "name": "read_fuzzer_data_file_to_profile", "type": "function" }, { "name": "Set", "type": "class" }, { "name": "Tuple", "type": "class" }, { "name": "__doc__", "type": "instance" }, { "name": "__file__", "type": "instance" }, { "name": "__name__", "type": "instance" }, { "name": "__package__", "type": "instance" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.
29
0
5,761
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
inproject
html_get_header
true
function
9
9
false
true
[ "html_create_table_head", "html_table_add_row", "html_get_header", "html_get_navbar", "List", "html_add_header_with_link", "html_get_table_of_contents", "Any", "Tuple" ]
[ { "name": "Any", "type": "class" }, { "name": "html_add_header_with_link", "type": "function" }, { "name": "html_create_table_head", "type": "function" }, { "name": "html_get_header", "type": "function" }, { "name": "html_get_navbar", "type": "function" }, { "name": "html_get_table_of_contents", "type": "function" }, { "name": "html_table_add_row", "type": "function" }, { "name": "List", "type": "class" }, { "name": "Tuple", "type": "class" }, { "name": "__doc__", "type": "instance" }, { "name": "__file__", "type": "instance" }, { "name": "__name__", "type": "instance" }, { "name": "__package__", "type": "instance" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.
31
0
6,077
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
get_fuzz_blockers
true
function
7
7
false
true
[ "get_fuzz_blockers", "create_fuzz_blocker_table", "name", "create_str_node_ctx_idx", "html_create_dedicated_calltree_file", "__init__", "analysis_func", "create_calltree", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "analysis_func", "type": "function" }, { "name": "create_calltree", "type": "function" }, { "name": "create_fuzz_blocker_table", "type": "function" }, { "name": "create_str_node_ctx_idx", "type": "function" }, { "name": "get_fuzz_blockers", "type": "function" }, { "name": "html_create_dedicated_calltree_file", "type": "function" }, { "name": "name", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.html_get_header( calltree=True, title=f"Fuzz introspector: { profile.get_key() }" ) html_header += '<div class="content-section calltree-content-section">' complete_html_string += html_header # Display fuzz blocker at top of page fuzz_blockers = self.
32
0
6,201
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
infile
create_fuzz_blocker_table
true
function
7
7
false
true
[ "get_fuzz_blockers", "name", "create_fuzz_blocker_table", "create_str_node_ctx_idx", "html_create_dedicated_calltree_file", "__init__", "analysis_func", "create_calltree", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "analysis_func", "type": "function" }, { "name": "create_calltree", "type": "function" }, { "name": "create_fuzz_blocker_table", "type": "function" }, { "name": "create_str_node_ctx_idx", "type": "function" }, { "name": "get_fuzz_blockers", "type": "function" }, { "name": "html_create_dedicated_calltree_file", "type": "function" }, { "name": "name", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.html_get_header( calltree=True, title=f"Fuzz introspector: { profile.get_key() }" ) html_header += '<div class="content-section calltree-content-section">' complete_html_string += html_header # Display fuzz blocker at top of page fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) fuzz_blocker_table = self.
33
0
6,814
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
infile
create_str_node_ctx_idx
true
function
7
7
false
false
[ "get_fuzz_blockers", "name", "create_fuzz_blocker_table", "create_str_node_ctx_idx", "create_calltree", "__init__", "analysis_func", "html_create_dedicated_calltree_file", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "analysis_func", "type": "function" }, { "name": "create_calltree", "type": "function" }, { "name": "create_fuzz_blocker_table", "type": "function" }, { "name": "create_str_node_ctx_idx", "type": "function" }, { "name": "get_fuzz_blockers", "type": "function" }, { "name": "html_create_dedicated_calltree_file", "type": "function" }, { "name": "name", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.html_get_header( calltree=True, title=f"Fuzz introspector: { profile.get_key() }" ) html_header += '<div class="content-section calltree-content-section">' complete_html_string += html_header # Display fuzz blocker at top of page fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], "", fuzz_blockers) if fuzz_blocker_table is not None: complete_html_string += "<div class=\"report-box\">" complete_html_string += "<h1>Fuzz blockers</h1>" complete_html_string += fuzz_blocker_table complete_html_string += "</div>" # Display calltree complete_html_string += calltree_html_string complete_html_string += "</div></div></div></div>" # HTML end html_end = '</div>' blocker_idxs = [] for node in fuzz_blockers: blocker_idxs.append(self.
34
0
6,847
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
infile
cov_ct_idx
true
statement
17
17
false
false
[ "cov_ct_idx", "depth", "cov_forward_reds", "dst_function_name", "dst_function_source_file", "children", "cov_callsite_link", "cov_color", "cov_hitcount", "cov_largest_blocked_func", "cov_link", "cov_parent", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.html_get_header( calltree=True, title=f"Fuzz introspector: { profile.get_key() }" ) html_header += '<div class="content-section calltree-content-section">' complete_html_string += html_header # Display fuzz blocker at top of page fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], "", fuzz_blockers) if fuzz_blocker_table is not None: complete_html_string += "<div class=\"report-box\">" complete_html_string += "<h1>Fuzz blockers</h1>" complete_html_string += fuzz_blocker_table complete_html_string += "</div>" # Display calltree complete_html_string += calltree_html_string complete_html_string += "</div></div></div></div>" # HTML end html_end = '</div>' blocker_idxs = [] for node in fuzz_blockers: blocker_idxs.append(self.create_str_node_ctx_idx(str(node.
35
0
7,754
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
inproject
FuzzerProfile
true
class
14
19
false
false
[ "FuzzerProfile", "MergedProjectProfile", "List", "None", "logger", "add_func_to_reached_and_clone", "FunctionProfile", "load_all_profiles", "read_fuzzer_data_file_to_profile", "Any", "Dict", "Optional", "Set", "Tuple" ]
[ { "name": "add_func_to_reached_and_clone", "type": "function" }, { "name": "Any", "type": "class" }, { "name": "copy", "type": "module" }, { "name": "Dict", "type": "class" }, { "name": "FunctionProfile", "type": "class" }, { "name": "fuzz_cfg_load", "type": "module" }, { "name": "fuzz_cov_load", "type": "module" }, { "name": "fuzz_utils", "type": "module" }, { "name": "FuzzerProfile", "type": "class" }, { "name": "List", "type": "class" }, { "name": "load_all_profiles", "type": "function" }, { "name": "logger", "type": "statement" }, { "name": "logging", "type": "module" }, { "name": "MergedProjectProfile", "type": "class" }, { "name": "Optional", "type": "class" }, { "name": "os", "type": "module" }, { "name": "read_fuzzer_data_file_to_profile", "type": "function" }, { "name": "Set", "type": "class" }, { "name": "Tuple", "type": "class" }, { "name": "__doc__", "type": "instance" }, { "name": "__file__", "type": "instance" }, { "name": "__name__", "type": "instance" }, { "name": "__package__", "type": "instance" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.html_get_header( calltree=True, title=f"Fuzz introspector: { profile.get_key() }" ) html_header += '<div class="content-section calltree-content-section">' complete_html_string += html_header # Display fuzz blocker at top of page fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], "", fuzz_blockers) if fuzz_blocker_table is not None: complete_html_string += "<div class=\"report-box\">" complete_html_string += "<h1>Fuzz blockers</h1>" complete_html_string += fuzz_blocker_table complete_html_string += "</div>" # Display calltree complete_html_string += calltree_html_string complete_html_string += "</div></div></div></div>" # HTML end html_end = '</div>' blocker_idxs = [] for node in fuzz_blockers: blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx))) if len(blocker_idxs) > 0: html_end = "<script>" html_end += f"var fuzz_blocker_idxs = {json.dumps(blocker_idxs)};" html_end += "</script>" html_end += "<script src=\"prism.js\"></script>" html_end += "<script src=\"clike.js\"></script>" html_end += "<script src=\"calltree.js\"></script>" complete_html_string += html_end complete_html_string += "</body></html>" # Beautify and write HTML soup = bs(complete_html_string, 'lxml') pretty_html = soup.prettify() with open(filename, "w+") as cf: cf.write(pretty_html) def create_str_node_ctx_idx(self, cov_ct_idx): prefixed_zeros = "0" * (len("00000") - len(cov_ct_idx)) return f"{prefixed_zeros}{cov_ct_idx}" def get_fuzz_blockers( self, profile: fuzz_data_loader.
36
0
7,895
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
inproject
CalltreeCallsite
true
class
9
9
false
true
[ "extract_all_callsites", "List", "None", "logger", "Optional", "CalltreeCallsite", "data_file_read_calltree", "extract_all_callsites_recursive", "print_ctcs_tree" ]
[ { "name": "CalltreeCallsite", "type": "class" }, { "name": "data_file_read_calltree", "type": "function" }, { "name": "extract_all_callsites", "type": "function" }, { "name": "extract_all_callsites_recursive", "type": "function" }, { "name": "List", "type": "class" }, { "name": "logger", "type": "statement" }, { "name": "logging", "type": "module" }, { "name": "Optional", "type": "class" }, { "name": "print_ctcs_tree", "type": "function" }, { "name": "__doc__", "type": "instance" }, { "name": "__file__", "type": "instance" }, { "name": "__name__", "type": "instance" }, { "name": "__package__", "type": "instance" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.html_get_header( calltree=True, title=f"Fuzz introspector: { profile.get_key() }" ) html_header += '<div class="content-section calltree-content-section">' complete_html_string += html_header # Display fuzz blocker at top of page fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], "", fuzz_blockers) if fuzz_blocker_table is not None: complete_html_string += "<div class=\"report-box\">" complete_html_string += "<h1>Fuzz blockers</h1>" complete_html_string += fuzz_blocker_table complete_html_string += "</div>" # Display calltree complete_html_string += calltree_html_string complete_html_string += "</div></div></div></div>" # HTML end html_end = '</div>' blocker_idxs = [] for node in fuzz_blockers: blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx))) if len(blocker_idxs) > 0: html_end = "<script>" html_end += f"var fuzz_blocker_idxs = {json.dumps(blocker_idxs)};" html_end += "</script>" html_end += "<script src=\"prism.js\"></script>" html_end += "<script src=\"clike.js\"></script>" html_end += "<script src=\"calltree.js\"></script>" complete_html_string += html_end complete_html_string += "</body></html>" # Beautify and write HTML soup = bs(complete_html_string, 'lxml') pretty_html = soup.prettify() with open(filename, "w+") as cf: cf.write(pretty_html) def create_str_node_ctx_idx(self, cov_ct_idx): prefixed_zeros = "0" * (len("00000") - len(cov_ct_idx)) return f"{prefixed_zeros}{cov_ct_idx}" def get_fuzz_blockers( self, profile: fuzz_data_loader.FuzzerProfile, max_blockers_to_extract=999): """Gets a list of fuzz blockers""" blocker_list: List[fuzz_cfg_load.
37
0
8,028
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
inproject
extract_all_callsites
true
function
8
9
false
false
[ "extract_all_callsites", "CalltreeCallsite", "List", "logger", "extract_all_callsites_recursive", "data_file_read_calltree", "print_ctcs_tree", "Optional" ]
[ { "name": "CalltreeCallsite", "type": "class" }, { "name": "data_file_read_calltree", "type": "function" }, { "name": "extract_all_callsites", "type": "function" }, { "name": "extract_all_callsites_recursive", "type": "function" }, { "name": "List", "type": "class" }, { "name": "logger", "type": "statement" }, { "name": "logging", "type": "module" }, { "name": "Optional", "type": "class" }, { "name": "print_ctcs_tree", "type": "function" }, { "name": "__doc__", "type": "instance" }, { "name": "__file__", "type": "instance" }, { "name": "__name__", "type": "instance" }, { "name": "__package__", "type": "instance" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.html_get_header( calltree=True, title=f"Fuzz introspector: { profile.get_key() }" ) html_header += '<div class="content-section calltree-content-section">' complete_html_string += html_header # Display fuzz blocker at top of page fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], "", fuzz_blockers) if fuzz_blocker_table is not None: complete_html_string += "<div class=\"report-box\">" complete_html_string += "<h1>Fuzz blockers</h1>" complete_html_string += fuzz_blocker_table complete_html_string += "</div>" # Display calltree complete_html_string += calltree_html_string complete_html_string += "</div></div></div></div>" # HTML end html_end = '</div>' blocker_idxs = [] for node in fuzz_blockers: blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx))) if len(blocker_idxs) > 0: html_end = "<script>" html_end += f"var fuzz_blocker_idxs = {json.dumps(blocker_idxs)};" html_end += "</script>" html_end += "<script src=\"prism.js\"></script>" html_end += "<script src=\"clike.js\"></script>" html_end += "<script src=\"calltree.js\"></script>" complete_html_string += html_end complete_html_string += "</body></html>" # Beautify and write HTML soup = bs(complete_html_string, 'lxml') pretty_html = soup.prettify() with open(filename, "w+") as cf: cf.write(pretty_html) def create_str_node_ctx_idx(self, cov_ct_idx): prefixed_zeros = "0" * (len("00000") - len(cov_ct_idx)) return f"{prefixed_zeros}{cov_ct_idx}" def get_fuzz_blockers( self, profile: fuzz_data_loader.FuzzerProfile, max_blockers_to_extract=999): """Gets a list of fuzz blockers""" blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list() # Extract all callsites in calltree and exit early if none all_callsites = fuzz_cfg_load.
39
0
8,501
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
cov_forward_reds
true
statement
17
17
false
true
[ "depth", "cov_ct_idx", "dst_function_source_file", "cov_forward_reds", "cov_callsite_link", "children", "cov_color", "cov_hitcount", "cov_largest_blocked_func", "cov_link", "cov_parent", "dst_function_name", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.html_get_header( calltree=True, title=f"Fuzz introspector: { profile.get_key() }" ) html_header += '<div class="content-section calltree-content-section">' complete_html_string += html_header # Display fuzz blocker at top of page fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], "", fuzz_blockers) if fuzz_blocker_table is not None: complete_html_string += "<div class=\"report-box\">" complete_html_string += "<h1>Fuzz blockers</h1>" complete_html_string += fuzz_blocker_table complete_html_string += "</div>" # Display calltree complete_html_string += calltree_html_string complete_html_string += "</div></div></div></div>" # HTML end html_end = '</div>' blocker_idxs = [] for node in fuzz_blockers: blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx))) if len(blocker_idxs) > 0: html_end = "<script>" html_end += f"var fuzz_blocker_idxs = {json.dumps(blocker_idxs)};" html_end += "</script>" html_end += "<script src=\"prism.js\"></script>" html_end += "<script src=\"clike.js\"></script>" html_end += "<script src=\"calltree.js\"></script>" complete_html_string += html_end complete_html_string += "</body></html>" # Beautify and write HTML soup = bs(complete_html_string, 'lxml') pretty_html = soup.prettify() with open(filename, "w+") as cf: cf.write(pretty_html) def create_str_node_ctx_idx(self, cov_ct_idx): prefixed_zeros = "0" * (len("00000") - len(cov_ct_idx)) return f"{prefixed_zeros}{cov_ct_idx}" def get_fuzz_blockers( self, profile: fuzz_data_loader.FuzzerProfile, max_blockers_to_extract=999): """Gets a list of fuzz blockers""" blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list() # Extract all callsites in calltree and exit early if none all_callsites = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) if len(all_callsites) == 0: return blocker_list # Filter nodes that has forward reds. Extract maximum max_blockers_to_extract nodes. nodes_sorted_by_red_ahead = sorted(all_callsites, key=lambda x: x.cov_forward_reds, reverse=True) for node in nodes_sorted_by_red_ahead: if node.
40
0
8,752
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
FuzzerProfile
true
class
14
19
false
false
[ "FuzzerProfile", "MergedProjectProfile", "logger", "List", "None", "add_func_to_reached_and_clone", "FunctionProfile", "load_all_profiles", "read_fuzzer_data_file_to_profile", "Any", "Dict", "Optional", "Set", "Tuple" ]
[ { "name": "add_func_to_reached_and_clone", "type": "function" }, { "name": "Any", "type": "class" }, { "name": "copy", "type": "module" }, { "name": "Dict", "type": "class" }, { "name": "FunctionProfile", "type": "class" }, { "name": "fuzz_cfg_load", "type": "module" }, { "name": "fuzz_cov_load", "type": "module" }, { "name": "fuzz_utils", "type": "module" }, { "name": "FuzzerProfile", "type": "class" }, { "name": "List", "type": "class" }, { "name": "load_all_profiles", "type": "function" }, { "name": "logger", "type": "statement" }, { "name": "logging", "type": "module" }, { "name": "MergedProjectProfile", "type": "class" }, { "name": "Optional", "type": "class" }, { "name": "os", "type": "module" }, { "name": "read_fuzzer_data_file_to_profile", "type": "function" }, { "name": "Set", "type": "class" }, { "name": "Tuple", "type": "class" }, { "name": "__doc__", "type": "instance" }, { "name": "__file__", "type": "instance" }, { "name": "__name__", "type": "instance" }, { "name": "__package__", "type": "instance" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.html_get_header( calltree=True, title=f"Fuzz introspector: { profile.get_key() }" ) html_header += '<div class="content-section calltree-content-section">' complete_html_string += html_header # Display fuzz blocker at top of page fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], "", fuzz_blockers) if fuzz_blocker_table is not None: complete_html_string += "<div class=\"report-box\">" complete_html_string += "<h1>Fuzz blockers</h1>" complete_html_string += fuzz_blocker_table complete_html_string += "</div>" # Display calltree complete_html_string += calltree_html_string complete_html_string += "</div></div></div></div>" # HTML end html_end = '</div>' blocker_idxs = [] for node in fuzz_blockers: blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx))) if len(blocker_idxs) > 0: html_end = "<script>" html_end += f"var fuzz_blocker_idxs = {json.dumps(blocker_idxs)};" html_end += "</script>" html_end += "<script src=\"prism.js\"></script>" html_end += "<script src=\"clike.js\"></script>" html_end += "<script src=\"calltree.js\"></script>" complete_html_string += html_end complete_html_string += "</body></html>" # Beautify and write HTML soup = bs(complete_html_string, 'lxml') pretty_html = soup.prettify() with open(filename, "w+") as cf: cf.write(pretty_html) def create_str_node_ctx_idx(self, cov_ct_idx): prefixed_zeros = "0" * (len("00000") - len(cov_ct_idx)) return f"{prefixed_zeros}{cov_ct_idx}" def get_fuzz_blockers( self, profile: fuzz_data_loader.FuzzerProfile, max_blockers_to_extract=999): """Gets a list of fuzz blockers""" blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list() # Extract all callsites in calltree and exit early if none all_callsites = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) if len(all_callsites) == 0: return blocker_list # Filter nodes that has forward reds. Extract maximum max_blockers_to_extract nodes. nodes_sorted_by_red_ahead = sorted(all_callsites, key=lambda x: x.cov_forward_reds, reverse=True) for node in nodes_sorted_by_red_ahead: if node.cov_forward_reds == 0 or len(blocker_list) >= max_blockers_to_extract: break blocker_list.append(node) return blocker_list def create_fuzz_blocker_table( self, profile: fuzz_data_loader.
41
0
9,121
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
infile
get_fuzz_blockers
true
function
7
7
false
false
[ "get_fuzz_blockers", "create_fuzz_blocker_table", "name", "create_str_node_ctx_idx", "html_create_dedicated_calltree_file", "__init__", "analysis_func", "create_calltree", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "analysis_func", "type": "function" }, { "name": "create_calltree", "type": "function" }, { "name": "create_fuzz_blocker_table", "type": "function" }, { "name": "create_str_node_ctx_idx", "type": "function" }, { "name": "get_fuzz_blockers", "type": "function" }, { "name": "html_create_dedicated_calltree_file", "type": "function" }, { "name": "name", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.html_get_header( calltree=True, title=f"Fuzz introspector: { profile.get_key() }" ) html_header += '<div class="content-section calltree-content-section">' complete_html_string += html_header # Display fuzz blocker at top of page fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], "", fuzz_blockers) if fuzz_blocker_table is not None: complete_html_string += "<div class=\"report-box\">" complete_html_string += "<h1>Fuzz blockers</h1>" complete_html_string += fuzz_blocker_table complete_html_string += "</div>" # Display calltree complete_html_string += calltree_html_string complete_html_string += "</div></div></div></div>" # HTML end html_end = '</div>' blocker_idxs = [] for node in fuzz_blockers: blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx))) if len(blocker_idxs) > 0: html_end = "<script>" html_end += f"var fuzz_blocker_idxs = {json.dumps(blocker_idxs)};" html_end += "</script>" html_end += "<script src=\"prism.js\"></script>" html_end += "<script src=\"clike.js\"></script>" html_end += "<script src=\"calltree.js\"></script>" complete_html_string += html_end complete_html_string += "</body></html>" # Beautify and write HTML soup = bs(complete_html_string, 'lxml') pretty_html = soup.prettify() with open(filename, "w+") as cf: cf.write(pretty_html) def create_str_node_ctx_idx(self, cov_ct_idx): prefixed_zeros = "0" * (len("00000") - len(cov_ct_idx)) return f"{prefixed_zeros}{cov_ct_idx}" def get_fuzz_blockers( self, profile: fuzz_data_loader.FuzzerProfile, max_blockers_to_extract=999): """Gets a list of fuzz blockers""" blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list() # Extract all callsites in calltree and exit early if none all_callsites = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) if len(all_callsites) == 0: return blocker_list # Filter nodes that has forward reds. Extract maximum max_blockers_to_extract nodes. nodes_sorted_by_red_ahead = sorted(all_callsites, key=lambda x: x.cov_forward_reds, reverse=True) for node in nodes_sorted_by_red_ahead: if node.cov_forward_reds == 0 or len(blocker_list) >= max_blockers_to_extract: break blocker_list.append(node) return blocker_list def create_fuzz_blocker_table( self, profile: fuzz_data_loader.FuzzerProfile, tables: List[str], calltree_file_name: str, fuzz_blockers=None) -> Optional[str]: """ Creates HTML string for table showing fuzz blockers. """ logger.info("Creating fuzz blocker table") # Get the fuzz blockers if fuzz_blockers is None: fuzz_blockers = self.
42
0
9,537
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
inproject
html_create_table_head
true
function
9
9
false
true
[ "html_table_add_row", "html_get_header", "html_create_table_head", "html_get_table_of_contents", "html_get_navbar", "html_add_header_with_link", "Any", "List", "Tuple" ]
[ { "name": "Any", "type": "class" }, { "name": "html_add_header_with_link", "type": "function" }, { "name": "html_create_table_head", "type": "function" }, { "name": "html_get_header", "type": "function" }, { "name": "html_get_navbar", "type": "function" }, { "name": "html_get_table_of_contents", "type": "function" }, { "name": "html_table_add_row", "type": "function" }, { "name": "List", "type": "class" }, { "name": "Tuple", "type": "class" }, { "name": "__doc__", "type": "instance" }, { "name": "__file__", "type": "instance" }, { "name": "__name__", "type": "instance" }, { "name": "__package__", "type": "instance" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.html_get_header( calltree=True, title=f"Fuzz introspector: { profile.get_key() }" ) html_header += '<div class="content-section calltree-content-section">' complete_html_string += html_header # Display fuzz blocker at top of page fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], "", fuzz_blockers) if fuzz_blocker_table is not None: complete_html_string += "<div class=\"report-box\">" complete_html_string += "<h1>Fuzz blockers</h1>" complete_html_string += fuzz_blocker_table complete_html_string += "</div>" # Display calltree complete_html_string += calltree_html_string complete_html_string += "</div></div></div></div>" # HTML end html_end = '</div>' blocker_idxs = [] for node in fuzz_blockers: blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx))) if len(blocker_idxs) > 0: html_end = "<script>" html_end += f"var fuzz_blocker_idxs = {json.dumps(blocker_idxs)};" html_end += "</script>" html_end += "<script src=\"prism.js\"></script>" html_end += "<script src=\"clike.js\"></script>" html_end += "<script src=\"calltree.js\"></script>" complete_html_string += html_end complete_html_string += "</body></html>" # Beautify and write HTML soup = bs(complete_html_string, 'lxml') pretty_html = soup.prettify() with open(filename, "w+") as cf: cf.write(pretty_html) def create_str_node_ctx_idx(self, cov_ct_idx): prefixed_zeros = "0" * (len("00000") - len(cov_ct_idx)) return f"{prefixed_zeros}{cov_ct_idx}" def get_fuzz_blockers( self, profile: fuzz_data_loader.FuzzerProfile, max_blockers_to_extract=999): """Gets a list of fuzz blockers""" blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list() # Extract all callsites in calltree and exit early if none all_callsites = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) if len(all_callsites) == 0: return blocker_list # Filter nodes that has forward reds. Extract maximum max_blockers_to_extract nodes. nodes_sorted_by_red_ahead = sorted(all_callsites, key=lambda x: x.cov_forward_reds, reverse=True) for node in nodes_sorted_by_red_ahead: if node.cov_forward_reds == 0 or len(blocker_list) >= max_blockers_to_extract: break blocker_list.append(node) return blocker_list def create_fuzz_blocker_table( self, profile: fuzz_data_loader.FuzzerProfile, tables: List[str], calltree_file_name: str, fuzz_blockers=None) -> Optional[str]: """ Creates HTML string for table showing fuzz blockers. """ logger.info("Creating fuzz blocker table") # Get the fuzz blockers if fuzz_blockers is None: fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) if len(fuzz_blockers) == 0: return None html_table_string = "<p class='no-top-margin'>The followings nodes " \ "represent call sites where fuzz blockers occur</p>" tables.append(f"myTable{len(tables)}") html_table_string += fuzz_html_helpers.
43
0
10,426
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
cov_ct_idx
true
statement
18
17
false
false
[ "depth", "cov_ct_idx", "cov_link", "cov_forward_reds", "dst_function_name", "children", "cov_callsite_link", "cov_color", "cov_hitcount", "cov_largest_blocked_func", "cov_parent", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "yield", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.html_get_header( calltree=True, title=f"Fuzz introspector: { profile.get_key() }" ) html_header += '<div class="content-section calltree-content-section">' complete_html_string += html_header # Display fuzz blocker at top of page fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], "", fuzz_blockers) if fuzz_blocker_table is not None: complete_html_string += "<div class=\"report-box\">" complete_html_string += "<h1>Fuzz blockers</h1>" complete_html_string += fuzz_blocker_table complete_html_string += "</div>" # Display calltree complete_html_string += calltree_html_string complete_html_string += "</div></div></div></div>" # HTML end html_end = '</div>' blocker_idxs = [] for node in fuzz_blockers: blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx))) if len(blocker_idxs) > 0: html_end = "<script>" html_end += f"var fuzz_blocker_idxs = {json.dumps(blocker_idxs)};" html_end += "</script>" html_end += "<script src=\"prism.js\"></script>" html_end += "<script src=\"clike.js\"></script>" html_end += "<script src=\"calltree.js\"></script>" complete_html_string += html_end complete_html_string += "</body></html>" # Beautify and write HTML soup = bs(complete_html_string, 'lxml') pretty_html = soup.prettify() with open(filename, "w+") as cf: cf.write(pretty_html) def create_str_node_ctx_idx(self, cov_ct_idx): prefixed_zeros = "0" * (len("00000") - len(cov_ct_idx)) return f"{prefixed_zeros}{cov_ct_idx}" def get_fuzz_blockers( self, profile: fuzz_data_loader.FuzzerProfile, max_blockers_to_extract=999): """Gets a list of fuzz blockers""" blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list() # Extract all callsites in calltree and exit early if none all_callsites = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) if len(all_callsites) == 0: return blocker_list # Filter nodes that has forward reds. Extract maximum max_blockers_to_extract nodes. nodes_sorted_by_red_ahead = sorted(all_callsites, key=lambda x: x.cov_forward_reds, reverse=True) for node in nodes_sorted_by_red_ahead: if node.cov_forward_reds == 0 or len(blocker_list) >= max_blockers_to_extract: break blocker_list.append(node) return blocker_list def create_fuzz_blocker_table( self, profile: fuzz_data_loader.FuzzerProfile, tables: List[str], calltree_file_name: str, fuzz_blockers=None) -> Optional[str]: """ Creates HTML string for table showing fuzz blockers. """ logger.info("Creating fuzz blocker table") # Get the fuzz blockers if fuzz_blockers is None: fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) if len(fuzz_blockers) == 0: return None html_table_string = "<p class='no-top-margin'>The followings nodes " \ "represent call sites where fuzz blockers occur</p>" tables.append(f"myTable{len(tables)}") html_table_string += fuzz_html_helpers.html_create_table_head( tables[-1], [ ("Amount of callsites blocked", "Total amount of callsites blocked"), ("Calltree index", "Index in call tree where the fuzz blocker is."), ("Parent function", "Function in which the call site that blocks resides."), ("Callsite", ""), ("Largest blocked function", "This is the function with highest cyclomatiic complexity amongst" "all of the functions that are blocked. As such, it's a way of " "highlighting a potentially important function being blocked") ], sort_by_column=0, sort_order="desc" ) for node in fuzz_blockers: link_prefix = "0" * (5 - len(str(node.
44
0
10,577
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
cov_ct_idx
true
statement
19
17
false
false
[ "depth", "cov_parent", "cov_ct_idx", "cov_largest_blocked_func", "cov_forward_reds", "children", "cov_callsite_link", "cov_color", "cov_hitcount", "cov_link", "dst_function_name", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "for", "yield", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.html_get_header( calltree=True, title=f"Fuzz introspector: { profile.get_key() }" ) html_header += '<div class="content-section calltree-content-section">' complete_html_string += html_header # Display fuzz blocker at top of page fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], "", fuzz_blockers) if fuzz_blocker_table is not None: complete_html_string += "<div class=\"report-box\">" complete_html_string += "<h1>Fuzz blockers</h1>" complete_html_string += fuzz_blocker_table complete_html_string += "</div>" # Display calltree complete_html_string += calltree_html_string complete_html_string += "</div></div></div></div>" # HTML end html_end = '</div>' blocker_idxs = [] for node in fuzz_blockers: blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx))) if len(blocker_idxs) > 0: html_end = "<script>" html_end += f"var fuzz_blocker_idxs = {json.dumps(blocker_idxs)};" html_end += "</script>" html_end += "<script src=\"prism.js\"></script>" html_end += "<script src=\"clike.js\"></script>" html_end += "<script src=\"calltree.js\"></script>" complete_html_string += html_end complete_html_string += "</body></html>" # Beautify and write HTML soup = bs(complete_html_string, 'lxml') pretty_html = soup.prettify() with open(filename, "w+") as cf: cf.write(pretty_html) def create_str_node_ctx_idx(self, cov_ct_idx): prefixed_zeros = "0" * (len("00000") - len(cov_ct_idx)) return f"{prefixed_zeros}{cov_ct_idx}" def get_fuzz_blockers( self, profile: fuzz_data_loader.FuzzerProfile, max_blockers_to_extract=999): """Gets a list of fuzz blockers""" blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list() # Extract all callsites in calltree and exit early if none all_callsites = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) if len(all_callsites) == 0: return blocker_list # Filter nodes that has forward reds. Extract maximum max_blockers_to_extract nodes. nodes_sorted_by_red_ahead = sorted(all_callsites, key=lambda x: x.cov_forward_reds, reverse=True) for node in nodes_sorted_by_red_ahead: if node.cov_forward_reds == 0 or len(blocker_list) >= max_blockers_to_extract: break blocker_list.append(node) return blocker_list def create_fuzz_blocker_table( self, profile: fuzz_data_loader.FuzzerProfile, tables: List[str], calltree_file_name: str, fuzz_blockers=None) -> Optional[str]: """ Creates HTML string for table showing fuzz blockers. """ logger.info("Creating fuzz blocker table") # Get the fuzz blockers if fuzz_blockers is None: fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) if len(fuzz_blockers) == 0: return None html_table_string = "<p class='no-top-margin'>The followings nodes " \ "represent call sites where fuzz blockers occur</p>" tables.append(f"myTable{len(tables)}") html_table_string += fuzz_html_helpers.html_create_table_head( tables[-1], [ ("Amount of callsites blocked", "Total amount of callsites blocked"), ("Calltree index", "Index in call tree where the fuzz blocker is."), ("Parent function", "Function in which the call site that blocks resides."), ("Callsite", ""), ("Largest blocked function", "This is the function with highest cyclomatiic complexity amongst" "all of the functions that are blocked. As such, it's a way of " "highlighting a potentially important function being blocked") ], sort_by_column=0, sort_order="desc" ) for node in fuzz_blockers: link_prefix = "0" * (5 - len(str(node.cov_ct_idx))) node_link = "%s?scrollToNode=%s%s" % ( calltree_file_name, link_prefix, node.
45
0
10,653
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
inproject
html_table_add_row
true
function
9
9
false
true
[ "html_create_table_head", "html_get_header", "List", "html_get_table_of_contents", "html_table_add_row", "html_add_header_with_link", "html_get_navbar", "Any", "Tuple" ]
[ { "name": "Any", "type": "class" }, { "name": "html_add_header_with_link", "type": "function" }, { "name": "html_create_table_head", "type": "function" }, { "name": "html_get_header", "type": "function" }, { "name": "html_get_navbar", "type": "function" }, { "name": "html_get_table_of_contents", "type": "function" }, { "name": "html_table_add_row", "type": "function" }, { "name": "List", "type": "class" }, { "name": "Tuple", "type": "class" }, { "name": "__doc__", "type": "instance" }, { "name": "__file__", "type": "instance" }, { "name": "__name__", "type": "instance" }, { "name": "__package__", "type": "instance" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.html_get_header( calltree=True, title=f"Fuzz introspector: { profile.get_key() }" ) html_header += '<div class="content-section calltree-content-section">' complete_html_string += html_header # Display fuzz blocker at top of page fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], "", fuzz_blockers) if fuzz_blocker_table is not None: complete_html_string += "<div class=\"report-box\">" complete_html_string += "<h1>Fuzz blockers</h1>" complete_html_string += fuzz_blocker_table complete_html_string += "</div>" # Display calltree complete_html_string += calltree_html_string complete_html_string += "</div></div></div></div>" # HTML end html_end = '</div>' blocker_idxs = [] for node in fuzz_blockers: blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx))) if len(blocker_idxs) > 0: html_end = "<script>" html_end += f"var fuzz_blocker_idxs = {json.dumps(blocker_idxs)};" html_end += "</script>" html_end += "<script src=\"prism.js\"></script>" html_end += "<script src=\"clike.js\"></script>" html_end += "<script src=\"calltree.js\"></script>" complete_html_string += html_end complete_html_string += "</body></html>" # Beautify and write HTML soup = bs(complete_html_string, 'lxml') pretty_html = soup.prettify() with open(filename, "w+") as cf: cf.write(pretty_html) def create_str_node_ctx_idx(self, cov_ct_idx): prefixed_zeros = "0" * (len("00000") - len(cov_ct_idx)) return f"{prefixed_zeros}{cov_ct_idx}" def get_fuzz_blockers( self, profile: fuzz_data_loader.FuzzerProfile, max_blockers_to_extract=999): """Gets a list of fuzz blockers""" blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list() # Extract all callsites in calltree and exit early if none all_callsites = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) if len(all_callsites) == 0: return blocker_list # Filter nodes that has forward reds. Extract maximum max_blockers_to_extract nodes. nodes_sorted_by_red_ahead = sorted(all_callsites, key=lambda x: x.cov_forward_reds, reverse=True) for node in nodes_sorted_by_red_ahead: if node.cov_forward_reds == 0 or len(blocker_list) >= max_blockers_to_extract: break blocker_list.append(node) return blocker_list def create_fuzz_blocker_table( self, profile: fuzz_data_loader.FuzzerProfile, tables: List[str], calltree_file_name: str, fuzz_blockers=None) -> Optional[str]: """ Creates HTML string for table showing fuzz blockers. """ logger.info("Creating fuzz blocker table") # Get the fuzz blockers if fuzz_blockers is None: fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) if len(fuzz_blockers) == 0: return None html_table_string = "<p class='no-top-margin'>The followings nodes " \ "represent call sites where fuzz blockers occur</p>" tables.append(f"myTable{len(tables)}") html_table_string += fuzz_html_helpers.html_create_table_head( tables[-1], [ ("Amount of callsites blocked", "Total amount of callsites blocked"), ("Calltree index", "Index in call tree where the fuzz blocker is."), ("Parent function", "Function in which the call site that blocks resides."), ("Callsite", ""), ("Largest blocked function", "This is the function with highest cyclomatiic complexity amongst" "all of the functions that are blocked. As such, it's a way of " "highlighting a potentially important function being blocked") ], sort_by_column=0, sort_order="desc" ) for node in fuzz_blockers: link_prefix = "0" * (5 - len(str(node.cov_ct_idx))) node_link = "%s?scrollToNode=%s%s" % ( calltree_file_name, link_prefix, node.cov_ct_idx ) html_table_string += fuzz_html_helpers.
46
0
10,699
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
cov_forward_reds
true
statement
18
17
false
false
[ "depth", "cov_ct_idx", "dst_function_name", "cov_link", "cov_parent", "children", "cov_callsite_link", "cov_color", "cov_forward_reds", "cov_hitcount", "cov_largest_blocked_func", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "for", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.html_get_header( calltree=True, title=f"Fuzz introspector: { profile.get_key() }" ) html_header += '<div class="content-section calltree-content-section">' complete_html_string += html_header # Display fuzz blocker at top of page fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], "", fuzz_blockers) if fuzz_blocker_table is not None: complete_html_string += "<div class=\"report-box\">" complete_html_string += "<h1>Fuzz blockers</h1>" complete_html_string += fuzz_blocker_table complete_html_string += "</div>" # Display calltree complete_html_string += calltree_html_string complete_html_string += "</div></div></div></div>" # HTML end html_end = '</div>' blocker_idxs = [] for node in fuzz_blockers: blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx))) if len(blocker_idxs) > 0: html_end = "<script>" html_end += f"var fuzz_blocker_idxs = {json.dumps(blocker_idxs)};" html_end += "</script>" html_end += "<script src=\"prism.js\"></script>" html_end += "<script src=\"clike.js\"></script>" html_end += "<script src=\"calltree.js\"></script>" complete_html_string += html_end complete_html_string += "</body></html>" # Beautify and write HTML soup = bs(complete_html_string, 'lxml') pretty_html = soup.prettify() with open(filename, "w+") as cf: cf.write(pretty_html) def create_str_node_ctx_idx(self, cov_ct_idx): prefixed_zeros = "0" * (len("00000") - len(cov_ct_idx)) return f"{prefixed_zeros}{cov_ct_idx}" def get_fuzz_blockers( self, profile: fuzz_data_loader.FuzzerProfile, max_blockers_to_extract=999): """Gets a list of fuzz blockers""" blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list() # Extract all callsites in calltree and exit early if none all_callsites = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) if len(all_callsites) == 0: return blocker_list # Filter nodes that has forward reds. Extract maximum max_blockers_to_extract nodes. nodes_sorted_by_red_ahead = sorted(all_callsites, key=lambda x: x.cov_forward_reds, reverse=True) for node in nodes_sorted_by_red_ahead: if node.cov_forward_reds == 0 or len(blocker_list) >= max_blockers_to_extract: break blocker_list.append(node) return blocker_list def create_fuzz_blocker_table( self, profile: fuzz_data_loader.FuzzerProfile, tables: List[str], calltree_file_name: str, fuzz_blockers=None) -> Optional[str]: """ Creates HTML string for table showing fuzz blockers. """ logger.info("Creating fuzz blocker table") # Get the fuzz blockers if fuzz_blockers is None: fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) if len(fuzz_blockers) == 0: return None html_table_string = "<p class='no-top-margin'>The followings nodes " \ "represent call sites where fuzz blockers occur</p>" tables.append(f"myTable{len(tables)}") html_table_string += fuzz_html_helpers.html_create_table_head( tables[-1], [ ("Amount of callsites blocked", "Total amount of callsites blocked"), ("Calltree index", "Index in call tree where the fuzz blocker is."), ("Parent function", "Function in which the call site that blocks resides."), ("Callsite", ""), ("Largest blocked function", "This is the function with highest cyclomatiic complexity amongst" "all of the functions that are blocked. As such, it's a way of " "highlighting a potentially important function being blocked") ], sort_by_column=0, sort_order="desc" ) for node in fuzz_blockers: link_prefix = "0" * (5 - len(str(node.cov_ct_idx))) node_link = "%s?scrollToNode=%s%s" % ( calltree_file_name, link_prefix, node.cov_ct_idx ) html_table_string += fuzz_html_helpers.html_table_add_row([ str(node.
47
0
10,743
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
cov_ct_idx
true
statement
18
17
false
false
[ "depth", "cov_ct_idx", "cov_forward_reds", "dst_function_name", "cov_link", "children", "cov_callsite_link", "cov_color", "cov_hitcount", "cov_largest_blocked_func", "cov_parent", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "for", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.html_get_header( calltree=True, title=f"Fuzz introspector: { profile.get_key() }" ) html_header += '<div class="content-section calltree-content-section">' complete_html_string += html_header # Display fuzz blocker at top of page fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], "", fuzz_blockers) if fuzz_blocker_table is not None: complete_html_string += "<div class=\"report-box\">" complete_html_string += "<h1>Fuzz blockers</h1>" complete_html_string += fuzz_blocker_table complete_html_string += "</div>" # Display calltree complete_html_string += calltree_html_string complete_html_string += "</div></div></div></div>" # HTML end html_end = '</div>' blocker_idxs = [] for node in fuzz_blockers: blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx))) if len(blocker_idxs) > 0: html_end = "<script>" html_end += f"var fuzz_blocker_idxs = {json.dumps(blocker_idxs)};" html_end += "</script>" html_end += "<script src=\"prism.js\"></script>" html_end += "<script src=\"clike.js\"></script>" html_end += "<script src=\"calltree.js\"></script>" complete_html_string += html_end complete_html_string += "</body></html>" # Beautify and write HTML soup = bs(complete_html_string, 'lxml') pretty_html = soup.prettify() with open(filename, "w+") as cf: cf.write(pretty_html) def create_str_node_ctx_idx(self, cov_ct_idx): prefixed_zeros = "0" * (len("00000") - len(cov_ct_idx)) return f"{prefixed_zeros}{cov_ct_idx}" def get_fuzz_blockers( self, profile: fuzz_data_loader.FuzzerProfile, max_blockers_to_extract=999): """Gets a list of fuzz blockers""" blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list() # Extract all callsites in calltree and exit early if none all_callsites = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) if len(all_callsites) == 0: return blocker_list # Filter nodes that has forward reds. Extract maximum max_blockers_to_extract nodes. nodes_sorted_by_red_ahead = sorted(all_callsites, key=lambda x: x.cov_forward_reds, reverse=True) for node in nodes_sorted_by_red_ahead: if node.cov_forward_reds == 0 or len(blocker_list) >= max_blockers_to_extract: break blocker_list.append(node) return blocker_list def create_fuzz_blocker_table( self, profile: fuzz_data_loader.FuzzerProfile, tables: List[str], calltree_file_name: str, fuzz_blockers=None) -> Optional[str]: """ Creates HTML string for table showing fuzz blockers. """ logger.info("Creating fuzz blocker table") # Get the fuzz blockers if fuzz_blockers is None: fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) if len(fuzz_blockers) == 0: return None html_table_string = "<p class='no-top-margin'>The followings nodes " \ "represent call sites where fuzz blockers occur</p>" tables.append(f"myTable{len(tables)}") html_table_string += fuzz_html_helpers.html_create_table_head( tables[-1], [ ("Amount of callsites blocked", "Total amount of callsites blocked"), ("Calltree index", "Index in call tree where the fuzz blocker is."), ("Parent function", "Function in which the call site that blocks resides."), ("Callsite", ""), ("Largest blocked function", "This is the function with highest cyclomatiic complexity amongst" "all of the functions that are blocked. As such, it's a way of " "highlighting a potentially important function being blocked") ], sort_by_column=0, sort_order="desc" ) for node in fuzz_blockers: link_prefix = "0" * (5 - len(str(node.cov_ct_idx))) node_link = "%s?scrollToNode=%s%s" % ( calltree_file_name, link_prefix, node.cov_ct_idx ) html_table_string += fuzz_html_helpers.html_table_add_row([ str(node.cov_forward_reds), str(node.
48
0
10,777
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
cov_parent
true
statement
18
17
false
true
[ "cov_ct_idx", "depth", "cov_largest_blocked_func", "cov_link", "cov_forward_reds", "children", "cov_callsite_link", "cov_color", "cov_hitcount", "cov_parent", "dst_function_name", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "for", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.html_get_header( calltree=True, title=f"Fuzz introspector: { profile.get_key() }" ) html_header += '<div class="content-section calltree-content-section">' complete_html_string += html_header # Display fuzz blocker at top of page fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], "", fuzz_blockers) if fuzz_blocker_table is not None: complete_html_string += "<div class=\"report-box\">" complete_html_string += "<h1>Fuzz blockers</h1>" complete_html_string += fuzz_blocker_table complete_html_string += "</div>" # Display calltree complete_html_string += calltree_html_string complete_html_string += "</div></div></div></div>" # HTML end html_end = '</div>' blocker_idxs = [] for node in fuzz_blockers: blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx))) if len(blocker_idxs) > 0: html_end = "<script>" html_end += f"var fuzz_blocker_idxs = {json.dumps(blocker_idxs)};" html_end += "</script>" html_end += "<script src=\"prism.js\"></script>" html_end += "<script src=\"clike.js\"></script>" html_end += "<script src=\"calltree.js\"></script>" complete_html_string += html_end complete_html_string += "</body></html>" # Beautify and write HTML soup = bs(complete_html_string, 'lxml') pretty_html = soup.prettify() with open(filename, "w+") as cf: cf.write(pretty_html) def create_str_node_ctx_idx(self, cov_ct_idx): prefixed_zeros = "0" * (len("00000") - len(cov_ct_idx)) return f"{prefixed_zeros}{cov_ct_idx}" def get_fuzz_blockers( self, profile: fuzz_data_loader.FuzzerProfile, max_blockers_to_extract=999): """Gets a list of fuzz blockers""" blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list() # Extract all callsites in calltree and exit early if none all_callsites = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) if len(all_callsites) == 0: return blocker_list # Filter nodes that has forward reds. Extract maximum max_blockers_to_extract nodes. nodes_sorted_by_red_ahead = sorted(all_callsites, key=lambda x: x.cov_forward_reds, reverse=True) for node in nodes_sorted_by_red_ahead: if node.cov_forward_reds == 0 or len(blocker_list) >= max_blockers_to_extract: break blocker_list.append(node) return blocker_list def create_fuzz_blocker_table( self, profile: fuzz_data_loader.FuzzerProfile, tables: List[str], calltree_file_name: str, fuzz_blockers=None) -> Optional[str]: """ Creates HTML string for table showing fuzz blockers. """ logger.info("Creating fuzz blocker table") # Get the fuzz blockers if fuzz_blockers is None: fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) if len(fuzz_blockers) == 0: return None html_table_string = "<p class='no-top-margin'>The followings nodes " \ "represent call sites where fuzz blockers occur</p>" tables.append(f"myTable{len(tables)}") html_table_string += fuzz_html_helpers.html_create_table_head( tables[-1], [ ("Amount of callsites blocked", "Total amount of callsites blocked"), ("Calltree index", "Index in call tree where the fuzz blocker is."), ("Parent function", "Function in which the call site that blocks resides."), ("Callsite", ""), ("Largest blocked function", "This is the function with highest cyclomatiic complexity amongst" "all of the functions that are blocked. As such, it's a way of " "highlighting a potentially important function being blocked") ], sort_by_column=0, sort_order="desc" ) for node in fuzz_blockers: link_prefix = "0" * (5 - len(str(node.cov_ct_idx))) node_link = "%s?scrollToNode=%s%s" % ( calltree_file_name, link_prefix, node.cov_ct_idx ) html_table_string += fuzz_html_helpers.html_table_add_row([ str(node.cov_forward_reds), str(node.cov_ct_idx), node.
49
0
10,864
ossf__fuzz-introspector
4867924b714a7789f94fbcde53713a29ceab7272
post-processing/analyses/fuzz_calltree_analysis.py
Unknown
cov_largest_blocked_func
true
statement
18
17
false
true
[ "cov_ct_idx", "depth", "cov_parent", "cov_link", "cov_forward_reds", "children", "cov_callsite_link", "cov_color", "cov_hitcount", "cov_largest_blocked_func", "dst_function_name", "dst_function_source_file", "hitcount", "parent_calltree_callsite", "src_function_name", "src_function_source_file", "src_linenumber", "for", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "cov_callsite_link", "type": "statement" }, { "name": "cov_color", "type": "statement" }, { "name": "cov_ct_idx", "type": "statement" }, { "name": "cov_forward_reds", "type": "statement" }, { "name": "cov_hitcount", "type": "statement" }, { "name": "cov_largest_blocked_func", "type": "statement" }, { "name": "cov_link", "type": "statement" }, { "name": "cov_parent", "type": "statement" }, { "name": "depth", "type": "statement" }, { "name": "dst_function_name", "type": "statement" }, { "name": "dst_function_source_file", "type": "statement" }, { "name": "hitcount", "type": "statement" }, { "name": "parent_calltree_callsite", "type": "statement" }, { "name": "src_function_name", "type": "statement" }, { "name": "src_function_source_file", "type": "statement" }, { "name": "src_linenumber", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
# Copyright 2022 Fuzz Introspector Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Logic related to calltree analysis""" import os import logging import json from typing import ( List, Tuple, Optional, Set, ) import fuzz_analysis import fuzz_data_loader import fuzz_utils import fuzz_cfg_load import fuzz_html_helpers # For pretty printing the html code: from bs4 import BeautifulSoup as bs logger = logging.getLogger(name=__name__) class FuzzCalltreeAnalysis(fuzz_analysis.AnalysisInterface): def __init__(self): self.name = "FuzzCalltreeAnalysis" logger.info("Creating FuzzCalltreeAnalysis") def analysis_func(self, toc_list: List[Tuple[str, str, int]], tables: List[str], project_profile: fuzz_data_loader.MergedProjectProfile, profiles: List[fuzz_data_loader.FuzzerProfile], basefolder: str, coverage_url: str, conclusions) -> str: """ Creates the HTML of the calltree. Returns the HTML as a string. """ logger.info("Not implemented") return "" def create_calltree(self, profile: fuzz_data_loader.FuzzerProfile) -> str: logger.info("In calltree") # Generate HTML for the calltree calltree_html_string = "<div class='section-wrapper'>" calltree_html_string += "<h1>Fuzzer calltree</h1>" nodes = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) for i in range(len(nodes)): node = nodes[i] demangled_name = fuzz_utils.demangle_cpp_func(node.dst_function_name) # We may not want to show certain functions at times, e.g. libc functions # in case it bloats the calltree # libc_funcs = { "free" } libc_funcs: Set[str] = set() avoid = len([fn for fn in libc_funcs if fn in demangled_name]) > 0 if avoid: continue # Prepare strings needed in the HTML color_to_be = node.cov_color callsite_link = node.cov_callsite_link link = node.cov_link ct_idx_str = self.create_str_node_ctx_idx(str(node.cov_ct_idx)) # Only display [function] link if we have, otherwhise show no [function] text. if node.dst_function_source_file.replace(" ", "") != "/": func_href = f"""<a href="{link}">[function]</a>""" else: func_href = "" if i > 0: previous_node = nodes[i - 1] if previous_node.depth == node.depth: calltree_html_string += "</div>" depth_diff = previous_node.depth - node.depth if depth_diff >= 1: closing_divs = "</div>" # To close "calltree-line-wrapper" closing_divs = "</div>" * (int(depth_diff) + 1) calltree_html_string += closing_divs calltree_html_string += f""" <div class="{color_to_be}-background coverage-line"> <span class="coverage-line-inner" data-calltree-idx="{ct_idx_str}"> {node.depth} <code class="language-clike"> {demangled_name} </code> <span class="coverage-line-filename"> {func_href} <a href="{callsite_link}"> [call site2] </a> <span class="calltree-idx">[calltree idx: {ct_idx_str}]</span> </span> </span> """ if i != len(nodes) - 1: next_node = nodes[i + 1] if next_node.depth > node.depth: calltree_html_string += f"""<div class="calltree-line-wrapper open level-{int(node.depth)}" style="padding-left: 16px">""" elif next_node.depth < node.depth: depth_diff = int(node.depth - next_node.depth) calltree_html_string += "</div>" * depth_diff calltree_html_string += "</div>" logger.info("Calltree created") # Write the HTML to a file called calltree_view_XX.html where XX is a counter. calltree_file_idx = 0 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" while os.path.isfile(calltree_html_file): calltree_file_idx += 1 calltree_html_file = f"calltree_view_{calltree_file_idx}.html" self.html_create_dedicated_calltree_file( calltree_html_string, calltree_html_file, profile, ) return calltree_html_file def html_create_dedicated_calltree_file( self, calltree_html_string, filename, profile: fuzz_data_loader.FuzzerProfile): """ Write a wrapped HTML file with the tags needed from fuzz-introspector We use this only for wrapping calltrees at the moment, however, down the line it makes sense to have an easy wrapper for other HTML pages too. """ complete_html_string = "" # HTML start html_header = fuzz_html_helpers.html_get_header( calltree=True, title=f"Fuzz introspector: { profile.get_key() }" ) html_header += '<div class="content-section calltree-content-section">' complete_html_string += html_header # Display fuzz blocker at top of page fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) fuzz_blocker_table = self.create_fuzz_blocker_table(profile, [], "", fuzz_blockers) if fuzz_blocker_table is not None: complete_html_string += "<div class=\"report-box\">" complete_html_string += "<h1>Fuzz blockers</h1>" complete_html_string += fuzz_blocker_table complete_html_string += "</div>" # Display calltree complete_html_string += calltree_html_string complete_html_string += "</div></div></div></div>" # HTML end html_end = '</div>' blocker_idxs = [] for node in fuzz_blockers: blocker_idxs.append(self.create_str_node_ctx_idx(str(node.cov_ct_idx))) if len(blocker_idxs) > 0: html_end = "<script>" html_end += f"var fuzz_blocker_idxs = {json.dumps(blocker_idxs)};" html_end += "</script>" html_end += "<script src=\"prism.js\"></script>" html_end += "<script src=\"clike.js\"></script>" html_end += "<script src=\"calltree.js\"></script>" complete_html_string += html_end complete_html_string += "</body></html>" # Beautify and write HTML soup = bs(complete_html_string, 'lxml') pretty_html = soup.prettify() with open(filename, "w+") as cf: cf.write(pretty_html) def create_str_node_ctx_idx(self, cov_ct_idx): prefixed_zeros = "0" * (len("00000") - len(cov_ct_idx)) return f"{prefixed_zeros}{cov_ct_idx}" def get_fuzz_blockers( self, profile: fuzz_data_loader.FuzzerProfile, max_blockers_to_extract=999): """Gets a list of fuzz blockers""" blocker_list: List[fuzz_cfg_load.CalltreeCallsite] = list() # Extract all callsites in calltree and exit early if none all_callsites = fuzz_cfg_load.extract_all_callsites(profile.function_call_depths) if len(all_callsites) == 0: return blocker_list # Filter nodes that has forward reds. Extract maximum max_blockers_to_extract nodes. nodes_sorted_by_red_ahead = sorted(all_callsites, key=lambda x: x.cov_forward_reds, reverse=True) for node in nodes_sorted_by_red_ahead: if node.cov_forward_reds == 0 or len(blocker_list) >= max_blockers_to_extract: break blocker_list.append(node) return blocker_list def create_fuzz_blocker_table( self, profile: fuzz_data_loader.FuzzerProfile, tables: List[str], calltree_file_name: str, fuzz_blockers=None) -> Optional[str]: """ Creates HTML string for table showing fuzz blockers. """ logger.info("Creating fuzz blocker table") # Get the fuzz blockers if fuzz_blockers is None: fuzz_blockers = self.get_fuzz_blockers( profile, max_blockers_to_extract=12 ) if len(fuzz_blockers) == 0: return None html_table_string = "<p class='no-top-margin'>The followings nodes " \ "represent call sites where fuzz blockers occur</p>" tables.append(f"myTable{len(tables)}") html_table_string += fuzz_html_helpers.html_create_table_head( tables[-1], [ ("Amount of callsites blocked", "Total amount of callsites blocked"), ("Calltree index", "Index in call tree where the fuzz blocker is."), ("Parent function", "Function in which the call site that blocks resides."), ("Callsite", ""), ("Largest blocked function", "This is the function with highest cyclomatiic complexity amongst" "all of the functions that are blocked. As such, it's a way of " "highlighting a potentially important function being blocked") ], sort_by_column=0, sort_order="desc" ) for node in fuzz_blockers: link_prefix = "0" * (5 - len(str(node.cov_ct_idx))) node_link = "%s?scrollToNode=%s%s" % ( calltree_file_name, link_prefix, node.cov_ct_idx ) html_table_string += fuzz_html_helpers.html_table_add_row([ str(node.cov_forward_reds), str(node.cov_ct_idx), node.cov_parent, f"<a href={node_link}>call site</a>", node.
58
1
3,201
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
Unknown
edges
true
statement
16
16
false
true
[ "edges", "nodes", "name", "type", "edge_style", "__init__", "_get_node_id", "_order_edges", "color_node", "graph_style", "hide_node", "label2id", "node_style", "remove_edge", "remove_node", "transitive_reduction", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.
59
1
3,496
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
Unknown
nodes
true
statement
16
16
false
true
[ "nodes", "edges", "edge_style", "node_style", "graph_style", "__init__", "_get_node_id", "_order_edges", "color_node", "hide_node", "label2id", "name", "remove_edge", "remove_node", "transitive_reduction", "type", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.
60
1
3,662
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
Unknown
label2id
true
statement
16
16
false
true
[ "edges", "nodes", "name", "type", "label2id", "__init__", "_get_node_id", "_order_edges", "color_node", "edge_style", "graph_style", "hide_node", "node_style", "remove_edge", "remove_node", "transitive_reduction", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.
61
1
3,921
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
Unknown
edges
true
statement
16
16
false
false
[ "edges", "edge_style", "node_style", "graph_style", "nodes", "__init__", "_get_node_id", "_order_edges", "color_node", "hide_node", "label2id", "name", "remove_edge", "remove_node", "transitive_reduction", "type", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.
62
1
4,002
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
Unknown
edges
true
statement
16
16
false
false
[ "edges", "edge_style", "node_style", "graph_style", "nodes", "__init__", "_get_node_id", "_order_edges", "color_node", "hide_node", "label2id", "name", "remove_edge", "remove_node", "transitive_reduction", "type", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True) targets = sorted(set(int(e[1]) for e in list(self.
63
1
4,159
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
Unknown
edges
true
statement
16
16
false
false
[ "edges", "edge_style", "nodes", "label2id", "_order_edges", "__init__", "_get_node_id", "color_node", "graph_style", "hide_node", "name", "node_style", "remove_edge", "remove_node", "transitive_reduction", "type", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True) targets = sorted(set(int(e[1]) for e in list(self.edges))) for target in targets: for source in sources: edge = (str(source), str(target)) if edge in self.
64
1
4,330
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
infile
type
true
statement
17
16
false
true
[ "edges", "nodes", "label2id", "name", "type", "__init__", "_get_node_id", "_order_edges", "color_node", "edge_style", "graph_style", "hide_node", "node_style", "remove_edge", "remove_node", "transitive_reduction", "write", "for", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True) targets = sorted(set(int(e[1]) for e in list(self.edges))) for target in targets: for source in sources: edge = (str(source), str(target)) if edge in self.edges: ordered.append(edge) return ordered def write(self, fname): with open(fname, "w") as f: f.write(" ".join([self.
65
1
4,341
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
infile
name
true
statement
17
16
false
true
[ "name", "type", "edges", "nodes", "label2id", "__init__", "_get_node_id", "_order_edges", "color_node", "edge_style", "graph_style", "hide_node", "node_style", "remove_edge", "remove_node", "transitive_reduction", "write", "for", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True) targets = sorted(set(int(e[1]) for e in list(self.edges))) for target in targets: for source in sources: edge = (str(source), str(target)) if edge in self.edges: ordered.append(edge) return ordered def write(self, fname): with open(fname, "w") as f: f.write(" ".join([self.type, self.
66
1
4,381
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
infile
graph_style
true
statement
16
16
false
true
[ "edges", "nodes", "label2id", "edge_style", "node_style", "__init__", "_get_node_id", "_order_edges", "color_node", "graph_style", "hide_node", "name", "remove_edge", "remove_node", "transitive_reduction", "type", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True) targets = sorted(set(int(e[1]) for e in list(self.edges))) for target in targets: for source in sources: edge = (str(source), str(target)) if edge in self.edges: ordered.append(edge) return ordered def write(self, fname): with open(fname, "w") as f: f.write(" ".join([self.type, self.name, "{\n"])) f.write(self.
67
1
4,419
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
infile
node_style
true
statement
16
16
false
true
[ "edges", "nodes", "label2id", "edge_style", "graph_style", "__init__", "_get_node_id", "_order_edges", "color_node", "hide_node", "name", "node_style", "remove_edge", "remove_node", "transitive_reduction", "type", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True) targets = sorted(set(int(e[1]) for e in list(self.edges))) for target in targets: for source in sources: edge = (str(source), str(target)) if edge in self.edges: ordered.append(edge) return ordered def write(self, fname): with open(fname, "w") as f: f.write(" ".join([self.type, self.name, "{\n"])) f.write(self.graph_style) f.write(self.
68
1
4,456
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
infile
edge_style
true
statement
16
16
false
true
[ "edges", "nodes", "label2id", "node_style", "graph_style", "__init__", "_get_node_id", "_order_edges", "color_node", "edge_style", "hide_node", "name", "remove_edge", "remove_node", "transitive_reduction", "type", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True) targets = sorted(set(int(e[1]) for e in list(self.edges))) for target in targets: for source in sources: edge = (str(source), str(target)) if edge in self.edges: ordered.append(edge) return ordered def write(self, fname): with open(fname, "w") as f: f.write(" ".join([self.type, self.name, "{\n"])) f.write(self.graph_style) f.write(self.node_style) f.write(self.
69
1
4,497
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
Unknown
nodes
true
statement
16
16
false
false
[ "edges", "nodes", "name", "type", "label2id", "__init__", "_get_node_id", "_order_edges", "color_node", "edge_style", "graph_style", "hide_node", "node_style", "remove_edge", "remove_node", "transitive_reduction", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True) targets = sorted(set(int(e[1]) for e in list(self.edges))) for target in targets: for source in sources: edge = (str(source), str(target)) if edge in self.edges: ordered.append(edge) return ordered def write(self, fname): with open(fname, "w") as f: f.write(" ".join([self.type, self.name, "{\n"])) f.write(self.graph_style) f.write(self.node_style) f.write(self.edge_style) for k, v in self.
70
1
4,744
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
infile
_order_edges
true
function
16
16
true
true
[ "edges", "nodes", "label2id", "name", "type", "__init__", "_get_node_id", "_order_edges", "color_node", "edge_style", "graph_style", "hide_node", "node_style", "remove_edge", "remove_node", "transitive_reduction", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True) targets = sorted(set(int(e[1]) for e in list(self.edges))) for target in targets: for source in sources: edge = (str(source), str(target)) if edge in self.edges: ordered.append(edge) return ordered def write(self, fname): with open(fname, "w") as f: f.write(" ".join([self.type, self.name, "{\n"])) f.write(self.graph_style) f.write(self.node_style) f.write(self.edge_style) for k, v in self.nodes.items(): l = v["label"] c = v["color"] s = v["style"] line = f' {k}[label = "{l}", color = "{c}", style="{s}"];\n' f.write(line) for a, b in self.
71
1
4,963
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
Unknown
nodes
true
statement
16
16
false
false
[ "nodes", "node_style", "edges", "remove_node", "_get_node_id", "__init__", "_order_edges", "color_node", "edge_style", "graph_style", "hide_node", "label2id", "name", "remove_edge", "transitive_reduction", "type", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True) targets = sorted(set(int(e[1]) for e in list(self.edges))) for target in targets: for source in sources: edge = (str(source), str(target)) if edge in self.edges: ordered.append(edge) return ordered def write(self, fname): with open(fname, "w") as f: f.write(" ".join([self.type, self.name, "{\n"])) f.write(self.graph_style) f.write(self.node_style) f.write(self.edge_style) for k, v in self.nodes.items(): l = v["label"] c = v["color"] s = v["style"] line = f' {k}[label = "{l}", color = "{c}", style="{s}"];\n' f.write(line) for a, b in self._order_edges(): line = f" {a} -> {b}\n" f.write(line) f.write("}\n") def _get_node_id(self, node): node = str(node) if node.isdigit() and node in self.
72
1
5,014
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
common
label2id
true
statement
16
16
false
false
[ "nodes", "edges", "node_style", "name", "type", "__init__", "_get_node_id", "_order_edges", "color_node", "edge_style", "graph_style", "hide_node", "label2id", "remove_edge", "remove_node", "transitive_reduction", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True) targets = sorted(set(int(e[1]) for e in list(self.edges))) for target in targets: for source in sources: edge = (str(source), str(target)) if edge in self.edges: ordered.append(edge) return ordered def write(self, fname): with open(fname, "w") as f: f.write(" ".join([self.type, self.name, "{\n"])) f.write(self.graph_style) f.write(self.node_style) f.write(self.edge_style) for k, v in self.nodes.items(): l = v["label"] c = v["color"] s = v["style"] line = f' {k}[label = "{l}", color = "{c}", style="{s}"];\n' f.write(line) for a, b in self._order_edges(): line = f" {a} -> {b}\n" f.write(line) f.write("}\n") def _get_node_id(self, node): node = str(node) if node.isdigit() and node in self.nodes: return node return self.
73
1
5,096
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
Unknown
_get_node_id
true
function
16
16
true
true
[ "_get_node_id", "nodes", "node_style", "remove_node", "edges", "__init__", "_order_edges", "color_node", "edge_style", "graph_style", "hide_node", "label2id", "name", "remove_edge", "transitive_reduction", "type", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True) targets = sorted(set(int(e[1]) for e in list(self.edges))) for target in targets: for source in sources: edge = (str(source), str(target)) if edge in self.edges: ordered.append(edge) return ordered def write(self, fname): with open(fname, "w") as f: f.write(" ".join([self.type, self.name, "{\n"])) f.write(self.graph_style) f.write(self.node_style) f.write(self.edge_style) for k, v in self.nodes.items(): l = v["label"] c = v["color"] s = v["style"] line = f' {k}[label = "{l}", color = "{c}", style="{s}"];\n' f.write(line) for a, b in self._order_edges(): line = f" {a} -> {b}\n" f.write(line) f.write("}\n") def _get_node_id(self, node): node = str(node) if node.isdigit() and node in self.nodes: return node return self.label2id.get(node) def color_node(self, node, color): node_id = self.
74
1
5,176
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
Unknown
nodes
true
statement
16
16
false
false
[ "nodes", "label2id", "edges", "node_style", "_get_node_id", "__init__", "_order_edges", "color_node", "edge_style", "graph_style", "hide_node", "name", "remove_edge", "remove_node", "transitive_reduction", "type", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True) targets = sorted(set(int(e[1]) for e in list(self.edges))) for target in targets: for source in sources: edge = (str(source), str(target)) if edge in self.edges: ordered.append(edge) return ordered def write(self, fname): with open(fname, "w") as f: f.write(" ".join([self.type, self.name, "{\n"])) f.write(self.graph_style) f.write(self.node_style) f.write(self.edge_style) for k, v in self.nodes.items(): l = v["label"] c = v["color"] s = v["style"] line = f' {k}[label = "{l}", color = "{c}", style="{s}"];\n' f.write(line) for a, b in self._order_edges(): line = f" {a} -> {b}\n" f.write(line) f.write("}\n") def _get_node_id(self, node): node = str(node) if node.isdigit() and node in self.nodes: return node return self.label2id.get(node) def color_node(self, node, color): node_id = self._get_node_id(node) if node_id is None: return self.
75
1
5,265
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
infile
_get_node_id
true
function
16
16
true
false
[ "_get_node_id", "nodes", "node_style", "edges", "remove_node", "__init__", "_order_edges", "color_node", "edge_style", "graph_style", "hide_node", "label2id", "name", "remove_edge", "transitive_reduction", "type", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True) targets = sorted(set(int(e[1]) for e in list(self.edges))) for target in targets: for source in sources: edge = (str(source), str(target)) if edge in self.edges: ordered.append(edge) return ordered def write(self, fname): with open(fname, "w") as f: f.write(" ".join([self.type, self.name, "{\n"])) f.write(self.graph_style) f.write(self.node_style) f.write(self.edge_style) for k, v in self.nodes.items(): l = v["label"] c = v["color"] s = v["style"] line = f' {k}[label = "{l}", color = "{c}", style="{s}"];\n' f.write(line) for a, b in self._order_edges(): line = f" {a} -> {b}\n" f.write(line) f.write("}\n") def _get_node_id(self, node): node = str(node) if node.isdigit() and node in self.nodes: return node return self.label2id.get(node) def color_node(self, node, color): node_id = self._get_node_id(node) if node_id is None: return self.nodes[node_id]["color"] = color def remove_node(self, node): node_id = self.
76
1
5,379
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
Unknown
nodes
true
statement
16
16
false
false
[ "label2id", "_get_node_id", "nodes", "edges", "node_style", "__init__", "_order_edges", "color_node", "edge_style", "graph_style", "hide_node", "name", "remove_edge", "remove_node", "transitive_reduction", "type", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True) targets = sorted(set(int(e[1]) for e in list(self.edges))) for target in targets: for source in sources: edge = (str(source), str(target)) if edge in self.edges: ordered.append(edge) return ordered def write(self, fname): with open(fname, "w") as f: f.write(" ".join([self.type, self.name, "{\n"])) f.write(self.graph_style) f.write(self.node_style) f.write(self.edge_style) for k, v in self.nodes.items(): l = v["label"] c = v["color"] s = v["style"] line = f' {k}[label = "{l}", color = "{c}", style="{s}"];\n' f.write(line) for a, b in self._order_edges(): line = f" {a} -> {b}\n" f.write(line) f.write("}\n") def _get_node_id(self, node): node = str(node) if node.isdigit() and node in self.nodes: return node return self.label2id.get(node) def color_node(self, node, color): node_id = self._get_node_id(node) if node_id is None: return self.nodes[node_id]["color"] = color def remove_node(self, node): node_id = self._get_node_id(node) if node_id is None: return # remove the node label = self.
77
1
5,420
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
Unknown
nodes
true
statement
16
16
false
false
[ "nodes", "label2id", "edges", "node_style", "_get_node_id", "__init__", "_order_edges", "color_node", "edge_style", "graph_style", "hide_node", "name", "remove_edge", "remove_node", "transitive_reduction", "type", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True) targets = sorted(set(int(e[1]) for e in list(self.edges))) for target in targets: for source in sources: edge = (str(source), str(target)) if edge in self.edges: ordered.append(edge) return ordered def write(self, fname): with open(fname, "w") as f: f.write(" ".join([self.type, self.name, "{\n"])) f.write(self.graph_style) f.write(self.node_style) f.write(self.edge_style) for k, v in self.nodes.items(): l = v["label"] c = v["color"] s = v["style"] line = f' {k}[label = "{l}", color = "{c}", style="{s}"];\n' f.write(line) for a, b in self._order_edges(): line = f" {a} -> {b}\n" f.write(line) f.write("}\n") def _get_node_id(self, node): node = str(node) if node.isdigit() and node in self.nodes: return node return self.label2id.get(node) def color_node(self, node, color): node_id = self._get_node_id(node) if node_id is None: return self.nodes[node_id]["color"] = color def remove_node(self, node): node_id = self._get_node_id(node) if node_id is None: return # remove the node label = self.nodes[node_id]["label"] del self.
78
1
5,452
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
Unknown
label2id
true
statement
16
16
false
false
[ "nodes", "edges", "node_style", "_get_node_id", "name", "__init__", "_order_edges", "color_node", "edge_style", "graph_style", "hide_node", "label2id", "remove_edge", "remove_node", "transitive_reduction", "type", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True) targets = sorted(set(int(e[1]) for e in list(self.edges))) for target in targets: for source in sources: edge = (str(source), str(target)) if edge in self.edges: ordered.append(edge) return ordered def write(self, fname): with open(fname, "w") as f: f.write(" ".join([self.type, self.name, "{\n"])) f.write(self.graph_style) f.write(self.node_style) f.write(self.edge_style) for k, v in self.nodes.items(): l = v["label"] c = v["color"] s = v["style"] line = f' {k}[label = "{l}", color = "{c}", style="{s}"];\n' f.write(line) for a, b in self._order_edges(): line = f" {a} -> {b}\n" f.write(line) f.write("}\n") def _get_node_id(self, node): node = str(node) if node.isdigit() and node in self.nodes: return node return self.label2id.get(node) def color_node(self, node, color): node_id = self._get_node_id(node) if node_id is None: return self.nodes[node_id]["color"] = color def remove_node(self, node): node_id = self._get_node_id(node) if node_id is None: return # remove the node label = self.nodes[node_id]["label"] del self.nodes[node_id] del self.
79
1
5,535
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
Unknown
edges
true
statement
16
16
false
false
[ "edges", "edge_style", "nodes", "remove_edge", "node_style", "__init__", "_get_node_id", "_order_edges", "color_node", "graph_style", "hide_node", "label2id", "name", "remove_node", "transitive_reduction", "type", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True) targets = sorted(set(int(e[1]) for e in list(self.edges))) for target in targets: for source in sources: edge = (str(source), str(target)) if edge in self.edges: ordered.append(edge) return ordered def write(self, fname): with open(fname, "w") as f: f.write(" ".join([self.type, self.name, "{\n"])) f.write(self.graph_style) f.write(self.node_style) f.write(self.edge_style) for k, v in self.nodes.items(): l = v["label"] c = v["color"] s = v["style"] line = f' {k}[label = "{l}", color = "{c}", style="{s}"];\n' f.write(line) for a, b in self._order_edges(): line = f" {a} -> {b}\n" f.write(line) f.write("}\n") def _get_node_id(self, node): node = str(node) if node.isdigit() and node in self.nodes: return node return self.label2id.get(node) def color_node(self, node, color): node_id = self._get_node_id(node) if node_id is None: return self.nodes[node_id]["color"] = color def remove_node(self, node): node_id = self._get_node_id(node) if node_id is None: return # remove the node label = self.nodes[node_id]["label"] del self.nodes[node_id] del self.label2id[label] # remove all edges with this node for edge in self.
80
1
5,602
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
Unknown
edges
true
statement
16
16
false
false
[ "nodes", "edges", "node_style", "name", "type", "__init__", "_get_node_id", "_order_edges", "color_node", "edge_style", "graph_style", "hide_node", "label2id", "remove_edge", "remove_node", "transitive_reduction", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True) targets = sorted(set(int(e[1]) for e in list(self.edges))) for target in targets: for source in sources: edge = (str(source), str(target)) if edge in self.edges: ordered.append(edge) return ordered def write(self, fname): with open(fname, "w") as f: f.write(" ".join([self.type, self.name, "{\n"])) f.write(self.graph_style) f.write(self.node_style) f.write(self.edge_style) for k, v in self.nodes.items(): l = v["label"] c = v["color"] s = v["style"] line = f' {k}[label = "{l}", color = "{c}", style="{s}"];\n' f.write(line) for a, b in self._order_edges(): line = f" {a} -> {b}\n" f.write(line) f.write("}\n") def _get_node_id(self, node): node = str(node) if node.isdigit() and node in self.nodes: return node return self.label2id.get(node) def color_node(self, node, color): node_id = self._get_node_id(node) if node_id is None: return self.nodes[node_id]["color"] = color def remove_node(self, node): node_id = self._get_node_id(node) if node_id is None: return # remove the node label = self.nodes[node_id]["label"] del self.nodes[node_id] del self.label2id[label] # remove all edges with this node for edge in self.edges.copy(): if node_id in edge: self.
81
1
5,690
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
infile
_get_node_id
true
function
16
16
true
false
[ "edges", "_get_node_id", "nodes", "edge_style", "label2id", "__init__", "_order_edges", "color_node", "graph_style", "hide_node", "name", "node_style", "remove_edge", "remove_node", "transitive_reduction", "type", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True) targets = sorted(set(int(e[1]) for e in list(self.edges))) for target in targets: for source in sources: edge = (str(source), str(target)) if edge in self.edges: ordered.append(edge) return ordered def write(self, fname): with open(fname, "w") as f: f.write(" ".join([self.type, self.name, "{\n"])) f.write(self.graph_style) f.write(self.node_style) f.write(self.edge_style) for k, v in self.nodes.items(): l = v["label"] c = v["color"] s = v["style"] line = f' {k}[label = "{l}", color = "{c}", style="{s}"];\n' f.write(line) for a, b in self._order_edges(): line = f" {a} -> {b}\n" f.write(line) f.write("}\n") def _get_node_id(self, node): node = str(node) if node.isdigit() and node in self.nodes: return node return self.label2id.get(node) def color_node(self, node, color): node_id = self._get_node_id(node) if node_id is None: return self.nodes[node_id]["color"] = color def remove_node(self, node): node_id = self._get_node_id(node) if node_id is None: return # remove the node label = self.nodes[node_id]["label"] del self.nodes[node_id] del self.label2id[label] # remove all edges with this node for edge in self.edges.copy(): if node_id in edge: self.edges.remove(edge) def remove_edge(self, source, target): source_id = self.
82
1
5,736
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
infile
_get_node_id
true
function
16
16
true
false
[ "edges", "_get_node_id", "nodes", "edge_style", "label2id", "__init__", "_order_edges", "color_node", "graph_style", "hide_node", "name", "node_style", "remove_edge", "remove_node", "transitive_reduction", "type", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True) targets = sorted(set(int(e[1]) for e in list(self.edges))) for target in targets: for source in sources: edge = (str(source), str(target)) if edge in self.edges: ordered.append(edge) return ordered def write(self, fname): with open(fname, "w") as f: f.write(" ".join([self.type, self.name, "{\n"])) f.write(self.graph_style) f.write(self.node_style) f.write(self.edge_style) for k, v in self.nodes.items(): l = v["label"] c = v["color"] s = v["style"] line = f' {k}[label = "{l}", color = "{c}", style="{s}"];\n' f.write(line) for a, b in self._order_edges(): line = f" {a} -> {b}\n" f.write(line) f.write("}\n") def _get_node_id(self, node): node = str(node) if node.isdigit() and node in self.nodes: return node return self.label2id.get(node) def color_node(self, node, color): node_id = self._get_node_id(node) if node_id is None: return self.nodes[node_id]["color"] = color def remove_node(self, node): node_id = self._get_node_id(node) if node_id is None: return # remove the node label = self.nodes[node_id]["label"] del self.nodes[node_id] del self.label2id[label] # remove all edges with this node for edge in self.edges.copy(): if node_id in edge: self.edges.remove(edge) def remove_edge(self, source, target): source_id = self._get_node_id(source) target_id = self.
83
1
5,819
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
Unknown
edges
true
statement
16
16
false
false
[ "edges", "edge_style", "_order_edges", "nodes", "label2id", "__init__", "_get_node_id", "color_node", "graph_style", "hide_node", "name", "node_style", "remove_edge", "remove_node", "transitive_reduction", "type", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True) targets = sorted(set(int(e[1]) for e in list(self.edges))) for target in targets: for source in sources: edge = (str(source), str(target)) if edge in self.edges: ordered.append(edge) return ordered def write(self, fname): with open(fname, "w") as f: f.write(" ".join([self.type, self.name, "{\n"])) f.write(self.graph_style) f.write(self.node_style) f.write(self.edge_style) for k, v in self.nodes.items(): l = v["label"] c = v["color"] s = v["style"] line = f' {k}[label = "{l}", color = "{c}", style="{s}"];\n' f.write(line) for a, b in self._order_edges(): line = f" {a} -> {b}\n" f.write(line) f.write("}\n") def _get_node_id(self, node): node = str(node) if node.isdigit() and node in self.nodes: return node return self.label2id.get(node) def color_node(self, node, color): node_id = self._get_node_id(node) if node_id is None: return self.nodes[node_id]["color"] = color def remove_node(self, node): node_id = self._get_node_id(node) if node_id is None: return # remove the node label = self.nodes[node_id]["label"] del self.nodes[node_id] del self.label2id[label] # remove all edges with this node for edge in self.edges.copy(): if node_id in edge: self.edges.remove(edge) def remove_edge(self, source, target): source_id = self._get_node_id(source) target_id = self._get_node_id(target) edge = (source_id, target_id) if edge in self.
84
1
5,843
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
Unknown
edges
true
statement
16
16
false
false
[ "edges", "edge_style", "nodes", "write", "name", "__init__", "_get_node_id", "_order_edges", "color_node", "graph_style", "hide_node", "label2id", "node_style", "remove_edge", "remove_node", "transitive_reduction", "type", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True) targets = sorted(set(int(e[1]) for e in list(self.edges))) for target in targets: for source in sources: edge = (str(source), str(target)) if edge in self.edges: ordered.append(edge) return ordered def write(self, fname): with open(fname, "w") as f: f.write(" ".join([self.type, self.name, "{\n"])) f.write(self.graph_style) f.write(self.node_style) f.write(self.edge_style) for k, v in self.nodes.items(): l = v["label"] c = v["color"] s = v["style"] line = f' {k}[label = "{l}", color = "{c}", style="{s}"];\n' f.write(line) for a, b in self._order_edges(): line = f" {a} -> {b}\n" f.write(line) f.write("}\n") def _get_node_id(self, node): node = str(node) if node.isdigit() and node in self.nodes: return node return self.label2id.get(node) def color_node(self, node, color): node_id = self._get_node_id(node) if node_id is None: return self.nodes[node_id]["color"] = color def remove_node(self, node): node_id = self._get_node_id(node) if node_id is None: return # remove the node label = self.nodes[node_id]["label"] del self.nodes[node_id] del self.label2id[label] # remove all edges with this node for edge in self.edges.copy(): if node_id in edge: self.edges.remove(edge) def remove_edge(self, source, target): source_id = self._get_node_id(source) target_id = self._get_node_id(target) edge = (source_id, target_id) if edge in self.edges: self.
85
1
5,992
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
Unknown
_get_node_id
true
function
16
16
true
false
[ "_get_node_id", "nodes", "node_style", "remove_node", "edges", "__init__", "_order_edges", "color_node", "edge_style", "graph_style", "hide_node", "label2id", "name", "remove_edge", "transitive_reduction", "type", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True) targets = sorted(set(int(e[1]) for e in list(self.edges))) for target in targets: for source in sources: edge = (str(source), str(target)) if edge in self.edges: ordered.append(edge) return ordered def write(self, fname): with open(fname, "w") as f: f.write(" ".join([self.type, self.name, "{\n"])) f.write(self.graph_style) f.write(self.node_style) f.write(self.edge_style) for k, v in self.nodes.items(): l = v["label"] c = v["color"] s = v["style"] line = f' {k}[label = "{l}", color = "{c}", style="{s}"];\n' f.write(line) for a, b in self._order_edges(): line = f" {a} -> {b}\n" f.write(line) f.write("}\n") def _get_node_id(self, node): node = str(node) if node.isdigit() and node in self.nodes: return node return self.label2id.get(node) def color_node(self, node, color): node_id = self._get_node_id(node) if node_id is None: return self.nodes[node_id]["color"] = color def remove_node(self, node): node_id = self._get_node_id(node) if node_id is None: return # remove the node label = self.nodes[node_id]["label"] del self.nodes[node_id] del self.label2id[label] # remove all edges with this node for edge in self.edges.copy(): if node_id in edge: self.edges.remove(edge) def remove_edge(self, source, target): source_id = self._get_node_id(source) target_id = self._get_node_id(target) edge = (source_id, target_id) if edge in self.edges: self.edges.remove(edge) def hide_node(self, node): """remove a node, and connect incoming edges and outgoing edges""" node_id = self.
86
1
6,173
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
Unknown
edges
true
statement
16
16
false
false
[ "edges", "nodes", "edge_style", "_order_edges", "node_style", "__init__", "_get_node_id", "color_node", "graph_style", "hide_node", "label2id", "name", "remove_edge", "remove_node", "transitive_reduction", "type", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True) targets = sorted(set(int(e[1]) for e in list(self.edges))) for target in targets: for source in sources: edge = (str(source), str(target)) if edge in self.edges: ordered.append(edge) return ordered def write(self, fname): with open(fname, "w") as f: f.write(" ".join([self.type, self.name, "{\n"])) f.write(self.graph_style) f.write(self.node_style) f.write(self.edge_style) for k, v in self.nodes.items(): l = v["label"] c = v["color"] s = v["style"] line = f' {k}[label = "{l}", color = "{c}", style="{s}"];\n' f.write(line) for a, b in self._order_edges(): line = f" {a} -> {b}\n" f.write(line) f.write("}\n") def _get_node_id(self, node): node = str(node) if node.isdigit() and node in self.nodes: return node return self.label2id.get(node) def color_node(self, node, color): node_id = self._get_node_id(node) if node_id is None: return self.nodes[node_id]["color"] = color def remove_node(self, node): node_id = self._get_node_id(node) if node_id is None: return # remove the node label = self.nodes[node_id]["label"] del self.nodes[node_id] del self.label2id[label] # remove all edges with this node for edge in self.edges.copy(): if node_id in edge: self.edges.remove(edge) def remove_edge(self, source, target): source_id = self._get_node_id(source) target_id = self._get_node_id(target) edge = (source_id, target_id) if edge in self.edges: self.edges.remove(edge) def hide_node(self, node): """remove a node, and connect incoming edges and outgoing edges""" node_id = self._get_node_id(node) if node_id is None: return # identify parent and daughter nodes parents = [] daughters = [] for edge in self.
87
1
6,374
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
infile
remove_node
true
function
16
16
false
true
[ "edges", "nodes", "type", "label2id", "node_style", "__init__", "_get_node_id", "_order_edges", "color_node", "edge_style", "graph_style", "hide_node", "name", "remove_edge", "remove_node", "transitive_reduction", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True) targets = sorted(set(int(e[1]) for e in list(self.edges))) for target in targets: for source in sources: edge = (str(source), str(target)) if edge in self.edges: ordered.append(edge) return ordered def write(self, fname): with open(fname, "w") as f: f.write(" ".join([self.type, self.name, "{\n"])) f.write(self.graph_style) f.write(self.node_style) f.write(self.edge_style) for k, v in self.nodes.items(): l = v["label"] c = v["color"] s = v["style"] line = f' {k}[label = "{l}", color = "{c}", style="{s}"];\n' f.write(line) for a, b in self._order_edges(): line = f" {a} -> {b}\n" f.write(line) f.write("}\n") def _get_node_id(self, node): node = str(node) if node.isdigit() and node in self.nodes: return node return self.label2id.get(node) def color_node(self, node, color): node_id = self._get_node_id(node) if node_id is None: return self.nodes[node_id]["color"] = color def remove_node(self, node): node_id = self._get_node_id(node) if node_id is None: return # remove the node label = self.nodes[node_id]["label"] del self.nodes[node_id] del self.label2id[label] # remove all edges with this node for edge in self.edges.copy(): if node_id in edge: self.edges.remove(edge) def remove_edge(self, source, target): source_id = self._get_node_id(source) target_id = self._get_node_id(target) edge = (source_id, target_id) if edge in self.edges: self.edges.remove(edge) def hide_node(self, node): """remove a node, and connect incoming edges and outgoing edges""" node_id = self._get_node_id(node) if node_id is None: return # identify parent and daughter nodes parents = [] daughters = [] for edge in self.edges: if node_id == edge[0]: daughters.append(edge[1]) elif node_id == edge[1]: parents.append(edge[0]) # remove the node self.
88
1
6,565
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
Unknown
edges
true
statement
16
16
false
false
[ "nodes", "edges", "node_style", "edge_style", "name", "__init__", "_get_node_id", "_order_edges", "color_node", "graph_style", "hide_node", "label2id", "remove_edge", "remove_node", "transitive_reduction", "type", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True) targets = sorted(set(int(e[1]) for e in list(self.edges))) for target in targets: for source in sources: edge = (str(source), str(target)) if edge in self.edges: ordered.append(edge) return ordered def write(self, fname): with open(fname, "w") as f: f.write(" ".join([self.type, self.name, "{\n"])) f.write(self.graph_style) f.write(self.node_style) f.write(self.edge_style) for k, v in self.nodes.items(): l = v["label"] c = v["color"] s = v["style"] line = f' {k}[label = "{l}", color = "{c}", style="{s}"];\n' f.write(line) for a, b in self._order_edges(): line = f" {a} -> {b}\n" f.write(line) f.write("}\n") def _get_node_id(self, node): node = str(node) if node.isdigit() and node in self.nodes: return node return self.label2id.get(node) def color_node(self, node, color): node_id = self._get_node_id(node) if node_id is None: return self.nodes[node_id]["color"] = color def remove_node(self, node): node_id = self._get_node_id(node) if node_id is None: return # remove the node label = self.nodes[node_id]["label"] del self.nodes[node_id] del self.label2id[label] # remove all edges with this node for edge in self.edges.copy(): if node_id in edge: self.edges.remove(edge) def remove_edge(self, source, target): source_id = self._get_node_id(source) target_id = self._get_node_id(target) edge = (source_id, target_id) if edge in self.edges: self.edges.remove(edge) def hide_node(self, node): """remove a node, and connect incoming edges and outgoing edges""" node_id = self._get_node_id(node) if node_id is None: return # identify parent and daughter nodes parents = [] daughters = [] for edge in self.edges: if node_id == edge[0]: daughters.append(edge[1]) elif node_id == edge[1]: parents.append(edge[0]) # remove the node self.remove_node(node) # connect the neighboring nodes for parent in parents: for daughter in daughters: edge = (parent, daughter) self.
89
1
6,646
vanheeringen-lab__seq2science
d5ff9782c8f6c4cd989f74684154c508b7c65127
docs/scripts/clean_dags.py
Unknown
edges
true
statement
16
16
false
false
[ "graph_style", "edges", "edge_style", "nodes", "node_style", "__init__", "_get_node_id", "_order_edges", "color_node", "hide_node", "label2id", "name", "remove_edge", "remove_node", "transitive_reduction", "type", "write", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "color_node", "type": "function" }, { "name": "edge_style", "type": "statement" }, { "name": "edges", "type": "statement" }, { "name": "graph_style", "type": "statement" }, { "name": "hide_node", "type": "function" }, { "name": "label2id", "type": "statement" }, { "name": "name", "type": "statement" }, { "name": "node_style", "type": "statement" }, { "name": "nodes", "type": "statement" }, { "name": "remove_edge", "type": "function" }, { "name": "remove_node", "type": "function" }, { "name": "transitive_reduction", "type": "function" }, { "name": "type", "type": "statement" }, { "name": "write", "type": "function" }, { "name": "_get_node_id", "type": "function" }, { "name": "_order_edges", "type": "function" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
import re import networkx as nx rules_to_keep = { # "0.13 0.6 0.85", # yellow # "0.09 0.6 0.85", # brown # "0.28 0.6 0.85", # green # "0.04 0.6 0.85", # red # "0.00 0.6 0.85", # cherry # "0.63 0.6 0.85", # purple # "0.59 0.6 0.85", # dark blue # "0.58 0.6 0.85", # blue # "0.49 0.6 0.85", # teal # input "get_genome": "0.49 0.6 0.85", # teal "ena2fastq_SE": "0.49 0.6 0.85", # teal "ena2fastq_PE": "0.49 0.6 0.85", # teal "sra2fastq_SE": "0.49 0.6 0.85", # teal "sra2fastq_PE": "0.49 0.6 0.85", # teal # fastq "fastp_SE": "0.13 0.6 0.85", # yellow "fastp_PE": "0.13 0.6 0.85", # yellow "trimgalore_SE": "0.13 0.6 0.85", # yellow "trimgalore_PE": "0.13 0.6 0.85", # yellow "merge_replicates": "0.13 0.6 0.85", # yellow # align "bowtie2_align": "0.13 0.6 0.85", # yellow "bwa_mem": "0.13 0.6 0.85", # yellow "bwa_mem2": "0.13 0.6 0.85", # yellow "hisat2_align": "0.13 0.6 0.85", # yellow "minimap2_align": "0.13 0.6 0.85", # yellow "star_align": "0.13 0.6 0.85", # yellow "mark_duplicates": "0.13 0.6 0.85", # yellow "sieve_bam": "0.13 0.6 0.85", # yellow # peak counting "macs2_callpeak": "0.13 0.6 0.85", # yellow "call_peak_genrich": "0.13 0.6 0.85", # yellow "hmmratac": "0.13 0.6 0.85", # yellow "create_SNAP_object": "0.13 0.6 0.85", # yellow # gene counting/quantification "htseq_count": "0.13 0.6 0.85", # yellow "featurecounts": "0.13 0.6 0.85", # yellow "salmon_quant": "0.13 0.6 0.85", # yellow # trackhub "bam_bigwig": "0.00 0.6 0.85", # cherry "peak_bigpeak": "0.00 0.6 0.85", # cherry "bedgraph_bigwig": "0.00 0.6 0.85", # cherry "trackhub": "0.00 0.6 0.85", # cherry # multiqc "multiqc": "0.63 0.6 0.85", # purple # peak files "coverage_table": "0.28 0.6 0.85", # green "onehot_peaks": "0.28 0.6 0.85", # green "create_bins_SNAP_object": "0.28 0.6 0.85", # green # gene files "gene_id2name": "0.28 0.6 0.85", # green "tpm_matrix": "0.28 0.6 0.85", # green "count_matrix": "0.28 0.6 0.85", # green "txi_count_matrix": "0.28 0.6 0.85", # green "pytxi_count_matrix": "0.28 0.6 0.85", # green "citeseqcount": "0.28 0.6 0.85", # green "kallistobus_count": "0.28 0.6 0.85", # green # other "gimme_maelstrom": "0.28 0.6 0.85", # green "deseq2": "0.28 0.6 0.85", # green "dexseq_count_matrix": "0.28 0.6 0.85", # green } class Digraph: def __init__(self, infile): with open(infile) as f: lines = f.readlines() self.type, self.name = lines[0].split()[0:2] self.graph_style = lines[1] self.node_style = lines[2] self.edge_style = lines[3] self.nodes = dict() self.edges = set() self.label2id = dict() l = re.compile(r'label = "(.*?)"') c = re.compile(r'color = "(.*?)"') s = re.compile(r'style="(.*?)"') for line in lines[4:]: line = line.strip() # read edges edge = tuple(line.split(" -> ")) if len(edge) == 2: self.edges.add(edge) # read nodes elif "[" in line[:5]: node_id = line.split("[")[0] label = l.search(line).groups()[0] color = c.search(line).groups()[0] style = s.search(line).groups()[0] self.nodes[node_id] = { "label": label, "color": color, "style": style, } self.label2id[label] = node_id def _order_edges(self): """ edges are sorted by 1) ascending target nodes and 2) descending source nodes """ ordered = [] sources = sorted(set(int(e[0]) for e in list(self.edges)), reverse=True) targets = sorted(set(int(e[1]) for e in list(self.edges))) for target in targets: for source in sources: edge = (str(source), str(target)) if edge in self.edges: ordered.append(edge) return ordered def write(self, fname): with open(fname, "w") as f: f.write(" ".join([self.type, self.name, "{\n"])) f.write(self.graph_style) f.write(self.node_style) f.write(self.edge_style) for k, v in self.nodes.items(): l = v["label"] c = v["color"] s = v["style"] line = f' {k}[label = "{l}", color = "{c}", style="{s}"];\n' f.write(line) for a, b in self._order_edges(): line = f" {a} -> {b}\n" f.write(line) f.write("}\n") def _get_node_id(self, node): node = str(node) if node.isdigit() and node in self.nodes: return node return self.label2id.get(node) def color_node(self, node, color): node_id = self._get_node_id(node) if node_id is None: return self.nodes[node_id]["color"] = color def remove_node(self, node): node_id = self._get_node_id(node) if node_id is None: return # remove the node label = self.nodes[node_id]["label"] del self.nodes[node_id] del self.label2id[label] # remove all edges with this node for edge in self.edges.copy(): if node_id in edge: self.edges.remove(edge) def remove_edge(self, source, target): source_id = self._get_node_id(source) target_id = self._get_node_id(target) edge = (source_id, target_id) if edge in self.edges: self.edges.remove(edge) def hide_node(self, node): """remove a node, and connect incoming edges and outgoing edges""" node_id = self._get_node_id(node) if node_id is None: return # identify parent and daughter nodes parents = [] daughters = [] for edge in self.edges: if node_id == edge[0]: daughters.append(edge[1]) elif node_id == edge[1]: parents.append(edge[0]) # remove the node self.remove_node(node) # connect the neighboring nodes for parent in parents: for daughter in daughters: edge = (parent, daughter) self.edges.add(edge) def transitive_reduction(self): g = nx.DiGraph(self.
96
4
1,958
Significant-Gravitas__Auto-GPT
0569d6652fbffa665de6e42403a48783fbede8ce
autogpt/commands.py
Unknown
google_api_key
true
statement
63
63
false
true
[ "speak_mode", "google_api_key", "execute_local_commands", "custom_search_engine_id", "fast_llm_model", "ai_settings_file", "AZURE_CONFIG_FILE", "azure_model_to_deployment_id_map", "browse_chunk_max_length", "browse_summary_max_token", "continuous_limit", "continuous_mode", "debug_mode", "elevenlabs_api_key", "elevenlabs_voice_1_id", "elevenlabs_voice_2_id", "fast_token_limit", "get_azure_deployment_id_for_model", "github_api_key", "github_username", "huggingface_api_token", "image_provider", "load_azure_config", "memory_backend", "memory_index", "milvus_addr", "milvus_collection", "openai_api_base", "openai_api_key", "openai_api_type", "openai_api_version", "pinecone_api_key", "pinecone_region", "redis_host", "redis_password", "redis_port", "set_browse_chunk_max_length", "set_browse_summary_max_token", "set_continuous_limit", "set_continuous_mode", "set_custom_search_engine_id", "set_debug_mode", "set_elevenlabs_api_key", "set_elevenlabs_voice_1_id", "set_elevenlabs_voice_2_id", "set_fast_llm_model", "set_fast_token_limit", "set_google_api_key", "set_openai_api_key", "set_pinecone_api_key", "set_pinecone_region", "set_smart_llm_model", "set_smart_token_limit", "set_speak_mode", "skip_reprompt", "smart_llm_model", "smart_token_limit", "temperature", "use_azure", "use_brian_tts", "use_mac_os_tts", "user_agent", "wipe_redis_on_start", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "ai_settings_file", "type": "statement" }, { "name": "AZURE_CONFIG_FILE", "type": "statement" }, { "name": "azure_model_to_deployment_id_map", "type": "statement" }, { "name": "browse_chunk_max_length", "type": "statement" }, { "name": "browse_summary_max_token", "type": "statement" }, { "name": "continuous_limit", "type": "statement" }, { "name": "continuous_mode", "type": "statement" }, { "name": "custom_search_engine_id", "type": "statement" }, { "name": "debug_mode", "type": "statement" }, { "name": "elevenlabs_api_key", "type": "statement" }, { "name": "elevenlabs_voice_1_id", "type": "statement" }, { "name": "elevenlabs_voice_2_id", "type": "statement" }, { "name": "execute_local_commands", "type": "statement" }, { "name": "fast_llm_model", "type": "statement" }, { "name": "fast_token_limit", "type": "statement" }, { "name": "get_azure_deployment_id_for_model", "type": "function" }, { "name": "github_api_key", "type": "statement" }, { "name": "github_username", "type": "statement" }, { "name": "google_api_key", "type": "statement" }, { "name": "huggingface_api_token", "type": "statement" }, { "name": "image_provider", "type": "statement" }, { "name": "load_azure_config", "type": "function" }, { "name": "memory_backend", "type": "statement" }, { "name": "memory_index", "type": "statement" }, { "name": "milvus_addr", "type": "statement" }, { "name": "milvus_collection", "type": "statement" }, { "name": "openai_api_base", "type": "statement" }, { "name": "openai_api_key", "type": "statement" }, { "name": "openai_api_type", "type": "statement" }, { "name": "openai_api_version", "type": "statement" }, { "name": "pinecone_api_key", "type": "statement" }, { "name": "pinecone_region", "type": "statement" }, { "name": "redis_host", "type": "statement" }, { "name": "redis_password", "type": "statement" }, { "name": "redis_port", "type": "statement" }, { "name": "set_browse_chunk_max_length", "type": "function" }, { "name": "set_browse_summary_max_token", "type": "function" }, { "name": "set_continuous_limit", "type": "function" }, { "name": "set_continuous_mode", "type": "function" }, { "name": "set_custom_search_engine_id", "type": "function" }, { "name": "set_debug_mode", "type": "function" }, { "name": "set_elevenlabs_api_key", "type": "function" }, { "name": "set_elevenlabs_voice_1_id", "type": "function" }, { "name": "set_elevenlabs_voice_2_id", "type": "function" }, { "name": "set_fast_llm_model", "type": "function" }, { "name": "set_fast_token_limit", "type": "function" }, { "name": "set_google_api_key", "type": "function" }, { "name": "set_openai_api_key", "type": "function" }, { "name": "set_pinecone_api_key", "type": "function" }, { "name": "set_pinecone_region", "type": "function" }, { "name": "set_smart_llm_model", "type": "function" }, { "name": "set_smart_token_limit", "type": "function" }, { "name": "set_speak_mode", "type": "function" }, { "name": "skip_reprompt", "type": "statement" }, { "name": "smart_llm_model", "type": "statement" }, { "name": "smart_token_limit", "type": "statement" }, { "name": "speak_mode", "type": "statement" }, { "name": "temperature", "type": "statement" }, { "name": "use_azure", "type": "statement" }, { "name": "use_brian_tts", "type": "statement" }, { "name": "use_mac_os_tts", "type": "statement" }, { "name": "user_agent", "type": "statement" }, { "name": "wipe_redis_on_start", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
from autogpt import browse import json from autogpt.memory import get_memory import datetime import autogpt.agent_manager as agents from autogpt import speak from autogpt.config import Config import autogpt.ai_functions as ai from autogpt.file_operations import read_file, write_to_file, append_to_file, delete_file, search_files from autogpt.execute_code import execute_python_file, execute_shell from autogpt.json_parser import fix_and_parse_json from autogpt.image_gen import generate_image from duckduckgo_search import ddg from googleapiclient.discovery import build from googleapiclient.errors import HttpError cfg = Config() def is_valid_int(value): try: int(value) return True except ValueError: return False def get_command(response): """Parse the response and return the command name and arguments""" try: response_json = fix_and_parse_json(response) if "command" not in response_json: return "Error:" , "Missing 'command' object in JSON" command = response_json["command"] if "name" not in command: return "Error:", "Missing 'name' field in 'command' object" command_name = command["name"] # Use an empty dictionary if 'args' field is not present in 'command' object arguments = command.get("args", {}) return command_name, arguments except json.decoder.JSONDecodeError: return "Error:", "Invalid JSON" # All other errors, return "Error: + error message" except Exception as e: return "Error:", str(e) def execute_command(command_name, arguments): """Execute the command and return the result""" memory = get_memory(cfg) try: if command_name == "google": # Check if the Google API key is set and use the official search method # If the API key is not set or has only whitespaces, use the unofficial search method if cfg.
97
4
1,982
Significant-Gravitas__Auto-GPT
0569d6652fbffa665de6e42403a48783fbede8ce
autogpt/commands.py
Unknown
google_api_key
true
statement
64
63
false
false
[ "google_api_key", "set_google_api_key", "execute_local_commands", "github_api_key", "openai_api_key", "ai_settings_file", "AZURE_CONFIG_FILE", "azure_model_to_deployment_id_map", "browse_chunk_max_length", "browse_summary_max_token", "continuous_limit", "continuous_mode", "custom_search_engine_id", "debug_mode", "elevenlabs_api_key", "elevenlabs_voice_1_id", "elevenlabs_voice_2_id", "fast_llm_model", "fast_token_limit", "get_azure_deployment_id_for_model", "github_username", "huggingface_api_token", "image_provider", "load_azure_config", "memory_backend", "memory_index", "milvus_addr", "milvus_collection", "openai_api_base", "openai_api_type", "openai_api_version", "pinecone_api_key", "pinecone_region", "redis_host", "redis_password", "redis_port", "set_browse_chunk_max_length", "set_browse_summary_max_token", "set_continuous_limit", "set_continuous_mode", "set_custom_search_engine_id", "set_debug_mode", "set_elevenlabs_api_key", "set_elevenlabs_voice_1_id", "set_elevenlabs_voice_2_id", "set_fast_llm_model", "set_fast_token_limit", "set_openai_api_key", "set_pinecone_api_key", "set_pinecone_region", "set_smart_llm_model", "set_smart_token_limit", "set_speak_mode", "skip_reprompt", "smart_llm_model", "smart_token_limit", "speak_mode", "temperature", "use_azure", "use_brian_tts", "use_mac_os_tts", "user_agent", "wipe_redis_on_start", "yield", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "ai_settings_file", "type": "statement" }, { "name": "AZURE_CONFIG_FILE", "type": "statement" }, { "name": "azure_model_to_deployment_id_map", "type": "statement" }, { "name": "browse_chunk_max_length", "type": "statement" }, { "name": "browse_summary_max_token", "type": "statement" }, { "name": "continuous_limit", "type": "statement" }, { "name": "continuous_mode", "type": "statement" }, { "name": "custom_search_engine_id", "type": "statement" }, { "name": "debug_mode", "type": "statement" }, { "name": "elevenlabs_api_key", "type": "statement" }, { "name": "elevenlabs_voice_1_id", "type": "statement" }, { "name": "elevenlabs_voice_2_id", "type": "statement" }, { "name": "execute_local_commands", "type": "statement" }, { "name": "fast_llm_model", "type": "statement" }, { "name": "fast_token_limit", "type": "statement" }, { "name": "get_azure_deployment_id_for_model", "type": "function" }, { "name": "github_api_key", "type": "statement" }, { "name": "github_username", "type": "statement" }, { "name": "google_api_key", "type": "statement" }, { "name": "huggingface_api_token", "type": "statement" }, { "name": "image_provider", "type": "statement" }, { "name": "load_azure_config", "type": "function" }, { "name": "memory_backend", "type": "statement" }, { "name": "memory_index", "type": "statement" }, { "name": "milvus_addr", "type": "statement" }, { "name": "milvus_collection", "type": "statement" }, { "name": "openai_api_base", "type": "statement" }, { "name": "openai_api_key", "type": "statement" }, { "name": "openai_api_type", "type": "statement" }, { "name": "openai_api_version", "type": "statement" }, { "name": "pinecone_api_key", "type": "statement" }, { "name": "pinecone_region", "type": "statement" }, { "name": "redis_host", "type": "statement" }, { "name": "redis_password", "type": "statement" }, { "name": "redis_port", "type": "statement" }, { "name": "set_browse_chunk_max_length", "type": "function" }, { "name": "set_browse_summary_max_token", "type": "function" }, { "name": "set_continuous_limit", "type": "function" }, { "name": "set_continuous_mode", "type": "function" }, { "name": "set_custom_search_engine_id", "type": "function" }, { "name": "set_debug_mode", "type": "function" }, { "name": "set_elevenlabs_api_key", "type": "function" }, { "name": "set_elevenlabs_voice_1_id", "type": "function" }, { "name": "set_elevenlabs_voice_2_id", "type": "function" }, { "name": "set_fast_llm_model", "type": "function" }, { "name": "set_fast_token_limit", "type": "function" }, { "name": "set_google_api_key", "type": "function" }, { "name": "set_openai_api_key", "type": "function" }, { "name": "set_pinecone_api_key", "type": "function" }, { "name": "set_pinecone_region", "type": "function" }, { "name": "set_smart_llm_model", "type": "function" }, { "name": "set_smart_token_limit", "type": "function" }, { "name": "set_speak_mode", "type": "function" }, { "name": "skip_reprompt", "type": "statement" }, { "name": "smart_llm_model", "type": "statement" }, { "name": "smart_token_limit", "type": "statement" }, { "name": "speak_mode", "type": "statement" }, { "name": "temperature", "type": "statement" }, { "name": "use_azure", "type": "statement" }, { "name": "use_brian_tts", "type": "statement" }, { "name": "use_mac_os_tts", "type": "statement" }, { "name": "user_agent", "type": "statement" }, { "name": "wipe_redis_on_start", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
from autogpt import browse import json from autogpt.memory import get_memory import datetime import autogpt.agent_manager as agents from autogpt import speak from autogpt.config import Config import autogpt.ai_functions as ai from autogpt.file_operations import read_file, write_to_file, append_to_file, delete_file, search_files from autogpt.execute_code import execute_python_file, execute_shell from autogpt.json_parser import fix_and_parse_json from autogpt.image_gen import generate_image from duckduckgo_search import ddg from googleapiclient.discovery import build from googleapiclient.errors import HttpError cfg = Config() def is_valid_int(value): try: int(value) return True except ValueError: return False def get_command(response): """Parse the response and return the command name and arguments""" try: response_json = fix_and_parse_json(response) if "command" not in response_json: return "Error:" , "Missing 'command' object in JSON" command = response_json["command"] if "name" not in command: return "Error:", "Missing 'name' field in 'command' object" command_name = command["name"] # Use an empty dictionary if 'args' field is not present in 'command' object arguments = command.get("args", {}) return command_name, arguments except json.decoder.JSONDecodeError: return "Error:", "Invalid JSON" # All other errors, return "Error: + error message" except Exception as e: return "Error:", str(e) def execute_command(command_name, arguments): """Execute the command and return the result""" memory = get_memory(cfg) try: if command_name == "google": # Check if the Google API key is set and use the official search method # If the API key is not set or has only whitespaces, use the unofficial search method if cfg.google_api_key and (cfg.
98
4
2,012
Significant-Gravitas__Auto-GPT
0569d6652fbffa665de6e42403a48783fbede8ce
autogpt/commands.py
Unknown
google_api_key
true
statement
64
63
false
false
[ "google_api_key", "speak_mode", "execute_local_commands", "custom_search_engine_id", "fast_llm_model", "ai_settings_file", "AZURE_CONFIG_FILE", "azure_model_to_deployment_id_map", "browse_chunk_max_length", "browse_summary_max_token", "continuous_limit", "continuous_mode", "debug_mode", "elevenlabs_api_key", "elevenlabs_voice_1_id", "elevenlabs_voice_2_id", "fast_token_limit", "get_azure_deployment_id_for_model", "github_api_key", "github_username", "huggingface_api_token", "image_provider", "load_azure_config", "memory_backend", "memory_index", "milvus_addr", "milvus_collection", "openai_api_base", "openai_api_key", "openai_api_type", "openai_api_version", "pinecone_api_key", "pinecone_region", "redis_host", "redis_password", "redis_port", "set_browse_chunk_max_length", "set_browse_summary_max_token", "set_continuous_limit", "set_continuous_mode", "set_custom_search_engine_id", "set_debug_mode", "set_elevenlabs_api_key", "set_elevenlabs_voice_1_id", "set_elevenlabs_voice_2_id", "set_fast_llm_model", "set_fast_token_limit", "set_google_api_key", "set_openai_api_key", "set_pinecone_api_key", "set_pinecone_region", "set_smart_llm_model", "set_smart_token_limit", "set_speak_mode", "skip_reprompt", "smart_llm_model", "smart_token_limit", "temperature", "use_azure", "use_brian_tts", "use_mac_os_tts", "user_agent", "wipe_redis_on_start", "yield", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "ai_settings_file", "type": "statement" }, { "name": "AZURE_CONFIG_FILE", "type": "statement" }, { "name": "azure_model_to_deployment_id_map", "type": "statement" }, { "name": "browse_chunk_max_length", "type": "statement" }, { "name": "browse_summary_max_token", "type": "statement" }, { "name": "continuous_limit", "type": "statement" }, { "name": "continuous_mode", "type": "statement" }, { "name": "custom_search_engine_id", "type": "statement" }, { "name": "debug_mode", "type": "statement" }, { "name": "elevenlabs_api_key", "type": "statement" }, { "name": "elevenlabs_voice_1_id", "type": "statement" }, { "name": "elevenlabs_voice_2_id", "type": "statement" }, { "name": "execute_local_commands", "type": "statement" }, { "name": "fast_llm_model", "type": "statement" }, { "name": "fast_token_limit", "type": "statement" }, { "name": "get_azure_deployment_id_for_model", "type": "function" }, { "name": "github_api_key", "type": "statement" }, { "name": "github_username", "type": "statement" }, { "name": "google_api_key", "type": "statement" }, { "name": "huggingface_api_token", "type": "statement" }, { "name": "image_provider", "type": "statement" }, { "name": "load_azure_config", "type": "function" }, { "name": "memory_backend", "type": "statement" }, { "name": "memory_index", "type": "statement" }, { "name": "milvus_addr", "type": "statement" }, { "name": "milvus_collection", "type": "statement" }, { "name": "openai_api_base", "type": "statement" }, { "name": "openai_api_key", "type": "statement" }, { "name": "openai_api_type", "type": "statement" }, { "name": "openai_api_version", "type": "statement" }, { "name": "pinecone_api_key", "type": "statement" }, { "name": "pinecone_region", "type": "statement" }, { "name": "redis_host", "type": "statement" }, { "name": "redis_password", "type": "statement" }, { "name": "redis_port", "type": "statement" }, { "name": "set_browse_chunk_max_length", "type": "function" }, { "name": "set_browse_summary_max_token", "type": "function" }, { "name": "set_continuous_limit", "type": "function" }, { "name": "set_continuous_mode", "type": "function" }, { "name": "set_custom_search_engine_id", "type": "function" }, { "name": "set_debug_mode", "type": "function" }, { "name": "set_elevenlabs_api_key", "type": "function" }, { "name": "set_elevenlabs_voice_1_id", "type": "function" }, { "name": "set_elevenlabs_voice_2_id", "type": "function" }, { "name": "set_fast_llm_model", "type": "function" }, { "name": "set_fast_token_limit", "type": "function" }, { "name": "set_google_api_key", "type": "function" }, { "name": "set_openai_api_key", "type": "function" }, { "name": "set_pinecone_api_key", "type": "function" }, { "name": "set_pinecone_region", "type": "function" }, { "name": "set_smart_llm_model", "type": "function" }, { "name": "set_smart_token_limit", "type": "function" }, { "name": "set_speak_mode", "type": "function" }, { "name": "skip_reprompt", "type": "statement" }, { "name": "smart_llm_model", "type": "statement" }, { "name": "smart_token_limit", "type": "statement" }, { "name": "speak_mode", "type": "statement" }, { "name": "temperature", "type": "statement" }, { "name": "use_azure", "type": "statement" }, { "name": "use_brian_tts", "type": "statement" }, { "name": "use_mac_os_tts", "type": "statement" }, { "name": "user_agent", "type": "statement" }, { "name": "wipe_redis_on_start", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
from autogpt import browse import json from autogpt.memory import get_memory import datetime import autogpt.agent_manager as agents from autogpt import speak from autogpt.config import Config import autogpt.ai_functions as ai from autogpt.file_operations import read_file, write_to_file, append_to_file, delete_file, search_files from autogpt.execute_code import execute_python_file, execute_shell from autogpt.json_parser import fix_and_parse_json from autogpt.image_gen import generate_image from duckduckgo_search import ddg from googleapiclient.discovery import build from googleapiclient.errors import HttpError cfg = Config() def is_valid_int(value): try: int(value) return True except ValueError: return False def get_command(response): """Parse the response and return the command name and arguments""" try: response_json = fix_and_parse_json(response) if "command" not in response_json: return "Error:" , "Missing 'command' object in JSON" command = response_json["command"] if "name" not in command: return "Error:", "Missing 'name' field in 'command' object" command_name = command["name"] # Use an empty dictionary if 'args' field is not present in 'command' object arguments = command.get("args", {}) return command_name, arguments except json.decoder.JSONDecodeError: return "Error:", "Invalid JSON" # All other errors, return "Error: + error message" except Exception as e: return "Error:", str(e) def execute_command(command_name, arguments): """Execute the command and return the result""" memory = get_memory(cfg) try: if command_name == "google": # Check if the Google API key is set and use the official search method # If the API key is not set or has only whitespaces, use the unofficial search method if cfg.google_api_key and (cfg.google_api_key.strip() if cfg.
99
4
2,249
Significant-Gravitas__Auto-GPT
0569d6652fbffa665de6e42403a48783fbede8ce
autogpt/commands.py
inproject
add
true
function
12
12
false
true
[ "get", "cfg", "get_stats", "data", "index", "add", "clear", "dimension", "filename", "get_relevant", "redis", "vec_num", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "add", "type": "function" }, { "name": "cfg", "type": "statement" }, { "name": "clear", "type": "function" }, { "name": "data", "type": "statement" }, { "name": "dimension", "type": "statement" }, { "name": "filename", "type": "statement" }, { "name": "get", "type": "function" }, { "name": "get_relevant", "type": "function" }, { "name": "get_stats", "type": "function" }, { "name": "index", "type": "statement" }, { "name": "redis", "type": "statement" }, { "name": "vec_num", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__bool__", "type": "instance" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__ge__", "type": "instance" }, { "name": "__getattribute__", "type": "function" }, { "name": "__gt__", "type": "instance" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__le__", "type": "instance" }, { "name": "__lt__", "type": "instance" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" }, { "name": "__subclasshook__", "type": "function" } ]
from autogpt import browse import json from autogpt.memory import get_memory import datetime import autogpt.agent_manager as agents from autogpt import speak from autogpt.config import Config import autogpt.ai_functions as ai from autogpt.file_operations import read_file, write_to_file, append_to_file, delete_file, search_files from autogpt.execute_code import execute_python_file, execute_shell from autogpt.json_parser import fix_and_parse_json from autogpt.image_gen import generate_image from duckduckgo_search import ddg from googleapiclient.discovery import build from googleapiclient.errors import HttpError cfg = Config() def is_valid_int(value): try: int(value) return True except ValueError: return False def get_command(response): """Parse the response and return the command name and arguments""" try: response_json = fix_and_parse_json(response) if "command" not in response_json: return "Error:" , "Missing 'command' object in JSON" command = response_json["command"] if "name" not in command: return "Error:", "Missing 'name' field in 'command' object" command_name = command["name"] # Use an empty dictionary if 'args' field is not present in 'command' object arguments = command.get("args", {}) return command_name, arguments except json.decoder.JSONDecodeError: return "Error:", "Invalid JSON" # All other errors, return "Error: + error message" except Exception as e: return "Error:", str(e) def execute_command(command_name, arguments): """Execute the command and return the result""" memory = get_memory(cfg) try: if command_name == "google": # Check if the Google API key is set and use the official search method # If the API key is not set or has only whitespaces, use the unofficial search method if cfg.google_api_key and (cfg.google_api_key.strip() if cfg.google_api_key else None): return google_official_search(arguments["input"]) else: return google_search(arguments["input"]) elif command_name == "memory_add": return memory.
100
4
4,500
Significant-Gravitas__Auto-GPT
0569d6652fbffa665de6e42403a48783fbede8ce
autogpt/commands.py
Unknown
execute_local_commands
true
statement
63
63
false
true
[ "speak_mode", "google_api_key", "custom_search_engine_id", "fast_llm_model", "execute_local_commands", "ai_settings_file", "AZURE_CONFIG_FILE", "azure_model_to_deployment_id_map", "browse_chunk_max_length", "browse_summary_max_token", "continuous_limit", "continuous_mode", "debug_mode", "elevenlabs_api_key", "elevenlabs_voice_1_id", "elevenlabs_voice_2_id", "fast_token_limit", "get_azure_deployment_id_for_model", "github_api_key", "github_username", "huggingface_api_token", "image_provider", "load_azure_config", "memory_backend", "memory_index", "milvus_addr", "milvus_collection", "openai_api_base", "openai_api_key", "openai_api_type", "openai_api_version", "pinecone_api_key", "pinecone_region", "redis_host", "redis_password", "redis_port", "set_browse_chunk_max_length", "set_browse_summary_max_token", "set_continuous_limit", "set_continuous_mode", "set_custom_search_engine_id", "set_debug_mode", "set_elevenlabs_api_key", "set_elevenlabs_voice_1_id", "set_elevenlabs_voice_2_id", "set_fast_llm_model", "set_fast_token_limit", "set_google_api_key", "set_openai_api_key", "set_pinecone_api_key", "set_pinecone_region", "set_smart_llm_model", "set_smart_token_limit", "set_speak_mode", "skip_reprompt", "smart_llm_model", "smart_token_limit", "temperature", "use_azure", "use_brian_tts", "use_mac_os_tts", "user_agent", "wipe_redis_on_start", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "ai_settings_file", "type": "statement" }, { "name": "AZURE_CONFIG_FILE", "type": "statement" }, { "name": "azure_model_to_deployment_id_map", "type": "statement" }, { "name": "browse_chunk_max_length", "type": "statement" }, { "name": "browse_summary_max_token", "type": "statement" }, { "name": "continuous_limit", "type": "statement" }, { "name": "continuous_mode", "type": "statement" }, { "name": "custom_search_engine_id", "type": "statement" }, { "name": "debug_mode", "type": "statement" }, { "name": "elevenlabs_api_key", "type": "statement" }, { "name": "elevenlabs_voice_1_id", "type": "statement" }, { "name": "elevenlabs_voice_2_id", "type": "statement" }, { "name": "execute_local_commands", "type": "statement" }, { "name": "fast_llm_model", "type": "statement" }, { "name": "fast_token_limit", "type": "statement" }, { "name": "get_azure_deployment_id_for_model", "type": "function" }, { "name": "github_api_key", "type": "statement" }, { "name": "github_username", "type": "statement" }, { "name": "google_api_key", "type": "statement" }, { "name": "huggingface_api_token", "type": "statement" }, { "name": "image_provider", "type": "statement" }, { "name": "load_azure_config", "type": "function" }, { "name": "memory_backend", "type": "statement" }, { "name": "memory_index", "type": "statement" }, { "name": "milvus_addr", "type": "statement" }, { "name": "milvus_collection", "type": "statement" }, { "name": "openai_api_base", "type": "statement" }, { "name": "openai_api_key", "type": "statement" }, { "name": "openai_api_type", "type": "statement" }, { "name": "openai_api_version", "type": "statement" }, { "name": "pinecone_api_key", "type": "statement" }, { "name": "pinecone_region", "type": "statement" }, { "name": "redis_host", "type": "statement" }, { "name": "redis_password", "type": "statement" }, { "name": "redis_port", "type": "statement" }, { "name": "set_browse_chunk_max_length", "type": "function" }, { "name": "set_browse_summary_max_token", "type": "function" }, { "name": "set_continuous_limit", "type": "function" }, { "name": "set_continuous_mode", "type": "function" }, { "name": "set_custom_search_engine_id", "type": "function" }, { "name": "set_debug_mode", "type": "function" }, { "name": "set_elevenlabs_api_key", "type": "function" }, { "name": "set_elevenlabs_voice_1_id", "type": "function" }, { "name": "set_elevenlabs_voice_2_id", "type": "function" }, { "name": "set_fast_llm_model", "type": "function" }, { "name": "set_fast_token_limit", "type": "function" }, { "name": "set_google_api_key", "type": "function" }, { "name": "set_openai_api_key", "type": "function" }, { "name": "set_pinecone_api_key", "type": "function" }, { "name": "set_pinecone_region", "type": "function" }, { "name": "set_smart_llm_model", "type": "function" }, { "name": "set_smart_token_limit", "type": "function" }, { "name": "set_speak_mode", "type": "function" }, { "name": "skip_reprompt", "type": "statement" }, { "name": "smart_llm_model", "type": "statement" }, { "name": "smart_token_limit", "type": "statement" }, { "name": "speak_mode", "type": "statement" }, { "name": "temperature", "type": "statement" }, { "name": "use_azure", "type": "statement" }, { "name": "use_brian_tts", "type": "statement" }, { "name": "use_mac_os_tts", "type": "statement" }, { "name": "user_agent", "type": "statement" }, { "name": "wipe_redis_on_start", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
from autogpt import browse import json from autogpt.memory import get_memory import datetime import autogpt.agent_manager as agents from autogpt import speak from autogpt.config import Config import autogpt.ai_functions as ai from autogpt.file_operations import read_file, write_to_file, append_to_file, delete_file, search_files from autogpt.execute_code import execute_python_file, execute_shell from autogpt.json_parser import fix_and_parse_json from autogpt.image_gen import generate_image from duckduckgo_search import ddg from googleapiclient.discovery import build from googleapiclient.errors import HttpError cfg = Config() def is_valid_int(value): try: int(value) return True except ValueError: return False def get_command(response): """Parse the response and return the command name and arguments""" try: response_json = fix_and_parse_json(response) if "command" not in response_json: return "Error:" , "Missing 'command' object in JSON" command = response_json["command"] if "name" not in command: return "Error:", "Missing 'name' field in 'command' object" command_name = command["name"] # Use an empty dictionary if 'args' field is not present in 'command' object arguments = command.get("args", {}) return command_name, arguments except json.decoder.JSONDecodeError: return "Error:", "Invalid JSON" # All other errors, return "Error: + error message" except Exception as e: return "Error:", str(e) def execute_command(command_name, arguments): """Execute the command and return the result""" memory = get_memory(cfg) try: if command_name == "google": # Check if the Google API key is set and use the official search method # If the API key is not set or has only whitespaces, use the unofficial search method if cfg.google_api_key and (cfg.google_api_key.strip() if cfg.google_api_key else None): return google_official_search(arguments["input"]) else: return google_search(arguments["input"]) elif command_name == "memory_add": return memory.add(arguments["string"]) elif command_name == "start_agent": return start_agent( arguments["name"], arguments["task"], arguments["prompt"]) elif command_name == "message_agent": return message_agent(arguments["key"], arguments["message"]) elif command_name == "list_agents": return list_agents() elif command_name == "delete_agent": return delete_agent(arguments["key"]) elif command_name == "get_text_summary": return get_text_summary(arguments["url"], arguments["question"]) elif command_name == "get_hyperlinks": return get_hyperlinks(arguments["url"]) elif command_name == "clone_repository": return clone_repository(arguments["repo_url"], arguments["clone_path"]) elif command_name == "read_file": return read_file(arguments["file"]) elif command_name == "write_to_file": return write_to_file(arguments["file"], arguments["text"]) elif command_name == "append_to_file": return append_to_file(arguments["file"], arguments["text"]) elif command_name == "delete_file": return delete_file(arguments["file"]) elif command_name == "search_files": return search_files(arguments["directory"]) elif command_name == "browse_website": return browse_website(arguments["url"], arguments["question"]) # TODO: Change these to take in a file rather than pasted code, if # non-file is given, return instructions "Input should be a python # filepath, write your code to file and try again" elif command_name == "evaluate_code": return ai.evaluate_code(arguments["code"]) elif command_name == "improve_code": return ai.improve_code(arguments["suggestions"], arguments["code"]) elif command_name == "write_tests": return ai.write_tests(arguments["code"], arguments.get("focus")) elif command_name == "execute_python_file": # Add this command return execute_python_file(arguments["file"]) elif command_name == "execute_shell": if cfg.
101
4
6,145
Significant-Gravitas__Auto-GPT
0569d6652fbffa665de6e42403a48783fbede8ce
autogpt/commands.py
Unknown
google_api_key
true
statement
63
63
false
false
[ "google_api_key", "custom_search_engine_id", "set_google_api_key", "fast_llm_model", "github_api_key", "ai_settings_file", "AZURE_CONFIG_FILE", "azure_model_to_deployment_id_map", "browse_chunk_max_length", "browse_summary_max_token", "continuous_limit", "continuous_mode", "debug_mode", "elevenlabs_api_key", "elevenlabs_voice_1_id", "elevenlabs_voice_2_id", "execute_local_commands", "fast_token_limit", "get_azure_deployment_id_for_model", "github_username", "huggingface_api_token", "image_provider", "load_azure_config", "memory_backend", "memory_index", "milvus_addr", "milvus_collection", "openai_api_base", "openai_api_key", "openai_api_type", "openai_api_version", "pinecone_api_key", "pinecone_region", "redis_host", "redis_password", "redis_port", "set_browse_chunk_max_length", "set_browse_summary_max_token", "set_continuous_limit", "set_continuous_mode", "set_custom_search_engine_id", "set_debug_mode", "set_elevenlabs_api_key", "set_elevenlabs_voice_1_id", "set_elevenlabs_voice_2_id", "set_fast_llm_model", "set_fast_token_limit", "set_openai_api_key", "set_pinecone_api_key", "set_pinecone_region", "set_smart_llm_model", "set_smart_token_limit", "set_speak_mode", "skip_reprompt", "smart_llm_model", "smart_token_limit", "speak_mode", "temperature", "use_azure", "use_brian_tts", "use_mac_os_tts", "user_agent", "wipe_redis_on_start", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "ai_settings_file", "type": "statement" }, { "name": "AZURE_CONFIG_FILE", "type": "statement" }, { "name": "azure_model_to_deployment_id_map", "type": "statement" }, { "name": "browse_chunk_max_length", "type": "statement" }, { "name": "browse_summary_max_token", "type": "statement" }, { "name": "continuous_limit", "type": "statement" }, { "name": "continuous_mode", "type": "statement" }, { "name": "custom_search_engine_id", "type": "statement" }, { "name": "debug_mode", "type": "statement" }, { "name": "elevenlabs_api_key", "type": "statement" }, { "name": "elevenlabs_voice_1_id", "type": "statement" }, { "name": "elevenlabs_voice_2_id", "type": "statement" }, { "name": "execute_local_commands", "type": "statement" }, { "name": "fast_llm_model", "type": "statement" }, { "name": "fast_token_limit", "type": "statement" }, { "name": "get_azure_deployment_id_for_model", "type": "function" }, { "name": "github_api_key", "type": "statement" }, { "name": "github_username", "type": "statement" }, { "name": "google_api_key", "type": "statement" }, { "name": "huggingface_api_token", "type": "statement" }, { "name": "image_provider", "type": "statement" }, { "name": "load_azure_config", "type": "function" }, { "name": "memory_backend", "type": "statement" }, { "name": "memory_index", "type": "statement" }, { "name": "milvus_addr", "type": "statement" }, { "name": "milvus_collection", "type": "statement" }, { "name": "openai_api_base", "type": "statement" }, { "name": "openai_api_key", "type": "statement" }, { "name": "openai_api_type", "type": "statement" }, { "name": "openai_api_version", "type": "statement" }, { "name": "pinecone_api_key", "type": "statement" }, { "name": "pinecone_region", "type": "statement" }, { "name": "redis_host", "type": "statement" }, { "name": "redis_password", "type": "statement" }, { "name": "redis_port", "type": "statement" }, { "name": "set_browse_chunk_max_length", "type": "function" }, { "name": "set_browse_summary_max_token", "type": "function" }, { "name": "set_continuous_limit", "type": "function" }, { "name": "set_continuous_mode", "type": "function" }, { "name": "set_custom_search_engine_id", "type": "function" }, { "name": "set_debug_mode", "type": "function" }, { "name": "set_elevenlabs_api_key", "type": "function" }, { "name": "set_elevenlabs_voice_1_id", "type": "function" }, { "name": "set_elevenlabs_voice_2_id", "type": "function" }, { "name": "set_fast_llm_model", "type": "function" }, { "name": "set_fast_token_limit", "type": "function" }, { "name": "set_google_api_key", "type": "function" }, { "name": "set_openai_api_key", "type": "function" }, { "name": "set_pinecone_api_key", "type": "function" }, { "name": "set_pinecone_region", "type": "function" }, { "name": "set_smart_llm_model", "type": "function" }, { "name": "set_smart_token_limit", "type": "function" }, { "name": "set_speak_mode", "type": "function" }, { "name": "skip_reprompt", "type": "statement" }, { "name": "smart_llm_model", "type": "statement" }, { "name": "smart_token_limit", "type": "statement" }, { "name": "speak_mode", "type": "statement" }, { "name": "temperature", "type": "statement" }, { "name": "use_azure", "type": "statement" }, { "name": "use_brian_tts", "type": "statement" }, { "name": "use_mac_os_tts", "type": "statement" }, { "name": "user_agent", "type": "statement" }, { "name": "wipe_redis_on_start", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
from autogpt import browse import json from autogpt.memory import get_memory import datetime import autogpt.agent_manager as agents from autogpt import speak from autogpt.config import Config import autogpt.ai_functions as ai from autogpt.file_operations import read_file, write_to_file, append_to_file, delete_file, search_files from autogpt.execute_code import execute_python_file, execute_shell from autogpt.json_parser import fix_and_parse_json from autogpt.image_gen import generate_image from duckduckgo_search import ddg from googleapiclient.discovery import build from googleapiclient.errors import HttpError cfg = Config() def is_valid_int(value): try: int(value) return True except ValueError: return False def get_command(response): """Parse the response and return the command name and arguments""" try: response_json = fix_and_parse_json(response) if "command" not in response_json: return "Error:" , "Missing 'command' object in JSON" command = response_json["command"] if "name" not in command: return "Error:", "Missing 'name' field in 'command' object" command_name = command["name"] # Use an empty dictionary if 'args' field is not present in 'command' object arguments = command.get("args", {}) return command_name, arguments except json.decoder.JSONDecodeError: return "Error:", "Invalid JSON" # All other errors, return "Error: + error message" except Exception as e: return "Error:", str(e) def execute_command(command_name, arguments): """Execute the command and return the result""" memory = get_memory(cfg) try: if command_name == "google": # Check if the Google API key is set and use the official search method # If the API key is not set or has only whitespaces, use the unofficial search method if cfg.google_api_key and (cfg.google_api_key.strip() if cfg.google_api_key else None): return google_official_search(arguments["input"]) else: return google_search(arguments["input"]) elif command_name == "memory_add": return memory.add(arguments["string"]) elif command_name == "start_agent": return start_agent( arguments["name"], arguments["task"], arguments["prompt"]) elif command_name == "message_agent": return message_agent(arguments["key"], arguments["message"]) elif command_name == "list_agents": return list_agents() elif command_name == "delete_agent": return delete_agent(arguments["key"]) elif command_name == "get_text_summary": return get_text_summary(arguments["url"], arguments["question"]) elif command_name == "get_hyperlinks": return get_hyperlinks(arguments["url"]) elif command_name == "clone_repository": return clone_repository(arguments["repo_url"], arguments["clone_path"]) elif command_name == "read_file": return read_file(arguments["file"]) elif command_name == "write_to_file": return write_to_file(arguments["file"], arguments["text"]) elif command_name == "append_to_file": return append_to_file(arguments["file"], arguments["text"]) elif command_name == "delete_file": return delete_file(arguments["file"]) elif command_name == "search_files": return search_files(arguments["directory"]) elif command_name == "browse_website": return browse_website(arguments["url"], arguments["question"]) # TODO: Change these to take in a file rather than pasted code, if # non-file is given, return instructions "Input should be a python # filepath, write your code to file and try again" elif command_name == "evaluate_code": return ai.evaluate_code(arguments["code"]) elif command_name == "improve_code": return ai.improve_code(arguments["suggestions"], arguments["code"]) elif command_name == "write_tests": return ai.write_tests(arguments["code"], arguments.get("focus")) elif command_name == "execute_python_file": # Add this command return execute_python_file(arguments["file"]) elif command_name == "execute_shell": if cfg.execute_local_commands: return execute_shell(arguments["command_line"]) else: return "You are not allowed to run local shell commands. To execute shell commands, EXECUTE_LOCAL_COMMANDS must be set to 'True' in your config. Do not attempt to bypass the restriction." elif command_name == "generate_image": return generate_image(arguments["prompt"]) elif command_name == "do_nothing": return "No action performed." elif command_name == "task_complete": shutdown() else: return f"Unknown command '{command_name}'. Please refer to the 'COMMANDS' list for available commands and only respond in the specified JSON format." # All errors, return "Error: + error message" except Exception as e: return "Error: " + str(e) def get_datetime(): """Return the current date and time""" return "Current date and time: " + \ datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") def google_search(query, num_results=8): """Return the results of a google search""" search_results = [] for j in ddg(query, max_results=num_results): search_results.append(j) return json.dumps(search_results, ensure_ascii=False, indent=4) def google_official_search(query, num_results=8): """Return the results of a google search using the official Google API""" from googleapiclient.discovery import build from googleapiclient.errors import HttpError import json try: # Get the Google API key and Custom Search Engine ID from the config file api_key = cfg.
102
4
6,198
Significant-Gravitas__Auto-GPT
0569d6652fbffa665de6e42403a48783fbede8ce
autogpt/commands.py
Unknown
custom_search_engine_id
true
statement
63
63
false
true
[ "custom_search_engine_id", "google_api_key", "set_custom_search_engine_id", "fast_llm_model", "speak_mode", "ai_settings_file", "AZURE_CONFIG_FILE", "azure_model_to_deployment_id_map", "browse_chunk_max_length", "browse_summary_max_token", "continuous_limit", "continuous_mode", "debug_mode", "elevenlabs_api_key", "elevenlabs_voice_1_id", "elevenlabs_voice_2_id", "execute_local_commands", "fast_token_limit", "get_azure_deployment_id_for_model", "github_api_key", "github_username", "huggingface_api_token", "image_provider", "load_azure_config", "memory_backend", "memory_index", "milvus_addr", "milvus_collection", "openai_api_base", "openai_api_key", "openai_api_type", "openai_api_version", "pinecone_api_key", "pinecone_region", "redis_host", "redis_password", "redis_port", "set_browse_chunk_max_length", "set_browse_summary_max_token", "set_continuous_limit", "set_continuous_mode", "set_debug_mode", "set_elevenlabs_api_key", "set_elevenlabs_voice_1_id", "set_elevenlabs_voice_2_id", "set_fast_llm_model", "set_fast_token_limit", "set_google_api_key", "set_openai_api_key", "set_pinecone_api_key", "set_pinecone_region", "set_smart_llm_model", "set_smart_token_limit", "set_speak_mode", "skip_reprompt", "smart_llm_model", "smart_token_limit", "temperature", "use_azure", "use_brian_tts", "use_mac_os_tts", "user_agent", "wipe_redis_on_start", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "ai_settings_file", "type": "statement" }, { "name": "AZURE_CONFIG_FILE", "type": "statement" }, { "name": "azure_model_to_deployment_id_map", "type": "statement" }, { "name": "browse_chunk_max_length", "type": "statement" }, { "name": "browse_summary_max_token", "type": "statement" }, { "name": "continuous_limit", "type": "statement" }, { "name": "continuous_mode", "type": "statement" }, { "name": "custom_search_engine_id", "type": "statement" }, { "name": "debug_mode", "type": "statement" }, { "name": "elevenlabs_api_key", "type": "statement" }, { "name": "elevenlabs_voice_1_id", "type": "statement" }, { "name": "elevenlabs_voice_2_id", "type": "statement" }, { "name": "execute_local_commands", "type": "statement" }, { "name": "fast_llm_model", "type": "statement" }, { "name": "fast_token_limit", "type": "statement" }, { "name": "get_azure_deployment_id_for_model", "type": "function" }, { "name": "github_api_key", "type": "statement" }, { "name": "github_username", "type": "statement" }, { "name": "google_api_key", "type": "statement" }, { "name": "huggingface_api_token", "type": "statement" }, { "name": "image_provider", "type": "statement" }, { "name": "load_azure_config", "type": "function" }, { "name": "memory_backend", "type": "statement" }, { "name": "memory_index", "type": "statement" }, { "name": "milvus_addr", "type": "statement" }, { "name": "milvus_collection", "type": "statement" }, { "name": "openai_api_base", "type": "statement" }, { "name": "openai_api_key", "type": "statement" }, { "name": "openai_api_type", "type": "statement" }, { "name": "openai_api_version", "type": "statement" }, { "name": "pinecone_api_key", "type": "statement" }, { "name": "pinecone_region", "type": "statement" }, { "name": "redis_host", "type": "statement" }, { "name": "redis_password", "type": "statement" }, { "name": "redis_port", "type": "statement" }, { "name": "set_browse_chunk_max_length", "type": "function" }, { "name": "set_browse_summary_max_token", "type": "function" }, { "name": "set_continuous_limit", "type": "function" }, { "name": "set_continuous_mode", "type": "function" }, { "name": "set_custom_search_engine_id", "type": "function" }, { "name": "set_debug_mode", "type": "function" }, { "name": "set_elevenlabs_api_key", "type": "function" }, { "name": "set_elevenlabs_voice_1_id", "type": "function" }, { "name": "set_elevenlabs_voice_2_id", "type": "function" }, { "name": "set_fast_llm_model", "type": "function" }, { "name": "set_fast_token_limit", "type": "function" }, { "name": "set_google_api_key", "type": "function" }, { "name": "set_openai_api_key", "type": "function" }, { "name": "set_pinecone_api_key", "type": "function" }, { "name": "set_pinecone_region", "type": "function" }, { "name": "set_smart_llm_model", "type": "function" }, { "name": "set_smart_token_limit", "type": "function" }, { "name": "set_speak_mode", "type": "function" }, { "name": "skip_reprompt", "type": "statement" }, { "name": "smart_llm_model", "type": "statement" }, { "name": "smart_token_limit", "type": "statement" }, { "name": "speak_mode", "type": "statement" }, { "name": "temperature", "type": "statement" }, { "name": "use_azure", "type": "statement" }, { "name": "use_brian_tts", "type": "statement" }, { "name": "use_mac_os_tts", "type": "statement" }, { "name": "user_agent", "type": "statement" }, { "name": "wipe_redis_on_start", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
from autogpt import browse import json from autogpt.memory import get_memory import datetime import autogpt.agent_manager as agents from autogpt import speak from autogpt.config import Config import autogpt.ai_functions as ai from autogpt.file_operations import read_file, write_to_file, append_to_file, delete_file, search_files from autogpt.execute_code import execute_python_file, execute_shell from autogpt.json_parser import fix_and_parse_json from autogpt.image_gen import generate_image from duckduckgo_search import ddg from googleapiclient.discovery import build from googleapiclient.errors import HttpError cfg = Config() def is_valid_int(value): try: int(value) return True except ValueError: return False def get_command(response): """Parse the response and return the command name and arguments""" try: response_json = fix_and_parse_json(response) if "command" not in response_json: return "Error:" , "Missing 'command' object in JSON" command = response_json["command"] if "name" not in command: return "Error:", "Missing 'name' field in 'command' object" command_name = command["name"] # Use an empty dictionary if 'args' field is not present in 'command' object arguments = command.get("args", {}) return command_name, arguments except json.decoder.JSONDecodeError: return "Error:", "Invalid JSON" # All other errors, return "Error: + error message" except Exception as e: return "Error:", str(e) def execute_command(command_name, arguments): """Execute the command and return the result""" memory = get_memory(cfg) try: if command_name == "google": # Check if the Google API key is set and use the official search method # If the API key is not set or has only whitespaces, use the unofficial search method if cfg.google_api_key and (cfg.google_api_key.strip() if cfg.google_api_key else None): return google_official_search(arguments["input"]) else: return google_search(arguments["input"]) elif command_name == "memory_add": return memory.add(arguments["string"]) elif command_name == "start_agent": return start_agent( arguments["name"], arguments["task"], arguments["prompt"]) elif command_name == "message_agent": return message_agent(arguments["key"], arguments["message"]) elif command_name == "list_agents": return list_agents() elif command_name == "delete_agent": return delete_agent(arguments["key"]) elif command_name == "get_text_summary": return get_text_summary(arguments["url"], arguments["question"]) elif command_name == "get_hyperlinks": return get_hyperlinks(arguments["url"]) elif command_name == "clone_repository": return clone_repository(arguments["repo_url"], arguments["clone_path"]) elif command_name == "read_file": return read_file(arguments["file"]) elif command_name == "write_to_file": return write_to_file(arguments["file"], arguments["text"]) elif command_name == "append_to_file": return append_to_file(arguments["file"], arguments["text"]) elif command_name == "delete_file": return delete_file(arguments["file"]) elif command_name == "search_files": return search_files(arguments["directory"]) elif command_name == "browse_website": return browse_website(arguments["url"], arguments["question"]) # TODO: Change these to take in a file rather than pasted code, if # non-file is given, return instructions "Input should be a python # filepath, write your code to file and try again" elif command_name == "evaluate_code": return ai.evaluate_code(arguments["code"]) elif command_name == "improve_code": return ai.improve_code(arguments["suggestions"], arguments["code"]) elif command_name == "write_tests": return ai.write_tests(arguments["code"], arguments.get("focus")) elif command_name == "execute_python_file": # Add this command return execute_python_file(arguments["file"]) elif command_name == "execute_shell": if cfg.execute_local_commands: return execute_shell(arguments["command_line"]) else: return "You are not allowed to run local shell commands. To execute shell commands, EXECUTE_LOCAL_COMMANDS must be set to 'True' in your config. Do not attempt to bypass the restriction." elif command_name == "generate_image": return generate_image(arguments["prompt"]) elif command_name == "do_nothing": return "No action performed." elif command_name == "task_complete": shutdown() else: return f"Unknown command '{command_name}'. Please refer to the 'COMMANDS' list for available commands and only respond in the specified JSON format." # All errors, return "Error: + error message" except Exception as e: return "Error: " + str(e) def get_datetime(): """Return the current date and time""" return "Current date and time: " + \ datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") def google_search(query, num_results=8): """Return the results of a google search""" search_results = [] for j in ddg(query, max_results=num_results): search_results.append(j) return json.dumps(search_results, ensure_ascii=False, indent=4) def google_official_search(query, num_results=8): """Return the results of a google search using the official Google API""" from googleapiclient.discovery import build from googleapiclient.errors import HttpError import json try: # Get the Google API key and Custom Search Engine ID from the config file api_key = cfg.google_api_key custom_search_engine_id = cfg.
103
4
9,742
Significant-Gravitas__Auto-GPT
0569d6652fbffa665de6e42403a48783fbede8ce
autogpt/commands.py
Unknown
fast_llm_model
true
statement
63
63
false
true
[ "google_api_key", "speak_mode", "custom_search_engine_id", "execute_local_commands", "user_agent", "ai_settings_file", "AZURE_CONFIG_FILE", "azure_model_to_deployment_id_map", "browse_chunk_max_length", "browse_summary_max_token", "continuous_limit", "continuous_mode", "debug_mode", "elevenlabs_api_key", "elevenlabs_voice_1_id", "elevenlabs_voice_2_id", "fast_llm_model", "fast_token_limit", "get_azure_deployment_id_for_model", "github_api_key", "github_username", "huggingface_api_token", "image_provider", "load_azure_config", "memory_backend", "memory_index", "milvus_addr", "milvus_collection", "openai_api_base", "openai_api_key", "openai_api_type", "openai_api_version", "pinecone_api_key", "pinecone_region", "redis_host", "redis_password", "redis_port", "set_browse_chunk_max_length", "set_browse_summary_max_token", "set_continuous_limit", "set_continuous_mode", "set_custom_search_engine_id", "set_debug_mode", "set_elevenlabs_api_key", "set_elevenlabs_voice_1_id", "set_elevenlabs_voice_2_id", "set_fast_llm_model", "set_fast_token_limit", "set_google_api_key", "set_openai_api_key", "set_pinecone_api_key", "set_pinecone_region", "set_smart_llm_model", "set_smart_token_limit", "set_speak_mode", "skip_reprompt", "smart_llm_model", "smart_token_limit", "temperature", "use_azure", "use_brian_tts", "use_mac_os_tts", "wipe_redis_on_start", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "ai_settings_file", "type": "statement" }, { "name": "AZURE_CONFIG_FILE", "type": "statement" }, { "name": "azure_model_to_deployment_id_map", "type": "statement" }, { "name": "browse_chunk_max_length", "type": "statement" }, { "name": "browse_summary_max_token", "type": "statement" }, { "name": "continuous_limit", "type": "statement" }, { "name": "continuous_mode", "type": "statement" }, { "name": "custom_search_engine_id", "type": "statement" }, { "name": "debug_mode", "type": "statement" }, { "name": "elevenlabs_api_key", "type": "statement" }, { "name": "elevenlabs_voice_1_id", "type": "statement" }, { "name": "elevenlabs_voice_2_id", "type": "statement" }, { "name": "execute_local_commands", "type": "statement" }, { "name": "fast_llm_model", "type": "statement" }, { "name": "fast_token_limit", "type": "statement" }, { "name": "get_azure_deployment_id_for_model", "type": "function" }, { "name": "github_api_key", "type": "statement" }, { "name": "github_username", "type": "statement" }, { "name": "google_api_key", "type": "statement" }, { "name": "huggingface_api_token", "type": "statement" }, { "name": "image_provider", "type": "statement" }, { "name": "load_azure_config", "type": "function" }, { "name": "memory_backend", "type": "statement" }, { "name": "memory_index", "type": "statement" }, { "name": "milvus_addr", "type": "statement" }, { "name": "milvus_collection", "type": "statement" }, { "name": "openai_api_base", "type": "statement" }, { "name": "openai_api_key", "type": "statement" }, { "name": "openai_api_type", "type": "statement" }, { "name": "openai_api_version", "type": "statement" }, { "name": "pinecone_api_key", "type": "statement" }, { "name": "pinecone_region", "type": "statement" }, { "name": "redis_host", "type": "statement" }, { "name": "redis_password", "type": "statement" }, { "name": "redis_port", "type": "statement" }, { "name": "set_browse_chunk_max_length", "type": "function" }, { "name": "set_browse_summary_max_token", "type": "function" }, { "name": "set_continuous_limit", "type": "function" }, { "name": "set_continuous_mode", "type": "function" }, { "name": "set_custom_search_engine_id", "type": "function" }, { "name": "set_debug_mode", "type": "function" }, { "name": "set_elevenlabs_api_key", "type": "function" }, { "name": "set_elevenlabs_voice_1_id", "type": "function" }, { "name": "set_elevenlabs_voice_2_id", "type": "function" }, { "name": "set_fast_llm_model", "type": "function" }, { "name": "set_fast_token_limit", "type": "function" }, { "name": "set_google_api_key", "type": "function" }, { "name": "set_openai_api_key", "type": "function" }, { "name": "set_pinecone_api_key", "type": "function" }, { "name": "set_pinecone_region", "type": "function" }, { "name": "set_smart_llm_model", "type": "function" }, { "name": "set_smart_token_limit", "type": "function" }, { "name": "set_speak_mode", "type": "function" }, { "name": "skip_reprompt", "type": "statement" }, { "name": "smart_llm_model", "type": "statement" }, { "name": "smart_token_limit", "type": "statement" }, { "name": "speak_mode", "type": "statement" }, { "name": "temperature", "type": "statement" }, { "name": "use_azure", "type": "statement" }, { "name": "use_brian_tts", "type": "statement" }, { "name": "use_mac_os_tts", "type": "statement" }, { "name": "user_agent", "type": "statement" }, { "name": "wipe_redis_on_start", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
from autogpt import browse import json from autogpt.memory import get_memory import datetime import autogpt.agent_manager as agents from autogpt import speak from autogpt.config import Config import autogpt.ai_functions as ai from autogpt.file_operations import read_file, write_to_file, append_to_file, delete_file, search_files from autogpt.execute_code import execute_python_file, execute_shell from autogpt.json_parser import fix_and_parse_json from autogpt.image_gen import generate_image from duckduckgo_search import ddg from googleapiclient.discovery import build from googleapiclient.errors import HttpError cfg = Config() def is_valid_int(value): try: int(value) return True except ValueError: return False def get_command(response): """Parse the response and return the command name and arguments""" try: response_json = fix_and_parse_json(response) if "command" not in response_json: return "Error:" , "Missing 'command' object in JSON" command = response_json["command"] if "name" not in command: return "Error:", "Missing 'name' field in 'command' object" command_name = command["name"] # Use an empty dictionary if 'args' field is not present in 'command' object arguments = command.get("args", {}) return command_name, arguments except json.decoder.JSONDecodeError: return "Error:", "Invalid JSON" # All other errors, return "Error: + error message" except Exception as e: return "Error:", str(e) def execute_command(command_name, arguments): """Execute the command and return the result""" memory = get_memory(cfg) try: if command_name == "google": # Check if the Google API key is set and use the official search method # If the API key is not set or has only whitespaces, use the unofficial search method if cfg.google_api_key and (cfg.google_api_key.strip() if cfg.google_api_key else None): return google_official_search(arguments["input"]) else: return google_search(arguments["input"]) elif command_name == "memory_add": return memory.add(arguments["string"]) elif command_name == "start_agent": return start_agent( arguments["name"], arguments["task"], arguments["prompt"]) elif command_name == "message_agent": return message_agent(arguments["key"], arguments["message"]) elif command_name == "list_agents": return list_agents() elif command_name == "delete_agent": return delete_agent(arguments["key"]) elif command_name == "get_text_summary": return get_text_summary(arguments["url"], arguments["question"]) elif command_name == "get_hyperlinks": return get_hyperlinks(arguments["url"]) elif command_name == "clone_repository": return clone_repository(arguments["repo_url"], arguments["clone_path"]) elif command_name == "read_file": return read_file(arguments["file"]) elif command_name == "write_to_file": return write_to_file(arguments["file"], arguments["text"]) elif command_name == "append_to_file": return append_to_file(arguments["file"], arguments["text"]) elif command_name == "delete_file": return delete_file(arguments["file"]) elif command_name == "search_files": return search_files(arguments["directory"]) elif command_name == "browse_website": return browse_website(arguments["url"], arguments["question"]) # TODO: Change these to take in a file rather than pasted code, if # non-file is given, return instructions "Input should be a python # filepath, write your code to file and try again" elif command_name == "evaluate_code": return ai.evaluate_code(arguments["code"]) elif command_name == "improve_code": return ai.improve_code(arguments["suggestions"], arguments["code"]) elif command_name == "write_tests": return ai.write_tests(arguments["code"], arguments.get("focus")) elif command_name == "execute_python_file": # Add this command return execute_python_file(arguments["file"]) elif command_name == "execute_shell": if cfg.execute_local_commands: return execute_shell(arguments["command_line"]) else: return "You are not allowed to run local shell commands. To execute shell commands, EXECUTE_LOCAL_COMMANDS must be set to 'True' in your config. Do not attempt to bypass the restriction." elif command_name == "generate_image": return generate_image(arguments["prompt"]) elif command_name == "do_nothing": return "No action performed." elif command_name == "task_complete": shutdown() else: return f"Unknown command '{command_name}'. Please refer to the 'COMMANDS' list for available commands and only respond in the specified JSON format." # All errors, return "Error: + error message" except Exception as e: return "Error: " + str(e) def get_datetime(): """Return the current date and time""" return "Current date and time: " + \ datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") def google_search(query, num_results=8): """Return the results of a google search""" search_results = [] for j in ddg(query, max_results=num_results): search_results.append(j) return json.dumps(search_results, ensure_ascii=False, indent=4) def google_official_search(query, num_results=8): """Return the results of a google search using the official Google API""" from googleapiclient.discovery import build from googleapiclient.errors import HttpError import json try: # Get the Google API key and Custom Search Engine ID from the config file api_key = cfg.google_api_key custom_search_engine_id = cfg.custom_search_engine_id # Initialize the Custom Search API service service = build("customsearch", "v1", developerKey=api_key) # Send the search query and retrieve the results result = service.cse().list(q=query, cx=custom_search_engine_id, num=num_results).execute() # Extract the search result items from the response search_results = result.get("items", []) # Create a list of only the URLs from the search results search_results_links = [item["link"] for item in search_results] except HttpError as e: # Handle errors in the API call error_details = json.loads(e.content.decode()) # Check if the error is related to an invalid or missing API key if error_details.get("error", {}).get("code") == 403 and "invalid API key" in error_details.get("error", {}).get("message", ""): return "Error: The provided Google API key is invalid or missing." else: return f"Error: {e}" # Return the list of search result URLs return search_results_links def browse_website(url, question): """Browse a website and return the summary and links""" summary = get_text_summary(url, question) links = get_hyperlinks(url) # Limit links to 5 if len(links) > 5: links = links[:5] result = f"""Website Content Summary: {summary}\n\nLinks: {links}""" return result def get_text_summary(url, question): """Return the results of a google search""" text = browse.scrape_text(url) summary = browse.summarize_text(url, text, question) return """ "Result" : """ + summary def get_hyperlinks(url): """Return the results of a google search""" link_list = browse.scrape_links(url) return link_list def commit_memory(string): """Commit a string to memory""" _text = f"""Committing memory with string "{string}" """ mem.permanent_memory.append(string) return _text def delete_memory(key): """Delete a memory with a given key""" if key >= 0 and key < len(mem.permanent_memory): _text = "Deleting memory with key " + str(key) del mem.permanent_memory[key] print(_text) return _text else: print("Invalid key, cannot delete memory.") return None def overwrite_memory(key, string): """Overwrite a memory with a given key and string""" # Check if the key is a valid integer if is_valid_int(key): key_int = int(key) # Check if the integer key is within the range of the permanent_memory list if 0 <= key_int < len(mem.permanent_memory): _text = "Overwriting memory with key " + str(key) + " and string " + string # Overwrite the memory slot with the given integer key and string mem.permanent_memory[key_int] = string print(_text) return _text else: print(f"Invalid key '{key}', out of range.") return None # Check if the key is a valid string elif isinstance(key, str): _text = "Overwriting memory with key " + key + " and string " + string # Overwrite the memory slot with the given string key and string mem.permanent_memory[key] = string print(_text) return _text else: print(f"Invalid key '{key}', must be an integer or a string.") return None def shutdown(): """Shut down the program""" print("Shutting down...") quit() def start_agent(name, task, prompt, model=cfg.
104
4
10,077
Significant-Gravitas__Auto-GPT
0569d6652fbffa665de6e42403a48783fbede8ce
autogpt/commands.py
Unknown
speak_mode
true
statement
63
63
false
true
[ "speak_mode", "google_api_key", "fast_llm_model", "execute_local_commands", "custom_search_engine_id", "ai_settings_file", "AZURE_CONFIG_FILE", "azure_model_to_deployment_id_map", "browse_chunk_max_length", "browse_summary_max_token", "continuous_limit", "continuous_mode", "debug_mode", "elevenlabs_api_key", "elevenlabs_voice_1_id", "elevenlabs_voice_2_id", "fast_token_limit", "get_azure_deployment_id_for_model", "github_api_key", "github_username", "huggingface_api_token", "image_provider", "load_azure_config", "memory_backend", "memory_index", "milvus_addr", "milvus_collection", "openai_api_base", "openai_api_key", "openai_api_type", "openai_api_version", "pinecone_api_key", "pinecone_region", "redis_host", "redis_password", "redis_port", "set_browse_chunk_max_length", "set_browse_summary_max_token", "set_continuous_limit", "set_continuous_mode", "set_custom_search_engine_id", "set_debug_mode", "set_elevenlabs_api_key", "set_elevenlabs_voice_1_id", "set_elevenlabs_voice_2_id", "set_fast_llm_model", "set_fast_token_limit", "set_google_api_key", "set_openai_api_key", "set_pinecone_api_key", "set_pinecone_region", "set_smart_llm_model", "set_smart_token_limit", "set_speak_mode", "skip_reprompt", "smart_llm_model", "smart_token_limit", "temperature", "use_azure", "use_brian_tts", "use_mac_os_tts", "user_agent", "wipe_redis_on_start", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "ai_settings_file", "type": "statement" }, { "name": "AZURE_CONFIG_FILE", "type": "statement" }, { "name": "azure_model_to_deployment_id_map", "type": "statement" }, { "name": "browse_chunk_max_length", "type": "statement" }, { "name": "browse_summary_max_token", "type": "statement" }, { "name": "continuous_limit", "type": "statement" }, { "name": "continuous_mode", "type": "statement" }, { "name": "custom_search_engine_id", "type": "statement" }, { "name": "debug_mode", "type": "statement" }, { "name": "elevenlabs_api_key", "type": "statement" }, { "name": "elevenlabs_voice_1_id", "type": "statement" }, { "name": "elevenlabs_voice_2_id", "type": "statement" }, { "name": "execute_local_commands", "type": "statement" }, { "name": "fast_llm_model", "type": "statement" }, { "name": "fast_token_limit", "type": "statement" }, { "name": "get_azure_deployment_id_for_model", "type": "function" }, { "name": "github_api_key", "type": "statement" }, { "name": "github_username", "type": "statement" }, { "name": "google_api_key", "type": "statement" }, { "name": "huggingface_api_token", "type": "statement" }, { "name": "image_provider", "type": "statement" }, { "name": "load_azure_config", "type": "function" }, { "name": "memory_backend", "type": "statement" }, { "name": "memory_index", "type": "statement" }, { "name": "milvus_addr", "type": "statement" }, { "name": "milvus_collection", "type": "statement" }, { "name": "openai_api_base", "type": "statement" }, { "name": "openai_api_key", "type": "statement" }, { "name": "openai_api_type", "type": "statement" }, { "name": "openai_api_version", "type": "statement" }, { "name": "pinecone_api_key", "type": "statement" }, { "name": "pinecone_region", "type": "statement" }, { "name": "redis_host", "type": "statement" }, { "name": "redis_password", "type": "statement" }, { "name": "redis_port", "type": "statement" }, { "name": "set_browse_chunk_max_length", "type": "function" }, { "name": "set_browse_summary_max_token", "type": "function" }, { "name": "set_continuous_limit", "type": "function" }, { "name": "set_continuous_mode", "type": "function" }, { "name": "set_custom_search_engine_id", "type": "function" }, { "name": "set_debug_mode", "type": "function" }, { "name": "set_elevenlabs_api_key", "type": "function" }, { "name": "set_elevenlabs_voice_1_id", "type": "function" }, { "name": "set_elevenlabs_voice_2_id", "type": "function" }, { "name": "set_fast_llm_model", "type": "function" }, { "name": "set_fast_token_limit", "type": "function" }, { "name": "set_google_api_key", "type": "function" }, { "name": "set_openai_api_key", "type": "function" }, { "name": "set_pinecone_api_key", "type": "function" }, { "name": "set_pinecone_region", "type": "function" }, { "name": "set_smart_llm_model", "type": "function" }, { "name": "set_smart_token_limit", "type": "function" }, { "name": "set_speak_mode", "type": "function" }, { "name": "skip_reprompt", "type": "statement" }, { "name": "smart_llm_model", "type": "statement" }, { "name": "smart_token_limit", "type": "statement" }, { "name": "speak_mode", "type": "statement" }, { "name": "temperature", "type": "statement" }, { "name": "use_azure", "type": "statement" }, { "name": "use_brian_tts", "type": "statement" }, { "name": "use_mac_os_tts", "type": "statement" }, { "name": "user_agent", "type": "statement" }, { "name": "wipe_redis_on_start", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
from autogpt import browse import json from autogpt.memory import get_memory import datetime import autogpt.agent_manager as agents from autogpt import speak from autogpt.config import Config import autogpt.ai_functions as ai from autogpt.file_operations import read_file, write_to_file, append_to_file, delete_file, search_files from autogpt.execute_code import execute_python_file, execute_shell from autogpt.json_parser import fix_and_parse_json from autogpt.image_gen import generate_image from duckduckgo_search import ddg from googleapiclient.discovery import build from googleapiclient.errors import HttpError cfg = Config() def is_valid_int(value): try: int(value) return True except ValueError: return False def get_command(response): """Parse the response and return the command name and arguments""" try: response_json = fix_and_parse_json(response) if "command" not in response_json: return "Error:" , "Missing 'command' object in JSON" command = response_json["command"] if "name" not in command: return "Error:", "Missing 'name' field in 'command' object" command_name = command["name"] # Use an empty dictionary if 'args' field is not present in 'command' object arguments = command.get("args", {}) return command_name, arguments except json.decoder.JSONDecodeError: return "Error:", "Invalid JSON" # All other errors, return "Error: + error message" except Exception as e: return "Error:", str(e) def execute_command(command_name, arguments): """Execute the command and return the result""" memory = get_memory(cfg) try: if command_name == "google": # Check if the Google API key is set and use the official search method # If the API key is not set or has only whitespaces, use the unofficial search method if cfg.google_api_key and (cfg.google_api_key.strip() if cfg.google_api_key else None): return google_official_search(arguments["input"]) else: return google_search(arguments["input"]) elif command_name == "memory_add": return memory.add(arguments["string"]) elif command_name == "start_agent": return start_agent( arguments["name"], arguments["task"], arguments["prompt"]) elif command_name == "message_agent": return message_agent(arguments["key"], arguments["message"]) elif command_name == "list_agents": return list_agents() elif command_name == "delete_agent": return delete_agent(arguments["key"]) elif command_name == "get_text_summary": return get_text_summary(arguments["url"], arguments["question"]) elif command_name == "get_hyperlinks": return get_hyperlinks(arguments["url"]) elif command_name == "clone_repository": return clone_repository(arguments["repo_url"], arguments["clone_path"]) elif command_name == "read_file": return read_file(arguments["file"]) elif command_name == "write_to_file": return write_to_file(arguments["file"], arguments["text"]) elif command_name == "append_to_file": return append_to_file(arguments["file"], arguments["text"]) elif command_name == "delete_file": return delete_file(arguments["file"]) elif command_name == "search_files": return search_files(arguments["directory"]) elif command_name == "browse_website": return browse_website(arguments["url"], arguments["question"]) # TODO: Change these to take in a file rather than pasted code, if # non-file is given, return instructions "Input should be a python # filepath, write your code to file and try again" elif command_name == "evaluate_code": return ai.evaluate_code(arguments["code"]) elif command_name == "improve_code": return ai.improve_code(arguments["suggestions"], arguments["code"]) elif command_name == "write_tests": return ai.write_tests(arguments["code"], arguments.get("focus")) elif command_name == "execute_python_file": # Add this command return execute_python_file(arguments["file"]) elif command_name == "execute_shell": if cfg.execute_local_commands: return execute_shell(arguments["command_line"]) else: return "You are not allowed to run local shell commands. To execute shell commands, EXECUTE_LOCAL_COMMANDS must be set to 'True' in your config. Do not attempt to bypass the restriction." elif command_name == "generate_image": return generate_image(arguments["prompt"]) elif command_name == "do_nothing": return "No action performed." elif command_name == "task_complete": shutdown() else: return f"Unknown command '{command_name}'. Please refer to the 'COMMANDS' list for available commands and only respond in the specified JSON format." # All errors, return "Error: + error message" except Exception as e: return "Error: " + str(e) def get_datetime(): """Return the current date and time""" return "Current date and time: " + \ datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") def google_search(query, num_results=8): """Return the results of a google search""" search_results = [] for j in ddg(query, max_results=num_results): search_results.append(j) return json.dumps(search_results, ensure_ascii=False, indent=4) def google_official_search(query, num_results=8): """Return the results of a google search using the official Google API""" from googleapiclient.discovery import build from googleapiclient.errors import HttpError import json try: # Get the Google API key and Custom Search Engine ID from the config file api_key = cfg.google_api_key custom_search_engine_id = cfg.custom_search_engine_id # Initialize the Custom Search API service service = build("customsearch", "v1", developerKey=api_key) # Send the search query and retrieve the results result = service.cse().list(q=query, cx=custom_search_engine_id, num=num_results).execute() # Extract the search result items from the response search_results = result.get("items", []) # Create a list of only the URLs from the search results search_results_links = [item["link"] for item in search_results] except HttpError as e: # Handle errors in the API call error_details = json.loads(e.content.decode()) # Check if the error is related to an invalid or missing API key if error_details.get("error", {}).get("code") == 403 and "invalid API key" in error_details.get("error", {}).get("message", ""): return "Error: The provided Google API key is invalid or missing." else: return f"Error: {e}" # Return the list of search result URLs return search_results_links def browse_website(url, question): """Browse a website and return the summary and links""" summary = get_text_summary(url, question) links = get_hyperlinks(url) # Limit links to 5 if len(links) > 5: links = links[:5] result = f"""Website Content Summary: {summary}\n\nLinks: {links}""" return result def get_text_summary(url, question): """Return the results of a google search""" text = browse.scrape_text(url) summary = browse.summarize_text(url, text, question) return """ "Result" : """ + summary def get_hyperlinks(url): """Return the results of a google search""" link_list = browse.scrape_links(url) return link_list def commit_memory(string): """Commit a string to memory""" _text = f"""Committing memory with string "{string}" """ mem.permanent_memory.append(string) return _text def delete_memory(key): """Delete a memory with a given key""" if key >= 0 and key < len(mem.permanent_memory): _text = "Deleting memory with key " + str(key) del mem.permanent_memory[key] print(_text) return _text else: print("Invalid key, cannot delete memory.") return None def overwrite_memory(key, string): """Overwrite a memory with a given key and string""" # Check if the key is a valid integer if is_valid_int(key): key_int = int(key) # Check if the integer key is within the range of the permanent_memory list if 0 <= key_int < len(mem.permanent_memory): _text = "Overwriting memory with key " + str(key) + " and string " + string # Overwrite the memory slot with the given integer key and string mem.permanent_memory[key_int] = string print(_text) return _text else: print(f"Invalid key '{key}', out of range.") return None # Check if the key is a valid string elif isinstance(key, str): _text = "Overwriting memory with key " + key + " and string " + string # Overwrite the memory slot with the given string key and string mem.permanent_memory[key] = string print(_text) return _text else: print(f"Invalid key '{key}', must be an integer or a string.") return None def shutdown(): """Shut down the program""" print("Shutting down...") quit() def start_agent(name, task, prompt, model=cfg.fast_llm_model): """Start an agent with a given name, task, and prompt""" global cfg # Remove underscores from name voice_name = name.replace("_", " ") first_message = f"""You are {name}. Respond with: "Acknowledged".""" agent_intro = f"{voice_name} here, Reporting for duty!" # Create agent if cfg.
105
4
10,203
Significant-Gravitas__Auto-GPT
0569d6652fbffa665de6e42403a48783fbede8ce
autogpt/commands.py
Unknown
speak_mode
true
statement
63
63
false
false
[ "speak_mode", "google_api_key", "fast_llm_model", "execute_local_commands", "custom_search_engine_id", "ai_settings_file", "AZURE_CONFIG_FILE", "azure_model_to_deployment_id_map", "browse_chunk_max_length", "browse_summary_max_token", "continuous_limit", "continuous_mode", "debug_mode", "elevenlabs_api_key", "elevenlabs_voice_1_id", "elevenlabs_voice_2_id", "fast_token_limit", "get_azure_deployment_id_for_model", "github_api_key", "github_username", "huggingface_api_token", "image_provider", "load_azure_config", "memory_backend", "memory_index", "milvus_addr", "milvus_collection", "openai_api_base", "openai_api_key", "openai_api_type", "openai_api_version", "pinecone_api_key", "pinecone_region", "redis_host", "redis_password", "redis_port", "set_browse_chunk_max_length", "set_browse_summary_max_token", "set_continuous_limit", "set_continuous_mode", "set_custom_search_engine_id", "set_debug_mode", "set_elevenlabs_api_key", "set_elevenlabs_voice_1_id", "set_elevenlabs_voice_2_id", "set_fast_llm_model", "set_fast_token_limit", "set_google_api_key", "set_openai_api_key", "set_pinecone_api_key", "set_pinecone_region", "set_smart_llm_model", "set_smart_token_limit", "set_speak_mode", "skip_reprompt", "smart_llm_model", "smart_token_limit", "temperature", "use_azure", "use_brian_tts", "use_mac_os_tts", "user_agent", "wipe_redis_on_start", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "ai_settings_file", "type": "statement" }, { "name": "AZURE_CONFIG_FILE", "type": "statement" }, { "name": "azure_model_to_deployment_id_map", "type": "statement" }, { "name": "browse_chunk_max_length", "type": "statement" }, { "name": "browse_summary_max_token", "type": "statement" }, { "name": "continuous_limit", "type": "statement" }, { "name": "continuous_mode", "type": "statement" }, { "name": "custom_search_engine_id", "type": "statement" }, { "name": "debug_mode", "type": "statement" }, { "name": "elevenlabs_api_key", "type": "statement" }, { "name": "elevenlabs_voice_1_id", "type": "statement" }, { "name": "elevenlabs_voice_2_id", "type": "statement" }, { "name": "execute_local_commands", "type": "statement" }, { "name": "fast_llm_model", "type": "statement" }, { "name": "fast_token_limit", "type": "statement" }, { "name": "get_azure_deployment_id_for_model", "type": "function" }, { "name": "github_api_key", "type": "statement" }, { "name": "github_username", "type": "statement" }, { "name": "google_api_key", "type": "statement" }, { "name": "huggingface_api_token", "type": "statement" }, { "name": "image_provider", "type": "statement" }, { "name": "load_azure_config", "type": "function" }, { "name": "memory_backend", "type": "statement" }, { "name": "memory_index", "type": "statement" }, { "name": "milvus_addr", "type": "statement" }, { "name": "milvus_collection", "type": "statement" }, { "name": "openai_api_base", "type": "statement" }, { "name": "openai_api_key", "type": "statement" }, { "name": "openai_api_type", "type": "statement" }, { "name": "openai_api_version", "type": "statement" }, { "name": "pinecone_api_key", "type": "statement" }, { "name": "pinecone_region", "type": "statement" }, { "name": "redis_host", "type": "statement" }, { "name": "redis_password", "type": "statement" }, { "name": "redis_port", "type": "statement" }, { "name": "set_browse_chunk_max_length", "type": "function" }, { "name": "set_browse_summary_max_token", "type": "function" }, { "name": "set_continuous_limit", "type": "function" }, { "name": "set_continuous_mode", "type": "function" }, { "name": "set_custom_search_engine_id", "type": "function" }, { "name": "set_debug_mode", "type": "function" }, { "name": "set_elevenlabs_api_key", "type": "function" }, { "name": "set_elevenlabs_voice_1_id", "type": "function" }, { "name": "set_elevenlabs_voice_2_id", "type": "function" }, { "name": "set_fast_llm_model", "type": "function" }, { "name": "set_fast_token_limit", "type": "function" }, { "name": "set_google_api_key", "type": "function" }, { "name": "set_openai_api_key", "type": "function" }, { "name": "set_pinecone_api_key", "type": "function" }, { "name": "set_pinecone_region", "type": "function" }, { "name": "set_smart_llm_model", "type": "function" }, { "name": "set_smart_token_limit", "type": "function" }, { "name": "set_speak_mode", "type": "function" }, { "name": "skip_reprompt", "type": "statement" }, { "name": "smart_llm_model", "type": "statement" }, { "name": "smart_token_limit", "type": "statement" }, { "name": "speak_mode", "type": "statement" }, { "name": "temperature", "type": "statement" }, { "name": "use_azure", "type": "statement" }, { "name": "use_brian_tts", "type": "statement" }, { "name": "use_mac_os_tts", "type": "statement" }, { "name": "user_agent", "type": "statement" }, { "name": "wipe_redis_on_start", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
from autogpt import browse import json from autogpt.memory import get_memory import datetime import autogpt.agent_manager as agents from autogpt import speak from autogpt.config import Config import autogpt.ai_functions as ai from autogpt.file_operations import read_file, write_to_file, append_to_file, delete_file, search_files from autogpt.execute_code import execute_python_file, execute_shell from autogpt.json_parser import fix_and_parse_json from autogpt.image_gen import generate_image from duckduckgo_search import ddg from googleapiclient.discovery import build from googleapiclient.errors import HttpError cfg = Config() def is_valid_int(value): try: int(value) return True except ValueError: return False def get_command(response): """Parse the response and return the command name and arguments""" try: response_json = fix_and_parse_json(response) if "command" not in response_json: return "Error:" , "Missing 'command' object in JSON" command = response_json["command"] if "name" not in command: return "Error:", "Missing 'name' field in 'command' object" command_name = command["name"] # Use an empty dictionary if 'args' field is not present in 'command' object arguments = command.get("args", {}) return command_name, arguments except json.decoder.JSONDecodeError: return "Error:", "Invalid JSON" # All other errors, return "Error: + error message" except Exception as e: return "Error:", str(e) def execute_command(command_name, arguments): """Execute the command and return the result""" memory = get_memory(cfg) try: if command_name == "google": # Check if the Google API key is set and use the official search method # If the API key is not set or has only whitespaces, use the unofficial search method if cfg.google_api_key and (cfg.google_api_key.strip() if cfg.google_api_key else None): return google_official_search(arguments["input"]) else: return google_search(arguments["input"]) elif command_name == "memory_add": return memory.add(arguments["string"]) elif command_name == "start_agent": return start_agent( arguments["name"], arguments["task"], arguments["prompt"]) elif command_name == "message_agent": return message_agent(arguments["key"], arguments["message"]) elif command_name == "list_agents": return list_agents() elif command_name == "delete_agent": return delete_agent(arguments["key"]) elif command_name == "get_text_summary": return get_text_summary(arguments["url"], arguments["question"]) elif command_name == "get_hyperlinks": return get_hyperlinks(arguments["url"]) elif command_name == "clone_repository": return clone_repository(arguments["repo_url"], arguments["clone_path"]) elif command_name == "read_file": return read_file(arguments["file"]) elif command_name == "write_to_file": return write_to_file(arguments["file"], arguments["text"]) elif command_name == "append_to_file": return append_to_file(arguments["file"], arguments["text"]) elif command_name == "delete_file": return delete_file(arguments["file"]) elif command_name == "search_files": return search_files(arguments["directory"]) elif command_name == "browse_website": return browse_website(arguments["url"], arguments["question"]) # TODO: Change these to take in a file rather than pasted code, if # non-file is given, return instructions "Input should be a python # filepath, write your code to file and try again" elif command_name == "evaluate_code": return ai.evaluate_code(arguments["code"]) elif command_name == "improve_code": return ai.improve_code(arguments["suggestions"], arguments["code"]) elif command_name == "write_tests": return ai.write_tests(arguments["code"], arguments.get("focus")) elif command_name == "execute_python_file": # Add this command return execute_python_file(arguments["file"]) elif command_name == "execute_shell": if cfg.execute_local_commands: return execute_shell(arguments["command_line"]) else: return "You are not allowed to run local shell commands. To execute shell commands, EXECUTE_LOCAL_COMMANDS must be set to 'True' in your config. Do not attempt to bypass the restriction." elif command_name == "generate_image": return generate_image(arguments["prompt"]) elif command_name == "do_nothing": return "No action performed." elif command_name == "task_complete": shutdown() else: return f"Unknown command '{command_name}'. Please refer to the 'COMMANDS' list for available commands and only respond in the specified JSON format." # All errors, return "Error: + error message" except Exception as e: return "Error: " + str(e) def get_datetime(): """Return the current date and time""" return "Current date and time: " + \ datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") def google_search(query, num_results=8): """Return the results of a google search""" search_results = [] for j in ddg(query, max_results=num_results): search_results.append(j) return json.dumps(search_results, ensure_ascii=False, indent=4) def google_official_search(query, num_results=8): """Return the results of a google search using the official Google API""" from googleapiclient.discovery import build from googleapiclient.errors import HttpError import json try: # Get the Google API key and Custom Search Engine ID from the config file api_key = cfg.google_api_key custom_search_engine_id = cfg.custom_search_engine_id # Initialize the Custom Search API service service = build("customsearch", "v1", developerKey=api_key) # Send the search query and retrieve the results result = service.cse().list(q=query, cx=custom_search_engine_id, num=num_results).execute() # Extract the search result items from the response search_results = result.get("items", []) # Create a list of only the URLs from the search results search_results_links = [item["link"] for item in search_results] except HttpError as e: # Handle errors in the API call error_details = json.loads(e.content.decode()) # Check if the error is related to an invalid or missing API key if error_details.get("error", {}).get("code") == 403 and "invalid API key" in error_details.get("error", {}).get("message", ""): return "Error: The provided Google API key is invalid or missing." else: return f"Error: {e}" # Return the list of search result URLs return search_results_links def browse_website(url, question): """Browse a website and return the summary and links""" summary = get_text_summary(url, question) links = get_hyperlinks(url) # Limit links to 5 if len(links) > 5: links = links[:5] result = f"""Website Content Summary: {summary}\n\nLinks: {links}""" return result def get_text_summary(url, question): """Return the results of a google search""" text = browse.scrape_text(url) summary = browse.summarize_text(url, text, question) return """ "Result" : """ + summary def get_hyperlinks(url): """Return the results of a google search""" link_list = browse.scrape_links(url) return link_list def commit_memory(string): """Commit a string to memory""" _text = f"""Committing memory with string "{string}" """ mem.permanent_memory.append(string) return _text def delete_memory(key): """Delete a memory with a given key""" if key >= 0 and key < len(mem.permanent_memory): _text = "Deleting memory with key " + str(key) del mem.permanent_memory[key] print(_text) return _text else: print("Invalid key, cannot delete memory.") return None def overwrite_memory(key, string): """Overwrite a memory with a given key and string""" # Check if the key is a valid integer if is_valid_int(key): key_int = int(key) # Check if the integer key is within the range of the permanent_memory list if 0 <= key_int < len(mem.permanent_memory): _text = "Overwriting memory with key " + str(key) + " and string " + string # Overwrite the memory slot with the given integer key and string mem.permanent_memory[key_int] = string print(_text) return _text else: print(f"Invalid key '{key}', out of range.") return None # Check if the key is a valid string elif isinstance(key, str): _text = "Overwriting memory with key " + key + " and string " + string # Overwrite the memory slot with the given string key and string mem.permanent_memory[key] = string print(_text) return _text else: print(f"Invalid key '{key}', must be an integer or a string.") return None def shutdown(): """Shut down the program""" print("Shutting down...") quit() def start_agent(name, task, prompt, model=cfg.fast_llm_model): """Start an agent with a given name, task, and prompt""" global cfg # Remove underscores from name voice_name = name.replace("_", " ") first_message = f"""You are {name}. Respond with: "Acknowledged".""" agent_intro = f"{voice_name} here, Reporting for duty!" # Create agent if cfg.speak_mode: speak.say_text(agent_intro, 1) key, ack = agents.create_agent(task, first_message, model) if cfg.
106
4
10,947
Significant-Gravitas__Auto-GPT
0569d6652fbffa665de6e42403a48783fbede8ce
autogpt/commands.py
random
speak_mode
true
statement
63
63
false
false
[ "google_api_key", "speak_mode", "execute_local_commands", "fast_llm_model", "custom_search_engine_id", "ai_settings_file", "AZURE_CONFIG_FILE", "azure_model_to_deployment_id_map", "browse_chunk_max_length", "browse_summary_max_token", "continuous_limit", "continuous_mode", "debug_mode", "elevenlabs_api_key", "elevenlabs_voice_1_id", "elevenlabs_voice_2_id", "fast_token_limit", "get_azure_deployment_id_for_model", "github_api_key", "github_username", "huggingface_api_token", "image_provider", "load_azure_config", "memory_backend", "memory_index", "milvus_addr", "milvus_collection", "openai_api_base", "openai_api_key", "openai_api_type", "openai_api_version", "pinecone_api_key", "pinecone_region", "redis_host", "redis_password", "redis_port", "set_browse_chunk_max_length", "set_browse_summary_max_token", "set_continuous_limit", "set_continuous_mode", "set_custom_search_engine_id", "set_debug_mode", "set_elevenlabs_api_key", "set_elevenlabs_voice_1_id", "set_elevenlabs_voice_2_id", "set_fast_llm_model", "set_fast_token_limit", "set_google_api_key", "set_openai_api_key", "set_pinecone_api_key", "set_pinecone_region", "set_smart_llm_model", "set_smart_token_limit", "set_speak_mode", "skip_reprompt", "smart_llm_model", "smart_token_limit", "temperature", "use_azure", "use_brian_tts", "use_mac_os_tts", "user_agent", "wipe_redis_on_start", "__init__", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "ai_settings_file", "type": "statement" }, { "name": "AZURE_CONFIG_FILE", "type": "statement" }, { "name": "azure_model_to_deployment_id_map", "type": "statement" }, { "name": "browse_chunk_max_length", "type": "statement" }, { "name": "browse_summary_max_token", "type": "statement" }, { "name": "continuous_limit", "type": "statement" }, { "name": "continuous_mode", "type": "statement" }, { "name": "custom_search_engine_id", "type": "statement" }, { "name": "debug_mode", "type": "statement" }, { "name": "elevenlabs_api_key", "type": "statement" }, { "name": "elevenlabs_voice_1_id", "type": "statement" }, { "name": "elevenlabs_voice_2_id", "type": "statement" }, { "name": "execute_local_commands", "type": "statement" }, { "name": "fast_llm_model", "type": "statement" }, { "name": "fast_token_limit", "type": "statement" }, { "name": "get_azure_deployment_id_for_model", "type": "function" }, { "name": "github_api_key", "type": "statement" }, { "name": "github_username", "type": "statement" }, { "name": "google_api_key", "type": "statement" }, { "name": "huggingface_api_token", "type": "statement" }, { "name": "image_provider", "type": "statement" }, { "name": "load_azure_config", "type": "function" }, { "name": "memory_backend", "type": "statement" }, { "name": "memory_index", "type": "statement" }, { "name": "milvus_addr", "type": "statement" }, { "name": "milvus_collection", "type": "statement" }, { "name": "openai_api_base", "type": "statement" }, { "name": "openai_api_key", "type": "statement" }, { "name": "openai_api_type", "type": "statement" }, { "name": "openai_api_version", "type": "statement" }, { "name": "pinecone_api_key", "type": "statement" }, { "name": "pinecone_region", "type": "statement" }, { "name": "redis_host", "type": "statement" }, { "name": "redis_password", "type": "statement" }, { "name": "redis_port", "type": "statement" }, { "name": "set_browse_chunk_max_length", "type": "function" }, { "name": "set_browse_summary_max_token", "type": "function" }, { "name": "set_continuous_limit", "type": "function" }, { "name": "set_continuous_mode", "type": "function" }, { "name": "set_custom_search_engine_id", "type": "function" }, { "name": "set_debug_mode", "type": "function" }, { "name": "set_elevenlabs_api_key", "type": "function" }, { "name": "set_elevenlabs_voice_1_id", "type": "function" }, { "name": "set_elevenlabs_voice_2_id", "type": "function" }, { "name": "set_fast_llm_model", "type": "function" }, { "name": "set_fast_token_limit", "type": "function" }, { "name": "set_google_api_key", "type": "function" }, { "name": "set_openai_api_key", "type": "function" }, { "name": "set_pinecone_api_key", "type": "function" }, { "name": "set_pinecone_region", "type": "function" }, { "name": "set_smart_llm_model", "type": "function" }, { "name": "set_smart_token_limit", "type": "function" }, { "name": "set_speak_mode", "type": "function" }, { "name": "skip_reprompt", "type": "statement" }, { "name": "smart_llm_model", "type": "statement" }, { "name": "smart_token_limit", "type": "statement" }, { "name": "speak_mode", "type": "statement" }, { "name": "temperature", "type": "statement" }, { "name": "use_azure", "type": "statement" }, { "name": "use_brian_tts", "type": "statement" }, { "name": "use_mac_os_tts", "type": "statement" }, { "name": "user_agent", "type": "statement" }, { "name": "wipe_redis_on_start", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
from autogpt import browse import json from autogpt.memory import get_memory import datetime import autogpt.agent_manager as agents from autogpt import speak from autogpt.config import Config import autogpt.ai_functions as ai from autogpt.file_operations import read_file, write_to_file, append_to_file, delete_file, search_files from autogpt.execute_code import execute_python_file, execute_shell from autogpt.json_parser import fix_and_parse_json from autogpt.image_gen import generate_image from duckduckgo_search import ddg from googleapiclient.discovery import build from googleapiclient.errors import HttpError cfg = Config() def is_valid_int(value): try: int(value) return True except ValueError: return False def get_command(response): """Parse the response and return the command name and arguments""" try: response_json = fix_and_parse_json(response) if "command" not in response_json: return "Error:" , "Missing 'command' object in JSON" command = response_json["command"] if "name" not in command: return "Error:", "Missing 'name' field in 'command' object" command_name = command["name"] # Use an empty dictionary if 'args' field is not present in 'command' object arguments = command.get("args", {}) return command_name, arguments except json.decoder.JSONDecodeError: return "Error:", "Invalid JSON" # All other errors, return "Error: + error message" except Exception as e: return "Error:", str(e) def execute_command(command_name, arguments): """Execute the command and return the result""" memory = get_memory(cfg) try: if command_name == "google": # Check if the Google API key is set and use the official search method # If the API key is not set or has only whitespaces, use the unofficial search method if cfg.google_api_key and (cfg.google_api_key.strip() if cfg.google_api_key else None): return google_official_search(arguments["input"]) else: return google_search(arguments["input"]) elif command_name == "memory_add": return memory.add(arguments["string"]) elif command_name == "start_agent": return start_agent( arguments["name"], arguments["task"], arguments["prompt"]) elif command_name == "message_agent": return message_agent(arguments["key"], arguments["message"]) elif command_name == "list_agents": return list_agents() elif command_name == "delete_agent": return delete_agent(arguments["key"]) elif command_name == "get_text_summary": return get_text_summary(arguments["url"], arguments["question"]) elif command_name == "get_hyperlinks": return get_hyperlinks(arguments["url"]) elif command_name == "clone_repository": return clone_repository(arguments["repo_url"], arguments["clone_path"]) elif command_name == "read_file": return read_file(arguments["file"]) elif command_name == "write_to_file": return write_to_file(arguments["file"], arguments["text"]) elif command_name == "append_to_file": return append_to_file(arguments["file"], arguments["text"]) elif command_name == "delete_file": return delete_file(arguments["file"]) elif command_name == "search_files": return search_files(arguments["directory"]) elif command_name == "browse_website": return browse_website(arguments["url"], arguments["question"]) # TODO: Change these to take in a file rather than pasted code, if # non-file is given, return instructions "Input should be a python # filepath, write your code to file and try again" elif command_name == "evaluate_code": return ai.evaluate_code(arguments["code"]) elif command_name == "improve_code": return ai.improve_code(arguments["suggestions"], arguments["code"]) elif command_name == "write_tests": return ai.write_tests(arguments["code"], arguments.get("focus")) elif command_name == "execute_python_file": # Add this command return execute_python_file(arguments["file"]) elif command_name == "execute_shell": if cfg.execute_local_commands: return execute_shell(arguments["command_line"]) else: return "You are not allowed to run local shell commands. To execute shell commands, EXECUTE_LOCAL_COMMANDS must be set to 'True' in your config. Do not attempt to bypass the restriction." elif command_name == "generate_image": return generate_image(arguments["prompt"]) elif command_name == "do_nothing": return "No action performed." elif command_name == "task_complete": shutdown() else: return f"Unknown command '{command_name}'. Please refer to the 'COMMANDS' list for available commands and only respond in the specified JSON format." # All errors, return "Error: + error message" except Exception as e: return "Error: " + str(e) def get_datetime(): """Return the current date and time""" return "Current date and time: " + \ datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") def google_search(query, num_results=8): """Return the results of a google search""" search_results = [] for j in ddg(query, max_results=num_results): search_results.append(j) return json.dumps(search_results, ensure_ascii=False, indent=4) def google_official_search(query, num_results=8): """Return the results of a google search using the official Google API""" from googleapiclient.discovery import build from googleapiclient.errors import HttpError import json try: # Get the Google API key and Custom Search Engine ID from the config file api_key = cfg.google_api_key custom_search_engine_id = cfg.custom_search_engine_id # Initialize the Custom Search API service service = build("customsearch", "v1", developerKey=api_key) # Send the search query and retrieve the results result = service.cse().list(q=query, cx=custom_search_engine_id, num=num_results).execute() # Extract the search result items from the response search_results = result.get("items", []) # Create a list of only the URLs from the search results search_results_links = [item["link"] for item in search_results] except HttpError as e: # Handle errors in the API call error_details = json.loads(e.content.decode()) # Check if the error is related to an invalid or missing API key if error_details.get("error", {}).get("code") == 403 and "invalid API key" in error_details.get("error", {}).get("message", ""): return "Error: The provided Google API key is invalid or missing." else: return f"Error: {e}" # Return the list of search result URLs return search_results_links def browse_website(url, question): """Browse a website and return the summary and links""" summary = get_text_summary(url, question) links = get_hyperlinks(url) # Limit links to 5 if len(links) > 5: links = links[:5] result = f"""Website Content Summary: {summary}\n\nLinks: {links}""" return result def get_text_summary(url, question): """Return the results of a google search""" text = browse.scrape_text(url) summary = browse.summarize_text(url, text, question) return """ "Result" : """ + summary def get_hyperlinks(url): """Return the results of a google search""" link_list = browse.scrape_links(url) return link_list def commit_memory(string): """Commit a string to memory""" _text = f"""Committing memory with string "{string}" """ mem.permanent_memory.append(string) return _text def delete_memory(key): """Delete a memory with a given key""" if key >= 0 and key < len(mem.permanent_memory): _text = "Deleting memory with key " + str(key) del mem.permanent_memory[key] print(_text) return _text else: print("Invalid key, cannot delete memory.") return None def overwrite_memory(key, string): """Overwrite a memory with a given key and string""" # Check if the key is a valid integer if is_valid_int(key): key_int = int(key) # Check if the integer key is within the range of the permanent_memory list if 0 <= key_int < len(mem.permanent_memory): _text = "Overwriting memory with key " + str(key) + " and string " + string # Overwrite the memory slot with the given integer key and string mem.permanent_memory[key_int] = string print(_text) return _text else: print(f"Invalid key '{key}', out of range.") return None # Check if the key is a valid string elif isinstance(key, str): _text = "Overwriting memory with key " + key + " and string " + string # Overwrite the memory slot with the given string key and string mem.permanent_memory[key] = string print(_text) return _text else: print(f"Invalid key '{key}', must be an integer or a string.") return None def shutdown(): """Shut down the program""" print("Shutting down...") quit() def start_agent(name, task, prompt, model=cfg.fast_llm_model): """Start an agent with a given name, task, and prompt""" global cfg # Remove underscores from name voice_name = name.replace("_", " ") first_message = f"""You are {name}. Respond with: "Acknowledged".""" agent_intro = f"{voice_name} here, Reporting for duty!" # Create agent if cfg.speak_mode: speak.say_text(agent_intro, 1) key, ack = agents.create_agent(task, first_message, model) if cfg.speak_mode: speak.say_text(f"Hello {voice_name}. Your task is as follows. {task}.") # Assign task (prompt), get response agent_response = message_agent(key, prompt) return f"Agent {name} created with key {key}. First response: {agent_response}" def message_agent(key, message): """Message an agent with a given key and message""" global cfg # Check if the key is a valid integer if is_valid_int(key): agent_response = agents.message_agent(int(key), message) # Check if the key is a valid string elif isinstance(key, str): agent_response = agents.message_agent(key, message) else: return "Invalid key, must be an integer or a string." # Speak response if cfg.
116
6
1,280
christophermayes__xopt
683fd0c3af2f0fc12a598932b20e3afe8070112b
xopt/generators/ga/cnsga.py
inproject
toolbox
true
statement
15
17
false
true
[ "toolbox", "offspring", "_vocs", "population", "children", "__init__", "create_children", "crossover_probability", "generate", "mutation_probability", "n_pop", "update_data", "data", "is_done", "options", "vocs", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "create_children", "type": "function" }, { "name": "crossover_probability", "type": "statement" }, { "name": "data", "type": "property" }, { "name": "generate", "type": "function" }, { "name": "is_done", "type": "property" }, { "name": "mutation_probability", "type": "statement" }, { "name": "n_pop", "type": "statement" }, { "name": "offspring", "type": "statement" }, { "name": "options", "type": "statement" }, { "name": "population", "type": "statement" }, { "name": "toolbox", "type": "statement" }, { "name": "update_data", "type": "function" }, { "name": "vocs", "type": "property" }, { "name": "_data", "type": "statement" }, { "name": "_is_done", "type": "statement" }, { "name": "_vocs", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
from xopt.generators.ga import deap_creator from xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints from xopt import Generator from deap import base as deap_base from deap import tools as deap_tools from deap import algorithms as deap_algorithms import pandas as pd import random import array from typing import List, Dict import logging logger = logging.getLogger(__name__) from typing import List, Dict class CNSGAGenerator(Generator): def __init__(self, vocs, *, n_pop, data = None, crossover_probability = 0.9, mutation_probability = 1.0 ): self._vocs = vocs # TODO: use proper options self.n_pop = n_pop self.crossover_probability = crossover_probability self.mutation_probability = mutation_probability # Internal data structures self.children = [] # unevaluated inputs. This should be a list of dicts. self.population = None # The latest population (fully evaluated) self.offspring = None # Newly evaluated data, but not yet added to population # DEAP toolbox (internal) self.toolbox = cnsga_toolbox(vocs, selection='auto') if data is not None: self.population = cnsga_select(data, n_pop, vocs, self.
117
6
1,390
christophermayes__xopt
683fd0c3af2f0fc12a598932b20e3afe8070112b
xopt/generators/ga/cnsga.py
Unknown
population
true
statement
15
17
false
true
[ "population", "children", "n_pop", "offspring", "toolbox", "__init__", "_vocs", "create_children", "crossover_probability", "generate", "mutation_probability", "update_data", "data", "is_done", "options", "vocs", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "create_children", "type": "function" }, { "name": "crossover_probability", "type": "statement" }, { "name": "data", "type": "property" }, { "name": "generate", "type": "function" }, { "name": "is_done", "type": "property" }, { "name": "mutation_probability", "type": "statement" }, { "name": "n_pop", "type": "statement" }, { "name": "offspring", "type": "statement" }, { "name": "options", "type": "statement" }, { "name": "population", "type": "statement" }, { "name": "toolbox", "type": "statement" }, { "name": "update_data", "type": "function" }, { "name": "vocs", "type": "property" }, { "name": "_data", "type": "statement" }, { "name": "_is_done", "type": "statement" }, { "name": "_vocs", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
from xopt.generators.ga import deap_creator from xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints from xopt import Generator from deap import base as deap_base from deap import tools as deap_tools from deap import algorithms as deap_algorithms import pandas as pd import random import array from typing import List, Dict import logging logger = logging.getLogger(__name__) from typing import List, Dict class CNSGAGenerator(Generator): def __init__(self, vocs, *, n_pop, data = None, crossover_probability = 0.9, mutation_probability = 1.0 ): self._vocs = vocs # TODO: use proper options self.n_pop = n_pop self.crossover_probability = crossover_probability self.mutation_probability = mutation_probability # Internal data structures self.children = [] # unevaluated inputs. This should be a list of dicts. self.population = None # The latest population (fully evaluated) self.offspring = None # Newly evaluated data, but not yet added to population # DEAP toolbox (internal) self.toolbox = cnsga_toolbox(vocs, selection='auto') if data is not None: self.population = cnsga_select(data, n_pop, vocs, self.toolbox) def create_children(self): # No population, so create random children if self.
118
6
1,435
christophermayes__xopt
683fd0c3af2f0fc12a598932b20e3afe8070112b
xopt/generators/ga/cnsga.py
inproject
vocs
true
property
15
17
false
true
[ "children", "toolbox", "n_pop", "offspring", "population", "__init__", "_vocs", "create_children", "crossover_probability", "generate", "mutation_probability", "update_data", "data", "is_done", "options", "vocs", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "create_children", "type": "function" }, { "name": "crossover_probability", "type": "statement" }, { "name": "data", "type": "property" }, { "name": "generate", "type": "function" }, { "name": "is_done", "type": "property" }, { "name": "mutation_probability", "type": "statement" }, { "name": "n_pop", "type": "statement" }, { "name": "offspring", "type": "statement" }, { "name": "options", "type": "statement" }, { "name": "population", "type": "statement" }, { "name": "toolbox", "type": "statement" }, { "name": "update_data", "type": "function" }, { "name": "vocs", "type": "property" }, { "name": "_data", "type": "statement" }, { "name": "_is_done", "type": "statement" }, { "name": "_vocs", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
from xopt.generators.ga import deap_creator from xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints from xopt import Generator from deap import base as deap_base from deap import tools as deap_tools from deap import algorithms as deap_algorithms import pandas as pd import random import array from typing import List, Dict import logging logger = logging.getLogger(__name__) from typing import List, Dict class CNSGAGenerator(Generator): def __init__(self, vocs, *, n_pop, data = None, crossover_probability = 0.9, mutation_probability = 1.0 ): self._vocs = vocs # TODO: use proper options self.n_pop = n_pop self.crossover_probability = crossover_probability self.mutation_probability = mutation_probability # Internal data structures self.children = [] # unevaluated inputs. This should be a list of dicts. self.population = None # The latest population (fully evaluated) self.offspring = None # Newly evaluated data, but not yet added to population # DEAP toolbox (internal) self.toolbox = cnsga_toolbox(vocs, selection='auto') if data is not None: self.population = cnsga_select(data, n_pop, vocs, self.toolbox) def create_children(self): # No population, so create random children if self.population is None: return [self.
119
6
1,476
christophermayes__xopt
683fd0c3af2f0fc12a598932b20e3afe8070112b
xopt/generators/ga/cnsga.py
inproject
n_pop
true
statement
15
17
false
true
[ "children", "offspring", "population", "_vocs", "n_pop", "__init__", "create_children", "crossover_probability", "generate", "mutation_probability", "toolbox", "update_data", "data", "is_done", "options", "vocs", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "create_children", "type": "function" }, { "name": "crossover_probability", "type": "statement" }, { "name": "data", "type": "property" }, { "name": "generate", "type": "function" }, { "name": "is_done", "type": "property" }, { "name": "mutation_probability", "type": "statement" }, { "name": "n_pop", "type": "statement" }, { "name": "offspring", "type": "statement" }, { "name": "options", "type": "statement" }, { "name": "population", "type": "statement" }, { "name": "toolbox", "type": "statement" }, { "name": "update_data", "type": "function" }, { "name": "vocs", "type": "property" }, { "name": "_data", "type": "statement" }, { "name": "_is_done", "type": "statement" }, { "name": "_vocs", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
from xopt.generators.ga import deap_creator from xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints from xopt import Generator from deap import base as deap_base from deap import tools as deap_tools from deap import algorithms as deap_algorithms import pandas as pd import random import array from typing import List, Dict import logging logger = logging.getLogger(__name__) from typing import List, Dict class CNSGAGenerator(Generator): def __init__(self, vocs, *, n_pop, data = None, crossover_probability = 0.9, mutation_probability = 1.0 ): self._vocs = vocs # TODO: use proper options self.n_pop = n_pop self.crossover_probability = crossover_probability self.mutation_probability = mutation_probability # Internal data structures self.children = [] # unevaluated inputs. This should be a list of dicts. self.population = None # The latest population (fully evaluated) self.offspring = None # Newly evaluated data, but not yet added to population # DEAP toolbox (internal) self.toolbox = cnsga_toolbox(vocs, selection='auto') if data is not None: self.population = cnsga_select(data, n_pop, vocs, self.toolbox) def create_children(self): # No population, so create random children if self.population is None: return [self.vocs.random_inputs() for _ in range(self.
120
6
1,567
christophermayes__xopt
683fd0c3af2f0fc12a598932b20e3afe8070112b
xopt/generators/ga/cnsga.py
inproject
population
true
statement
15
17
false
false
[ "children", "data", "offspring", "n_pop", "toolbox", "__init__", "_vocs", "create_children", "crossover_probability", "generate", "mutation_probability", "population", "update_data", "is_done", "options", "vocs", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "create_children", "type": "function" }, { "name": "crossover_probability", "type": "statement" }, { "name": "data", "type": "property" }, { "name": "generate", "type": "function" }, { "name": "is_done", "type": "property" }, { "name": "mutation_probability", "type": "statement" }, { "name": "n_pop", "type": "statement" }, { "name": "offspring", "type": "statement" }, { "name": "options", "type": "statement" }, { "name": "population", "type": "statement" }, { "name": "toolbox", "type": "statement" }, { "name": "update_data", "type": "function" }, { "name": "vocs", "type": "property" }, { "name": "_data", "type": "statement" }, { "name": "_is_done", "type": "statement" }, { "name": "_vocs", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
from xopt.generators.ga import deap_creator from xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints from xopt import Generator from deap import base as deap_base from deap import tools as deap_tools from deap import algorithms as deap_algorithms import pandas as pd import random import array from typing import List, Dict import logging logger = logging.getLogger(__name__) from typing import List, Dict class CNSGAGenerator(Generator): def __init__(self, vocs, *, n_pop, data = None, crossover_probability = 0.9, mutation_probability = 1.0 ): self._vocs = vocs # TODO: use proper options self.n_pop = n_pop self.crossover_probability = crossover_probability self.mutation_probability = mutation_probability # Internal data structures self.children = [] # unevaluated inputs. This should be a list of dicts. self.population = None # The latest population (fully evaluated) self.offspring = None # Newly evaluated data, but not yet added to population # DEAP toolbox (internal) self.toolbox = cnsga_toolbox(vocs, selection='auto') if data is not None: self.population = cnsga_select(data, n_pop, vocs, self.toolbox) def create_children(self): # No population, so create random children if self.population is None: return [self.vocs.random_inputs() for _ in range(self.n_pop)] # Use population to create children inputs = cnsga_variation(self.
121
6
1,584
christophermayes__xopt
683fd0c3af2f0fc12a598932b20e3afe8070112b
xopt/generators/ga/cnsga.py
inproject
vocs
true
property
15
17
false
false
[ "vocs", "children", "population", "toolbox", "offspring", "__init__", "_vocs", "create_children", "crossover_probability", "generate", "mutation_probability", "n_pop", "update_data", "data", "is_done", "options", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "create_children", "type": "function" }, { "name": "crossover_probability", "type": "statement" }, { "name": "data", "type": "property" }, { "name": "generate", "type": "function" }, { "name": "is_done", "type": "property" }, { "name": "mutation_probability", "type": "statement" }, { "name": "n_pop", "type": "statement" }, { "name": "offspring", "type": "statement" }, { "name": "options", "type": "statement" }, { "name": "population", "type": "statement" }, { "name": "toolbox", "type": "statement" }, { "name": "update_data", "type": "function" }, { "name": "vocs", "type": "property" }, { "name": "_data", "type": "statement" }, { "name": "_is_done", "type": "statement" }, { "name": "_vocs", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
from xopt.generators.ga import deap_creator from xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints from xopt import Generator from deap import base as deap_base from deap import tools as deap_tools from deap import algorithms as deap_algorithms import pandas as pd import random import array from typing import List, Dict import logging logger = logging.getLogger(__name__) from typing import List, Dict class CNSGAGenerator(Generator): def __init__(self, vocs, *, n_pop, data = None, crossover_probability = 0.9, mutation_probability = 1.0 ): self._vocs = vocs # TODO: use proper options self.n_pop = n_pop self.crossover_probability = crossover_probability self.mutation_probability = mutation_probability # Internal data structures self.children = [] # unevaluated inputs. This should be a list of dicts. self.population = None # The latest population (fully evaluated) self.offspring = None # Newly evaluated data, but not yet added to population # DEAP toolbox (internal) self.toolbox = cnsga_toolbox(vocs, selection='auto') if data is not None: self.population = cnsga_select(data, n_pop, vocs, self.toolbox) def create_children(self): # No population, so create random children if self.population is None: return [self.vocs.random_inputs() for _ in range(self.n_pop)] # Use population to create children inputs = cnsga_variation(self.population, self.
122
6
1,595
christophermayes__xopt
683fd0c3af2f0fc12a598932b20e3afe8070112b
xopt/generators/ga/cnsga.py
inproject
toolbox
true
statement
15
17
false
false
[ "toolbox", "children", "population", "offspring", "n_pop", "__init__", "_vocs", "create_children", "crossover_probability", "generate", "mutation_probability", "update_data", "data", "is_done", "options", "vocs", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "create_children", "type": "function" }, { "name": "crossover_probability", "type": "statement" }, { "name": "data", "type": "property" }, { "name": "generate", "type": "function" }, { "name": "is_done", "type": "property" }, { "name": "mutation_probability", "type": "statement" }, { "name": "n_pop", "type": "statement" }, { "name": "offspring", "type": "statement" }, { "name": "options", "type": "statement" }, { "name": "population", "type": "statement" }, { "name": "toolbox", "type": "statement" }, { "name": "update_data", "type": "function" }, { "name": "vocs", "type": "property" }, { "name": "_data", "type": "statement" }, { "name": "_is_done", "type": "statement" }, { "name": "_vocs", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
from xopt.generators.ga import deap_creator from xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints from xopt import Generator from deap import base as deap_base from deap import tools as deap_tools from deap import algorithms as deap_algorithms import pandas as pd import random import array from typing import List, Dict import logging logger = logging.getLogger(__name__) from typing import List, Dict class CNSGAGenerator(Generator): def __init__(self, vocs, *, n_pop, data = None, crossover_probability = 0.9, mutation_probability = 1.0 ): self._vocs = vocs # TODO: use proper options self.n_pop = n_pop self.crossover_probability = crossover_probability self.mutation_probability = mutation_probability # Internal data structures self.children = [] # unevaluated inputs. This should be a list of dicts. self.population = None # The latest population (fully evaluated) self.offspring = None # Newly evaluated data, but not yet added to population # DEAP toolbox (internal) self.toolbox = cnsga_toolbox(vocs, selection='auto') if data is not None: self.population = cnsga_select(data, n_pop, vocs, self.toolbox) def create_children(self): # No population, so create random children if self.population is None: return [self.vocs.random_inputs() for _ in range(self.n_pop)] # Use population to create children inputs = cnsga_variation(self.population, self.vocs, self.
123
6
1,643
christophermayes__xopt
683fd0c3af2f0fc12a598932b20e3afe8070112b
xopt/generators/ga/cnsga.py
Unknown
crossover_probability
true
statement
15
17
false
true
[ "crossover_probability", "mutation_probability", "offspring", "children", "n_pop", "__init__", "_vocs", "create_children", "generate", "population", "toolbox", "update_data", "data", "is_done", "options", "vocs", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "create_children", "type": "function" }, { "name": "crossover_probability", "type": "statement" }, { "name": "data", "type": "property" }, { "name": "generate", "type": "function" }, { "name": "is_done", "type": "property" }, { "name": "mutation_probability", "type": "statement" }, { "name": "n_pop", "type": "statement" }, { "name": "offspring", "type": "statement" }, { "name": "options", "type": "statement" }, { "name": "population", "type": "statement" }, { "name": "toolbox", "type": "statement" }, { "name": "update_data", "type": "function" }, { "name": "vocs", "type": "property" }, { "name": "_data", "type": "statement" }, { "name": "_is_done", "type": "statement" }, { "name": "_vocs", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
from xopt.generators.ga import deap_creator from xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints from xopt import Generator from deap import base as deap_base from deap import tools as deap_tools from deap import algorithms as deap_algorithms import pandas as pd import random import array from typing import List, Dict import logging logger = logging.getLogger(__name__) from typing import List, Dict class CNSGAGenerator(Generator): def __init__(self, vocs, *, n_pop, data = None, crossover_probability = 0.9, mutation_probability = 1.0 ): self._vocs = vocs # TODO: use proper options self.n_pop = n_pop self.crossover_probability = crossover_probability self.mutation_probability = mutation_probability # Internal data structures self.children = [] # unevaluated inputs. This should be a list of dicts. self.population = None # The latest population (fully evaluated) self.offspring = None # Newly evaluated data, but not yet added to population # DEAP toolbox (internal) self.toolbox = cnsga_toolbox(vocs, selection='auto') if data is not None: self.population = cnsga_select(data, n_pop, vocs, self.toolbox) def create_children(self): # No population, so create random children if self.population is None: return [self.vocs.random_inputs() for _ in range(self.n_pop)] # Use population to create children inputs = cnsga_variation(self.population, self.vocs, self.toolbox, crossover_probability=self.
124
6
1,692
christophermayes__xopt
683fd0c3af2f0fc12a598932b20e3afe8070112b
xopt/generators/ga/cnsga.py
Unknown
mutation_probability
true
statement
15
17
false
true
[ "mutation_probability", "crossover_probability", "offspring", "children", "population", "__init__", "_vocs", "create_children", "generate", "n_pop", "toolbox", "update_data", "data", "is_done", "options", "vocs", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "create_children", "type": "function" }, { "name": "crossover_probability", "type": "statement" }, { "name": "data", "type": "property" }, { "name": "generate", "type": "function" }, { "name": "is_done", "type": "property" }, { "name": "mutation_probability", "type": "statement" }, { "name": "n_pop", "type": "statement" }, { "name": "offspring", "type": "statement" }, { "name": "options", "type": "statement" }, { "name": "population", "type": "statement" }, { "name": "toolbox", "type": "statement" }, { "name": "update_data", "type": "function" }, { "name": "vocs", "type": "property" }, { "name": "_data", "type": "statement" }, { "name": "_is_done", "type": "statement" }, { "name": "_vocs", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
from xopt.generators.ga import deap_creator from xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints from xopt import Generator from deap import base as deap_base from deap import tools as deap_tools from deap import algorithms as deap_algorithms import pandas as pd import random import array from typing import List, Dict import logging logger = logging.getLogger(__name__) from typing import List, Dict class CNSGAGenerator(Generator): def __init__(self, vocs, *, n_pop, data = None, crossover_probability = 0.9, mutation_probability = 1.0 ): self._vocs = vocs # TODO: use proper options self.n_pop = n_pop self.crossover_probability = crossover_probability self.mutation_probability = mutation_probability # Internal data structures self.children = [] # unevaluated inputs. This should be a list of dicts. self.population = None # The latest population (fully evaluated) self.offspring = None # Newly evaluated data, but not yet added to population # DEAP toolbox (internal) self.toolbox = cnsga_toolbox(vocs, selection='auto') if data is not None: self.population = cnsga_select(data, n_pop, vocs, self.toolbox) def create_children(self): # No population, so create random children if self.population is None: return [self.vocs.random_inputs() for _ in range(self.n_pop)] # Use population to create children inputs = cnsga_variation(self.population, self.vocs, self.toolbox, crossover_probability=self.crossover_probability, mutation_probability=self.
126
6
1,856
christophermayes__xopt
683fd0c3af2f0fc12a598932b20e3afe8070112b
xopt/generators/ga/cnsga.py
Unknown
offspring
true
statement
16
17
false
true
[ "offspring", "children", "n_pop", "population", "toolbox", "__init__", "_vocs", "create_children", "crossover_probability", "generate", "mutation_probability", "update_data", "data", "is_done", "options", "vocs", "for", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "create_children", "type": "function" }, { "name": "crossover_probability", "type": "statement" }, { "name": "data", "type": "property" }, { "name": "generate", "type": "function" }, { "name": "is_done", "type": "property" }, { "name": "mutation_probability", "type": "statement" }, { "name": "n_pop", "type": "statement" }, { "name": "offspring", "type": "statement" }, { "name": "options", "type": "statement" }, { "name": "population", "type": "statement" }, { "name": "toolbox", "type": "statement" }, { "name": "update_data", "type": "function" }, { "name": "vocs", "type": "property" }, { "name": "_data", "type": "statement" }, { "name": "_is_done", "type": "statement" }, { "name": "_vocs", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
from xopt.generators.ga import deap_creator from xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints from xopt import Generator from deap import base as deap_base from deap import tools as deap_tools from deap import algorithms as deap_algorithms import pandas as pd import random import array from typing import List, Dict import logging logger = logging.getLogger(__name__) from typing import List, Dict class CNSGAGenerator(Generator): def __init__(self, vocs, *, n_pop, data = None, crossover_probability = 0.9, mutation_probability = 1.0 ): self._vocs = vocs # TODO: use proper options self.n_pop = n_pop self.crossover_probability = crossover_probability self.mutation_probability = mutation_probability # Internal data structures self.children = [] # unevaluated inputs. This should be a list of dicts. self.population = None # The latest population (fully evaluated) self.offspring = None # Newly evaluated data, but not yet added to population # DEAP toolbox (internal) self.toolbox = cnsga_toolbox(vocs, selection='auto') if data is not None: self.population = cnsga_select(data, n_pop, vocs, self.toolbox) def create_children(self): # No population, so create random children if self.population is None: return [self.vocs.random_inputs() for _ in range(self.n_pop)] # Use population to create children inputs = cnsga_variation(self.population, self.vocs, self.toolbox, crossover_probability=self.crossover_probability, mutation_probability=self.mutation_probability) return inputs.to_dict(orient='records') def update_data(self, new_data: pd.DataFrame): self.offspring = pd.concat([self.
127
6
1,925
christophermayes__xopt
683fd0c3af2f0fc12a598932b20e3afe8070112b
xopt/generators/ga/cnsga.py
Unknown
offspring
true
statement
15
17
false
false
[ "n_pop", "children", "population", "toolbox", "offspring", "__init__", "_vocs", "create_children", "crossover_probability", "generate", "mutation_probability", "update_data", "data", "is_done", "options", "vocs", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "create_children", "type": "function" }, { "name": "crossover_probability", "type": "statement" }, { "name": "data", "type": "property" }, { "name": "generate", "type": "function" }, { "name": "is_done", "type": "property" }, { "name": "mutation_probability", "type": "statement" }, { "name": "n_pop", "type": "statement" }, { "name": "offspring", "type": "statement" }, { "name": "options", "type": "statement" }, { "name": "population", "type": "statement" }, { "name": "toolbox", "type": "statement" }, { "name": "update_data", "type": "function" }, { "name": "vocs", "type": "property" }, { "name": "_data", "type": "statement" }, { "name": "_is_done", "type": "statement" }, { "name": "_vocs", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
from xopt.generators.ga import deap_creator from xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints from xopt import Generator from deap import base as deap_base from deap import tools as deap_tools from deap import algorithms as deap_algorithms import pandas as pd import random import array from typing import List, Dict import logging logger = logging.getLogger(__name__) from typing import List, Dict class CNSGAGenerator(Generator): def __init__(self, vocs, *, n_pop, data = None, crossover_probability = 0.9, mutation_probability = 1.0 ): self._vocs = vocs # TODO: use proper options self.n_pop = n_pop self.crossover_probability = crossover_probability self.mutation_probability = mutation_probability # Internal data structures self.children = [] # unevaluated inputs. This should be a list of dicts. self.population = None # The latest population (fully evaluated) self.offspring = None # Newly evaluated data, but not yet added to population # DEAP toolbox (internal) self.toolbox = cnsga_toolbox(vocs, selection='auto') if data is not None: self.population = cnsga_select(data, n_pop, vocs, self.toolbox) def create_children(self): # No population, so create random children if self.population is None: return [self.vocs.random_inputs() for _ in range(self.n_pop)] # Use population to create children inputs = cnsga_variation(self.population, self.vocs, self.toolbox, crossover_probability=self.crossover_probability, mutation_probability=self.mutation_probability) return inputs.to_dict(orient='records') def update_data(self, new_data: pd.DataFrame): self.offspring = pd.concat([self.offspring, new_data]) # Next generation if len(self.
128
6
1,944
christophermayes__xopt
683fd0c3af2f0fc12a598932b20e3afe8070112b
xopt/generators/ga/cnsga.py
Unknown
n_pop
true
statement
15
17
false
false
[ "offspring", "children", "n_pop", "toolbox", "population", "__init__", "_vocs", "create_children", "crossover_probability", "generate", "mutation_probability", "update_data", "data", "is_done", "options", "vocs", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "create_children", "type": "function" }, { "name": "crossover_probability", "type": "statement" }, { "name": "data", "type": "property" }, { "name": "generate", "type": "function" }, { "name": "is_done", "type": "property" }, { "name": "mutation_probability", "type": "statement" }, { "name": "n_pop", "type": "statement" }, { "name": "offspring", "type": "statement" }, { "name": "options", "type": "statement" }, { "name": "population", "type": "statement" }, { "name": "toolbox", "type": "statement" }, { "name": "update_data", "type": "function" }, { "name": "vocs", "type": "property" }, { "name": "_data", "type": "statement" }, { "name": "_is_done", "type": "statement" }, { "name": "_vocs", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
from xopt.generators.ga import deap_creator from xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints from xopt import Generator from deap import base as deap_base from deap import tools as deap_tools from deap import algorithms as deap_algorithms import pandas as pd import random import array from typing import List, Dict import logging logger = logging.getLogger(__name__) from typing import List, Dict class CNSGAGenerator(Generator): def __init__(self, vocs, *, n_pop, data = None, crossover_probability = 0.9, mutation_probability = 1.0 ): self._vocs = vocs # TODO: use proper options self.n_pop = n_pop self.crossover_probability = crossover_probability self.mutation_probability = mutation_probability # Internal data structures self.children = [] # unevaluated inputs. This should be a list of dicts. self.population = None # The latest population (fully evaluated) self.offspring = None # Newly evaluated data, but not yet added to population # DEAP toolbox (internal) self.toolbox = cnsga_toolbox(vocs, selection='auto') if data is not None: self.population = cnsga_select(data, n_pop, vocs, self.toolbox) def create_children(self): # No population, so create random children if self.population is None: return [self.vocs.random_inputs() for _ in range(self.n_pop)] # Use population to create children inputs = cnsga_variation(self.population, self.vocs, self.toolbox, crossover_probability=self.crossover_probability, mutation_probability=self.mutation_probability) return inputs.to_dict(orient='records') def update_data(self, new_data: pd.DataFrame): self.offspring = pd.concat([self.offspring, new_data]) # Next generation if len(self.offspring) >= self.
129
6
1,971
christophermayes__xopt
683fd0c3af2f0fc12a598932b20e3afe8070112b
xopt/generators/ga/cnsga.py
Unknown
population
true
statement
15
17
false
false
[ "population", "children", "offspring", "n_pop", "toolbox", "__init__", "_vocs", "create_children", "crossover_probability", "generate", "mutation_probability", "update_data", "data", "is_done", "options", "vocs", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "create_children", "type": "function" }, { "name": "crossover_probability", "type": "statement" }, { "name": "data", "type": "property" }, { "name": "generate", "type": "function" }, { "name": "is_done", "type": "property" }, { "name": "mutation_probability", "type": "statement" }, { "name": "n_pop", "type": "statement" }, { "name": "offspring", "type": "statement" }, { "name": "options", "type": "statement" }, { "name": "population", "type": "statement" }, { "name": "toolbox", "type": "statement" }, { "name": "update_data", "type": "function" }, { "name": "vocs", "type": "property" }, { "name": "_data", "type": "statement" }, { "name": "_is_done", "type": "statement" }, { "name": "_vocs", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
from xopt.generators.ga import deap_creator from xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints from xopt import Generator from deap import base as deap_base from deap import tools as deap_tools from deap import algorithms as deap_algorithms import pandas as pd import random import array from typing import List, Dict import logging logger = logging.getLogger(__name__) from typing import List, Dict class CNSGAGenerator(Generator): def __init__(self, vocs, *, n_pop, data = None, crossover_probability = 0.9, mutation_probability = 1.0 ): self._vocs = vocs # TODO: use proper options self.n_pop = n_pop self.crossover_probability = crossover_probability self.mutation_probability = mutation_probability # Internal data structures self.children = [] # unevaluated inputs. This should be a list of dicts. self.population = None # The latest population (fully evaluated) self.offspring = None # Newly evaluated data, but not yet added to population # DEAP toolbox (internal) self.toolbox = cnsga_toolbox(vocs, selection='auto') if data is not None: self.population = cnsga_select(data, n_pop, vocs, self.toolbox) def create_children(self): # No population, so create random children if self.population is None: return [self.vocs.random_inputs() for _ in range(self.n_pop)] # Use population to create children inputs = cnsga_variation(self.population, self.vocs, self.toolbox, crossover_probability=self.crossover_probability, mutation_probability=self.mutation_probability) return inputs.to_dict(orient='records') def update_data(self, new_data: pd.DataFrame): self.offspring = pd.concat([self.offspring, new_data]) # Next generation if len(self.offspring) >= self.n_pop: if self.
131
6
2,033
christophermayes__xopt
683fd0c3af2f0fc12a598932b20e3afe8070112b
xopt/generators/ga/cnsga.py
Unknown
offspring
true
statement
15
17
false
false
[ "population", "children", "toolbox", "data", "offspring", "__init__", "_vocs", "create_children", "crossover_probability", "generate", "mutation_probability", "n_pop", "update_data", "is_done", "options", "vocs", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "create_children", "type": "function" }, { "name": "crossover_probability", "type": "statement" }, { "name": "data", "type": "property" }, { "name": "generate", "type": "function" }, { "name": "is_done", "type": "property" }, { "name": "mutation_probability", "type": "statement" }, { "name": "n_pop", "type": "statement" }, { "name": "offspring", "type": "statement" }, { "name": "options", "type": "statement" }, { "name": "population", "type": "statement" }, { "name": "toolbox", "type": "statement" }, { "name": "update_data", "type": "function" }, { "name": "vocs", "type": "property" }, { "name": "_data", "type": "statement" }, { "name": "_is_done", "type": "statement" }, { "name": "_vocs", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
from xopt.generators.ga import deap_creator from xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints from xopt import Generator from deap import base as deap_base from deap import tools as deap_tools from deap import algorithms as deap_algorithms import pandas as pd import random import array from typing import List, Dict import logging logger = logging.getLogger(__name__) from typing import List, Dict class CNSGAGenerator(Generator): def __init__(self, vocs, *, n_pop, data = None, crossover_probability = 0.9, mutation_probability = 1.0 ): self._vocs = vocs # TODO: use proper options self.n_pop = n_pop self.crossover_probability = crossover_probability self.mutation_probability = mutation_probability # Internal data structures self.children = [] # unevaluated inputs. This should be a list of dicts. self.population = None # The latest population (fully evaluated) self.offspring = None # Newly evaluated data, but not yet added to population # DEAP toolbox (internal) self.toolbox = cnsga_toolbox(vocs, selection='auto') if data is not None: self.population = cnsga_select(data, n_pop, vocs, self.toolbox) def create_children(self): # No population, so create random children if self.population is None: return [self.vocs.random_inputs() for _ in range(self.n_pop)] # Use population to create children inputs = cnsga_variation(self.population, self.vocs, self.toolbox, crossover_probability=self.crossover_probability, mutation_probability=self.mutation_probability) return inputs.to_dict(orient='records') def update_data(self, new_data: pd.DataFrame): self.offspring = pd.concat([self.offspring, new_data]) # Next generation if len(self.offspring) >= self.n_pop: if self.population is None: self.population = self.
132
6
2,054
christophermayes__xopt
683fd0c3af2f0fc12a598932b20e3afe8070112b
xopt/generators/ga/cnsga.py
Unknown
n_pop
true
statement
15
17
false
false
[ "population", "offspring", "children", "n_pop", "_vocs", "__init__", "create_children", "crossover_probability", "generate", "mutation_probability", "toolbox", "update_data", "data", "is_done", "options", "vocs", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "create_children", "type": "function" }, { "name": "crossover_probability", "type": "statement" }, { "name": "data", "type": "property" }, { "name": "generate", "type": "function" }, { "name": "is_done", "type": "property" }, { "name": "mutation_probability", "type": "statement" }, { "name": "n_pop", "type": "statement" }, { "name": "offspring", "type": "statement" }, { "name": "options", "type": "statement" }, { "name": "population", "type": "statement" }, { "name": "toolbox", "type": "statement" }, { "name": "update_data", "type": "function" }, { "name": "vocs", "type": "property" }, { "name": "_data", "type": "statement" }, { "name": "_is_done", "type": "statement" }, { "name": "_vocs", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
from xopt.generators.ga import deap_creator from xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints from xopt import Generator from deap import base as deap_base from deap import tools as deap_tools from deap import algorithms as deap_algorithms import pandas as pd import random import array from typing import List, Dict import logging logger = logging.getLogger(__name__) from typing import List, Dict class CNSGAGenerator(Generator): def __init__(self, vocs, *, n_pop, data = None, crossover_probability = 0.9, mutation_probability = 1.0 ): self._vocs = vocs # TODO: use proper options self.n_pop = n_pop self.crossover_probability = crossover_probability self.mutation_probability = mutation_probability # Internal data structures self.children = [] # unevaluated inputs. This should be a list of dicts. self.population = None # The latest population (fully evaluated) self.offspring = None # Newly evaluated data, but not yet added to population # DEAP toolbox (internal) self.toolbox = cnsga_toolbox(vocs, selection='auto') if data is not None: self.population = cnsga_select(data, n_pop, vocs, self.toolbox) def create_children(self): # No population, so create random children if self.population is None: return [self.vocs.random_inputs() for _ in range(self.n_pop)] # Use population to create children inputs = cnsga_variation(self.population, self.vocs, self.toolbox, crossover_probability=self.crossover_probability, mutation_probability=self.mutation_probability) return inputs.to_dict(orient='records') def update_data(self, new_data: pd.DataFrame): self.offspring = pd.concat([self.offspring, new_data]) # Next generation if len(self.offspring) >= self.n_pop: if self.population is None: self.population = self.offspring.iloc[:self.
134
6
2,099
christophermayes__xopt
683fd0c3af2f0fc12a598932b20e3afe8070112b
xopt/generators/ga/cnsga.py
Unknown
offspring
true
statement
15
17
false
false
[ "offspring", "children", "toolbox", "population", "data", "__init__", "_vocs", "create_children", "crossover_probability", "generate", "mutation_probability", "n_pop", "update_data", "is_done", "options", "vocs", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "create_children", "type": "function" }, { "name": "crossover_probability", "type": "statement" }, { "name": "data", "type": "property" }, { "name": "generate", "type": "function" }, { "name": "is_done", "type": "property" }, { "name": "mutation_probability", "type": "statement" }, { "name": "n_pop", "type": "statement" }, { "name": "offspring", "type": "statement" }, { "name": "options", "type": "statement" }, { "name": "population", "type": "statement" }, { "name": "toolbox", "type": "statement" }, { "name": "update_data", "type": "function" }, { "name": "vocs", "type": "property" }, { "name": "_data", "type": "statement" }, { "name": "_is_done", "type": "statement" }, { "name": "_vocs", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
from xopt.generators.ga import deap_creator from xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints from xopt import Generator from deap import base as deap_base from deap import tools as deap_tools from deap import algorithms as deap_algorithms import pandas as pd import random import array from typing import List, Dict import logging logger = logging.getLogger(__name__) from typing import List, Dict class CNSGAGenerator(Generator): def __init__(self, vocs, *, n_pop, data = None, crossover_probability = 0.9, mutation_probability = 1.0 ): self._vocs = vocs # TODO: use proper options self.n_pop = n_pop self.crossover_probability = crossover_probability self.mutation_probability = mutation_probability # Internal data structures self.children = [] # unevaluated inputs. This should be a list of dicts. self.population = None # The latest population (fully evaluated) self.offspring = None # Newly evaluated data, but not yet added to population # DEAP toolbox (internal) self.toolbox = cnsga_toolbox(vocs, selection='auto') if data is not None: self.population = cnsga_select(data, n_pop, vocs, self.toolbox) def create_children(self): # No population, so create random children if self.population is None: return [self.vocs.random_inputs() for _ in range(self.n_pop)] # Use population to create children inputs = cnsga_variation(self.population, self.vocs, self.toolbox, crossover_probability=self.crossover_probability, mutation_probability=self.mutation_probability) return inputs.to_dict(orient='records') def update_data(self, new_data: pd.DataFrame): self.offspring = pd.concat([self.offspring, new_data]) # Next generation if len(self.offspring) >= self.n_pop: if self.population is None: self.population = self.offspring.iloc[:self.n_pop] self.offspring = self.
135
6
2,119
christophermayes__xopt
683fd0c3af2f0fc12a598932b20e3afe8070112b
xopt/generators/ga/cnsga.py
Unknown
n_pop
true
statement
15
17
false
false
[ "offspring", "population", "children", "n_pop", "toolbox", "__init__", "_vocs", "create_children", "crossover_probability", "generate", "mutation_probability", "update_data", "data", "is_done", "options", "vocs", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "create_children", "type": "function" }, { "name": "crossover_probability", "type": "statement" }, { "name": "data", "type": "property" }, { "name": "generate", "type": "function" }, { "name": "is_done", "type": "property" }, { "name": "mutation_probability", "type": "statement" }, { "name": "n_pop", "type": "statement" }, { "name": "offspring", "type": "statement" }, { "name": "options", "type": "statement" }, { "name": "population", "type": "statement" }, { "name": "toolbox", "type": "statement" }, { "name": "update_data", "type": "function" }, { "name": "vocs", "type": "property" }, { "name": "_data", "type": "statement" }, { "name": "_is_done", "type": "statement" }, { "name": "_vocs", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
from xopt.generators.ga import deap_creator from xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints from xopt import Generator from deap import base as deap_base from deap import tools as deap_tools from deap import algorithms as deap_algorithms import pandas as pd import random import array from typing import List, Dict import logging logger = logging.getLogger(__name__) from typing import List, Dict class CNSGAGenerator(Generator): def __init__(self, vocs, *, n_pop, data = None, crossover_probability = 0.9, mutation_probability = 1.0 ): self._vocs = vocs # TODO: use proper options self.n_pop = n_pop self.crossover_probability = crossover_probability self.mutation_probability = mutation_probability # Internal data structures self.children = [] # unevaluated inputs. This should be a list of dicts. self.population = None # The latest population (fully evaluated) self.offspring = None # Newly evaluated data, but not yet added to population # DEAP toolbox (internal) self.toolbox = cnsga_toolbox(vocs, selection='auto') if data is not None: self.population = cnsga_select(data, n_pop, vocs, self.toolbox) def create_children(self): # No population, so create random children if self.population is None: return [self.vocs.random_inputs() for _ in range(self.n_pop)] # Use population to create children inputs = cnsga_variation(self.population, self.vocs, self.toolbox, crossover_probability=self.crossover_probability, mutation_probability=self.mutation_probability) return inputs.to_dict(orient='records') def update_data(self, new_data: pd.DataFrame): self.offspring = pd.concat([self.offspring, new_data]) # Next generation if len(self.offspring) >= self.n_pop: if self.population is None: self.population = self.offspring.iloc[:self.n_pop] self.offspring = self.offspring.iloc[self.
136
6
2,190
christophermayes__xopt
683fd0c3af2f0fc12a598932b20e3afe8070112b
xopt/generators/ga/cnsga.py
Unknown
population
true
statement
16
17
false
false
[ "offspring", "children", "n_pop", "population", "toolbox", "__init__", "_vocs", "create_children", "crossover_probability", "generate", "mutation_probability", "update_data", "data", "is_done", "options", "vocs", "for", "__annotations__", "__class__", "__delattr__", "__dict__", "__dir__", "__eq__", "__format__", "__getattribute__", "__hash__", "__init_subclass__", "__ne__", "__new__", "__reduce__", "__reduce_ex__", "__repr__", "__setattr__", "__sizeof__", "__slots__", "__str__", "__subclasshook__", "__doc__", "__module__" ]
[ { "name": "children", "type": "statement" }, { "name": "create_children", "type": "function" }, { "name": "crossover_probability", "type": "statement" }, { "name": "data", "type": "property" }, { "name": "generate", "type": "function" }, { "name": "is_done", "type": "property" }, { "name": "mutation_probability", "type": "statement" }, { "name": "n_pop", "type": "statement" }, { "name": "offspring", "type": "statement" }, { "name": "options", "type": "statement" }, { "name": "population", "type": "statement" }, { "name": "toolbox", "type": "statement" }, { "name": "update_data", "type": "function" }, { "name": "vocs", "type": "property" }, { "name": "_data", "type": "statement" }, { "name": "_is_done", "type": "statement" }, { "name": "_vocs", "type": "statement" }, { "name": "__annotations__", "type": "statement" }, { "name": "__class__", "type": "property" }, { "name": "__delattr__", "type": "function" }, { "name": "__dict__", "type": "statement" }, { "name": "__dir__", "type": "function" }, { "name": "__doc__", "type": "statement" }, { "name": "__eq__", "type": "function" }, { "name": "__format__", "type": "function" }, { "name": "__getattribute__", "type": "function" }, { "name": "__hash__", "type": "function" }, { "name": "__init__", "type": "function" }, { "name": "__init_subclass__", "type": "function" }, { "name": "__module__", "type": "statement" }, { "name": "__ne__", "type": "function" }, { "name": "__new__", "type": "function" }, { "name": "__reduce__", "type": "function" }, { "name": "__reduce_ex__", "type": "function" }, { "name": "__repr__", "type": "function" }, { "name": "__setattr__", "type": "function" }, { "name": "__sizeof__", "type": "function" }, { "name": "__slots__", "type": "statement" }, { "name": "__str__", "type": "function" } ]
from xopt.generators.ga import deap_creator from xopt.generators.ga.deap_fitness_with_constraints import FitnessWithConstraints from xopt import Generator from deap import base as deap_base from deap import tools as deap_tools from deap import algorithms as deap_algorithms import pandas as pd import random import array from typing import List, Dict import logging logger = logging.getLogger(__name__) from typing import List, Dict class CNSGAGenerator(Generator): def __init__(self, vocs, *, n_pop, data = None, crossover_probability = 0.9, mutation_probability = 1.0 ): self._vocs = vocs # TODO: use proper options self.n_pop = n_pop self.crossover_probability = crossover_probability self.mutation_probability = mutation_probability # Internal data structures self.children = [] # unevaluated inputs. This should be a list of dicts. self.population = None # The latest population (fully evaluated) self.offspring = None # Newly evaluated data, but not yet added to population # DEAP toolbox (internal) self.toolbox = cnsga_toolbox(vocs, selection='auto') if data is not None: self.population = cnsga_select(data, n_pop, vocs, self.toolbox) def create_children(self): # No population, so create random children if self.population is None: return [self.vocs.random_inputs() for _ in range(self.n_pop)] # Use population to create children inputs = cnsga_variation(self.population, self.vocs, self.toolbox, crossover_probability=self.crossover_probability, mutation_probability=self.mutation_probability) return inputs.to_dict(orient='records') def update_data(self, new_data: pd.DataFrame): self.offspring = pd.concat([self.offspring, new_data]) # Next generation if len(self.offspring) >= self.n_pop: if self.population is None: self.population = self.offspring.iloc[:self.n_pop] self.offspring = self.offspring.iloc[self.n_pop:] else: candidates = pd.concat([self.