Ejemplo n.º 1
0
def ali_needleFasta(fic1,fic2,outfile = "", gop = 10, gep = 0.5):
    # par defaut, le fichier de sortie est place dans le repertoire du fichier 1
    if outfile == "":
        rep = files.get_filepath(fic1)
        name = "%s-%s.needle" % (files.get_name(fic1).lower(),files.get_name(fic2).lower()) 
        outfile = "%s/%s" % (rep, name)
        
    cmd = "%s -asequence %s -bsequence %s -gapopen %s -gapextend %s -outfile %s -aformat3 fasta" % (System.NEEDLE,fic1,fic2,gop,gep,outfile)
    os.system(cmd)
Ejemplo n.º 2
0
def lanceReverseComplementALaChaine():
    for fqFile in glob.glob("/Volumes/BioSan/Users/friedrich/Reads/BGI/20130726/CleanData/CBS4104/*.fq"):
        repOut = files.get_filepath(fqFile).replace("CleanData/", "CleanData/ReverseComplement/")
        #repOut = rep
        if not os.path.isdir(repOut):
            os.mkdir(repOut)
            cmd = "chmod 777 %s" % repOut
            os.system(cmd)
        outfile = "%s/%s.fq" % (repOut, files.get_name(fqFile))
        reverseComplement(fqFile, outfile)
Ejemplo n.º 3
0
def ali_water(fic1,fic2,outfile = "", gop = 10, gep = 0.5):
    # par defaut, le fichier de sortie est place dans le repertoire du fichier 1
    if outfile == "":
        rep = files.get_filepath(fic1)
        name = "%s-%s.water" % (files.get_name(fic1).lower(),files.get_name(fic2).lower()) 
        outfile = "%s/%s" % (rep, name)
        
    cmd = "%s -asequence %s -bsequence %s -gapopen %s -gapextend %s -outfile %s" % (System.WATER,fic1,fic2,gop,gep,outfile)
    #print cmd
    os.system(cmd)
Ejemplo n.º 4
0
def createSVConfFile(confFile, strain, bamFile, readLen, mapLen, mu, sigma):
    outdir = files.get_filepath(confFile)
    of = open(confFile, "w")
    of.write(
        "<general>\ninput_format = bam\nsv_type = all\nmates_orientation=FR\nread1_length=%s\nread2_length=%s\nmates_file=%s\ncmap_file=%s\noutput_dir=%s\n</general>\n\n" % (
        readLen, readLen, bamFile, mapLen, outdir))
    of.write("<detection>\nwindow_size=5000\nstep_length=2000\n</detection>\n\n")
    of.write(
        "<filtering>\nstrand_filtering=1\norder_filtering=1\ninsert_size_filtering=1\nnb_pairs_threshold=10\nnb_pairs_order_threshold=5\nindel_sigma_threshold=10\ndup_sigma_threshold=10\nsingleton_sigma_threshold=10\nfinal_score_threshold=0.9\nmu_length=%s\nsigma_length=%s\n</filtering>\n\n" % (
        mu, sigma))
    of.close()
Ejemplo n.º 5
0
def ali_stretcherFasta(fic1,fic2,outfile = ""):
    # par defaut, le fichier de sortie est place dans le repertoire du fichier 1
    if outfile == "":
        rep = files.get_filepath(fic1)
        name = "%s-%s.stretcher" % (files.get_name(fic1).lower(),files.get_name(fic2).lower()) 
        outfile = "%s/%s" % (rep, name)
    if not os.path.isfile(outfile):    
        cmd = "%s -asequence %s -bsequence %s -outfile %s -aformat3 fasta" % (System.STRETCHER,fic1,fic2,outfile)
        #print cmd
        os.system(cmd)
    else:
        print "%s already exists" % outfile
Ejemplo n.º 6
0
def client_delete_file(
    sock, filename
):  # the logic for when the client deletes a file and asks the host to delete it for everyone else too
    try:
        os.remove(files.get_filepath(filename))  # removes it locally
    except Exception as e:
        print("Error in client_delete_file: %s" % str(e))

    message = DEL + filename + EOT
    print("Sending: %s to %s" % (message, str(sock.getpeername())))
    sock.send(message.encode(ENCODING))
    time.sleep(0.01)
    print("Sent Successfully!")
