示例#1
0
def getDataDirectory():

    # Check for the text file which should contain the path to the data directory.
    dataDirectoryTextFilePath = os.path.join(os.getenv("HOME"), ".mutperiod",
                                             "data_dir.txt")

    # If it exists, return the directory path within.
    if os.path.exists(dataDirectoryTextFilePath):
        with open(dataDirectoryTextFilePath, 'r') as dataDirectoryTextFile:

            dataDirectory = dataDirectoryTextFile.readline().strip()

            # Double check to make sure the data directory is still intact.
            # If it isn't, inform the user, and progress through the function to recreate it.
            if not os.path.exists(dataDirectory):
                print(
                    "Data directory not found at expected location: {}".format(
                        dataDirectory))
                print(
                    "Please select a new location to create a data directory.")
            else:
                return dataDirectory

    else:

        # Create a simple dialog to select a new data directory location.
        from benbiohelpers.TkWrappers.TkinterDialog import TkinterDialog, Selections
        checkDirs(os.path.dirname(dataDirectoryTextFilePath))
        dialog = TkinterDialog(
            workingDirectory=os.path.dirname(dataDirectoryTextFilePath))
        dialog.createFileSelector("Location to create new data directory:",
                                  0, ("Fasta Files", ".fa"),
                                  directory=True)

        # Run the UI
        dialog.mainloop()

        # If no input was received (i.e. the UI was terminated prematurely), then quit!
        if dialog.selections is None: quit()

        selections: Selections = dialog.selections
        dataDirectoryDirectory = selections.getIndividualFilePaths()[0]

        # Make sure a valid, writeable directory was given.  Then create the new directory (if it doesn't exist already),
        # write it to the text file, and return it!  (Also create the __external_data directory.)
        if not os.path.exists(dataDirectoryDirectory):
            raise UserInputError("Given directory: " + dataDirectoryDirectory +
                                 " does not exist.")

        dataDirectory = os.path.join(dataDirectoryDirectory, "mutperiod_data")
        try:
            checkDirs(dataDirectory)
            checkDirs(os.path.join(dataDirectory, "__external_data"))
        except IOError:
            raise InvalidPathError(
                dataDirectoryDirectory,
                "Given location for data directory is not writeable:")
        with open(dataDirectoryTextFilePath, 'w') as dataDirectoryTextFile:
            dataDirectoryTextFile.write(dataDirectory + '\n')
        return dataDirectory
示例#2
0
def main():

    #Create the Tkinter UI
    dialog = TkinterDialog(workingDirectory=getDataDirectory())
    dialog.createMultipleFileSelector("Custom bed Input Files:", 0,
                                      "custom_input.bed",
                                      ("bed files", ".bed"))
    dialog.createFileSelector("Genome Fasta File:", 1, ("Fasta Files", ".fa"))
    dialog.createCheckbox("Stratify data by microsatellite stability?", 2, 0)
    dialog.createCheckbox("Stratify by mutation signature?", 2, 1)
    dialog.createCheckbox("Separate individual cohorts?", 3, 0)
    dialog.createCheckbox("Only use single nucleotide substitutions?", 4, 0)
    dialog.createCheckbox("Include indels in output?", 4, 1)

    # Run the UI
    dialog.mainloop()

    # If no input was received (i.e. the UI was terminated prematurely), then quit!
    if dialog.selections is None: quit()

    # Get the user's input from the dialog.
    selections: Selections = dialog.selections
    bedInputFilePaths = selections.getFilePathGroups()[0]
    genomeFilePath = selections.getIndividualFilePaths()[0]
    stratifyByMS = selections.getToggleStates()[0]
    stratifyByMutSig = selections.getToggleStates()[1]
    separateIndividualCohorts = selections.getToggleStates()[2]
    onlySingleBaseSubs = selections.getToggleStates()[3]
    includeIndels = selections.getToggleStates()[4]

    parseCustomBed(bedInputFilePaths, genomeFilePath, stratifyByMS,
                   stratifyByMutSig, separateIndividualCohorts,
                   onlySingleBaseSubs, includeIndels)
