View Single Post
Old 07-08-2010, 11:28 AM   #2
Bio.X2Y
Member
 
Location: Europe

Join Date: Apr 2010
Posts: 46
Default

I'm not aware of anything convenient for doing this, but someone else might be able to shed light.

If you are comfortable with programming, I'd sort the file by name, leaving the header records on top (samtools probably has something for this). Then write a program to pluck out your target record using a binary search algorithm (http://en.wikipedia.org/wiki/Binary_search_algorithm). Java has a RandomAccessFile class for quickly accessing arbitary file bytes, though I'm sure other languages have their equivalents. The tricky part will be finding the start of a record containing an arbitary byte - you will have to work backwards to find a newline or the start-of-file.

I know this isn't creating an index, but it should be lightning fast for practical purposes.
Bio.X2Y is offline   Reply With Quote