Example #1
0
def main():

    # Create the Tkinter dialog.
    dialog = TkinterDialog(workingDirectory=getDataDirectory())
    dialog.createMultipleFileSelector(
        "Bed Mutation File:", 0, "singlenuc_" + DataTypeStr.mutations + ".bed",
        ("Bed Files", ".bed"))
    dialog.createDropdown("Expansion Context", 1, 0,
                          ("Trinuc/Quadrunuc", "Pentanuc/Hexanuc"))

    # 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
    inputBedFilePaths = list(selections.getFilePathGroups())[
        0]  # A list of paths to original bed mutation files
    expansionContext = list(selections.getDropdownSelections())[
        0]  # What context the file should be expanded to.

    if expansionContext == "Trinuc/Quadrunuc":
        expansionContextNum = 3
    elif expansionContext == "Pentanuc/Hexanuc":
        expansionContextNum = 5
    else:
        raise ValueError("Matching strings is hard.")

    expandContext(inputBedFilePaths, expansionContextNum)
Example #2
0
def main():

    #Create the Tkinter UI
    dialog = TkinterDialog(workingDirectory=getDataDirectory())
    dialog.createMultipleFileSelector("Bed Mutation Files:", 0,
                                      DataTypeStr.mutations + ".bed",
                                      ("Bed Files", ".bed"))
    dialog.createDropdown(
        "Background Context", 1, 0,
        ("Singlenuc/Dinuc", "Trinuc/Quadrunuc", "Pentanuc/Hexanuc"))

    # 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 = list(selections.getFilePathGroups())[
        0]  # A list of paths to the bed mutation files
    backgroundContext: str = list(selections.getDropdownSelections())[
        0]  # What context should be used to generate the background.

    # Convert background context to int
    if backgroundContext == "Singlenuc/Dinuc":
        backgroundContextNum = 1
    elif backgroundContext == "Trinuc/Quadrunuc":
        backgroundContextNum = 3
    elif backgroundContext == "Pentanuc/Hexanuc":
        backgroundContextNum = 5
    else:
        raise ValueError("Matching strings is hard.")

    generateMutationBackground(mutationFilePaths, backgroundContextNum)
def main():

    with TkinterDialog(workingDirectory = getDataDirectory()) as dialog:
        dialog.createMultipleFileSelector("Sam Files:", 0, ".sam", ("Sam Files",(".sam.gz",".sam")),
                                          additionalFileEndings = ".sam.gz")

    trimmedFastqToSam(dialog.selections.getFilePathGroups()[0])
