Skip to content
Browse files

Reversed ORF logic

  • Loading branch information...
1 parent 3cd6f2b commit da5f4bac00ebf3903ffaff534178f40dd8428b9a @pjotrp committed Jan 22, 2011
Showing with 28 additions and 12 deletions.
  1. +22 −9 lib/bigbio/db/emitters/orf_emitter.rb
  2. +6 −3 spec/emitter_spec.rb
View
31 lib/bigbio/db/emitters/orf_emitter.rb
@@ -35,19 +35,32 @@ def CreateShortFrame.create_right fr,orfs,rseq
ShortFrameState.new nseq,ntseq_pos,fr.min_size_codons*3
end
- def CreateShortFrame.create_left fr,orfs,lseq
- seq = fr.seq # original sequence
- ntseq_pos = fr.ntseq_pos # right side of seq
- bridge = seq.size % 3 # chomp left side
+ def CreateShortFrame.create_left fr,orfs,nseq
+ # Reversed (real locations on contig):
+ #
+ # | 3 21 B |
+ # ttaaatgtaatttaggtaaatttat atgtaaattaggta (reversed)
+ # ...^--============xxx^=======xxx
+ #
+ # Actual feed:
+ #
+ # "tatttaaatggatttaatgtaaatt"
+ # ~===xx^============--^...
+ # "atggattaaatgta"
+ # ......xxx=====
+ #
+ seq1 = fr.seq # original sequence
+ len1 = seq1.size
+ ntseq_pos1 = fr.ntseq_pos # right side of seq (|)
+ bridge = len1 % 3 # chomp left side (B)
remove = if orfs.size > 0
- # remove the tail of the sequence
- seq.size - bridge - (orfs.first.pos)*3 +1
+ len1 - bridge - (orfs.first.pos)*3
else
0
end
- ntseq_pos += remove
- nseq = lseq + seq[0..(seq.size-remove)]
- ShortFrameState.new nseq,ntseq_pos,fr.min_size_codons*3
+ ntseq_pos2 = ntseq_pos1+remove # pos against main contig
+ seq2 = nseq + seq1[0..(len1-remove)]
+ ShortFrameState.new seq2,ntseq_pos2,fr.min_size_codons*3
end
end
View
9 spec/emitter_spec.rb
@@ -183,8 +183,11 @@
end
it "should combine a reverse frame" do
+ # ttaaatgtaatttaggtaaatttat atgtaaattaggta
+ # ...^--============xxx^=======xxx
+
s2 = "tatttaaatggatttaatgtaaatt"
- # ~===xxx============---...
+ # ~===xx^============--^...
s1 = "atggattaaatgta"
# ......xxx=====
# now move the other way, as sequences get emitted on the left
@@ -196,13 +199,13 @@
orfs.map{ | orf | orf.to_seq }.should == ["ATGGATTTAATGTAA"]
orfs.first.pos.should == 2 # in codons
fr3 = FrameCodonHelpers::CreateShortFrame.create_left(fr,orfs,s1)
- fr3.ntseq_pos.should == 19
+ fr3.ntseq_pos.should == 18 # 6 codons
fr3.codons.to_seq.should == "ATGGATTAAATGTATATTTAA"
norfs = fr3.get_stopstop_orfs
orfs += norfs
p orfs
orfs.map{ | orf | orf.to_seq }.should == ["ATGGATTTAATGTAA", "ATGTATATTTAA"]
- orfs.map{ | orf | orf.track_ntseq_pos }.should == [18,18+12]
+ orfs.map{ | orf | orf.track_ntseq_pos }.should == [3,21]
end
end

0 comments on commit da5f4ba

Please sign in to comment.
Something went wrong with that request. Please try again.