def create_one_wormtable(schema_path, inp_file, out_file): """ Create a single wormtable database from the input file and an .xml schema. """ cachesize = '16G ' if WIN_PLATFORM_NONFREE: cachesize = '4G ' # to deal with BDB error... runargs = '-q --schema ' + schema_path + ' --cache-size=' + cachesize + \ inp_file + ' ' + out_file #run vcf2wt as a library function, no system calls try: wt.vcf2wt_main(runargs.split()) except: raise #return quietly # add row index for this wormtable # supersedes add_all_rowid_indexes() and add_one_rowid_index() # doing it here means we avail of the thread/process that is already spawned # sys.stderr.write('Indexing %s\n' % (out_file,)) runargs = 'add -q --cache-size=' + cachesize + out_file + ' row_id' wt.wtadmin_main(runargs.split()) return
def add_one_rowid_index(wt_path): """ Add the 'row_id' index to the wormtable wt_path. """ cachesize = '16G ' if WIN_PLATFORM_NONFREE: cachesize = '4G ' # to deal with BDB error... wt_path = wt_path.replace('\\', '\\\\') # run wtadmin as a library function, no system calls runargs = 'add -q --cache-size=' + cachesize + wt_path + ' row_id' wt.wtadmin_main(runargs.split()) return
def add_chrompos_index(out_folder): """ Add the 'CHROM+POS' index to the wormtable 'CHROM+POS.wt'. """ # Turning this off for now, since it's not much overhead # and needs to be created the first time, which this check won't allow! #if os.path.exists(os.path.join(out_folder, 'CHROM+POS.wt')): # return cachesize = '16G ' divider = '/' if WIN_PLATFORM_NONFREE: cachesize = '4G ' # to deal with BDB error... out_folder = out_folder.replace('\\', '\\\\') divider = '\\\\' #run wtadmin as a library function, no system calls! #for now, force this index to run each time... runargs = 'add -q --force --cache-size=' + cachesize + out_folder + divider + \ 'CHROM+POS.wt CHROM+POS' wt.wtadmin_main(runargs.split()) return
import wormtable as wt if __name__ == "__main__": wt.wtadmin_main()