Ejemplo n.º 7
0
def lancePregCont(strain, config, K):
    if string.atoi(K) < 32:
        soap = csys.SOAPDENOVO31
    elif string.atoi(K) < 64:
        soap = csys.SOAPDENOVO63
    else:
        soap = csys.SOAPDENOVO127

    outfile = "%s/ace%s_%s" % (files.get_filepath(config), strain, K)
    cmdPG = "%s pregraph -s %s -K %s -d -R -o %s" % (soap, config, K, outfile)
    os.system(cmdPG)

    cmdC = "%s contig -R -g %s" % (soap, outfile)
    os.system(cmdC)
Ejemplo n.º 8
0
def lanceMapScaf(strain, config, K):
    if string.atoi(K) < 31:
        soap = csys.SOAPDENOVO31
    elif string.atoi(K) < 63:
        soap = csys.SOAPDENOVO63
    else:
        soap = csys.SOAPDENOVO127

    outfile = "%s/ace%s_%sPrep" % (files.get_filepath(config), strain, K)
    cmdM = "%s map -s %s -g %s" % (soap, config, outfile)
    os.system(cmdM)

    cmdS = "%s scaff -F -g %s" % (soap, outfile)
    os.system(cmdS)
Ejemplo n.º 9
0
def client_delete_file_from_host(
    s, n, data
):  # the logic for deleting a file that the host wants the client to delete
    fname = data[CCLEN:data.find(EOT)]
    print("Request to delete %s" % fname)
    currfiles = n.get_file_list()

    if fname not in currfiles:  # if they dont have the file, for some reason. never ran into this tho
        print("do nothing pretty much")
    else:
        time.sleep(0.1)
        print("Deleting file named: %s " % (fname))
        try:
            os.remove(files.get_filepath(fname))
        except Exception as e:
            print("Error in client_delete_file_from_host: %s" % str(e))
Ejemplo n.º 10
0
def traiteFicBug(ficBug):

    lgBug = open(ficBug, "r").read().split("\n")
    ficBugPrio = "%s/bugPrio2.txt" % files.get_filepath(ficBug)
    f = open(ficBugPrio, "w")
    for lg in lgBug:
        if lg[0:6] == "Reading":
            print lg
            f.write("\n")
            f.write("%s\n" % lg)
        elif "n'est pas align" in lg:
            print lg
        elif "taille inferieur" in lg:
            print lg
        else:
            f.write("%s\n" % lg)
    f.close
Ejemplo n.º 11
0
def client_update_file(
        sock, name):  # logic for client updating a file and sending it out
    truepath = files.get_filepath(name)
    fsize = os.path.getsize(truepath)
    message = UPD + name + ETX + str(fsize) + EOT
    print("Sending: %s to %s" % (message, str(sock.getpeername())))
    sock.send(message.encode(ENCODING))
    time.sleep(0.01)
    with open(truepath, 'rb') as k:
        bytessent = 0
        while bytessent < fsize:
            data = k.read(BUFFER_SIZE)
            sock.send(data)
            bytessent += len(data)

        k.close()
        print("Sent Successfully!")
Ejemplo n.º 12
0
def host_delete_file(filename):

    try:
        os.remove(files.get_filepath(filename))  # removes it locally
        for file in masterlist:
            if file.name == filename:
                masterlist.remove(
                    file
                )  # Add to the master list of all files that are supposed to be synchronized
        print("File removed")
    except Exception as e:
        print("Error in host_delete_file: %s" % str(e))

    # Send out command to all current connections to delete that file as well
    for sock in sock_list:
        message = DEL + filename + EOT
        print("Sending: %s to %s" % (message, str(sock.getpeername())))
        sock.send(message.encode(ENCODING))
        time.sleep(0.01)
        print("Sent Successfully!")
