Source code for pygwas

__author__ = 'Eric Torstenson'
__version__ = '0.6.1'

import subprocess
import sys
import exceptions

__copyright__ = "Eric Torstenson"
__license__ = "GPL3.0"
#     This file is part of pyGWAS.
#
#     pyGWAS is free software: you can redistribute it and/or modify
#     it under the terms of the GNU General Public License as published by
#     the Free Software Foundation, either version 3 of the License, or
#     (at your option) any later version.
#
#     pyGWAS is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.
#
#     You should have received a copy of the GNU General Public License
#     along with MVtest.  If not, see <http://www.gnu.org/licenses/>.


"""PYthon GWAS (pygwas) library

This library contains all of the classes required to parse standard and
transposed pedigree data using most of PLINK style enhancements (such as
tolerating bases and missing/additional columns). In addition to standard
text pedigrees, there is also support for bed files.

Copyright (C) 2015 Edwards, Li & Torstenson

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

"""


def sys_call(cmd):
[docs] """Execute cmd and capture stdout and stderr :param cmd: command to be executed :return: (stdout, stderr) """ p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True) return p.stdout.readlines(), p.stderr.readlines() def Exit(msg, code=1):
[docs] """Exit execution with return code and message :param msg: Message displayed prior to exit :param code: code returned upon exiting """ print >> sys.stderr, msg sys.exit(code) def ExitIf(msg, do_exit, code=1):
[docs] """Exit if do_exit is true :param msg: Message displayed prior to exit :param do_exit: exit when true :param code: application's return code upon exit """ if do_exit: Exit(msg, code) def BuildReportLine(key, value):
[docs] """Prepare key/value for reporting in configuration report :param key: configuration 'keyword' :param value: value reported to be associated with keyword :return: formatted line starting with a comment """ return "# " + key.ljust(20) + " : " + str(value)