nargs=1, type=int, dest='first') parser.add_argument('-N', '--count', metavar='rows', help='how many reads', nargs=1, type=int, dest='count') parser.add_argument('--split', help='split spot', action='store_true') args = parser.parse_args() try: #open a manager in read-mode ( dflt-mode ) mgr = vdb.manager() for acc in args.accession: #detect path-type ( database or table or anything-else ) pt = mgr.PathType(acc) if pt == vdb.PathType.Database: #object is a database fastq_from_tbl(args, mgr.OpenDB(acc).OpenTable("SEQUENCE")) elif pt == vdb.PathType.Table: #object is a table fastq_from_tbl(args, mgr.OpenTable(acc)) else: print("%s is not an SRA-object" % (acc)) except vdb.vdb_error as e: print(e) except KeyboardInterrupt:
f.write("%d, line # %d\n" % (i, i)) f.close() def csv_to_vdb(mgr, csv_file, spec, vdb_table): with open(csv_file, 'r') as f: spec = 'CSVTAB' tbl_wr = mgr.CreateTable(mgr.MakeSchema(schematxt), spec, vdb_table) cur = tbl_wr.CreateCursor(vdb.OpenMode.Write) cols = cur.OpenColumns(["C1", "C2"]) for row in csv.reader(f): cur.OpenRow() cols["C1"].write([int(row[0])]) cols["C2"].write(row[1].strip()) cur.CommitRow() cur.CloseRow() cur.Commit() if __name__ == '__main__': csv_file = 'data.txt' write_csv(csv_file, 10) try: mgr = vdb.manager(vdb.OpenMode.Write) spec = 'CSVTAB' csv_to_vdb(mgr, csv_file, spec, 'L8') mgr.OpenTable('L8').print_rows() except vdb.vdb_error as e: print(e) os.remove(csv_file)
f.write("%d, line # %d\n" % (i, i)) f.close() def csv_to_vdb(mgr, csv_file, spec, vdb_table): with open(csv_file, 'r') as f: spec = 'CSVTAB' tbl_wr = mgr.CreateTable(mgr.MakeSchema(schematxt), spec, vdb_table) cur = tbl_wr.CreateCursor(vdb.OpenMode.Write) cols = cur.OpenColumns(["C1", "C2"]) for row in csv.reader(f): cur.OpenRow() cols["C1"].write([int(row[0])]) cols["C2"].write(row[1].strip()) cur.CommitRow() cur.CloseRow() cur.Commit() if __name__ == '__main__': csv_file = 'data.txt' write_csv(csv_file, 10) try: mgr = vdb.manager(vdb.OpenMode.Write, "./2.8.0/libncbi-wvdb.so.2.8.0") spec = 'CSVTAB' csv_to_vdb(mgr, csv_file, spec, 'L8') mgr.OpenTable(spec).print_rows() except vdb.vdb_error as e: print(e) os.remove(csv_file)
for row in xrange( first, first + count ) : read = c_read.Read( row ) print( fastq.format( acc, c_name.Read( row ), len( read ), read, c_qual.Read( row ) ) ) if __name__ == '__main__' : parser = argparse.ArgumentParser() parser.add_argument( 'accession', nargs='*' ) parser.add_argument( '-X', '--first', metavar='row-id', help='first row-id', nargs=1, type=int, dest='first' ) parser.add_argument( '-N', '--count', metavar='rows', help='how many reads', nargs=1, type=int, dest='count' ) parser.add_argument( '--split', help='split spot', action='store_true' ) args = parser.parse_args() try : #open a manager in read-mode ( dflt-mode ) mgr = vdb.manager() for acc in args.accession : #detect path-type ( database or table or anything-else ) pt = mgr.PathType( acc ) if pt == vdb.PathType.Database : #object is a database fastq_from_tbl( args, mgr.OpenDB( acc ).OpenTable( "SEQUENCE" ) ) elif pt == vdb.PathType.Table : #object is a table fastq_from_tbl( args, mgr.OpenTable( acc ) ) else : print( "%s is not an SRA-object"%( acc ) ) except vdb.vdb_error as e : print( e ) except KeyboardInterrupt :
help='schema', type=str, dest='schema') parser.add_argument('-F', '--freq', metavar='number', help='progress freq', type=int, dest='freq', default=2000) args = parser.parse_args() try: print("making a copy of : {}".format(args.accession)) #open 2 managers: rd_mgr = vdb.manager(vdb.OpenMode.Read, args.readlib) wr_mgr = vdb.manager(vdb.OpenMode.Write, args.writelib) rd_tbl = None pt = rd_mgr.PathType( args.accession ) #detect path-type ( database or table or anything-else ) if pt == vdb.PathType.Database: rd_tbl = rd_mgr.OpenDB(args.accession).OpenTable( "SEQUENCE") #object is a database elif pt == vdb.PathType.Table: rd_tbl = rd_mgr.OpenTable(args.accession) #object is a table else: print("%s is not an SRA-object" % (args.accession)) if rd_tbl != None:
with open( filename, 'w' ) as f : for i in range( 1, rowcount ) : f.write( "%d, line # %d\n"%( i, i ) ) f.close() def csv_to_vdb( mgr, csv_file, spec, vdb_table ) : with open( csv_file, 'r' ) as f : spec = 'CSVTAB' tbl_wr = mgr.CreateTable( mgr.MakeSchema( schematxt ), spec, vdb_table ) cur = tbl_wr.CreateCursor( vdb.OpenMode.Write ) cols = cur.OpenColumns( [ "C1", "C2" ] ) for row in csv.reader( f ) : cur.OpenRow() cols[ "C1" ].write( [ int( row[ 0 ] ) ] ) cols[ "C2" ].write( row[ 1 ].strip() ); cur.CommitRow() cur.CloseRow() cur.Commit() if __name__ == '__main__': csv_file = 'data.txt' write_csv( csv_file, 10 ) try : mgr = vdb.manager( vdb.OpenMode.Write, "./2.8.0/libncbi-wvdb.so.2.8.0" ) spec = 'CSVTAB' csv_to_vdb( mgr, csv_file, spec, 'L8' ) mgr.OpenTable( spec ).print_rows() except vdb.vdb_error as e : print( e ) os.remove( csv_file )