Example #1
0
        parser = get_parser()  # start command line argument parser
        args = parser.parse_args()  # parse command line arguments
        globals().update(args.__dict__)
        start_time = time.time()
        # start timing function
        get_input_variables()
        database_v = int(database_v)
        allowed_mismatches = int(allowed_mismatches)
        directory = directory + '/'

        # hash PSM_DATA and define variables
        psm_hash = proBAM_input.get_PSM_hash(psm_file, decoy_annotation,
                                             validated_only)

        parse_results = proBAM_IDparser.parseID(psm_hash, species, database,
                                                decoy_annotation, database_v,
                                                three_frame_translation,
                                                pre_picked_annotation)
        annotation = parse_results[1]
        psm_hash = parse_results[0]
        transcript_hash = annotation[0]
        exon_hash = annotation[1]
        id_map = parse_results[2]

        # convert to SAM
        if conversion_mode != 'proBED':
            file = open_sam_file(directory, name)
            create_SAM_header(file, version, database, sorting_order,
                              database_v, species, command_line, psm_file,
                              comments)
            PSM2SAM(psm_hash, transcript_hash, exon_hash, decoy_annotation,
                    allowed_mismatches, file, rm_duplicates,
Example #2
0
def execute_proBAM(root):
    """
    :param root: window root
    :return:
    """
    root.config(cursor="watch")
    root.update()

    start_time = time.time()  # start timing function

    Label(text="console:", pady=5, width=70, background="#f2f2f2").grid(row=12, columnspan=2)
    std_text = ScrolledText.ScrolledText(root, height=20)
    std_text.grid(row=15, columnspan=2)

    sys.stdout = Std_redirector(std_text)
    sys.stderr = Std_redirector(std_text)
    sys.stdin = Std_redirector(std_text)

    root.update()
    # get and print arguments
    try:
        _print_arguments_()
        command_line = (
            "python proBAM.py --name "
            + str(name)
            + " --mismatches "
            + str(allowed_mismatches.get())
            + " --version "
            + str(database_v.get())
            + " --database "
            + str(database.get().upper())
            + " --species "
            + str(species.get())
            + " --file "
            + str(psm_file)
            + " --directory "
            + str(directory)
            + " --rm_duplicates "
            + str(rm_duplicates.get())
            + " --allow_decoys "
            + str(allow_decoys.get())
            + " --tri_frame_translation "
            + str(three_frame_translation.get() + " --pre_picked_annotation " + pre_picked_annotation)
        )
        print "\n"

        # hash PSM_DATA and define variables
        psm_hash = proBAM_input.get_PSM_hash(psm_file, decoy_annotation)
        parse_results = proBAM_IDparser.parseID(
            psm_hash,
            species.get().replace(" ", "_"),
            database.get().upper(),
            decoy_annotation,
            int(database_v.get()),
            three_frame_translation.get(),
            pre_picked_annotation,
        )

        annotation = parse_results[1]
        psm_hash = parse_results[0]
        transcript_hash = annotation[0]
        exon_hash = annotation[1]
        id_map = parse_results[2]

        # convert to SAM
        if probed == "N":
            file = proBAM.open_sam_file(directory, name.get())
            proBAM.create_SAM_header(
                file,
                version,
                database.get().upper(),
                sorting_order,
                database_v.get(),
                species.get(),
                command_line,
                psm_file,
                comments,
            )
            proBAM.PSM2SAM(
                psm_hash,
                transcript_hash,
                exon_hash,
                decoy_annotation,
                int(allowed_mismatches.get()),
                file,
                allow_decoys.get(),
                rm_duplicates.get(),
                three_frame_translation.get(),
                psm_file,
                id_map,
                root,
            )
            proBAM.compute_NH_XL(directory, name.get())
            proBAM.sam_2_bam(directory, name.get())
        else:
            file = proBAM_proBED.open_bed_file(directory, name.get())
            proBAM_proBED.create_BED_header(
                file,
                version,
                database.get().upper(),
                sorting_order.get(),
                database_v.get(),
                species.get(),
                command_line,
                psm_file,
                comments,
            )
            proBAM_proBED.PSM2BED(
                psm_hash,
                transcript_hash,
                exon_hash,
                decoy_annotation,
                allowed_mismatches.get(),
                file,
                allow_decoys.get(),
                rm_duplicates.get(),
                three_frame_translation.get(),
                psm_file,
                id_map,
            )

        root.config(cursor="")
        print ("proBAM conversion succesful")
        print ("%f seconds" % (time.time() - start_time))  # output script run time
    except Exception, e:
        print "ERROR:" + str(
            e
        ) + "\n" "Please check if all parameters were supplied correctly, if the error keeps occuring contact " 'the developers at "https://github.com/Biobix/proBAMconvert/issues" ' "and provide the file to be processed along with the following error message:"
        print e
        root.config(cursor="")
Example #3
0
def execute_proBAM(root):
    '''
    :param root: window root
    :return:
    '''
    root.config(cursor="watch")
    root.update()

    start_time = time.time()  # start timing function

    Label(text='console:', pady=5, width=70,
          background="#f2f2f2").grid(row=12, columnspan=2)
    std_text = ScrolledText.ScrolledText(root, height=20)
    std_text.grid(row=15, columnspan=2)

    sys.stdout = Std_redirector(std_text)
    sys.stderr = Std_redirector(std_text)
    sys.stdin = Std_redirector(std_text)

    root.update()
    # get and print arguments
    try:
        _print_arguments_()
        command_line = "python proBAM.py --name " + str(name.get()) + " --mismatches " + str(
            allowed_mismatches.get()) + " --version " + str(database_v.get()) \
                       + " --database " + str(database.get().upper()) + " --species " + str(species.get().replace(' ','_')) + " --file " + str(psm_file) + \
                       " --directory " + str(directory) + " --rm_duplicates " + str(rm_duplicates.get()) + \
                       " --tri_frame_translation " + \
                       str(three_frame_translation+" --pre_picked_annotation "+pre_picked_annotation) +\
                       " --include_unmapped "+str(include_unmapped)
        print '\n'

        # hash PSM_DATA and define variables
        psm_hash = proBAM_input.get_PSM_hash(psm_file, decoy_annotation)
        parse_results = proBAM_IDparser.parseID(
            psm_hash,
            species.get().replace(' ', '_'),
            database.get().upper(), decoy_annotation, int(database_v.get()),
            three_frame_translation, pre_picked_annotation)

        annotation = parse_results[1]
        psm_hash = parse_results[0]
        transcript_hash = annotation[0]
        exon_hash = annotation[1]
        id_map = parse_results[2]

        # convert to SAM
        if conversion_mode.get() != 'proBED':
            file = proBAM.open_sam_file(directory, name.get())
            proBAM.create_SAM_header(file, version,
                                     database.get().upper(), sorting_order,
                                     database_v.get(),
                                     species.get().replace(' ', '_'),
                                     command_line, psm_file, comments)
            proBAM.PSM2SAM(psm_hash, transcript_hash,
                           exon_hash, decoy_annotation,
                           int(allowed_mismatches.get()), file,
                           rm_duplicates.get(), three_frame_translation,
                           psm_file, id_map, root)
            proBAM.compute_NH_XL(directory, name.get(), include_unmapped,
                                 conversion_mode)
            proBAM.sam_2_bam(directory, name.get())
        else:
            file = proBAM_proBED.open_bed_file(directory, name.get())
            proBAM_proBED.create_BED_header(file,
                                            database.get().upper(),
                                            database_v.get(), command_line,
                                            psm_file, comments)
            proBAM_proBED.PSM2BED(psm_hash, transcript_hash, exon_hash,
                                  decoy_annotation,
                                  int(allowed_mismatches.get()), file,
                                  rm_duplicates.get(), three_frame_translation,
                                  id_map, root, database_v.get(),
                                  species.get().replace(' ', '_'))

        root.config(cursor="")
        print("proBAM conversion succesful")
        print("%f seconds" % (time.time() - start_time)
              )  # output script run time
    except Exception, e:
        print "ERROR:"+str(e)+"\n" \
              "Please check if all parameters were supplied correctly, if the error keeps occuring contact " \
              "the developers at \"https://github.com/Biobix/proBAMconvert/issues\" " \
              "and provide the file to be processed along with the following error message:"
        print e
        root.config(cursor="")
Example #4
0
    line=line.split("\t")
    key=line[19]+"_"+line[0]
    return key

####################
### MAIN PROGRAM ###
####################

if __name__=='__main__':
    #get_input_variables()
    start_time = time.time()
    # start timing function

    # hash PSM_DATA and define variables
    psm_hash=proBAM_input.get_PSM_hash(psm_file,decoy_annotation)
    parse_results=proBAM_IDparser.parseID(psm_hash,species,database,decoy_annotation,database_v,three_frame_translation
                                          ,pre_picked_annotation)

    annotation=parse_results[1]
    psm_hash=parse_results[0]
    transcript_hash=annotation[0]
    exon_hash=annotation[1]
    id_map=parse_results[2]

    # convert to SAM
    if probed=='N':
        file = open_sam_file(directory, name)
        create_SAM_header(file, version, database, sorting_order, database_v, species, command_line, psm_file, comments)
        PSM2SAM(psm_hash,transcript_hash,exon_hash,decoy_annotation,allowed_mismatches,file,allow_decoys,rm_duplicates,
                three_frame_translation,psm_file,id_map,None)
        compute_NH_XL(directory, name)
        sam_2_bam(directory, name)