def main():

    #Create the Tkinter UI
    dialog = TkinterDialog(workingDirectory=getDataDirectory())
    dialog.createMultipleFileSelector("ICGC Mutation Files:", 0, ".tsv.gz",
                                      ("gzip files", ".gz"))
    dialog.createFileSelector("Genome Fasta File:", 1, ("Fasta Files", ".fa"))
    dialog.createCheckbox("Create individual bed files for each donor.", 2, 0)
    dialog.createCheckbox("Stratify results by microsatellite stability", 3, 0)
    dialog.createCheckbox("Stratify results by mutation signature", 4, 0)

    # Run the UI
    dialog.mainloop()

    # If no input was received (i.e. the UI was terminated prematurely), then quit!
    if dialog.selections is None: quit()

    # Get the user's input from the dialog.
    selections: Selections = dialog.selections
    ICGCFilePaths = list(selections.getFilePathGroups())[
        0]  # A list of ICGC mutation file paths
    genomeFilePath = list(selections.getIndividualFilePaths())[0]
    separateDonors = list(selections.getToggleStates())[0]
    stratifyByMS = list(selections.getToggleStates())[1]
    stratifyByMutSig = list(selections.getToggleStates())[2]

    parseICGC(ICGCFilePaths, genomeFilePath, separateDonors, stratifyByMS,
              stratifyByMutSig)
def main():

    # Create the Tkinter UI
    dialog = TkinterDialog(workingDirectory=getDataDirectory())
    dialog.createMultipleFileSelector("Feature Files (e.g. mutations):", 0,
                                      "bin_me.bed", ("Bed Files", ".bed"))
    dialog.createFileSelector("Gene Designations:", 1, ("Bed Files", ".bed"))
    dialog.createCheckbox("Color Domain is present in 7th (index=6) column", 2,
                          0)

    flankDialog = dialog.createDynamicSelector(3, 0)
    flankDialog.initCheckboxController(
        "Gene designations include flanking regions")
    flankSizeDialog = flankDialog.initDisplay(True, "FlankSize")
    flankSizeDialog.createTextField("Flanking bin size:",
                                    0,
                                    0,
                                    defaultText="0")
    flankSizeDialog.createTextField("Flanking bin number:",
                                    1,
                                    0,
                                    defaultText="0")
    flankDialog.initDisplayState()

    fileSuffixDialog = dialog.createDynamicSelector(4, 0)
    fileSuffixDialog.initCheckboxController("Custom file suffix")
    suffixDialog = fileSuffixDialog.initDisplay(True, "Suffix")
    suffixDialog.createTextField("File Suffix:", 0, 0, defaultText="all_genes")
    fileSuffixDialog.initDisplayState()

    # Run the UI
    dialog.mainloop()

    # If no input was received (i.e. the UI was terminated prematurely), then quit!
    if dialog.selections is None: quit()

    if dialog.selections.getToggleStates()[0]: colorColIndex = 6
    else: colorColIndex = None

    if flankDialog.getControllerVar():
        flankBinSize = int(dialog.selections.getTextEntries("FlankSize")[0])
        flankBinNum = int(dialog.selections.getTextEntries("FlankSize")[1])
    else:
        flankBinSize = 0
        flankBinNum = 0

    if fileSuffixDialog.getControllerVar():
        fileSuffix = dialog.selections.getTextEntries("Suffix")[0]
    else:
        fileSuffix = ""

    binInGenes(dialog.selections.getFilePathGroups()[0],
               dialog.selections.getIndividualFilePaths()[0], flankBinSize,
               flankBinNum, fileSuffix, colorColIndex)
def main():

    # Create a simple dialog for selecting the gene designation files.
    dialog = TkinterDialog(workingDirectory=os.path.dirname(__file__))
    dialog.createFileSelector("Bed File:", 0, ("bed file", ".bed"))

    dialog.mainloop()

    if dialog.selections is None: quit()

    expandToBothStrands(dialog.selections.getIndividualFilePaths()[0], )
示例#6
0
def main():

    #Create the Tkinter UI
    dialog = TkinterDialog(workingDirectory=os.path.dirname(__file__))
    dialog.createFileSelector("Spivakov File:", 0, ("Text File", ".txt"))

    # Run the UI
    dialog.mainloop()

    # If no input was received (i.e. the UI was terminated prematurely), then quit!
    if dialog.selections is None: quit()

    parseSpivakovToBed(dialog.selections.getIndividualFilePaths()[0])
示例#7
0
def main():

    dialog = TkinterDialog(workingDirectory=os.path.dirname(__file__))
    dialog.createFileSelector("Colored Gene Designations:", 0, ("Bed File",".bed"))
    dialog.createFileSelector("Colorless Gene Data (e.g. RPKM)", 1, ("Tab separated files",".tsv"))

    dialog.mainloop()

    # If no input was received (i.e. the UI was terminated prematurely), then quit!
    if dialog.selections is None: quit()

    assignToDomainByGene(dialog.selections.getIndividualFilePaths()[0],
                         dialog.selections.getIndividualFilePaths()[1])