Ejemplo n.º 13
0
def host_delete_file_from_client(sock, n, data):

    fname = data[CCLEN:data.find(
        EOT)]  # Pull the file name from the command sent to us
    try:
        os.remove(files.get_filepath(fname))  # removes it locally
        for file in masterlist:
            if file.name == fname:
                masterlist.remove(file)
        print("File removed")
    except Exception as e:
        print("Error in host_delete_file_from_client: %s" % str(e))

    # Send delete command to all other nodes
    for conn in sock_list:
        message = DEL + fname + EOT
        print("Sending %s to %s" % (message, str(conn.getpeername())))
        conn.send(message.encode(ENCODING))
        time.sleep(0.01)
        print("Sent Successfully!")
Ejemplo n.º 14
0
def filter_pe_in_fastq(PE_ids, input_fastq):
    """ Remove the Pair End sequences detected (the file is strainName-PEseq.sam) 
        from the fastq files 
    """

    #output_rep = files.get_filepath(input_fastq).replace("friedrich/Reads/BGI/20130726/CleanData/","dpflieger/NEW/Reads/clean_MP")
    output_rep = files.get_filepath(input_fastq).replace("GB-3G/Reads/RawMatePair/", "NEW/Reads/clean_MP/")

    print output_rep
    if not os.path.isdir(output_rep):
        os.mkdir(output_rep)
        cmd = "chmod 777 %s" % output_rep
        os.system(cmd)

    MP_ids = [rec for rec in SeqIO.parse(input_fastq, "fastq") if rec.id[:-2] not in PE_ids] #rm PE entries from fastq
    #print "Found %i sequences" % len(MP_ids)
    outfile = "%s/%s.fq" % (output_rep, files.get_name(input_fastq))
    output_handle = open(outfile, "w")
    SeqIO.write(MP_ids, output_handle, "fastq")
    output_handle.close()
    print "%s created" % outfile
Ejemplo n.º 15
0
def lanceALaChaine():
    
#    rep = "/Volumes/BioSan/Users/friedrich/GB-3G/SOAPdenovo/CleanReads/Complete/SofConfig/scafmap/scafToFasta"
#    #rep = "/Volumes/BioSan/Users/jhou/Documents/Incompatibility/SOAPdenovo/AceRef/ScaffChimere2610"
#    liStrains = ['55-86_1','62-196','62-1041','67-588','77-1003','CBS2861','CBS4104','CBS4568','CBS5828','CBS6545','CBS6547','CBS6626','CBS10367','CBS10368','dd281a','DBVPG3108','DBVPG4002','NCYC543',"CBS3082b","CBS3082a","NRBC1892","NRBC1811","NRBC10955","NRBC10572","NRBC101999","DBVPG3452","CBS6546","CBS10369","68917-2"]
#    liStrains = ['55-86_1','62-196','62-1041','67-588','77-1003','CBS2861','CBS4104','CBS4568','CBS5828','CBS6545']
#    liStrains = ['CBS6547','CBS6626','CBS10367','CBS10368','dd281a','DBVPG3108','DBVPG4002','NCYC543',"CBS3082b","CBS3082a"]
#    liStrains = ["NRBC1892","NRBC1811","NRBC10955","NRBC10572","NRBC101999","DBVPG3452","CBS6546","CBS10369","68917-2"]
#    #liStrains = ['CECT10266_1b','TL229S2.2','Y6_b','YJM428_1b','YJM454_1b']
#    #liStrains = ['Y6_b']
#    for strain in liStrains:
#    for infile in glob.glob("/Volumes/BioSan/Users/friedrich/GB-3G/SOAPdenovo/CleanReads/Complete/SofConfig/scafmap/scafToFasta/lakl/*fasta"):
##        infile = "%s/ace%s.fasta" % (rep, strain)
#        rep = files.get_filepath(infile)
#        print infile
#        identifyScaffChimere("lakl",infile,rep)
        #identifyScaffChimere("sace",infile,rep)
    for infile in glob.glob("/Volumes/BioSan/Users/friedrich/GB-3G/SOAPdenovo/CleanReads/Complete/SofConfig/scafmap/scafToFasta/lakl/ace10955_2j28_63Prep.fasta"):
#        infile = "%s/ace%s.fasta" % (rep, strain)
        rep = files.get_filepath(infile)
        print infile
        identifyScaffChimere("lakl",infile,rep)
