Beispiel #1
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--config', dest='config',
                        help="parallyze config file", default='parallyze.conf')
    parser.add_argument('--procedure', dest='procedure',
                        default='mutationTally', choices=['simulationRM',
                        'simulationEJB', 'dNdS', 'mutationTally', 'infoRegion',
                        'analyticalEJB'])
    parser.add_argument('--nonsynonymous', action='store_true')
    parser.add_argument('--synonymous', action='store_true')
    parser.add_argument('--noncoding', action='store_true')
    parser.add_argument('--pseudogene', action='store_true')
    parser.add_argument('--intergenic', action='store_true')
    parser.add_argument('--replicates', type=int)
    parser.add_argument('--genes_to_display', type=int)
    parser.add_argument('--fname')
    parser.add_argument('--gene_product', action='store_true')
    args = parser.parse_args()
    # print args.fname

    conf = SimpleConfig(config_keys, args.config)
    for fn in conf.GENOMEDIFF_FILES:
        assert os.path.isfile(fn)

    '''
    The user can override most of the options in config file
    with (optional) flags at runtime.
    '''

    if args.nonsynonymous:
        conf.NONSYNONYMOUS = True
    if args.synonymous:
        conf.SYNONYMOUS = True
    if args.noncoding:
        conf.NONCODING = True
    if args.pseudogene:
        conf.PSEUDOGENE = True
    if args.intergenic:
        conf.INTERGENIC = True
    if args.gene_product:
        conf.GENE_PRODUCT = True
    if args.replicates and args.replicates > 0:
        conf.REPLICATES = args.replicates
    if args.genes_to_display and args.genes_to_display >= 0:
        conf.GENES_TO_DISPLAY = args.genes_to_display

    '''
    Store the set of mutation types to use, for later reference
    in the program.
    '''

    conf.snp_types = set()
    if conf.NONSYNONYMOUS:
        conf.snp_types.add('nonsynonymous')
    if conf.SYNONYMOUS:
        conf.snp_types.add('synonymous')
    if conf.NONCODING:
        conf.snp_types.add('noncoding')
    if conf.PSEUDOGENE:
        conf.snp_types.add('pseudogene')
    if conf.INTERGENIC:
        conf.snp_types.add('intergenic')

    if args.procedure == 'simulationRM':
        simulationRM(conf)
    elif args.procedure == 'simulationEJB':
        simulationEJB(conf)
    elif args.procedure == 3:
        proc3(conf)
    elif args.procedure == 'dNdS':
        dNdS(conf)
    elif args.procedure == 'analyticalEJB':
        analyticalEJB(conf)
    elif args.procedure == 'mutationTally':
        mutationTally(conf, args)
    elif args.procedure == 'infoRegion':
        infoRegion(conf)
Beispiel #2
0
            config.batch_size, config.history_length, config.screen_height, config.screen_width

        self.history = np.zeros([self.history_length, self.screen_height, self.screen_width], dtype = np.float32)

    def add(self, screen):
        assert type(screen) is np.ndarray, "screen is not numpy.ndarray"
        assert screen.shape == (self.screen_height, self.screen_width), "%s != (%d, %d)" % (str(screen.shape), self.screen_height, self.screen_width)

        self.history[:-1] = self.history[1:]
        self.history[-1] = screen

    def get(self):
        return np.transpose(self.history, (1, 2, 0))

if __name__ == "__main__":
    config = SimpleConfig()

    env = SimpleGymEnvironment(config)
    env.new_game()

    history = History(config)

    for _ in range(10):
        screen, reward, terminal = env.act(0)
        history.add(screen)

    print history.get()



Beispiel #3
0
# _*_ coding: utf-8 _*_

__author__='fang'

import socket,re
from config import SimpleConfig
from httpProxy import ProxyHandler,serving,ThreadingHTTPServer
from filter import SQLFilter

if __name__=='__main__':

    try:
        #获取proxy的配置,返回一个dict
        #获取黑名单,返回一个list
        #获取过滤规则,返回一个list
        confile=SimpleConfig('proxy.cnf').config_proxy()
        refuseClients=SimpleConfig('blacklist.db').config_blacklist()
        filterPatterns=SimpleConfig('filterPattern.cnf').config_filter()

        #初始化SQLFilter的过滤规则
        patterns=[]
        for item in filterPatterns:
            pattern=re.compile(item)
            patterns.append(pattern)
        SQLFilter.patterns=patterns

        #初始化黑名单
        refuse=[]
        for c in refuseClients:
            client=socket.gethostbyname(c)
            refuse.append(client)