def main():

    # Create the Tkinter UI
    dialog = TkinterDialog(workingDirectory=getDataDirectory())
    dialog.createFileSelector("RNAseq File:", 0, ("Bed Files", ".bed"))
    dialog.createFileSelector("Gene Designations (color in 7th column):", 1,
                              ("Bed Files", ".bed"))

    # Run the UI
    dialog.mainloop()

    binRNASeqByChromatinDomainInGenes(
        dialog.selections.getIndividualFilePaths()[0],
        dialog.selections.getIndividualFilePaths()[1], 6)
示例#9
0
def main():

    # Create the Tkinter UI
    dialog = TkinterDialog(workingDirectory=getDataDirectory())
    dialog.createMultipleFileSelector("Bed Files:",0,"I_have_bad_chromosomes.bed",("Bed Files",".bed"))    
    dialog.createFileSelector("Genome Fasta File:",1,("Fasta Files",".fa"))

    # Run the UI
    dialog.mainloop()

    # If no input was received (i.e. the UI was terminated prematurely), then quit!
    if dialog.selections is None: quit()

    removeUnacceptableChromosomes(dialog.selections.getFilePathGroups()[0], dialog.selections.getIndividualFilePaths()[0])
def main():

    #Create the Tkinter UI
    dialog = TkinterDialog(workingDirectory=getDataDirectory())
    dialog.createMultipleFileSelector("Prepared Input Files:",0,DataTypeStr.mutations + ".bed",("bed files",".bed"))
    dialog.createFileSelector("Genome Fasta File:",1,("Fasta Files",".fa"))
    dialog.createCheckbox("Skip formatting checks for all but the first line",2,0)

    # Run the UI
    dialog.mainloop()

    # If no input was received (i.e. the UI was terminated prematurely), then quit!
    if dialog.selections is None: quit()

    # Get the user's input from the dialog.
    parsePreparedInput(dialog.selections.getFilePathGroups()[0], dialog.selections.getIndividualFilePaths()[0],
                       not dialog.selections.getToggleStates()[0])
示例#11
0
def main():

    # Create the Tkinter UI
    dialog = TkinterDialog(workingDirectory=getDataDirectory())
    dialog.createMultipleFileSelector("Genome Feature Positions Files:", 0,
                                      "context_mutations.bed",
                                      ("Bed Files", ".bed"))
    dialog.createFileSelector("Gene Ranges File (merged):", 1,
                              ("Bed Files", ".bed"))

    # Run the UI
    dialog.mainloop()

    # If no input was received (i.e. the UI was terminated prematurely), then quit!
    if dialog.selections is None: quit()

    splitGenicAndIntergenic(dialog.selections.getFilePathGroups()[0],
                            dialog.selections.getIndividualFilePaths()[0])
示例#12
0
def main():

    # Create the Tkinter UI
    dialog = TkinterDialog(workingDirectory=getDataDirectory())
    dialog.createFileSelector("Encompassing Feature File:", 0,
                              ("Bed Files", ".bed"))
    dialog.createFileSelector("Nucleosome Dyad Center Positions:", 1,
                              ("Bed Files", ".bed"))

    # Run the UI
    dialog.mainloop()

    # If no input was received (i.e. the UI was terminated prematurely), then quit!
    if dialog.selections is None: quit()

    stratifyNucleosomesByEncompassment(
        dialog.selections.getIndividualFilePaths()[0],
        dialog.selections.getIndividualFilePaths()[1])
示例#13
0
def main():

    #Create the Tkinter UI
    dialog = TkinterDialog(workingDirectory=getDataDirectory())
    dialog.createFileSelector("Data Set Directory:", 0, directory=True)

    # TODO: Maybe allow for different cohort selections here.  Right now, I'm assuming that we group MS data by mut sigs.
    #       This will probably work best if it communicates with the project manager to some capacity (what cohort data is available?)

    # Run the UI
    dialog.mainloop()

    # If no input was received (i.e. the UI was terminated prematurely), then quit!
    if dialog.selections is None: quit()

    # Get the user's input from the dialog.
    selections: Selections = dialog.selections
    dataSetDirectory = selections.getFilePaths()[0]

    groupCohorts(dataSetDirectory)
