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

import os
import argparse
import sys
from genomicode import jmath,config
import zipfile


def main():

    parser = argparse.ArgumentParser(description = 'run the gene pattern module')
    
    parser.add_argument('--parameters',dest = 'parameters',
                        action = 'append',default = None,
                        type = str,help='key:value')
    parser.add_argument('-o',dest = 'outpath',type = str,
                        help = 'specify the outpath',default='.')
    parser.add_argument(dest = 'module_name',type = str,
                        help = 'specify the module_name',default = None)
    args = parser.parse_args()
    parameters = dict()
    if args.parameters:
        for i in args.parameters:
            assert ':' in i, 'parameters should be in key:value format'
            key,value = i.split(':')
            assert ':' not in value,'parameters should be in key:value format'
            parameters[key] = value
    if not os.path.exists(args.outpath):
        os.mkdir(args.outpath)
    """given the module_name and the module parameters
       in dict, call module in Genepatttern"""
    R = jmath.start_R()
    username = config.gp_user
    password = <PASSWORD> 
    servername = config.gp_server
    jmath.R_equals(password, 'password')
    jmath.R_equals(servername, 'servername')
    jmath.R_equals(username, 'username')
    command = "\'" + args.module_name + "\'"
    for key in parameters.keys():
        command = command + ',' + key + '=' + '\"' + parameters[key] + '\"'
    cwd = os.getcwd()
    try:
        os.chdir(args.outpath)
        fullcommand = 'result<-run.analysis(gp.client,' + command + ')'
        R('library(GenePattern)')
        R('gp.client <- gp.login(servername, username, password)')
        R(fullcommand)
        jmath.R_equals(args.outpath,'outpath')
        R('job.result.download.files(result, outpath)')
    finally:
        os.chdir(cwd)

if __name__=='__main__':
    main()<commit_msg>fix run_genepattern.py bug<commit_after>#!/usr/bin/env python

import os
import argparse
import sys
from genomicode import jmath,config
import zipfile


def main():

    parser = argparse.ArgumentParser(description = 'run the gene pattern module')
    
    parser.add_argument('--parameters',dest = 'parameters',
                        action = 'append',default = None,
                        type = str,help='key:value')
    parser.add_argument('-o',dest = 'outpath',type = str,
                        help = 'specify the outpath',default='.')
    parser.add_argument(dest = 'module_name',type = str,
                        help = 'specify the module_name',default = None)
    args = parser.parse_args()
    parameters = dict()
    if args.parameters:
        for i in args.parameters:
            assert ':' in i, 'parameters should be in key:value format'
            key,value = i.split(':')
            assert ':' not in value,'parameters should be in key:value format'
            parameters[key] = value
    """given the module_name and the module parameters
       in dict, call module in Genepatttern"""
    R = jmath.start_R()
    username = config.gp_user
    password = <PASSWORD> 
    servername = config.gp_server
    jmath.R_equals(password, 'password')
    jmath.R_equals(servername, 'servername')
    jmath.R_equals(username, 'username')
    command = "\'" + args.module_name + "\'"
    for key in parameters.keys():
        command = command + ',' + key + '=' + '\"' + parameters[key] + '\"'
    fullcommand = 'result<-run.analysis(gp.client,' + command + ')'
    R('library(GenePattern)')
    R('gp.client <- gp.login(servername, username, password)')
    R(fullcommand)
    jmath.R_equals(args.outpath,'outpath')
    R('job.result.download.files(result, outpath)')

if __name__=='__main__':
    main()
{'fraction_non_alphanumeric': 0.1352480417754569, 'fraction_numerical': 0.0, 'mean_word_length': 2.627840909090909, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4763862', 'n_tokens_mistral': 1166, 'n_tokens_neox': 1139, 'n_words': 269}