Ejemplo n.º 16
0
def client_console(s, n):  # the main driver for client actions
    sg.theme('Default1')

    layout = [[sg.Listbox(files.get_file_names(), size=(60, 10), key='list')],
              [
                  sg.Button('Add File'),
                  sg.Button('Update File'),
                  sg.Button('Delete File'),
                  sg.Button('Open File'),
                  sg.Button('Disconnect')
              ]]
    hel = sg.Window('DoggyDoor', layout, icon=logo)
    while True:

        event, values = hel.read(timeout=3000)
        hel['list'].update(files.get_file_names())

        if event is None:
            break

        if event == 'Add File':  # logic for adding a file
            filepath = sg.popup_get_file('File to add')
            print(filepath)
            if filepath:
                try:
                    head, filename = os.path.split(filepath)
                    client_add_file(s, filepath, filename)
                    hel['list'].update(files.get_file_names())
                except socket.error as e:
                    if e.errno == errno.WSAECONNRESET:
                        s.close()
                        break

        if event == 'Update File':  # logic for updating a file
            filename = ''
            try:
                filename = values['list'][
                    0]  # Throws an exception when nothing is selected, catch it here
            except:
                print("Make sure you have selected a file to update")
            if filename:
                try:
                    client_update_file(s, filename)
                    hel['list'].update(files.get_file_names())
                except socket.error as e:
                    if e.errno == errno.WSAECONNRESET:
                        s.close()
                        break

        if event == 'Delete File':  # logic for deleting a file
            filename = ''
            try:
                filename = values['list'][
                    0]  # Throws an exception when nothing is selected, catch it here
            except:
                print("Make sure you have selected a file to delete")
            if filename:
                try:
                    client_delete_file(s, filename)
                    hel['list'].update(files.get_file_names())
                except socket.error as e:
                    if e.errno == errno.WSAECONNRESET:
                        s.close()
                        break

        if event == 'Open File':  # logic for opening a file
            filename = ''
            try:
                filename = values['list'][
                    0]  # Throws an exception when nothing is selected, catch it here
            except:
                print("Make sure you have selected a file to open")

            os.startfile(files.get_filepath(filename))

        if event == 'Disconnect':  # logic for disconnecting from the host
            # delete connection
            message = DIS + EOT
            try:
                s.send(message.encode(
                    ENCODING))  # sends a message that its disconnecting
            except Exception as e:
                print("Error in client_console: %s" % str(e))
            finally:
                s.close()
                hel.close()
            break

        hel['list'].update(files.get_file_names())
Ejemplo n.º 17
0
def host_console(name, n):
    sg.theme('Default1')

    layout = [[sg.Listbox(files.get_file_names(), size=(60, 10), key='list')],
              [
                  sg.Button('Add File'),
                  sg.Button('Update File'),
                  sg.Button('Delete File'),
                  sg.Button('Open File'),
                  sg.Button('Disconnect')
              ]]

    hel = sg.Window('Doggy Door', layout, icon=logo)
    while True:

        event, values = hel.read(timeout=3000)

        hel['list'].update(files.get_file_names())

        if event is None:
            break

        if event == 'Add File':
            filepath = sg.popup_get_file('File to add')
            print(filepath)
            if filepath:
                host_add_file(filepath, os.path.basename(filepath))
                hel['list'].update(files.get_file_names())

        if event == 'Update File':
            filename = ''
            try:
                filename = values['list'][
                    0]  # Throws an exception when nothing is selected, catch it here
            except:
                print("Make sure you have selected a file to update")
            if filename:
                host_update_file(filename)
                hel['list'].update(files.get_file_names())

        if event == 'Delete File':
            filename = ''
            try:
                filename = values['list'][
                    0]  # Throws an exception when nothing is selected, catch it here
            except:
                print("Make sure you have selected a file to delete")
            if filename:
                host_delete_file(filename)
                hel['list'].update(files.get_file_names())

        if event == 'Open File':
            filename = ''
            try:
                filename = values['list'][
                    0]  # Throws an exception when nothing is selected, catch it here
            except:
                print("Make sure you have selected a file to open")

            os.startfile(files.get_filepath(filename))

        if event == 'Disconnect':
            # delete connection
            host_close_connection()
            n.nodeOpen = False
            hel.close()
            break