def main():

    #Create the Tkinter UI
    dialog = TkinterDialog(workingDirectory=getDataDirectory())
    dialog.createMultipleFileSelector("CPD Files:", 0, "CPD_data.bed",
                                      ("Bed Files", ".bed"))
    dialog.createMultipleFileSelector("Deamination Files:", 1,
                                      "deamination_data.bed",
                                      ("Bed Files", ".bed"))
    dialog.createFileSelector("Genome Fasta File:", 2, ("Fasta File", ".fa"))

    # Run the UI
    dialog.mainloop()

    # If no input was received (i.e. the UI was terminated prematurely), then quit!
    if dialog.selections is None: quit()

    parseDeaminationData(dialog.selections.getFilePathGroups()[0],
                         dialog.selections.getFilePathGroups()[1],
                         dialog.selections.getIndividualFilePaths()[0])
def main():

    # Create the Tkinter UI
    dialog = TkinterDialog(workingDirectory=getDataDirectory())
    dialog.createFileSelector("Original Nucleosome Map Directory:",
                              0,
                              directory=True)
    dialog.createMultipleFileSelector("Stratifying Feature Ranges:", 1,
                                      "stratifying_feature_ranges.narrowPeak",
                                      ("Bed Files", ".bed"),
                                      ("Narrow Peak File", ".narrowPeak"))

    # Run the UI
    dialog.mainloop()

    # If no input was received (i.e. the UI was terminated prematurely), then quit!
    if dialog.selections is None: quit()

    stratifyNucleosomeMap(dialog.selections.getIndividualFilePaths()[0],
                          dialog.selections.getFilePathGroups()[0])
def main():

    #Create the Tkinter UI
    dialog = TkinterDialog(workingDirectory=os.path.dirname(__file__))
    dialog.createMultipleFileSelector("Genome Feature Files:", 0,
                                      DataTypeStr.mutations + ".bed",
                                      ("Bed Files", ".bed"))
    dialog.createFileSelector("Chromosome Sizes File:", 1,
                              ("Text File", ".txt"))
    dialog.createDropdown("Bin Size (bp):", 2, 0,
                          ("1000", "10000", "100000", "1000000"))

    # Run the UI
    dialog.mainloop()

    # If no input was received (i.e. the UI was terminated prematurely), then quit!
    if dialog.selections is None: quit()

    binAcrossGenome(dialog.selections.getFilePathGroups()[0],
                    dialog.selections.getIndividualFilePaths()[0],
                    int(dialog.selections.getDropdownSelections()[0]))
def main():

    # Create the Tkinter UI
    dialog = TkinterDialog(workingDirectory=getDataDirectory())
    dialog.createMultipleFileSelector("Quartile Files:", 0, "quartile.tsv",
                                      ("Tab Separated Files", ".tsv"))
    dialog.createFileSelector("Nucleosome Directory:", 1, directory=True)
    dialog.createDropdown("Stratification Type", 2, 0, ["h1 density", "other"])
    dialog.createCheckbox("Sloppy Copy?", 3, 0)

    # Run the UI
    dialog.mainloop()

    # If no input was received (i.e. the UI was terminated prematurely), then quit!
    if dialog.selections is None: quit()

    getQuartileNucleosomePositions(
        dialog.selections.getFilePathGroups()[0],
        dialog.selections.getIndividualFilePaths()[0],
        dialog.selections.getDropdownSelections()[0].replace(' ', '_'),
        dialog.selections.getToggleStates()[0])
def main():

    # Create the Tkinter UI
    dialog = TkinterDialog(workingDirectory=getDataDirectory())
    dialog.createMultipleFileSelector("Genome Feature Positions Files:", 0,
                                      "context_mutations.bed",
                                      ("Bed Files", ".bed"))
    dialog.createFileSelector("Nucleosome Dyad Center Positions:", 1,
                              ("Bed Files", ".bed"))
    dialog.createCheckbox("Only Count Linker", 2, 0)

    # Run the UI
    dialog.mainloop()

    # If no input was received (i.e. the UI was terminated prematurely), then quit!
    if dialog.selections is None: quit()

    countFeaturesAboutNucleosomes(
        dialog.selections.getFilePathGroups()[0],
        dialog.selections.getIndividualFilePaths()[0],
        dialog.selections.getToggleStates()[0])
