11 using namespace nvbio;
19 template <
typename WordType>
22 const uint32 bps_per_word =
sizeof(WordType) * 4;
23 const uint32 begin_word = begin / bps_per_word;
24 const uint32 end_word = (end+bps_per_word-1) / bps_per_word;
31 fseek( file, begin_word *
sizeof(WordType),
SEEK_CUR );
32 for (
uint32 w = begin_word; w < end_word; w += 1024)
37 fread( words,
sizeof(WordType), n_words, file );
41 stream_type
stream( words );
43 for (
uint32 i = 0; i < n_words * bps_per_word && i_bps < n_bps; ++i, ++i_bps)
49 fprintf(stdout,
"%03u ", line_num++ );
53 fprintf(stdout,
"%c", bp);
63 for (
uint32 i = begin; i < end; ++i)
67 fread( &read_id,
sizeof(
uint32), 1, file );
69 fprintf(stdout,
"%u\n", read_id);
73 int main(
int argc,
char* argv[])
75 if (argc < 3 || (argc == 2 && (strcmp(argv[1],
"--help") == 0 || strcmp(argv[1],
"-h") == 0)))
77 printf(
"nvbio-less is a program to read dna fragments from {.pac|.rpac|.bwt|.rbwt} files.\n");
78 printf(
"Copyright NVIDIA Corporation 2012. All rights reserved.\n");
80 printf(
"nvbio-less [options] begin end filename\n");
82 printf(
" -r row length specify output row length\n");
83 printf(
" -ln print line numbers\n");
85 printf(
" nvbio-less -r 50 0 100 mydna.pac\n");
96 for (; n_options < argc-4; ++n_options)
98 if (argv[n_options+1][0] !=
'-')
101 if (strcmp( argv[n_options+1],
"-r" ) == 0)
102 opts.
row_length = atoi( argv[++n_options + 1] );
103 else if (strcmp( argv[n_options+1],
"-ln" ) == 0)
107 sscanf( argv[1+n_options],
"%u", &begin );
108 sscanf( argv[2+n_options],
"%u", &end );
109 const std::string filename = argv[3+n_options];
111 FILE* file = fopen( filename.c_str(),
"rb" );
114 fprintf(stderr,
"error: file \"%s\" not found\n", filename.c_str());
118 if (filename.find(
".ft") != std::string::npos)
127 if (filename.find(
".pac") != std::string::npos ||
128 filename.find(
".rpac") != std::string::npos)
129 read<uint8>( file, begin, end, opts );
131 if (filename.find(
".wpac") != std::string::npos ||
132 filename.find(
".bwt") != std::string::npos ||
133 filename.find(
".rbwt") != std::string::npos)
136 if (filename.find(
".wpac") != std::string::npos)
138 else if (filename.find(
".bwt") != std::string::npos ||
139 filename.find(
".rbwt") != std::string::npos)
142 read<uint32>( file,
begin, end, opts );
148 fprintf(stderr,
"error: unsupported file type\n");