{"body": "<h1>Source code for iCallSV.checkparameters</h1><div class=\"highlight\"><pre>\n<span></span><span class=\"sd\">&quot;&quot;&quot;</span>\n<span class=\"sd\">checkparameters</span>\n<span class=\"sd\">~~~~~~~~~~~~~~~</span>\n\n<span class=\"sd\">:Description: This modules checks the parameters for various type of inputs.</span>\n\n<span class=\"sd\">&quot;&quot;&quot;</span>\n<span class=\"sd\">&#39;&#39;&#39;</span>\n<span class=\"sd\">Created on Mar 16, 2015</span>\n<span class=\"sd\">Description: This modules checks the parameters for various type of inputs.</span>\n<span class=\"sd\">@author: Ronak H Shah</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\">sys</span>\n<span class=\"kn\">import</span> <span class=\"nn\">logging</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.checkparameters&#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<span class=\"c1\"># Check if the file exist</span>\n\n\n<div class=\"viewcode-block\" id=\"checkFile\"><a class=\"viewcode-back\" href=\"../../../iCallSV/#iCallSV.checkparameters.checkFile\">[docs]</a><span class=\"k\">def</span> <span class=\"nf\">checkFile</span><span class=\"p\">(</span><span class=\"n\">fileToCheck</span><span class=\"p\">):</span>\n    <span class=\"sd\">&quot;&quot;&quot;</span>\n<span class=\"sd\">    Check `if the file exists or not``</span>\n\n<span class=\"sd\">    :param str fileToCheck: Name of the file to be checked.</span>\n<span class=\"sd\">    :return: None</span>\n<span class=\"sd\">    :rtype: None</span>\n\n<span class=\"sd\">    &quot;&quot;&quot;</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\">fileToCheck</span><span class=\"p\">)):</span>\n        <span class=\"n\">logger</span><span class=\"o\">.</span><span class=\"n\">info</span><span class=\"p\">(</span><span class=\"s2\">&quot;checkparameters:Given File: </span><span class=\"si\">%s</span><span class=\"s2\"> exists.&quot;</span><span class=\"p\">,</span> <span class=\"n\">fileToCheck</span><span class=\"p\">)</span>\n    <span class=\"k\">else</span><span class=\"p\">:</span>\n        <span class=\"n\">logger</span><span class=\"o\">.</span><span class=\"n\">fatal</span><span class=\"p\">(</span>\n            <span class=\"s2\">&quot;checkparameters:Given File: </span><span class=\"si\">%s</span><span class=\"s2\"> does not exists. Sorry please check this Input and Run Again.&quot;</span><span class=\"p\">,</span>\n            <span class=\"n\">fileToCheck</span><span class=\"p\">)</span>\n        <span class=\"n\">sys</span><span class=\"o\">.</span><span class=\"n\">exit</span><span class=\"p\">(</span><span class=\"mi\">1</span><span class=\"p\">)</span></div>\n\n\n<span class=\"c1\"># Check if the Directory exists</span>\n\n<div class=\"viewcode-block\" id=\"checkDir\"><a class=\"viewcode-back\" href=\"../../../iCallSV/#iCallSV.checkparameters.checkDir\">[docs]</a><span class=\"k\">def</span> <span class=\"nf\">checkDir</span><span class=\"p\">(</span><span class=\"n\">folderToCheck</span><span class=\"p\">):</span>\n    <span class=\"sd\">&quot;&quot;&quot;</span>\n<span class=\"sd\">    Check `if the folder exists or not``</span>\n\n<span class=\"sd\">    :class:`str`.</span>\n\n<span class=\"sd\">    :param str folderToCheck: Name of the folder to be checked.</span>\n<span class=\"sd\">    :return: None</span>\n<span class=\"sd\">    :rtype: None</span>\n\n<span class=\"sd\">    &quot;&quot;&quot;</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\">isdir</span><span class=\"p\">(</span><span class=\"n\">folderToCheck</span><span class=\"p\">)):</span>\n        <span class=\"n\">logger</span><span class=\"o\">.</span><span class=\"n\">info</span><span class=\"p\">(</span><span class=\"s2\">&quot;checkparameters:Given Directory: </span><span class=\"si\">%s</span><span class=\"s2\"> exists.&quot;</span><span class=\"p\">,</span> <span class=\"n\">folderToCheck</span><span class=\"p\">)</span>\n    <span class=\"k\">else</span><span class=\"p\">:</span>\n        <span class=\"n\">logger</span><span class=\"o\">.</span><span class=\"n\">fatal</span><span class=\"p\">(</span>\n            <span class=\"s2\">&quot;checkparameters:Given Directory: </span><span class=\"si\">%s</span><span class=\"s2\"> does not exists. Sorry please check this Input and Run Again.&quot;</span><span class=\"p\">,</span>\n            <span class=\"n\">folderToCheck</span><span class=\"p\">)</span>\n        <span class=\"n\">sys</span><span class=\"o\">.</span><span class=\"n\">exit</span><span class=\"p\">(</span><span class=\"mi\">1</span><span class=\"p\">)</span></div>\n\n\n<span class=\"c1\"># Check if the variable is and Integer</span>\n\n<div class=\"viewcode-block\" id=\"checkInt\"><a class=\"viewcode-back\" href=\"../../../iCallSV/#iCallSV.checkparameters.checkInt\">[docs]</a><span class=\"k\">def</span> <span class=\"nf\">checkInt</span><span class=\"p\">(</span><span class=\"n\">variableToCheck</span><span class=\"p\">,</span> <span class=\"n\">variableName</span><span class=\"p\">):</span>\n    <span class=\"sd\">&quot;&quot;&quot;</span>\n<span class=\"sd\">    Check `if the variable is int or not``</span>\n\n<span class=\"sd\">    :param int variableToCheck: Check if it is int or not</span>\n<span class=\"sd\">    :param str variableName: Name of the int object to be verified</span>\n<span class=\"sd\">    :return: None</span>\n<span class=\"sd\">    :rtype: None</span>\n\n<span class=\"sd\">    &quot;&quot;&quot;</span>\n    <span class=\"k\">if</span><span class=\"p\">(</span><span class=\"nb\">isinstance</span><span class=\"p\">(</span><span class=\"n\">variableToCheck</span><span class=\"p\">,</span> <span class=\"nb\">int</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;checkparameters: </span><span class=\"si\">%s</span><span class=\"s2\"> Variable: </span><span class=\"si\">%d</span><span class=\"s2\"> is an Integer.&quot;</span><span class=\"p\">,</span>\n            <span class=\"n\">variableName</span><span class=\"p\">,</span>\n            <span class=\"n\">variableToCheck</span><span class=\"p\">)</span>\n    <span class=\"k\">else</span><span class=\"p\">:</span>\n        <span class=\"n\">logger</span><span class=\"o\">.</span><span class=\"n\">fatal</span><span class=\"p\">(</span>\n            <span class=\"s2\">&quot;checkparameters: </span><span class=\"si\">%s</span><span class=\"s2\"> Variable: </span><span class=\"si\">%d</span><span class=\"s2\"> is not an Integer. Sorry please check this Input and Run Again.&quot;</span><span class=\"p\">,</span>\n            <span class=\"n\">variableName</span><span class=\"p\">,</span>\n            <span class=\"n\">variableToCheck</span><span class=\"p\">)</span>\n        <span class=\"n\">sys</span><span class=\"o\">.</span><span class=\"n\">exit</span><span class=\"p\">(</span><span class=\"mi\">1</span><span class=\"p\">)</span></div>\n\n\n<span class=\"c1\"># Check if the given variable is not Empty</span>\n\n<div class=\"viewcode-block\" id=\"checkEmpty\"><a class=\"viewcode-back\" href=\"../../../iCallSV/#iCallSV.checkparameters.checkEmpty\">[docs]</a><span class=\"k\">def</span> <span class=\"nf\">checkEmpty</span><span class=\"p\">(</span><span class=\"n\">variableToCheck</span><span class=\"p\">,</span> <span class=\"n\">variableName</span><span class=\"p\">):</span>\n    <span class=\"sd\">&quot;&quot;&quot;</span>\n<span class=\"sd\">    Check `if the variable is None or not``</span>\n\n<span class=\"sd\">    :param str variableToCheck: check if str is None or not</span>\n<span class=\"sd\">    :param str variableName: Name of the None object to be verified</span>\n<span class=\"sd\">    :return: None</span>\n<span class=\"sd\">    :rtype: None</span>\n\n<span class=\"sd\">    &quot;&quot;&quot;</span>\n    <span class=\"k\">if</span><span class=\"p\">(</span><span class=\"n\">variableToCheck</span><span class=\"p\">):</span>\n        <span class=\"n\">logger</span><span class=\"o\">.</span><span class=\"n\">info</span><span class=\"p\">(</span><span class=\"s2\">&quot;checkparameters: </span><span class=\"si\">%s</span><span class=\"s2\"> Variable:</span><span class=\"si\">%s</span><span class=\"s2\"> is not empty.&quot;</span><span class=\"p\">,</span> <span class=\"n\">variableName</span><span class=\"p\">,</span> <span class=\"n\">variableToCheck</span><span class=\"p\">)</span>\n    <span class=\"k\">else</span><span class=\"p\">:</span>\n        <span class=\"n\">logger</span><span class=\"o\">.</span><span class=\"n\">fatal</span><span class=\"p\">(</span>\n            <span class=\"s2\">&quot;checkparameters: </span><span class=\"si\">%s</span><span class=\"s2\"> Variable:</span><span class=\"si\">%s</span><span class=\"s2\"> is empty. Sorry please check this Input and Run Again.&quot;</span><span class=\"p\">,</span>\n            <span class=\"n\">variableName</span><span class=\"p\">,</span>\n            <span class=\"n\">variableToCheck</span><span class=\"p\">)</span>\n        <span class=\"n\">sys</span><span class=\"o\">.</span><span class=\"n\">exit</span><span class=\"p\">(</span><span class=\"mi\">1</span><span class=\"p\">)</span></div>\n\n\n<span class=\"c1\"># Check the Delly Analysis Type is Valid or Not</span>\n\n<div class=\"viewcode-block\" id=\"checkDellyAnalysisType\"><a class=\"viewcode-back\" href=\"../../../iCallSV/#iCallSV.checkparameters.checkDellyAnalysisType\">[docs]</a><span class=\"k\">def</span> <span class=\"nf\">checkDellyAnalysisType</span><span class=\"p\">(</span><span class=\"n\">varaibleToCheck</span><span class=\"p\">):</span>\n    <span class=\"sd\">&quot;&quot;&quot;</span>\n<span class=\"sd\">    Check `if the variable for Delly analysis exists or not``</span>\n\n<span class=\"sd\">    :param str variableToCheck: check if str is DEL|DUP|INV|TRA</span>\n<span class=\"sd\">    :return: None</span>\n<span class=\"sd\">    :rtype: None</span>\n\n<span class=\"sd\">    &quot;&quot;&quot;</span>\n    <span class=\"k\">if</span><span class=\"p\">(</span><span class=\"n\">varaibleToCheck</span> <span class=\"o\">==</span> <span class=\"s2\">&quot;DEL&quot;</span> <span class=\"ow\">or</span> <span class=\"n\">varaibleToCheck</span> <span class=\"o\">==</span> <span class=\"s2\">&quot;DUP&quot;</span> <span class=\"ow\">or</span> <span class=\"n\">varaibleToCheck</span> <span class=\"o\">==</span> <span class=\"s2\">&quot;INV&quot;</span> <span class=\"ow\">or</span> <span class=\"n\">varaibleToCheck</span> <span class=\"o\">==</span> <span class=\"s2\">&quot;TRA&quot;</span><span class=\"p\">):</span>\n        <span class=\"n\">logger</span><span class=\"o\">.</span><span class=\"n\">info</span><span class=\"p\">(</span><span class=\"s2\">&quot;checkparameters:Given Delly Analysis Type:</span><span class=\"si\">%s</span><span class=\"s2\"> is valid.&quot;</span><span class=\"p\">,</span> <span class=\"n\">varaibleToCheck</span><span class=\"p\">)</span>\n    <span class=\"k\">else</span><span class=\"p\">:</span>\n        <span class=\"n\">logger</span><span class=\"o\">.</span><span class=\"n\">fatal</span><span class=\"p\">(</span>\n            <span class=\"s2\">&quot;checkparameters:Given Delly Analysis Type: </span><span class=\"si\">%s</span><span class=\"s2\"> is not valid. Sorry please check this Input and Run Again.&quot;</span><span class=\"p\">,</span>\n            <span class=\"n\">varaibleToCheck</span><span class=\"p\">)</span>\n        <span class=\"n\">sys</span><span class=\"o\">.</span><span class=\"n\">exit</span><span class=\"p\">(</span><span class=\"mi\">1</span><span class=\"p\">)</span></div>\n</pre></div>", "title": "iCallSV.checkparameters", "customsidebar": null, "current_page_name": "_modules/iCallSV/checkparameters", "sidebars": null, "parents": [{"link": "../../", "title": "Module code"}], "alabaster_version": "0.7.9"}