Skip to content

Commit

Permalink
[partition] Sort reads by name
Browse files Browse the repository at this point in the history
  • Loading branch information
tanghaibao committed Nov 23, 2017
1 parent f0ffa16 commit 06200c0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions hic/partition.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#


import algorithm
import hts
import logging

Expand All @@ -18,6 +19,7 @@ logger.addHandler()
type
Partitioner* = ref object
bamfile*: string
ReadMapping* = tuple[name: string, contig: string]


proc initPartitioner*(bamfile: string): Partitioner =
Expand All @@ -29,6 +31,13 @@ proc count_links*(this: Partitioner) =
var b: Bam
open(b, this.bamfile, index=false)

var mappings: seq[ReadMapping] = @[]

for record in b:
echo record
break
mappings.add((record.qname, record.chrom))

mappings.sort do (x, y: ReadMapping) -> int:
result = cmp(x.name, y.name)

for mapping in mappings[0..<100]:
echo mapping

0 comments on commit 06200c0

Please sign in to comment.