{"body": "<h1>Source code for iCallSV.filterAnnotatedSV</h1><div class=\"highlight\"><pre>\n<span></span><span class=\"sd\">&quot;&quot;&quot;</span>\n<span class=\"sd\">filterAnnotatedSV</span>\n<span class=\"sd\">~~~~~~~~~~~~~~~~~</span>\n\n<span class=\"sd\">:Description: This module will filter calls from the merged file</span>\n<span class=\"sd\">&quot;&quot;&quot;</span>\n\n<span class=\"sd\">&#39;&#39;&#39;</span>\n<span class=\"sd\">Created on Mar 17, 2015</span>\n<span class=\"sd\">Description: This module will filter calls from the merged file</span>\n<span class=\"sd\">@author: Ronak H Shah</span>\n\n<span class=\"sd\">::Inputs::</span>\n<span class=\"sd\">inputTxt: Filter Text File</span>\n<span class=\"sd\">outputDir: Output directory</span>\n<span class=\"sd\">outPrefix: Prefix of the output file</span>\n<span class=\"sd\">blacklistGenesFile: List of genes that should be eliminated</span>\n<span class=\"sd\">verbose: Mode</span>\n<span class=\"sd\">genesToKeepFile: List of genes that should be kept</span>\n\n<span class=\"sd\">::Output::</span>\n<span class=\"sd\">Filtered Output files</span>\n<span class=\"sd\">&#39;&#39;&#39;</span>\n<span class=\"kn\">import</span> <span class=\"nn\">os</span>\n<span class=\"kn\">import</span> <span class=\"nn\">pandas</span> <span class=\"k\">as</span> <span class=\"nn\">pd</span>\n<span class=\"kn\">import</span> <span class=\"nn\">logging</span>\n<span class=\"kn\">import</span> <span class=\"nn\">checkparameters</span> <span class=\"k\">as</span> <span class=\"nn\">cp</span>\n<span class=\"kn\">import</span> <span class=\"nn\">re</span>\n<span class=\"kn\">import</span> <span class=\"nn\">coloredlogs</span>\n\n<span class=\"c1\"># Initiate logger</span>\n<span class=\"n\">logger</span> <span class=\"o\">=</span> <span class=\"n\">logging</span><span class=\"o\">.</span><span class=\"n\">getLogger</span><span class=\"p\">(</span><span class=\"s1\">&#39;iCallSV.FilterDellyCalls&#39;</span><span class=\"p\">)</span>\n<span class=\"n\">coloredlogs</span><span class=\"o\">.</span><span class=\"n\">install</span><span class=\"p\">(</span><span class=\"n\">level</span><span class=\"o\">=</span><span class=\"s1\">&#39;DEBUG&#39;</span><span class=\"p\">)</span>\n\n<div class=\"viewcode-block\" id=\"run\"><a class=\"viewcode-back\" href=\"../../../iCallSV/#iCallSV.filterAnnotatedSV.run\">[docs]</a><span class=\"k\">def</span> <span class=\"nf\">run</span><span class=\"p\">(</span><span class=\"n\">inputTxt</span><span class=\"p\">,</span> <span class=\"n\">outputDir</span><span class=\"p\">,</span> <span class=\"n\">outPrefix</span><span class=\"p\">,</span> <span class=\"n\">blacklistGenesFile</span><span class=\"p\">,</span> <span class=\"n\">verbose</span><span class=\"p\">,</span> <span class=\"n\">genesToKeepFile</span><span class=\"o\">=</span><span class=\"s2\">&quot;somefile.txt&quot;</span><span class=\"p\">):</span>\n    <span class=\"sd\">&quot;&quot;&quot;</span>\n<span class=\"sd\">    This will ``filter sv calls`` from the final merged file.</span>\n\n<span class=\"sd\">    :param str inputTxt: str for the txt file to be filtered</span>\n<span class=\"sd\">    :param str outputDir: str for the output directory</span>\n<span class=\"sd\">    :param str outputPrefix: str prefix for the output File</span>\n<span class=\"sd\">    :param str blacklistGenesFile: str for the txt file containing blacklisted genes</span>\n<span class=\"sd\">    :param bool verbose: a boolean</span>\n<span class=\"sd\">    :param str genesToKeepFile: str for the txt file containing genes to keep</span>\n<span class=\"sd\">    :return: A str name of final sv file</span>\n<span class=\"sd\">    :rtype: str</span>\n\n<span class=\"sd\">    &quot;&quot;&quot;</span>\n    <span class=\"n\">cp</span><span class=\"o\">.</span><span class=\"n\">checkFile</span><span class=\"p\">(</span><span class=\"n\">inputTxt</span><span class=\"p\">)</span>\n    <span class=\"n\">cp</span><span class=\"o\">.</span><span class=\"n\">checkFile</span><span class=\"p\">(</span><span class=\"n\">blacklistGenesFile</span><span class=\"p\">)</span>\n    <span class=\"n\">cp</span><span class=\"o\">.</span><span class=\"n\">checkDir</span><span class=\"p\">(</span><span class=\"n\">outputDir</span><span class=\"p\">)</span>\n    <span class=\"n\">cp</span><span class=\"o\">.</span><span class=\"n\">checkEmpty</span><span class=\"p\">(</span><span class=\"n\">outPrefix</span><span class=\"p\">,</span> <span class=\"s2\">&quot;Prefix for the output file&quot;</span><span class=\"p\">)</span>\n    <span class=\"k\">if</span><span class=\"p\">(</span><span class=\"n\">os</span><span class=\"o\">.</span><span class=\"n\">path</span><span class=\"o\">.</span><span class=\"n\">isfile</span><span class=\"p\">(</span><span class=\"n\">genesToKeepFile</span><span class=\"p\">)):</span>\n        <span class=\"n\">logger</span><span class=\"o\">.</span><span class=\"n\">info</span><span class=\"p\">(</span>\n            <span class=\"s2\">&quot;iCallSV::FilterFinalFile: Genes to Keep File Given </span><span class=\"si\">%s</span><span class=\"s2\"> and will be used.&quot;</span><span class=\"p\">,</span>\n            <span class=\"n\">genesToKeepFile</span><span class=\"p\">)</span>\n        <span class=\"n\">keepGenes</span> <span class=\"o\">=</span> <span class=\"p\">[</span><span class=\"n\">line</span><span class=\"o\">.</span><span class=\"n\">strip</span><span class=\"p\">()</span> <span class=\"k\">for</span> <span class=\"n\">line</span> <span class=\"ow\">in</span> <span class=\"nb\">open</span><span class=\"p\">(</span><span class=\"n\">genesToKeepFile</span><span class=\"p\">,</span> <span class=\"s1\">&#39;r&#39;</span><span class=\"p\">)]</span>\n    <span class=\"k\">else</span><span class=\"p\">:</span>\n        <span class=\"n\">keepGenes</span> <span class=\"o\">=</span> <span class=\"kc\">None</span>\n    <span class=\"n\">inputDF</span> <span class=\"o\">=</span> <span class=\"n\">pd</span><span class=\"o\">.</span><span class=\"n\">read_table</span><span class=\"p\">(</span><span class=\"n\">inputTxt</span><span class=\"p\">,</span> <span class=\"n\">keep_default_na</span><span class=\"o\">=</span><span class=\"s1\">&#39;True&#39;</span><span class=\"p\">)</span>\n    <span class=\"n\">outputDF</span> <span class=\"o\">=</span> <span class=\"n\">inputDF</span><span class=\"o\">.</span><span class=\"n\">copy</span><span class=\"p\">()</span>\n    <span class=\"c1\">#outputDF = pd.DataFrame(columns=inputDF.columns)</span>\n    <span class=\"n\">outputFile</span> <span class=\"o\">=</span> <span class=\"n\">os</span><span class=\"o\">.</span><span class=\"n\">path</span><span class=\"o\">.</span><span class=\"n\">join</span><span class=\"p\">(</span><span class=\"n\">outputDir</span><span class=\"p\">,</span> <span class=\"n\">outPrefix</span> <span class=\"o\">+</span> <span class=\"s2\">&quot;_final.txt&quot;</span><span class=\"p\">)</span>\n    <span class=\"k\">for</span> <span class=\"n\">index</span><span class=\"p\">,</span> <span class=\"n\">row</span> <span class=\"ow\">in</span> <span class=\"n\">inputDF</span><span class=\"o\">.</span><span class=\"n\">iterrows</span><span class=\"p\">():</span>\n        <span class=\"n\">gene1</span> <span class=\"o\">=</span> <span class=\"n\">row</span><span class=\"o\">.</span><span class=\"n\">loc</span><span class=\"p\">[</span><span class=\"s1\">&#39;Gene1&#39;</span><span class=\"p\">]</span>\n        <span class=\"n\">gene2</span> <span class=\"o\">=</span> <span class=\"n\">row</span><span class=\"o\">.</span><span class=\"n\">loc</span><span class=\"p\">[</span><span class=\"s1\">&#39;Gene2&#39;</span><span class=\"p\">]</span>\n        <span class=\"n\">site1</span> <span class=\"o\">=</span> <span class=\"n\">row</span><span class=\"o\">.</span><span class=\"n\">loc</span><span class=\"p\">[</span><span class=\"s1\">&#39;Site1Description&#39;</span><span class=\"p\">]</span>\n        <span class=\"n\">site2</span> <span class=\"o\">=</span> <span class=\"n\">row</span><span class=\"o\">.</span><span class=\"n\">loc</span><span class=\"p\">[</span><span class=\"s1\">&#39;Site2Description&#39;</span><span class=\"p\">]</span>\n        <span class=\"c1\"># skip IGR records</span>\n        <span class=\"k\">if</span><span class=\"p\">(</span><span class=\"s2\">&quot;IGR&quot;</span> <span class=\"ow\">in</span> <span class=\"n\">site1</span> <span class=\"ow\">and</span> <span class=\"s2\">&quot;IGR&quot;</span> <span class=\"ow\">in</span> <span class=\"n\">site2</span><span class=\"p\">):</span>\n            <span class=\"n\">igrFlag</span> <span class=\"o\">=</span> <span class=\"kc\">True</span>\n        <span class=\"k\">else</span><span class=\"p\">:</span>\n            <span class=\"n\">igrFlag</span> <span class=\"o\">=</span> <span class=\"kc\">False</span>\n\n        <span class=\"c1\"># check records from these gene</span>\n        <span class=\"k\">if</span><span class=\"p\">(</span><span class=\"n\">keepGenes</span><span class=\"p\">):</span>\n            <span class=\"n\">keepGeneFlag</span> <span class=\"o\">=</span> <span class=\"n\">checkGeneListToKeep</span><span class=\"p\">(</span><span class=\"n\">gene1</span><span class=\"p\">,</span> <span class=\"n\">gene2</span><span class=\"p\">,</span> <span class=\"n\">keepGenes</span><span class=\"p\">)</span>\n        <span class=\"k\">else</span><span class=\"p\">:</span>\n            <span class=\"n\">keepGeneFlag</span> <span class=\"o\">=</span> <span class=\"kc\">True</span>\n        <span class=\"c1\"># check records from these gene</span>\n        <span class=\"n\">blacklistGenes</span> <span class=\"o\">=</span> <span class=\"p\">[</span><span class=\"n\">line</span><span class=\"o\">.</span><span class=\"n\">strip</span><span class=\"p\">()</span> <span class=\"k\">for</span> <span class=\"n\">line</span> <span class=\"ow\">in</span> <span class=\"nb\">open</span><span class=\"p\">(</span><span class=\"n\">blacklistGenesFile</span><span class=\"p\">,</span> <span class=\"s1\">&#39;r&#39;</span><span class=\"p\">)]</span>\n        <span class=\"n\">blacklistGeneFlag</span> <span class=\"o\">=</span> <span class=\"n\">checkBlackListGene</span><span class=\"p\">(</span><span class=\"n\">gene1</span><span class=\"p\">,</span> <span class=\"n\">gene2</span><span class=\"p\">,</span> <span class=\"n\">blacklistGenes</span><span class=\"p\">)</span>\n        <span class=\"c1\"># skip record occurring within intron</span>\n        <span class=\"n\">eventInIntronFlag</span> <span class=\"o\">=</span> <span class=\"kc\">False</span>\n        <span class=\"k\">if</span><span class=\"p\">((</span><span class=\"n\">gene1</span> <span class=\"o\">==</span> <span class=\"n\">gene2</span><span class=\"p\">)</span> <span class=\"ow\">and</span> <span class=\"p\">((</span><span class=\"n\">igrFlag</span> <span class=\"ow\">is</span> <span class=\"kc\">False</span><span class=\"p\">)</span> <span class=\"ow\">or</span> <span class=\"p\">(</span><span class=\"n\">blacklistGeneFlag</span> <span class=\"ow\">is</span> <span class=\"kc\">False</span><span class=\"p\">))</span> <span class=\"ow\">and</span> <span class=\"p\">(</span><span class=\"s2\">&quot;Intron&quot;</span> <span class=\"ow\">in</span> <span class=\"n\">site1</span> <span class=\"ow\">and</span> <span class=\"s2\">&quot;Intron&quot;</span> <span class=\"ow\">in</span> <span class=\"n\">site2</span><span class=\"p\">)):</span>\n            <span class=\"n\">eventInIntronFlag</span> <span class=\"o\">=</span> <span class=\"n\">checkEventInIntronFlag</span><span class=\"p\">(</span><span class=\"n\">gene1</span><span class=\"p\">,</span> <span class=\"n\">gene2</span><span class=\"p\">,</span> <span class=\"n\">site1</span><span class=\"p\">,</span> <span class=\"n\">site2</span><span class=\"p\">)</span>\n        <span class=\"k\">else</span><span class=\"p\">:</span>\n            <span class=\"k\">pass</span>\n\n        <span class=\"k\">if</span><span class=\"p\">((</span><span class=\"n\">keepGeneFlag</span> <span class=\"ow\">is</span> <span class=\"kc\">False</span><span class=\"p\">)</span> <span class=\"ow\">or</span> <span class=\"p\">(</span><span class=\"n\">igrFlag</span><span class=\"p\">)</span> <span class=\"ow\">or</span> <span class=\"p\">(</span><span class=\"n\">blacklistGeneFlag</span><span class=\"p\">)</span> <span class=\"ow\">or</span> <span class=\"p\">(</span><span class=\"n\">eventInIntronFlag</span><span class=\"p\">)):</span>\n            <span class=\"k\">if</span><span class=\"p\">(</span><span class=\"n\">verbose</span><span class=\"p\">):</span>\n                <span class=\"n\">logger</span><span class=\"o\">.</span><span class=\"n\">warn</span><span class=\"p\">(</span>\n                    <span class=\"s2\">&quot;iCallSV::FilterFinalFile: Record: gene1:</span><span class=\"si\">%s</span><span class=\"s2\">; gene2:</span><span class=\"si\">%s</span><span class=\"s2\">; site1:</span><span class=\"si\">%s</span><span class=\"s2\">; site2:</span><span class=\"si\">%s</span><span class=\"s2\">; will be Filtered as keepGeneFlag:</span><span class=\"si\">%s</span><span class=\"s2\">; IGR:</span><span class=\"si\">%s</span><span class=\"s2\">; blackListGene:</span><span class=\"si\">%s</span><span class=\"s2\">; Intronic Event:</span><span class=\"si\">%s</span><span class=\"s2\">&quot;</span><span class=\"p\">,</span>\n                    <span class=\"n\">gene1</span><span class=\"p\">,</span>\n                    <span class=\"n\">gene2</span><span class=\"p\">,</span>\n                    <span class=\"n\">site1</span><span class=\"p\">,</span>\n                    <span class=\"n\">site2</span><span class=\"p\">,</span>\n                    <span class=\"nb\">str</span><span class=\"p\">(</span><span class=\"n\">keepGeneFlag</span><span class=\"p\">),</span>\n                    <span class=\"nb\">str</span><span class=\"p\">(</span><span class=\"n\">igrFlag</span><span class=\"p\">),</span>\n                    <span class=\"nb\">str</span><span class=\"p\">(</span><span class=\"n\">blacklistGeneFlag</span><span class=\"p\">),</span>\n                    <span class=\"nb\">str</span><span class=\"p\">(</span><span class=\"n\">eventInIntronFlag</span><span class=\"p\">))</span>\n            <span class=\"n\">outputDF</span> <span class=\"o\">=</span> <span class=\"n\">outputDF</span><span class=\"o\">.</span><span class=\"n\">drop</span><span class=\"p\">(</span><span class=\"n\">index</span><span class=\"p\">)</span>\n        <span class=\"k\">else</span><span class=\"p\">:</span>\n            <span class=\"k\">pass</span>\n    <span class=\"n\">outputDF</span><span class=\"p\">[[</span><span class=\"s1\">&#39;SV_LENGTH&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;Cosmic_Fusion_Counts&#39;</span><span class=\"p\">]]</span> <span class=\"o\">=</span> <span class=\"n\">outputDF</span><span class=\"p\">[[</span><span class=\"s1\">&#39;SV_LENGTH&#39;</span><span class=\"p\">,</span> <span class=\"s1\">&#39;Cosmic_Fusion_Counts&#39;</span><span class=\"p\">]]</span><span class=\"o\">.</span><span class=\"n\">astype</span><span class=\"p\">(</span><span class=\"nb\">int</span><span class=\"p\">)</span>\n    <span class=\"c1\"># Write The Final Output File</span>\n    <span class=\"n\">outputDF</span><span class=\"o\">.</span><span class=\"n\">to_csv</span><span class=\"p\">(</span><span class=\"n\">outputFile</span><span class=\"p\">,</span> <span class=\"n\">sep</span><span class=\"o\">=</span><span class=\"s1\">&#39;</span><span class=\"se\">\\t</span><span class=\"s1\">&#39;</span><span class=\"p\">,</span> <span class=\"n\">index</span><span class=\"o\">=</span><span class=\"kc\">False</span><span class=\"p\">)</span>\n    <span class=\"k\">if</span><span class=\"p\">(</span><span class=\"n\">verbose</span><span class=\"p\">):</span>\n        <span class=\"n\">logger</span><span class=\"o\">.</span><span class=\"n\">info</span><span class=\"p\">(</span>\n            <span class=\"s2\">&quot;iCallSV::FilterFinalFile: Finished Filtering, Final data written in </span><span class=\"si\">%s</span><span class=\"s2\">&quot;</span><span class=\"p\">,</span>\n            <span class=\"n\">outputFile</span><span class=\"p\">)</span>\n\n    <span class=\"k\">return</span><span class=\"p\">(</span><span class=\"n\">outputFile</span><span class=\"p\">)</span></div>\n\n<span class=\"c1\"># Check if the gene is a Keep gene</span>\n\n\n<div class=\"viewcode-block\" id=\"checkGeneListToKeep\"><a class=\"viewcode-back\" href=\"../../../iCallSV/#iCallSV.filterAnnotatedSV.checkGeneListToKeep\">[docs]</a><span class=\"k\">def</span> <span class=\"nf\">checkGeneListToKeep</span><span class=\"p\">(</span><span class=\"n\">gene1</span><span class=\"p\">,</span> <span class=\"n\">gene2</span><span class=\"p\">,</span> <span class=\"n\">keepGenes</span><span class=\"p\">):</span>\n    <span class=\"k\">if</span><span class=\"p\">((</span><span class=\"n\">gene1</span> <span class=\"ow\">in</span> <span class=\"n\">keepGenes</span><span class=\"p\">)</span> <span class=\"ow\">or</span> <span class=\"p\">(</span><span class=\"n\">gene2</span> <span class=\"ow\">in</span> <span class=\"n\">keepGenes</span><span class=\"p\">)):</span>\n        <span class=\"n\">kgFlag</span> <span class=\"o\">=</span> <span class=\"kc\">True</span>\n    <span class=\"k\">else</span><span class=\"p\">:</span>\n        <span class=\"n\">kgFlag</span> <span class=\"o\">=</span> <span class=\"kc\">False</span>\n    <span class=\"k\">return</span><span class=\"p\">(</span><span class=\"n\">kgFlag</span><span class=\"p\">)</span></div>\n\n<span class=\"c1\"># Check if the gene is a blacklist gene</span>\n\n\n<div class=\"viewcode-block\" id=\"checkBlackListGene\"><a class=\"viewcode-back\" href=\"../../../iCallSV/#iCallSV.filterAnnotatedSV.checkBlackListGene\">[docs]</a><span class=\"k\">def</span> <span class=\"nf\">checkBlackListGene</span><span class=\"p\">(</span><span class=\"n\">gene1</span><span class=\"p\">,</span> <span class=\"n\">gene2</span><span class=\"p\">,</span> <span class=\"n\">blacklistGenes</span><span class=\"p\">):</span>\n    <span class=\"sd\">&quot;&quot;&quot;</span>\n<span class=\"sd\">    This will ``check for blacklisted genes``</span>\n\n<span class=\"sd\">    :param str gene1: str for the name of gene at breakpoint 1</span>\n<span class=\"sd\">    :param str gene2: str for the name of gene at breakpoint 2</span>\n<span class=\"sd\">    :param list blacklistGenes:  list containing blacklisted genes</span>\n<span class=\"sd\">    :param str genesToKeepFile: str for the txt file containing genes to keep</span>\n<span class=\"sd\">    :return: A boolean tag indicating True or False</span>\n<span class=\"sd\">    :rtype: bool</span>\n\n<span class=\"sd\">    &quot;&quot;&quot;</span>\n    <span class=\"k\">if</span><span class=\"p\">((</span><span class=\"n\">gene1</span> <span class=\"ow\">in</span> <span class=\"n\">blacklistGenes</span><span class=\"p\">)</span> <span class=\"ow\">or</span> <span class=\"p\">(</span><span class=\"n\">gene2</span> <span class=\"ow\">in</span> <span class=\"n\">blacklistGenes</span><span class=\"p\">)):</span>\n        <span class=\"n\">bgFlag</span> <span class=\"o\">=</span> <span class=\"kc\">True</span>\n    <span class=\"k\">else</span><span class=\"p\">:</span>\n        <span class=\"n\">bgFlag</span> <span class=\"o\">=</span> <span class=\"kc\">False</span>\n    <span class=\"k\">return</span><span class=\"p\">(</span><span class=\"n\">bgFlag</span><span class=\"p\">)</span></div>\n\n\n<span class=\"c1\"># Check if the event is in the intron only and not affecting splicing</span>\n<div class=\"viewcode-block\" id=\"checkEventInIntronFlag\"><a class=\"viewcode-back\" href=\"../../../iCallSV/#iCallSV.filterAnnotatedSV.checkEventInIntronFlag\">[docs]</a><span class=\"k\">def</span> <span class=\"nf\">checkEventInIntronFlag</span><span class=\"p\">(</span><span class=\"n\">gene1</span><span class=\"p\">,</span> <span class=\"n\">gene2</span><span class=\"p\">,</span> <span class=\"n\">site1</span><span class=\"p\">,</span> <span class=\"n\">site2</span><span class=\"p\">):</span>\n    <span class=\"sd\">&quot;&quot;&quot;</span>\n<span class=\"sd\">    This will ``Check if the event is in the intron only and not affecting</span>\n<span class=\"sd\">    splicing``</span>\n\n<span class=\"sd\">    :param str gene1: str for the name of gene at breakpoint 1</span>\n<span class=\"sd\">    :param str gene2: str for the name of gene at breakpoint 2</span>\n<span class=\"sd\">    :param str site1: str for the description of site in breakpoint 1</span>\n<span class=\"sd\">    :param str site2: str for the description of site in breakpoint 2</span>\n<span class=\"sd\">    :return: A boolean tag indicating True or False</span>\n<span class=\"sd\">    :rtype: bool</span>\n\n<span class=\"sd\">    &quot;&quot;&quot;</span>\n    <span class=\"k\">if</span><span class=\"p\">(</span><span class=\"n\">gene1</span> <span class=\"o\">==</span> <span class=\"n\">gene2</span><span class=\"p\">):</span>\n        <span class=\"p\">(</span><span class=\"n\">s1A</span><span class=\"p\">,</span> <span class=\"n\">s1B</span><span class=\"p\">)</span> <span class=\"o\">=</span> <span class=\"n\">site1</span><span class=\"o\">.</span><span class=\"n\">split</span><span class=\"p\">(</span><span class=\"s2\">&quot;:&quot;</span><span class=\"p\">)</span>\n        <span class=\"p\">(</span><span class=\"n\">s2A</span><span class=\"p\">,</span> <span class=\"n\">s2B</span><span class=\"p\">)</span> <span class=\"o\">=</span> <span class=\"n\">site2</span><span class=\"o\">.</span><span class=\"n\">split</span><span class=\"p\">(</span><span class=\"s2\">&quot;:&quot;</span><span class=\"p\">)</span>\n        <span class=\"p\">(</span><span class=\"n\">s1a</span><span class=\"p\">,</span> <span class=\"n\">s1b</span><span class=\"p\">,</span> <span class=\"n\">s1c</span><span class=\"p\">,</span> <span class=\"n\">s1d</span><span class=\"p\">)</span> <span class=\"o\">=</span> <span class=\"n\">s1B</span><span class=\"o\">.</span><span class=\"n\">split</span><span class=\"p\">(</span><span class=\"s2\">&quot; &quot;</span><span class=\"p\">)</span>\n        <span class=\"p\">(</span><span class=\"n\">s2a</span><span class=\"p\">,</span> <span class=\"n\">s2b</span><span class=\"p\">,</span> <span class=\"n\">s2c</span><span class=\"p\">,</span> <span class=\"n\">s2d</span><span class=\"p\">)</span> <span class=\"o\">=</span> <span class=\"n\">s2B</span><span class=\"o\">.</span><span class=\"n\">split</span><span class=\"p\">(</span><span class=\"s2\">&quot; &quot;</span><span class=\"p\">)</span>\n        <span class=\"k\">if</span><span class=\"p\">((</span><span class=\"s2\">&quot;before&quot;</span> <span class=\"ow\">in</span> <span class=\"n\">site1</span> <span class=\"ow\">and</span> <span class=\"s2\">&quot;before&quot;</span> <span class=\"ow\">in</span> <span class=\"n\">site2</span><span class=\"p\">)</span> <span class=\"ow\">or</span> <span class=\"p\">(</span><span class=\"s2\">&quot;after&quot;</span> <span class=\"ow\">in</span> <span class=\"n\">site1</span> <span class=\"ow\">and</span> <span class=\"s2\">&quot;after&quot;</span> <span class=\"ow\">in</span> <span class=\"n\">site2</span><span class=\"p\">)):</span>\n            <span class=\"k\">if</span><span class=\"p\">(</span><span class=\"nb\">int</span><span class=\"p\">(</span><span class=\"n\">s1d</span><span class=\"p\">)</span> <span class=\"o\">==</span> <span class=\"nb\">int</span><span class=\"p\">(</span><span class=\"n\">s2d</span><span class=\"p\">)):</span>\n                <span class=\"k\">if</span><span class=\"p\">(</span><span class=\"s2\">&quot;bp&quot;</span> <span class=\"ow\">in</span> <span class=\"n\">s1a</span><span class=\"p\">):</span>\n                    <span class=\"n\">s1location</span> <span class=\"o\">=</span> <span class=\"n\">re</span><span class=\"o\">.</span><span class=\"n\">findall</span><span class=\"p\">(</span><span class=\"s1\">r&#39;\\d+&#39;</span><span class=\"p\">,</span> <span class=\"n\">s1a</span><span class=\"p\">)[</span><span class=\"mi\">0</span><span class=\"p\">]</span>\n                    <span class=\"n\">s2location</span> <span class=\"o\">=</span> <span class=\"n\">re</span><span class=\"o\">.</span><span class=\"n\">findall</span><span class=\"p\">(</span><span class=\"s1\">r&#39;\\d+&#39;</span><span class=\"p\">,</span> <span class=\"n\">s2a</span><span class=\"p\">)[</span><span class=\"mi\">0</span><span class=\"p\">]</span>\n                    <span class=\"k\">if</span><span class=\"p\">(</span><span class=\"nb\">int</span><span class=\"p\">(</span><span class=\"n\">s1location</span><span class=\"p\">)</span> <span class=\"o\">&lt;</span> <span class=\"mi\">5</span> <span class=\"ow\">or</span> <span class=\"nb\">int</span><span class=\"p\">(</span><span class=\"n\">s2location</span><span class=\"p\">)</span> <span class=\"o\">&lt;</span> <span class=\"mi\">5</span><span class=\"p\">):</span>\n                        <span class=\"n\">eviFlag</span> <span class=\"o\">=</span> <span class=\"kc\">False</span>\n                    <span class=\"k\">else</span><span class=\"p\">:</span>\n                        <span class=\"n\">eviFlag</span> <span class=\"o\">=</span> <span class=\"kc\">True</span>\n                <span class=\"k\">else</span><span class=\"p\">:</span>\n                    <span class=\"n\">eviFlag</span> <span class=\"o\">=</span> <span class=\"kc\">True</span>\n            <span class=\"k\">else</span><span class=\"p\">:</span>\n                <span class=\"n\">eviFlag</span> <span class=\"o\">=</span> <span class=\"kc\">True</span>\n        <span class=\"k\">else</span><span class=\"p\">:</span>\n            <span class=\"n\">eviFlag</span> <span class=\"o\">=</span> <span class=\"kc\">True</span>\n    <span class=\"k\">else</span><span class=\"p\">:</span>\n        <span class=\"n\">eviFlag</span> <span class=\"o\">=</span> <span class=\"kc\">True</span>\n    <span class=\"k\">return</span><span class=\"p\">(</span><span class=\"n\">eviFlag</span><span class=\"p\">)</span></div>\n</pre></div>", "title": "iCallSV.filterAnnotatedSV", "customsidebar": null, "current_page_name": "_modules/iCallSV/filterAnnotatedSV", "sidebars": null, "parents": [{"link": "../../", "title": "Module code"}], "alabaster_version": "0.7.9"}