{"body": "<h1>Source code for iCallSV.make_analysis_dir</h1><div class=\"highlight\"><pre>\n<span></span><span class=\"sd\">&quot;&quot;&quot;</span>\n<span class=\"sd\">make_analysis_dir</span>\n<span class=\"sd\">~~~~~~~~~~~~~~~~~</span>\n\n<span class=\"sd\">:Description: This module will make directory structure for running analysis</span>\n\n<span class=\"sd\">&quot;&quot;&quot;</span>\n<span class=\"sd\">&#39;&#39;&#39;</span>\n<span class=\"sd\">Created on November 19, 2015</span>\n<span class=\"sd\">Description: This module will make directory structure for running analysis</span>\n<span class=\"sd\">@author: Ronak H Shah</span>\n<span class=\"sd\">::Inputs::</span>\n<span class=\"sd\">args: Arguments passed to iCallSV</span>\n<span class=\"sd\">&#39;&#39;&#39;</span>\n\n<span class=\"kn\">import</span> <span class=\"nn\">os</span>\n<span class=\"kn\">import</span> <span class=\"nn\">re</span>\n<span class=\"kn\">import</span> <span class=\"nn\">logging</span>\n\n\n<div class=\"viewcode-block\" id=\"makeOutputDir\"><a class=\"viewcode-back\" href=\"../../../iCallSV/#iCallSV.make_analysis_dir.makeOutputDir\">[docs]</a><span class=\"k\">def</span> <span class=\"nf\">makeOutputDir</span><span class=\"p\">(</span><span class=\"n\">args</span><span class=\"p\">,</span> <span class=\"n\">tool</span><span class=\"p\">):</span>\n    <span class=\"sd\">&quot;&quot;&quot;</span>\n<span class=\"sd\">    This will make the output directory tree.</span>\n\n<span class=\"sd\">    :param Namespace args: Namespace of args to get other variables</span>\n<span class=\"sd\">    :return: Multiple objects</span>\n<span class=\"sd\">    :rtype: list</span>\n\n<span class=\"sd\">    &quot;&quot;&quot;</span>\n    <span class=\"c1\"># Get logging settings</span>\n    <span class=\"n\">SampleDirName</span> <span class=\"o\">=</span> <span class=\"n\">args</span><span class=\"o\">.</span><span class=\"n\">caseId</span>\n    <span class=\"n\">static_SV_Dir</span> <span class=\"o\">=</span> <span class=\"s2\">&quot;StructuralVariantAnalysis&quot;</span>\n    <span class=\"n\">static_tool_Dir</span> <span class=\"o\">=</span> <span class=\"n\">tool</span>\n    <span class=\"n\">AnalysisDir</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\">args</span><span class=\"o\">.</span><span class=\"n\">outdir</span><span class=\"p\">,</span> <span class=\"n\">static_SV_Dir</span><span class=\"p\">)</span>\n    <span class=\"n\">ToolDir</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\">AnalysisDir</span><span class=\"p\">,</span> <span class=\"n\">static_tool_Dir</span><span class=\"p\">)</span>\n    <span class=\"n\">SampleAnalysisDir</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\">ToolDir</span><span class=\"p\">,</span> <span class=\"n\">SampleDirName</span><span class=\"p\">)</span>\n    <span class=\"k\">if</span> <span class=\"ow\">not</span> <span class=\"n\">os</span><span class=\"o\">.</span><span class=\"n\">path</span><span class=\"o\">.</span><span class=\"n\">exists</span> <span class=\"p\">(</span><span class=\"n\">AnalysisDir</span><span class=\"p\">):</span>\n        <span class=\"k\">try</span><span class=\"p\">:</span>\n            <span class=\"n\">os</span><span class=\"o\">.</span><span class=\"n\">mkdir</span><span class=\"p\">(</span><span class=\"n\">AnalysisDir</span><span class=\"p\">)</span>\n        <span class=\"k\">except</span> <span class=\"ne\">OSError</span><span class=\"p\">:</span>\n            <span class=\"k\">if</span><span class=\"p\">(</span><span class=\"n\">args</span><span class=\"o\">.</span><span class=\"n\">verbose</span><span class=\"p\">):</span>\n                <span class=\"n\">logging</span><span class=\"o\">.</span><span class=\"n\">warn</span><span class=\"p\">(</span><span class=\"s2\">&quot;make_output_dir:Dir=&gt;</span><span class=\"si\">%s</span><span class=\"s2\"> exists thus we wont be making it&quot;</span><span class=\"p\">,</span> <span class=\"n\">AnalysisDir</span><span class=\"p\">)</span>\n            <span class=\"k\">pass</span>\n    <span class=\"k\">else</span><span class=\"p\">:</span>\n        <span class=\"k\">if</span><span class=\"p\">(</span><span class=\"n\">args</span><span class=\"o\">.</span><span class=\"n\">verbose</span><span class=\"p\">):</span>\n            <span class=\"n\">logging</span><span class=\"o\">.</span><span class=\"n\">warn</span><span class=\"p\">(</span><span class=\"s2\">&quot;make_output_dir:Dir=&gt;</span><span class=\"si\">%s</span><span class=\"s2\"> exists thus we wont be making it&quot;</span><span class=\"p\">,</span> <span class=\"n\">AnalysisDir</span><span class=\"p\">)</span>\n        <span class=\"k\">pass</span>\n    \n    <span class=\"k\">if</span> <span class=\"ow\">not</span> <span class=\"n\">os</span><span class=\"o\">.</span><span class=\"n\">path</span><span class=\"o\">.</span><span class=\"n\">exists</span> <span class=\"p\">(</span><span class=\"n\">AnalysisDir</span><span class=\"p\">):</span>\n        <span class=\"k\">try</span><span class=\"p\">:</span>\n            <span class=\"n\">os</span><span class=\"o\">.</span><span class=\"n\">mkdir</span><span class=\"p\">(</span><span class=\"n\">ToolDir</span><span class=\"p\">)</span>\n        <span class=\"k\">except</span> <span class=\"ne\">OSError</span><span class=\"p\">:</span>\n            <span class=\"k\">if</span><span class=\"p\">(</span><span class=\"n\">args</span><span class=\"o\">.</span><span class=\"n\">verbose</span><span class=\"p\">):</span>\n                <span class=\"n\">logging</span><span class=\"o\">.</span><span class=\"n\">warn</span><span class=\"p\">(</span><span class=\"s2\">&quot;make_output_dir:Dir=&gt;</span><span class=\"si\">%s</span><span class=\"s2\"> exists thus we wont be making it&quot;</span><span class=\"p\">,</span> <span class=\"n\">ToolDir</span><span class=\"p\">)</span>\n            <span class=\"k\">pass</span>\n    <span class=\"k\">else</span><span class=\"p\">:</span>\n        <span class=\"k\">if</span><span class=\"p\">(</span><span class=\"n\">args</span><span class=\"o\">.</span><span class=\"n\">verbose</span><span class=\"p\">):</span>\n            <span class=\"n\">logging</span><span class=\"o\">.</span><span class=\"n\">warn</span><span class=\"p\">(</span><span class=\"s2\">&quot;make_output_dir:Dir=&gt;</span><span class=\"si\">%s</span><span class=\"s2\"> exists thus we wont be making it&quot;</span><span class=\"p\">,</span> <span class=\"n\">ToolDir</span><span class=\"p\">)</span>\n        <span class=\"k\">pass</span>\n\n    <span class=\"k\">if</span> <span class=\"n\">os</span><span class=\"o\">.</span><span class=\"n\">path</span><span class=\"o\">.</span><span class=\"n\">isdir</span><span class=\"p\">(</span><span class=\"n\">SampleAnalysisDir</span><span class=\"p\">):</span>\n        <span class=\"k\">if</span><span class=\"p\">(</span><span class=\"n\">args</span><span class=\"o\">.</span><span class=\"n\">verbose</span><span class=\"p\">):</span>\n            <span class=\"n\">logging</span><span class=\"o\">.</span><span class=\"n\">fatal</span><span class=\"p\">(</span>\n                <span class=\"s2\">&quot;make_output_dir:Dir=&gt;</span><span class=\"si\">%s</span><span class=\"s2\"> exists and we wont run the analysis&quot;</span><span class=\"p\">,</span>\n                <span class=\"n\">SampleAnalysisDir</span><span class=\"p\">)</span>\n            <span class=\"n\">logging</span><span class=\"o\">.</span><span class=\"n\">info</span><span class=\"p\">(</span><span class=\"s2\">&quot;make_output_dir:Please delete this directory and rerun the program&quot;</span><span class=\"p\">)</span>\n        <span class=\"n\">tag</span> <span class=\"o\">=</span> <span class=\"kc\">False</span>\n    <span class=\"k\">else</span><span class=\"p\">:</span>\n        <span class=\"k\">try</span><span class=\"p\">:</span>\n            <span class=\"n\">os</span><span class=\"o\">.</span><span class=\"n\">mkdir</span><span class=\"p\">(</span><span class=\"n\">SampleAnalysisDir</span><span class=\"p\">)</span>\n            <span class=\"n\">tag</span> <span class=\"o\">=</span> <span class=\"kc\">True</span>\n        <span class=\"k\">except</span> <span class=\"ne\">OSError</span><span class=\"p\">:</span>\n            <span class=\"k\">if</span><span class=\"p\">(</span><span class=\"n\">args</span><span class=\"o\">.</span><span class=\"n\">verbose</span><span class=\"p\">):</span>\n                <span class=\"n\">logging</span><span class=\"o\">.</span><span class=\"n\">fatal</span><span class=\"p\">(</span>\n                <span class=\"s2\">&quot;make_output_dir:Dir=&gt;</span><span class=\"si\">%s</span><span class=\"s2\"> exists and we wont run the analysis&quot;</span><span class=\"p\">,</span>\n                <span class=\"n\">SampleAnalysisDir</span><span class=\"p\">)</span>\n                <span class=\"n\">logging</span><span class=\"o\">.</span><span class=\"n\">info</span><span class=\"p\">(</span><span class=\"s2\">&quot;make_output_dir:Please delete this directory and rerun the program&quot;</span><span class=\"p\">)</span>\n            <span class=\"n\">tag</span> <span class=\"o\">=</span> <span class=\"kc\">False</span>\n\n    <span class=\"k\">return</span><span class=\"p\">(</span><span class=\"n\">tag</span><span class=\"p\">,</span> <span class=\"n\">SampleAnalysisDir</span><span class=\"p\">)</span></div>\n</pre></div>", "title": "iCallSV.make_analysis_dir", "customsidebar": null, "current_page_name": "_modules/iCallSV/make_analysis_dir", "sidebars": null, "parents": [{"link": "../../", "title": "Module code"}], "alabaster_version": "0.7.9"}