Skip to content

Commit

Permalink
fix negative strand issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sfchen committed Feb 16, 2016
1 parent fcbf7c3 commit b2c99c8
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/Reference/Gencode/search.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,20 @@ function search_in_gene(gene, pos)
if !haskey(t.attributes, "tag") || !contains(t.attributes["tag"], "basic")
continue
end
range = 1:length(t.exons)
if gene.strand == "-"
range = length(t.exons):-1:1
end
for i in range
exon = t.exons[i]
if exon.start_pos<=pos && exon.end_pos>=pos
return Dict("gene"=>gene.name, "transcript"=>t.id, "type"=>"exon", "number"=>exon.number)
elseif exon.start_pos>pos
return Dict("gene"=>gene.name, "transcript"=>t.id, "type"=>"intron", "number"=>exon.number - 1)
for exon in t.exons
# strand is -, then exons are aligned big coord -> small coord
if gene.strand == "-"
if exon.start_pos<=pos && exon.end_pos>=pos
return Dict("gene"=>gene.name, "transcript"=>t.id, "type"=>"exon", "number"=>exon.number)
elseif exon.end_pos<pos
return Dict("gene"=>gene.name, "transcript"=>t.id, "type"=>"intron", "number"=>exon.number - 1)
end
else
if exon.start_pos<=pos && exon.end_pos>=pos
return Dict("gene"=>gene.name, "transcript"=>t.id, "type"=>"exon", "number"=>exon.number)
elseif exon.start_pos>pos
return Dict("gene"=>gene.name, "transcript"=>t.id, "type"=>"intron", "number"=>exon.number - 1)
end
end
end
end
Expand Down

0 comments on commit b2c99c8

Please sign in to comment.