newfilename = "%s/%s.txt" % (src_table_dir, name)

        if not os.path.exists( newfilename ) :
            fnew = open(newfilename, 'w')
            fnew.write( first_line )
            fnew.write( rest_lines )
            fnew.close()
            #update tables.txt, rebuild parsed tables

            #ftables = "%s/tables.txt" % os.environ["BIOSQL_HOME"]
            #ftables = open( ftables, 'a' )
            #ftables.write( first_line[1:] )
            #ftables.write("\n");
            #ftables.close()

            #pop = Popen(['bash','rebuild_parsed_tables.sh'], \
                        #stdin=PIPE, stdout=PIPE, stderr=PIPE)
            #(out, err) = pop.communicate()
            #sys.stderr.write(err)
            #sys.stdout.write(out)

            #check err here?

            json_data = "{'status':'OK','message':'%s'}" % name
        else :
            json_data = "{'status':'DUPLICATE','message':'A table named: \\'%s\\' already exists.'}" % name
else :
    json_data = "{'status':'ERROR','message':'Uploading went awry'}"

utils.printPayload( json_data );
Esempio n. 2
0
#index this using the ref file (maybe not all chroms are there, or are named differently)
#also, run_biosql will need to be changed
#run script to index
for chrom in range(1, 23) + ['X', 'Y']:
    bam = "%s/chr%s.bam" % (root, str(chrom))
    mates = "%s/chr%s.mates" % (root, str(chrom))
    indx = "%s/chr%s.mates.indx" % (root, str(chrom))
    if os.path.exists(bam):
        if not os.path.exists(indx):
            print "popping index_all.sh"
            pop = Popen(["bash",\
                         "index_all.sh", \
                         "%s/chr" % root, \
                         refinfo], \
                    stdin=PIPE, stdout=PIPE, stderr=PIPE )
            (out, err) = pop.communicate()
            #messages.append( "%s : %s" % (str(chrom),out) )
            sys.stdout.write(out)
            sys.stderr.write(err)
        else:
            messages.append("%s already exists" % indx)

    else:
        messages.append("chr%s.bam doesn't exist!" % str(chrom))

    status, message = "ok", "Donor genome has finished indexing."

message = ";".join(messages)
r = '{"status":"%s","message":"%s"}' % (status, message)
utils.printPayload(r)
Esempio n. 3
0
#also, run_biosql will need to be changed
#run script to index
for chrom in range(1,23) + ['X','Y'] :
    bam = "%s/chr%s.bam" % (root, str(chrom) )
    mates = "%s/chr%s.mates" % (root, str(chrom) )
    indx = "%s/chr%s.mates.indx" % (root, str(chrom) )
    if os.path.exists( bam ) :
        if not os.path.exists( indx ) :
            print "popping index_all.sh"
            pop = Popen(["bash",\
                         "index_all.sh", \
                         "%s/chr" % root, \
                         refinfo], \
                    stdin=PIPE, stdout=PIPE, stderr=PIPE )
            (out, err) = pop.communicate()
            #messages.append( "%s : %s" % (str(chrom),out) )
            sys.stdout.write( out )
            sys.stderr.write( err )
        else :
            messages.append( "%s already exists" % indx )

    else :
        messages.append( "chr%s.bam doesn't exist!" % str(chrom) )

    status, message = "ok", "Donor genome has finished indexing."


message = ";".join( messages )
r = '{"status":"%s","message":"%s"}' % (status,message)
utils.printPayload( r )