Thanks John for the suggestion and for adding this in one of the next 
releases.
It seems that bgfz_seek and bgzf_tell can work as well, do you see any 
issue with them?
Cheers,
Claudio

On 08/12/2015 13:44, John Marshall wrote:
> On 7 Dec 2015, at 21:47, Claudio Alberti <[email protected]> wrote:
>> I am implementing a parser that is able to read the BAM file in pairs so
>> whenever I read a record where pos < mpos I search for the mate and I
>> create a pair structure.
>> Once I find the mate I have to roll back to the second read and continue
>> building the pairs.
> The sensible way to do this using the existing HTSlib API would be to open 
> the BAM file twice.  Use one file handle to read sequentially, and use a 
> separate second file handle (via sam_itr_queryi()/sam_itr_next()) to search 
> for the mates.  No need to "roll back" as the first file handle is still in 
> the right place.
>
> (This would not work for streaming from standard input, but of course your 
> mate-reader requires seeking and an index, so already does not work for 
> standard input.)
>
> To be sure, it would be useful if HTSlib provided seek and tell functions 
> that worked at the high-level htsFile interface, so could be used alongside 
> sam_read1(), bcf_read(), etc.  This would be useful so that people could 
> build interesting new indexing structures, though in this case there would be 
> more seeking involved than in a two file handle implementation, so it would 
> be somewhat slower.  Until Ryan's (the September thread that James pointed 
> you at) and your requests, noone had expressed a desire for such functions.  
> Now they have, so such functions will be added, probably in a HTSlib 1.4 
> release.
>
>      John
>

-- 
Claudio Alberti
----------------------------------------------
http://gramm.epfl.ch
EPFL SCI STI MM
ELG 140 (ELG Building)
Station 11
CH-1015 Lausanne - Switzerland
Tel. +41 21 6936869
----------------------------------------------


------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140
_______________________________________________
Samtools-help mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/samtools-help

Reply via email to