def main():

    #Create the Tkinter UI
    dialog = TkinterDialog(workingDirectory=os.path.dirname(__file__))
    dialog.createFileSelector("Chromatin Domains File:", 0,
                              ("Bed Files", ".bed"))

    binnerTypeDS = dialog.createDynamicSelector(1, 0)
    binnerTypeDS.initDropdownController("Bins are...",
                                        ("Regular", "Specific Ranges"))
    regularBinsDialog = binnerTypeDS.initDisplay("Regular", "Regular")
    specificRangeBinsDialog = binnerTypeDS.initDisplay("Specific Ranges",
                                                       "Specific Ranges")

    regularBinsDialog.createFileSelector("Chromosome Sizes File:", 0,
                                         ("Text File", ".txt"))
    regularBinsDialog.createDropdown("Bin Size (bp):", 1, 0,
                                     ("1000", "10000", "100000", "1000000"))

    specificRangeBinsDialog.createFileSelector("Ranges to bin:", 0,
                                               ("Bed File", ".bed"))

    binnerTypeDS.initDisplayState()

    # Run the UI
    dialog.mainloop()

    # If no input was received (i.e. the UI was terminated prematurely), then quit!
    if dialog.selections is None: quit()

    if binnerTypeDS.getControllerVar() == "Regular":
        determineRegularBinColors(
            dialog.selections.getIndividualFilePaths()[0],
            dialog.selections.getIndividualFilePaths("Regular")[0],
            int(dialog.selections.getDropdownSelections("Regular")[0]))
    elif binnerTypeDS.getControllerVar() == "Specific Ranges":
        determineSpecifiedBinColors(
            dialog.selections.getIndividualFilePaths()[0],
            dialog.selections.getIndividualFilePaths("Specific Ranges")[0])
def main():

    #Create the Tkinter UI
    dialog = TkinterDialog(workingDirectory=getDataDirectory())
    dialog.createMultipleFileSelector("Mutation Files:", 0,
                                      DataTypeStr.mutations + ".bed",
                                      ("Bed Files", ".bed"))
    dialog.createFileSelector("Domain Range File:", 1, ("Bed File", ".bed"))

    # Run the UI
    dialog.mainloop()

    # If no input was received (i.e. the UI was terminated prematurely), then quit!
    if dialog.selections is None: quit()

    # Get the user's input from the dialog.
    selections: Selections = dialog.selections
    mutationFilePaths = selections.getFilePathGroups()[
        0]  # A list of mutation file paths
    domainRangesFilePath = selections.getIndividualFilePaths()[
        0]  # The gene positions file path

    separateByChromatinRegions(mutationFilePaths, domainRangesFilePath)
def main():

    # Create the Tkinter UI
    dialog = TkinterDialog(workingDirectory=getDataDirectory())
    dialog.createFileSelector("Bed Mutation Data:", 0, ("Bed Files", ".bed"))
    dialog.createFileSelector("TFBS Positions:", 1, ("Bed Files", ".bed"))
    dialog.createFileSelector("Output File:",
                              2, ("TSV Files", ".tsv"),
                              newFile=True)

    # Run the UI
    dialog.mainloop()

    # If no input was received (i.e. the UI was terminated prematurely), then quit!
    if dialog.selections is None: quit()

    recordMutationsInTFBSs(dialog.selections.getIndividualFilePaths()[0],
                           dialog.selections.getIndividualFilePaths()[1],
                           dialog.selections.getIndividualFilePaths()[2])
示例#22
0
        xRSeqOutputFilePaths.append(xRSeqInputDataPipeline.generateLesionsBedOutputFile())

    # Send the output files to the custom bed parser.
    parseCustomBed(xRSeqOutputFilePaths, genomeFilePath, False, False, False)
 

if __name__ == "__main__":

    # Create the Tkinter UI
    dialog = TkinterDialog(workingDirectory=getDataDirectory())
    dialog.createMultipleFileSelector("XR-seq bigwig data (plus strand):",0,
                                      "+.bigWig",("BigWig Files",".bigWig"))
    dialog.createMultipleFileSelector("XR-seq bed data (alternative to bigwig):",1,"aligned_reads.bed",
                                      ("Bed Files",".bed"), additionalFileEndings=("rep1.bed","rep2.bed"))

    dialog.createFileSelector("Lesion Call Parameter File:", 2, ("Tab Seperated Values",".tsv"))

    dialog.createFileSelector("Genome Fasta File:",3,("Fasta Files",".fa"))

    # Run the UI
    dialog.mainloop()

    # If no input was received (i.e. the UI was terminated prematurely), then quit!
    if dialog.selections is None: quit()

    # Get the user's input from the dialog.
    selections: Selections = dialog.selections
    xRSeqBigWigPlusReadsFilePaths: List[str] = list(selections.getFilePathGroups())[0]
    xRSeqBedReadsFilePaths: List[str] = list(selections.getFilePathGroups())[1]
    callParamsFilePath = selections.getIndividualFilePaths()[0]
    genomeFilePath = selections.getIndividualFilePaths()[1]