def main():

    #Create the Tkinter UI
    dialog = TkinterDialog(workingDirectory=getDataDirectory())
    dialog.createMultipleFileSelector(
        "Background Nucleosome Mutation Counts Files:", 0,
        DataTypeStr.nucMutBackground + ".tsv",
        ("Tab Seperated Values Files", ".tsv"))

    customBackgroundSelector = dialog.createDynamicSelector(1, 0)
    customBackgroundSelector.initCheckboxController(
        "Include files with another data set as custom background.")
    customBackgroundFileSelector = customBackgroundSelector.initDisplay(
        True, "customBackground")
    customBackgroundFileSelector.createMultipleFileSelector(
        "Raw nucleosome counts to be normalized", 0,
        DataTypeStr.rawNucCounts + ".tsv", ("TSV Files", ".tsv"))
    customBackgroundFileSelector.createFileSelector(
        "Data Directory for nucleosome counts to be used as background",
        1,
        directory=True)
    customBackgroundSelector.initDisplayState()

    dialog.createCheckbox(
        "Include alternative scaling factor indepedent of nucleosome map.", 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.
    selections: Selections = dialog.selections
    backgroundCountsFilePaths = selections.getFilePathGroups()[
        0]  # A list of background mutation counts file paths

    if customBackgroundSelector.getControllerVar():
        customRawCountsFilePaths = selections.getFilePathGroups(
            "customBackground")[0]
        customBackgroundCountsDir = selections.getIndividualFilePaths(
            "customBackground")[0]
    else:
        customRawCountsFilePaths = None
        customBackgroundCountsDir = None

    includeAlternativeScaling = selections.getToggleStates()[0]

    normalizeCounts(backgroundCountsFilePaths, customRawCountsFilePaths,
                    customBackgroundCountsDir, includeAlternativeScaling)
def main():

    # Create a simple dialog for selecting the gene designation files.
    with TkinterDialog(workingDirectory=getDataDirectory()) as dialog:
        dialog.createMultipleFileSelector("Bed formatted reads:", 0, ".bed", 
                                          ("Bed Files", ".bed"))

    trimDuplicateReads(dialog.selections.getFilePathGroups()[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])
def main():

    with TkinterDialog(workingDirectory=getDataDirectory()) as dialog:
        dialog.createMultipleFileSelector("Raw fastq reads:", 0, ".fastq.gz",
                                          ("Gzipped fastq Files", ".fastq.gz"))
        dialog.createFileSelector("Adaptor Sequences:", 1,
                                  ("Fasta Files", ".fa"))

    trimAdaptorSequences(dialog.selections.getFilePathGroups()[0],
                         dialog.selections.getIndividualFilePaths()[0])
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])
Example #9
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.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=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("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])
Example #13
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])
Example #14
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
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)
Example #16
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])
Example #17
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])
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], )
def main():

    with TkinterDialog(workingDirectory = getDataDirectory()) as dialog:
        dialog.createMultipleFileSelector("Trimmed fastq reads:", 0, "trimmed.fastq.gz", 
                                          ("Gzipped fastq Files", ".fastq.gz"))
        dialog.createFileSelector("Bowtie2 Index File (Any):", 1, ("Bowtie2 Index File", ".bt2"))

        with dialog.createDynamicSelector(2, 0) as bowtie2BinaryDS:
            bowtie2BinaryDS.initCheckboxController("Choose alternative bowtie2 binary")
            bowtie2BinarySelector = bowtie2BinaryDS.initDisplay(True, selectionsID = "bowtieBinary")
            bowtie2BinarySelector.createFileSelector("bowtie2 binary:", 0, ("Any File", "*"))

        dialog.createDropdown("Number of CPU threads to use:", 3, 0, ('1', '2', '3', '4'))

        with dialog.createDynamicSelector(4, 0) as customArgsDS:
            customArgsDS.initDropdownController("Custom Bowtie2 Arguments:", ("None", "From File", "Direct Input"))
            customArgsDS.initDisplay("From File", selectionsID = "customArgs").createFileSelector(
                "Custom Arguments File:", 0, ("Text File", ".txt")
            )
            customArgsDS.initDisplay("Direct Input", selectionsID = "customArgs").createTextField(
                "Custom Arguments:", 0, 0, defaultText = ''
            )

    fastqFilePaths = dialog.selections.getFilePathGroups()[0]

    bowtie2IndexBasenamePath: str = dialog.selections.getIndividualFilePaths()[0]
    bowtie2IndexBasenamePath = bowtie2IndexBasenamePath.rsplit('.', 2)[0]
    if bowtie2IndexBasenamePath.endswith(".rev"): bowtie2IndexBasenamePath = bowtie2IndexBasenamePath.rsplit('.', 1)[0]

    if bowtie2BinaryDS.getControllerVar():
        bowtie2BinaryPath = dialog.selections.getIndividualFilePaths("bowtieBinary")[0]
    else: bowtie2BinaryPath = None

    threads = dialog.selections.getDropdownSelections()[0]
    
    if customArgsDS.getControllerVar() == "None":
        customBowtie2Arguments = ''
    elif customArgsDS.getControllerVar() == "From File":
        customBowtie2ArgsFilePath = dialog.selections.getIndividualFilePaths("customArgs")[0]
        with open(customBowtie2ArgsFilePath, 'r') as customBowtie2ArgsFile:
            customBowtie2Arguments = customBowtie2ArgsFile.readline().strip()
    elif customArgsDS.getControllerVar() == "Direct Input":
        customBowtie2Arguments = dialog.selections.getTextEntries("customArgs")[0]

    trimmedFastqToSam(fastqFilePaths, bowtie2IndexBasenamePath,
                      bowtie2BinaryPath, threads, customBowtie2Arguments)
def main():

    #Create the Tkinter UI
    dialog = TkinterDialog(workingDirectory=getDataDirectory())
    dialog.createMultipleFileSelector("Mutation Files:", 0,
                                      DataTypeStr.mutations + ".bed",
                                      ("Bed Files", ".bed"))
    dialog.createMultipleFileSelector("Binding Motifs Files:", 1,
                                      "binding_motifs.bed",
                                      ("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()

    countInBindingMotifs(dialog.selections.getFilePathGroups()[0],
                         dialog.selections.getFilePathGroups()[1])
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])
Example #22
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])
Example #23
0
def main():

    # Create the UI.
    with TkinterDialog(workingDirectory=getDataDirectory()) as dialog:
        dialog.createFileSelector("SRA run accession IDs:", 0,
                                  ("text file", ".txt"))
        with dialog.createDynamicSelector(1, 0) as namesDynSel:
            namesDynSel.initCheckboxController("Specify Custom Names:")
            namesDynSel.initDisplay(True, "namesFilePath").createFileSelector(
                "Names File:", 0, ("text file", ".txt"))

    # Retrieve values from user input.
    selections = dialog.selections
    if namesDynSel.getControllerVar():
        namesFilePath = selections.getIndividualFilePaths("namesFilePath")[0]
    else:
        namesFilePath = None

    sRA_ToFastq(selections.getIndividualFilePaths()[0], namesFilePath)
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=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():

    with TkinterDialog(workingDirectory = getDataDirectory()) as dialog:
        dialog.createMultipleFileSelector("Bed files of aligned data:", 0, "aligned_reads.bed", 
                                          ("Bed Files", ".bed"))
        dialog.createFileSelector("Genome fasta file (If bed files are provided)", 1,
                                  ("Fasta File", ".fa"))
        dialog.createMultipleFileSelector("Fasta files of aligned data:", 2, "aligned_reads.fa", 
                                          ("Fasta Files", ".fa"))
        dialog.createCheckbox("Count individual bases", 3, 0)
        dialog.createCheckbox("Count dipys", 3, 1)
        dialog.createCheckbox("Record second-most enriched positions", 4, 0)

    # Get the input for the findEnrichedIndices function
    bedFilePaths = dialog.selections.getFilePathGroups()[0]
    genomeFastaFilePath = dialog.selections.getIndividualFilePaths()[0]
    fastaFilePaths = dialog.selections.getFilePathGroups()[1]

    countIndividualBases = dialog.selections.getToggleStates()[0]
    countDipys = dialog.selections.getToggleStates()[1]
    getSecondPlace = dialog.selections.getToggleStates()[2]

    findEnrichedIndices(bedFilePaths, genomeFastaFilePath, fastaFilePaths,
                        countIndividualBases, countDipys, getSecondPlace)
