view eden_utilities.py @ 2:295e085b8d60 draft default tip

Uploaded
author bgruening
date Thu, 12 Jun 2014 12:22:56 -0400
parents 95a776023fbc
children
line wrap: on
line source

#!/usr/bin/env python

__author__ = "Fabrizio Costa, Bjoern Gruening"
__copyright__ = "Copyright 2014, Fabrizio Costa"
__credits__ = ["Fabrizio Costa", "Bjoern Gruening"]
__license__ = "GPL"
__version__ = "1.0.1"
__maintainer__ = "Fabrizio Costa"
__email__ = "costa@informatik.uni-freiburg.de"
__status__ = "Production"

import logging
import sys
import argparse

log = logging.getLogger()
log.setLevel(logging.DEBUG)

std = logging.StreamHandler(sys.stdout)
std.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
std.setFormatter(formatter)
log.addHandler(std)

def create_params(parser, mode):
    #common parameters
    parser.add_argument('--input-file', '-i', 
            dest="fasta_file",
            type=str, 
            help='fasta file name with sequences.', 
            required=True)
    parser.add_argument('--radius', '-r',
            dest="radius",
            type=int, 
            help='Size of the largest radius used in EDeN.', 
            default=2)
    parser.add_argument('--distance', '-d',
            dest="distance",
            type=int, 
            help='Size of the largest distance used in EDeN.', 
            default=5)
    parser.add_argument('--version', action="version", version=__version__)
    
    if mode == 'eden_cluster_splitter' or  mode == 'eden_cluster_motif' :
        parser.add_argument("-o", "--output-dir", 
            dest="output_dir_path", 
            help="Path to output directory.")
        parser.add_argument('-n', '--num-nearest-neighbors', 
            dest="num_nearest_neighbors",
            type=int, 
            help='Number of nearest neighbors used in the density estimation.', 
            default=10)
        parser.add_argument('-z', '--neighborhood-intersection-size', 
            dest="neighborhood_intersection_size",
            type=int, 
            help='Number of nearest neighbors that must be shared in neighborhood in order to trigger neighborhood joining.', 
            default=5)
        parser.add_argument('-c','--fraction-center-scan', 
            dest="fraction_center_scan",
            type=int, 
            help='Fraction of total number of instances which is used to compute densities.', 
            default=1)
        
    if mode == 'eden_iterative_motif_finder' or  mode == 'eden_cluster_motif' :
        parser.add_argument("-f", "--output-file", 
            dest="output_file_path", 
            type=argparse.FileType('w'),
            default=sys.stdout,
            help="Path to output file.")
        parser.add_argument('-k', '--max-order', 
            dest="max_order",
            type=int, 
            help='Size of the order for negative shuffling.', 
            default=3)
        parser.add_argument('-s', '--min-motif-size', 
            dest="min_motif_size",
            type=int, 
            help='Size of the smallest returned motif.', 
            default=4)
        parser.add_argument('-e', '--num-negative-repetitions',
            dest="neg_rep",
            type=int, 
            help='Number of negative instances per order per positive instance.', 
            default=3)

    if mode == 'eden_cluster_motif' :
        parser.add_argument("--motif-file", 
            dest="motif_file", 
            type=argparse.FileType('w'),
            default=sys.stdout,
            help="Path to the output motif file.")
    return parser