示例#23
0
    # Write the stored mutations to the new omissions file.
    print("Writing to new file: ", filteredFilename)
    with open(filteredFilePath, 'w') as filteredFile:
        filteredFile.writelines(mutationsToKeep)


# Whitespace for AeStHeTiC pUrPoSeS
print()

# Create the list of mutations that can be omitted.
mutations = ("C>A", "C>G", "C>T", "T>A", "T>C", "T>G")

#Create the Tkinter UI
dialog = TkinterDialog(workingDirectory=getDataDirectory())
dialog.createFileSelector("Bed Mutation File:", 0, ("Bed Files", ".bed"))
# DEPRECATED: dialog.createDropdown("Mutation to omit:",1,0,options=mutations)
dialog.createLabel("Mutations:", 1, 0)
for i, mutation in enumerate(mutations):
    dialog.createCheckbox(mutation, 2 + int(i / 4), i % 4)
dialog.createLabel("Actions:", 4, 0)
dialog.createCheckbox("Omit selected mutations", 5, 0, 2)
dialog.createCheckbox("Keep selected mutations and omit others", 5, 2, 2)
dialog.createCheckbox("Create one file for each selected mutation", 6, 0, 2)
dialog.createReturnButton(7, 0, 2)
dialog.createQuitButton(7, 2, 2)

# Run the UI
dialog.mainloop()

# If no input was received (i.e. the UI was terminated prematurely), then quit!
        # Add the output file to the list.
        outputBedFilePaths.append(outputBedFilePath)

    # Pass the data to the custome bed parser.
    print("\nPassing data to custom bed parser.\n")
    parseCustomBed(outputBedFilePaths, genomeFilePath, nucPosFilePath, False,
                   False, False)


if __name__ == "__main__":

    #Create the Tkinter UI
    dialog = TkinterDialog(workingDirectory=getDataDirectory())
    dialog.createMultipleFileSelector("Input Files:", 0, "alexandrov.txt",
                                      ("text files", ".txt"))
    dialog.createFileSelector("Genome Fasta File:", 1, ("Fasta Files", ".fa"))
    dialog.createFileSelector("Strongly Positioned Nucleosome File:", 2,
                              ("Bed Files", ".bed"))

    # Run the UI
    dialog.mainloop()

    # If no input was received (i.e. the UI was terminated prematurely), then quit!
    if dialog.selections is None: quit()

    # Get the user's input from the dialog.
    selections: Selections = dialog.selections
    bedInputFilePaths = list(selections.getFilePathGroups())[0]
    genomeFilePath = list(selections.getIndividualFilePaths())[0]
    nucPosFilePath = list(selections.getIndividualFilePaths())[1]
示例#25
0
                    customBedOutputFile.write('\t'.join(choppedUpLine[:6]) +
                                              '\n')

    # Pass the generated files to the custom bed parser.
    parseCustomBed(customBedOutputFilePaths, genomeFilePath, False, False,
                   False, False)


if __name__ == "__main__":

    # Create the Tkinter UI
    dialog = TkinterDialog(workingDirectory=getDataDirectory())
    dialog.createMultipleFileSelector("Standard Bed Data:",
                                      0,
                                      "dipy.bed", ("Bed Files", ".bed"),
                                      additionalFileEndings=("TA.bed", ))
    dialog.createFileSelector("Genome Fasta File:", 1, ("Fasta Files", ".fa"))

    # Run the UI
    dialog.mainloop()

    # If no input was received (i.e. the UI was terminated prematurely), then quit!
    if dialog.selections is None: quit()

    # Get the user's input from the dialog.
    selections: Selections = dialog.selections
    standardBedFilePaths = list(selections.getFilePathGroups())[0]
    genomeFilePath = list(selections.getIndividualFilePaths())[0]

    parseStandardBed(standardBedFilePaths, genomeFilePath)
