<commit_before>#!/usr/bin/python
import gc
import os
import os.path
import sys
from platform import system as platformSys
from subprocess import call
sys.path.append('..')

import numpy
import scipy
from matplotlib import pyplot

from Tkinter import Tk
from tkFileDialog import askopenfilename

import fc.io
import fc.excel_io
import fc.gate
import fc.plot
import fc.transform
import fc.mef
import fc.stats

def main():
    # Launch dialogue to select input file
    Tk().withdraw() # don't show main window
    # OSX ONLY: Call bash script to prevent file select window from sticking after use
    if platformSys() == 'Darwin':
        call("defaults write org.python.python ApplePersistenceIgnoreState YES", shell=True)
        input_form = askopenfilename(filetypes = [('Excel files', '*.xlsx')])
        call("defaults write org.python.python ApplePersistenceIgnoreState NO", shell=True)    
    else:
        input_form = askopenfilename(filetypes = [('Excel files', '*.xlsx')])
    if not input_form:
        print "Cancelled."
        return

    # Get base directory
    basedir, input_file = os.path.split(input_form)
    input_filename, __ = os.path.splitext(input_file)

    # Generate plotting directories
    beads_plot_dir = "{}/{}".format(basedir, 'plot_beads')
    gated_plot_dir = "{}/{}".format(basedir, 'plot_gated')
    if not os.path.exists(beads_plot_dir):
        os.makedirs(beads_plot_dir)
    if not os.path.exists(gated_plot_dir):
        os.makedirs(gated_plot_dir)

    # Generate path of output file
    output_form = "{}/{}".format(basedir, input_filename + '_output.xlsx')

    # Get beads files data from input form
    beads_info = fc.excel_io.import_rows(input_form, "beads")
    to_mef_all = {}

    print "\nProcessing beads..."
    for bi in beads_info:
        # Open file
        di = fc.io.TaborLabFCSData("{}/{}".format(basedir, bi['File Path']))
        print "{} ({} events).".format(str(di), di.shape[0])
<commit_msg>Fixed format in OSX-specific lines in run_excel.py.<commit_after>#!/usr/bin/python
import gc
import os
import os.path
import sys
from platform import system as platformSys
from subprocess import call
sys.path.append('..')

import numpy
import scipy
from matplotlib import pyplot

from Tkinter import Tk
from tkFileDialog import askopenfilename

import fc.io
import fc.excel_io
import fc.gate
import fc.plot
import fc.transform
import fc.mef
import fc.stats

def main():
    # Launch dialogue to select input file
    Tk().withdraw() # don't show main window
    # OSX ONLY: Call bash script to prevent file select window from sticking 
    # after use.
    if platformSys() == 'Darwin':
        call("defaults write org.python.python ApplePersistenceIgnoreState YES", 
            shell=True)
        input_form = askopenfilename(filetypes = [('Excel files', '*.xlsx')])
        call("defaults write org.python.python ApplePersistenceIgnoreState NO", 
            shell=True)
    else:
        input_form = askopenfilename(filetypes = [('Excel files', '*.xlsx')])
    if not input_form:
        print "Cancelled."
        return

    # Get base directory
    basedir, input_file = os.path.split(input_form)
    input_filename, __ = os.path.splitext(input_file)

    # Generate plotting directories
    beads_plot_dir = "{}/{}".format(basedir, 'plot_beads')
    gated_plot_dir = "{}/{}".format(basedir, 'plot_gated')
    if not os.path.exists(beads_plot_dir):
        os.makedirs(beads_plot_dir)
    if not os.path.exists(gated_plot_dir):
        os.makedirs(gated_plot_dir)

    # Generate path of output file
    output_form = "{}/{}".format(basedir, input_filename + '_output.xlsx')

    # Get beads files data from input form
    beads_info = fc.excel_io.import_rows(input_form, "beads")
    to_mef_all = {}

    print "\nProcessing beads..."
    for bi in beads_info:
        # Open file
        di = fc.io.TaborLabFCSData("{}/{}".format(basedir, bi['File Path']))
        print "{} ({} events).".format(str(di), di.shape[0])

{'fraction_non_alphanumeric': 0.1154809619238477, 'fraction_numerical': 0.000501002004008016, 'mean_word_length': 3.402425578831312, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1419346', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1275, 'n_words': 346}