<commit_before>#!/usr/bin/env python

import argparse
import os
import tempfile
import shutil
import subprocess

# Constants giving names of file formats
FMT_PLINK_ASSOC = 'plink_assoc' # Treated as a list of locations to use
FMT_GENEMANIA_INTER ='genemania_interaction'
   # 3 columns tab-separated no header:
   #
   # geneid [tab] gene_id [tab] weight

FMT_HOTNET2_EDGE = 'hotnet2_edge' # 3 columns space-separated no header:
                                  # geneid geneid {}
                                  # geneid must be integer
FMT_GENE_LIST='gene_list' # newline separated list of gene ids
FMT_2_COL_GENE_NETWORK='networkx_2_col' # Tab-separated 2 column with
                                        # gene ids from a gene list.
                                        # No header.
FMT_PLINK_4_FUNSEQ='plink_4_funseq' # Tab separated 5 column
                                    # chrom start stop ref alt
                                    #
                                    # chrom is in format "chr2"
FMT_LOCATION_2_GENE_NAME='location_2_gene_name' # Tab separated 4 col No header
                                                # chromosome
                                                # start pos
                                                # end pos
                                                # gene name

FMT_HOTNET2_GENE_INDEX='hotnet2_gene_index' # 2 col space separated
                                            # gene number (used in edge file)
                                            # gene name (from gene list file)

class InputFile(object):
    """Represents a data in a specified format"""
    def __init__(self, file_format, path):
        self.file_format = file_format
        self.path = path
    def __repr__(self):
        return "InputFile('{}','{}')".format(self.file_format, self.path)

def readable_dir(prospective_dir):
    """Function for verifying that something is a readable directory. If not raises an exception, if so, returns prospective_dir

    Taken from stackoverflow question: http://stackoverflow.com/q/11415570/309334
    and not tested
    """
    if not os.path.isdir(prospective_dir):
        raise Exception("{0} is not a pre-existing readable directory path".format(prospective_dir))
    if os.access(prospective_dir, os.R_OK):
        return prospective_dir
    else:
        raise Exception("Can't read from {0}".format(prospective_dir))


def parsed_command_line():
    """Returns an object that results from parsing the command-line for this program argparse.ArgumentParser(...).parse_ags()
    """<commit_msg>Add constants for hotnet<commit_after>#!/usr/bin/env python

import argparse
import os
import tempfile
import shutil
import subprocess

# Constants giving names of file formats
FMT_PLINK_ASSOC = 'plink_assoc' # Treated as a list of locations to use
FMT_GENEMANIA_INTER ='genemania_interaction'
   # 3 columns tab-separated no header:
   #
   # geneid [tab] gene_id [tab] weight

FMT_HOTNET2_EDGE = 'hotnet2_edge' # 3 columns space-separated no header:
                                  # geneid geneid {}
                                  # geneid must be integer
FMT_GENE_LIST='gene_list' # newline separated list of gene ids
FMT_2_COL_GENE_NETWORK='networkx_2_col' # Tab-separated 2 column with
                                        # gene ids from a gene list.
                                        # No header.
FMT_PLINK_4_FUNSEQ='plink_4_funseq' # Tab separated 5 column
                                    # chrom start stop ref alt
                                    #
                                    # chrom is in format "chr2"
FMT_LOCATION_2_GENE_NAME='location_2_gene_name' # Tab separated 4 col No header
                                                # chromosome
                                                # start pos
                                                # end pos
                                                # gene name

FMT_HOTNET2_GENE_INDEX='hotnet2_gene_index' # 2 col space separated
                                            # gene number (used in edge file)
                                            # gene name (from gene list file)

FMT_GENE_PVALUE='gene_pvalue_file' # 2 column tab separated
                                   # gene_name
                                   # aggregate_p_value as a float in decimal

FMT_HOTNET2_INFLUENCE_MAT='hotnet_influence_mat'


FMT_HEAT_SCORE_JSON='hotnet_heat_score_json'

class InputFile(object):
    """Represents a data in a specified format"""
    def __init__(self, file_format, path):
        self.file_format = file_format
        self.path = path
    def __repr__(self):
        return "InputFile('{}','{}')".format(self.file_format, self.path)

def readable_dir(prospective_dir):
    """Function for verifying that something is a readable directory. If not raises an exception, if so, returns prospective_dir

    Taken from stackoverflow question: http://stackoverflow.com/q/11415570/309334
    and not tested
    """
    if not os.path.isdir(prospective_dir):
        raise Exception("{0} is not a pre-existing readable directory path".format(prospective_dir))
    if os.access(prospective_dir, os.R_OK):
        return prospective_dir
    else:
        raise Exception("Can't read from {0}".format(prospective_dir))

def parsed_command_line():
    """Returns an object that results from parsing the command-line for this program argparse.ArgumentParser(...).parse_ags()
    """
{'fraction_non_alphanumeric': 0.0700218818380744, 'fraction_numerical': 0.012399708242159009, 'mean_word_length': 1.8360910031023785, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 44, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2305859', 'n_tokens_mistral': 1489, 'n_tokens_neox': 1422, 'n_words': 431}