def main():

    #Create the Tkinter UI
    dialog = TkinterDialog(workingDirectory=getDataDirectory(),
                           scrollable=True)
    dialog.createMultipleFileSelector(
        "Nucleosome Mutation Counts files:",
        0,
        DataTypeStr.normNucCounts + ".tsv",
        ("Tab Seperated Values Files", ".tsv"),
        additionalFileEndings=(DataTypeStr.rawNucCounts + ".tsv", ))
    dialog.createFileSelector("Output File",
                              1, ("R Data File", ".rda"),
                              ("Tab Separated Values File", ".tsv"),
                              newFile=True)

    dialog.createCheckbox(
        "Use expected periodicity from nucleosome maps instead of peak periodicity",
        2, 0)
    dialog.createCheckbox(
        "Align both DNA strands to run 5' to 3' before running the analysis",
        3, 0)
    dialog.createLabel('', 4, 0)

    mainGroupSearchRefine = dialog.createDynamicSelector(5, 0)
    mainGroupSearchRefine.initCheckboxController("Filter counts files")
    mainGroupSearchRefine.initDisplay(True).createNucMutGroupSubDialog(
        "MainGroup", 0)
    mainGroupSearchRefine.initDisplayState()

    periodicityComparison = dialog.createDynamicSelector(6, 0)
    periodicityComparison.initCheckboxController(
        "Compare periodicities between two groups")
    periodicityGroupType = periodicityComparison.initDisplay(
        True, "periodicityGroupType")

    periodicityGroupTypeSelector = periodicityGroupType.createDynamicSelector(
        0, 0)
    periodicityGroupTypeSelector.initDropdownController(
        "Compare periodicities...",
        ("Within original selection", "Against a newly selected group"))
    periodicityGroupsWithin = periodicityGroupTypeSelector.initDisplay(
        "Within original selection", "withinGroup")
    secondaryPeriodicityGroup = periodicityGroupTypeSelector.initDisplay(
        "Against a newly selected group", "secondaryGroupFilePaths")

    # Create two "sub-dialogs" for each of the groups, allowing the user to specify the make-up of that group for the "withinGroup" dialog.
    for i, dialogID in enumerate(("Sub-Group 1", "Sub-Group 2")):
        periodicityGroupsWithin.createNucMutGroupSubDialog(dialogID, i + 1)

    # Create one multiple file selector and one sub-dialog for the "secondaryGroup" dialog
    secondaryPeriodicityGroup.createMultipleFileSelector(
        "Nucleosome Mutation Counts files:",
        0,
        DataTypeStr.normNucCounts + ".tsv",
        ("Tab Seperated Values Files", ".tsv"),
        additionalFileEndings=(DataTypeStr.rawNucCounts + ".tsv", ))

    secondaryPeriodicityGroupSearchRefine = secondaryPeriodicityGroup.createDynamicSelector(
        2, 0)
    secondaryPeriodicityGroupSearchRefine.initCheckboxController(
        "Filter counts files")
    secondaryPeriodicityGroupSearchRefine.initDisplay(
        True).createNucMutGroupSubDialog("Secondary Group", 0)
    secondaryPeriodicityGroupSearchRefine.initDisplayState()

    periodicityGroupTypeSelector.initDisplayState()
    periodicityComparison.initDisplayState()

    # Run the UI
    dialog.mainloop()

    # If no input was received (i.e. the UI was terminated prematurely), then quit!
    if dialog.selections is None: quit()

    # Get the user's input from the dialog.
    selections: Selections = dialog.selections
    nucleosomeMutationCountsFilePaths = selections.getFilePathGroups()[0]
    if periodicityGroupTypeSelector.getControllerVar(
    ) == "Against a newly selected group":
        secondaryNucMutCountsFilePaths = selections.getFilePathGroups(
            "secondaryGroupFilePaths")[0]
    outputFilePath = list(selections.getIndividualFilePaths())[0]

    # Get the default periodicity value, testing the string to see if it is a valid float, if necessary.
    overridePeakPeriodWithExpected = bool(selections.getToggleStates()[0])
    alignStrands = bool(selections.getToggleStates()[1])

    # If group comparisons were requested, get the respective groups.
    filePathGroups: List[list] = list()
    for i in range(3):
        filePathGroups.append(list())

    groups = ["MainGroup"]
    if periodicityComparison.getControllerVar():
        if periodicityGroupTypeSelector.getControllerVar(
        ) == "Within original selection":
            groups += ("Sub-Group 1", "Sub-Group 2")
        else:
            groups.append("Secondary Group")

    for i, dialogID in enumerate(groups):

        # Was filtering even requested for the main group?
        if i == 0 and not mainGroupSearchRefine.getControllerVar():
            filePathGroups[0] = nucleosomeMutationCountsFilePaths
            continue

        # If we are examining the secondary group, check to see if filtering was even requested.
        if dialogID == "Secondary Group" and not secondaryPeriodicityGroupSearchRefine.getControllerVar(
        ):
            assert i == 1, "Secondary group encountered on unexpected iteration of for loop: " + str(
                i)
            filePathGroups[2] = secondaryNucMutCountsFilePaths
            filePathGroups[1] = filePathGroups[0].copy()
            filePathGroups[0] += filePathGroups[2]
            continue

        # Determine what normalization methods were requested
        normalizationMethods = list()
        normalizationSelections = selections.getToggleStates(dialogID)[:5]
        if normalizationSelections[0]: normalizationMethods += (1, 2)
        if normalizationSelections[1]: normalizationMethods += (3, 4)
        if normalizationSelections[2]: normalizationMethods += (5, 6)
        if normalizationSelections[3]: normalizationMethods.append(-1)
        if normalizationSelections[4]: normalizationMethods.append(0)

        # Determine what microsatellite stability states were requested.
        acceptableMSCohorts = dict()
        if selections.getToggleStates(dialogID)[7]:
            MSSelection = selections.getDropdownSelections(dialogID + "MS")[0]
            if MSSelection == "MSS": acceptableMSCohorts["MSS"] = None
            elif MSSelection == "MSI": acceptableMSCohorts["MSI"] = None
            else:
                acceptableMSCohorts["MSS"] = None
                acceptableMSCohorts["MSI"] = None

        # Determine what mutation signature states were requested.
        acceptableMutSigCohorts = dict()
        if selections.getToggleStates(dialogID)[8]:
            with open(
                    selections.getIndividualFilePaths(dialogID + "MutSig")[0],
                    'r') as mutSigsFile:
                for line in mutSigsFile:
                    acceptableMutSigCohorts["mut_sig_" + line.strip()] = None

        # Check for custom cohort input
        acceptableCustomCohorts = dict()
        if selections.getToggleStates(dialogID)[9]:

            customCohortsFilePath = selections.getIndividualFilePaths(
                dialogID + "CustomCohorts")[0]
            with open(customCohortsFilePath, 'r') as customCohortsFile:

                for line in customCohortsFile:
                    acceptableCustomCohorts[line.strip()] = None

        # Check for nucleosome map input
        acceptableNucleosomeMaps = dict()
        if selections.getToggleStates(dialogID)[10]:

            acceptableNucMapsFilePath = selections.getIndividualFilePaths(
                dialogID + "NucleosomeMaps")[0]
            with open(acceptableNucMapsFilePath, 'r') as acceptableNucMapsFile:

                for line in acceptableNucMapsFile:
                    acceptableNucleosomeMaps[line.strip()] = None

        # Get the file paths associated with the given parameters.
        if dialogID != "Secondary Group":
            filePathGroups[i] += getFilePathGroup(
                nucleosomeMutationCountsFilePaths, normalizationMethods,
                selections.getToggleStates(dialogID)[5],
                selections.getToggleStates(dialogID)[6], acceptableMSCohorts,
                acceptableMutSigCohorts, acceptableCustomCohorts,
                acceptableNucleosomeMaps)
        else:
            assert i == 1, "Secondary group encountered on unexpected iteration of for loop: " + str(
                i)
            filePathGroups[2] += getFilePathGroup(
                secondaryNucMutCountsFilePaths, normalizationMethods,
                selections.getToggleStates(dialogID)[5],
                selections.getToggleStates(dialogID)[6], acceptableMSCohorts,
                acceptableMutSigCohorts, acceptableCustomCohorts,
                acceptableNucleosomeMaps)
            filePathGroups[1] = filePathGroups[0].copy()
            filePathGroups[0] += filePathGroups[2]

        #If this is the first pass through the loop, set the file paths list to the newly filtered list.
        if i == 0: nucleosomeMutationCountsFilePaths = filePathGroups[0]

    runNucleosomeMutationAnalysis(filePathGroups[0], outputFilePath,
                                  overridePeakPeriodWithExpected, alignStrands,
                                  filePathGroups[1], filePathGroups[2])