Example #27
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("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 dialog.
    dialog = TkinterDialog(workingDirectory=getDataDirectory())
    dialog.createMultipleFileSelector("Bed Mutation Files:", 0,
                                      DataTypeStr.mutations + ".bed",
                                      ("Bed Files", ".bed"))

    dialog.createMultipleFileSelector("Nucleosome Map Files", 1,
                                      "nucleosome_map.bed",
                                      ("Bed Files", ".bed"))

    normalizationSelector = dialog.createDynamicSelector(2, 0)
    normalizationSelector.initDropdownController(
        "Normalization Method",
        ("No Normalization", "Singlenuc/Dinuc", "Trinuc/Quadrunuc",
         "Pentanuc/Hexanuc", "Custom Background"))
    customBackgroundFileSelector = normalizationSelector.initDisplay(
        "Custom Background", "customBackground")
    customBackgroundFileSelector.createFileSelector(
        "Custom Background Directory:",
        0, ("Bed Files", ".bed"),
        directory=True)
    customBackgroundFileSelector.createCheckbox("Generate Background now", 1,
                                                0)
    normalizationSelector.initDisplayState()

    dialog.createCheckbox(
        "Include alternative scaling factor indepedent of nucleosome map.", 3,
        0)
    dialog.createLabel('', 4, 0)

    selectNucleosomeDyadRadius = dialog.createDynamicSelector(5, 0)
    selectNucleosomeDyadRadius.initCheckboxController(
        "Run analysis with a single nucleosome dyad radius (73 bp)")
    linkerSelectionDialog = selectNucleosomeDyadRadius.initDisplay(
        1, "singleNuc")
    linkerSelectionDialog.createCheckbox(
        "Include 30 bp linker DNA on either side of single nucleosome dyad radius.",
        0, 0)
    selectNucleosomeDyadRadius.initDisplayState()

    dialog.createCheckbox("Count with a nucleosome group radius (1000 bp)", 6,
                          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
    mutationFilePaths = selections.getFilePathGroups()[
        0]  # A list of paths to bed mutation files
    nucleosomeMapNames = [
        getIsolatedParentDir(nucleosomeMapFile)
        for nucleosomeMapFile in selections.getFilePathGroups()[1]
    ]

    normalizationMethod = normalizationSelector.getControllerVar(
    )  # The normalization method to be used.
    if normalizationMethod == "Custom Background":
        customBackgroundDir = selections.getFilePaths("customBackground")[
            0]  # Where to find raw counts files to use as custom background
        generateCustomBackgroundNow = selections.getToggleStates(
            "customBackground"
        )[0]  # Whether or not to generate the custom background counts on the fly
    else:
        customBackgroundDir = None
        generateCustomBackgroundNow = False

    useSingleNucRadius = selectNucleosomeDyadRadius.getControllerVar(
    )  # Whether or not to generate data with a 73 bp single nuc dyad radius
    if useSingleNucRadius:
        includeLinker = selections.getToggleStates(
            "singleNuc"
        )[0]  # Whether or not to include 30 bp linker DNA in nucleosome dyad positions
    else:
        includeLinker = False
    useNucGroupRadius = selections.getToggleStates(
    )[1]  # Whether or not to generate data with a 1000 bp nuc group dyad radius
    includeAlternativeScaling = selections.getToggleStates()[
        0]  # Whether or not to include scaling independent of nucleosome map

    # If requested, generate the background counts file(s).
    if generateCustomBackgroundNow:
        generateCustomBackground(customBackgroundDir, nucleosomeMapNames,
                                 useSingleNucRadius, includeLinker,
                                 useNucGroupRadius)

    runAnalysisSuite(mutationFilePaths, nucleosomeMapNames,
                     normalizationMethod, customBackgroundDir,
                     useSingleNucRadius, includeLinker, useNucGroupRadius,
                     includeAlternativeScaling)
        xRSeqInputDataPipeline = XRSeqInputDataPipeline(inputDataFilePath, callParamsFilePath, genomeFilePath)

        print("Generating trimmed reads bed file...")
        xRSeqInputDataPipeline.generateTrimmedReads()

        print("Locating and writing lesion locations to final output file...")
        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()