## Tools.pbs.Qsub


Usage

``` python
Tools.pbs.Qsub(
    python_script=None,
    author=None,
    project_name="OrthoEvol",
    description="This is a basic pbs job",
    date_format="%a %b %d %I:%M:%S %p %Y",
    chunk_resources=None,
    cput="72:00:00",
    walltime="48:00:00",
    email=None,
    directive_list=None,
    pbs_command_list=None,
    email_command=None,
    **kwargs
)
```


## Methods

| Name | Description |
|----|----|
| [__init__()](#__init__) | The Qsub class is the primary means of creating a job. It adds the additional |
| [create_commands_section()](#create_commands_section) | Create the command section of the PBS file. |
| [create_directives_section()](#create_directives_section) | Create the directive section of the PBS file. |
| [create_header_section()](#create_header_section) | Create the header section of the supplied PBS file. |
| [format_python_script()](#format_python_script) | Lightly wrapping the format_template_script, this function formats a python script |
| [format_template_string()](#format_template_string) | Using string Templating, this function takes a dictionary of attributes |
| [get_resource_string()](#get_resource_string) | Creates a list of chunk resources that will be used in the |
| [set_up_pbs_script()](#set_up_pbs_script) | Python code is supplied as a file or as a string. The string or file can be a template string or file, which |
| [submit_python_job()](#submit_python_job) | This function is the primary means of submitting a PBS job that runs a python script. |
| [write_template_string()](#write_template_string) | This function writes a code string to a file located in the |

------------------------------------------------------------------------


#### \_\_init\_\_()


The Qsub class is the primary means of creating a job. It adds the additional


Usage

``` python
__init__(
    python_script=None,
    author=None,
    project_name="OrthoEvol",
    description="This is a basic pbs job",
    date_format="%a %b %d %I:%M:%S %p %Y",
    chunk_resources=None,
    cput="72:00:00",
    walltime="48:00:00",
    email=None,
    directive_list=None,
    pbs_command_list=None,
    email_command=None,
    **kwargs
)
```


functionality of creating custom PBS jobs by using template PBS scripts or by utilizing the it's parameters to create each section of the PBS script (header, directives, and commands sections). It also gives the ability to format/template/submit python based PBS jobs.


##### Parameters


`python_script: str. = None`  
The path to the python script that will be submitted.

`author: str. = None`  
The name of the person submitting the PBS job. Used in the header section of the PBS script.

`project_name: str. = ``"OrthoEvol"`  
The project name associated with the PBS job. Used in the header section of the PBS script.

`description: str. = ``"This is a basic pbs job"`  
A description of the job used in the header section of the PBS script.

`date_format: str. = ``"%a %b %d %I:%M:%S %p %Y"`  
The date format used in the header section of the PBS script.

`chunk_resources: dict. = None`  
A dictionary of chunk resources used by the -l parameter. Used in the directives section of the PBS script.

`cput: str. = ``"72:00:00"`  
The cpu time used in the directives section of the PBS script.

`walltime: str. = ``"48:00:00"`  
The walltime used in the directives section of the PBS script.

`email: str. = None`  
The email of the author or user. Used in the directives section of the PBS script.

`directive_list: list. = None`  
A list of other directives to use in the PBS script.

`pbs_command_list: list. = None`  
A list of extra PBS commands to add to the PBS script.

`email_command: str. = None`  
A custom email command used in the command section of the PBS script.

`kwargs: dict. = {}`  
Keyword arguments given to the BaseQsub class.


------------------------------------------------------------------------


#### create_commands_section()


Create the command section of the PBS file.


Usage

``` python
create_commands_section(file)
```


##### Parameters


`file: str.`  
A path to the PBS file.


------------------------------------------------------------------------


#### create_directives_section()


Create the directive section of the PBS file.


Usage

``` python
create_directives_section(file)
```


##### Parameters


`file: str.`  
A path to the PBS file.


------------------------------------------------------------------------


#### create_header_section()


Create the header section of the supplied PBS file.


Usage

``` python
create_header_section(file)
```


##### Parameters


`file: str.`  
A path to the PBS file.


------------------------------------------------------------------------


#### format_python_script()


Lightly wrapping the format_template_script, this function formats a python script


Usage

``` python
format_python_script(
    py_template_string=None, py_template_file=None, python_attributes=None
)
```


as a string using the supplied attributes. The code/script is then writen to the the pbs working directory using the naming convention: /.py

See https://docs.python.org/3.4/library/string.html#string.Template.


##### Parameters


`py_template_string: str. = None`  
Python code as a string.

`py_template_file: str. = None`  
A path to the python template.

`python_attributes: dict. = None`  
A dictionary of attributes that will be used with the template.


------------------------------------------------------------------------


#### format_template_string()


Using string Templating, this function takes a dictionary of attributes


Usage

``` python
format_template_string(code=None, template=None, attributes=None)
```


that are used to format the given code or template file. See https://docs.python.org/3.4/library/string.html#string.Template.


##### Parameters


`code: str. = None`  
A string of code that is a template.

`template: str. = None`  
The path to a file that is a template.

`attributes: dict. = None`  
A dictionary of attributes for templating the code/file.


##### Returns


`str.`  
The template code with the attribute variables filled in.


------------------------------------------------------------------------


#### get_resource_string()


Creates a list of chunk resources that will be used in the


Usage

``` python
get_resource_string(chunk_resources=None)
```


directives section of the custom PBS script.


##### Parameters


`chunk_resources: dict. = None`  
A dictionary of values used in the PBS directive section. The default will look like this after it is added to the PBS script: '#PBS -l select=1:ncpus=1:mem=6gb'


##### Returns


`str.`  
A string that will added to the directive list.


------------------------------------------------------------------------


#### set_up_pbs_script()


Python code is supplied as a file or as a string. The string or file can be a template string or file, which


Usage

``` python
set_up_pbs_script(
    pbs_template_string=None, pbs_template_file=None, pbs_attributes=None
)
```


can be supplied a dictionary to fill in the templated variables. Additionally, a PBS file (the default from the package or a custom) is used in conjunction with the python file in order to submit the job. The PBS file can be generated from a template or a custom script can be generated with a minimum set of parameters already set up.

See https://docs.python.org/3.4/library/string.html#string.Template.


##### Parameters


`pbs_template_string: str. = None`  
The PBS script as a string.

`pbs_template_file: str. = None`  
A path to the PBS template.

`pbs_attributes: dict. = None`  
A dictionary of attributes that will be used with the template.


------------------------------------------------------------------------


#### submit_python_job()


This function is the primary means of submitting a PBS job that runs a python script.


Usage

``` python
submit_python_job(
    cmd=None,
    py_template_string=None,
    py_template_file=None,
    python_attributes=None,
    pbs_template_string=None,
    pbs_template_file=None,
    pbs_attributes=None,
    custom_python_cmd=None,
    rerun=False
)
```


It will format and copy the PBS script and the Python script that will be submitted by the PBS system. The PBS script will either be customized using the class parameters or it will be formatted using the template parameters. It also takes custom python commands as a list, which is useful for certain actions like activating virutal environments.


##### Parameters


`cmd: str. = None`  
The command used to run the qsub job.

`py_template_string: str. = None`  
Python code as a string.

`py_template_file: str. = None`  
A path to the python template.

`python_attributes: dict. = None`  
A dictionary of attributes that will be used with the template.

`pbs_template_string: str. = None`  
The PBS script as a string.

`pbs_template_file: str. = None`  
A path to the PBS template.

`pbs_attributes: dict. = None`  
A dictionary of attributes that will be used with the template.

`custom_python_cmd: list. = None`  
A list of custom commands that are used to create the command section of the PBS script.

`rerun: bool. = ``False`  
A flag used to rerun a previously created job.


------------------------------------------------------------------------


#### write_template_string()


This function writes a code string to a file located in the


Usage

``` python
write_template_string(code, extension, file=None)
```


PBS working directory. It uses the job_name and the extension to create the file: /.


##### Parameters


`code: str.`  
The code that will be written to the file.

`extension: str.`  
The extension of the file. Usually '.pbs' or '.py'.

`file: str. = None`  
A path to the file that will be written.
