7stud -- wrote in post #995683:
> If you don't have to use pos(), then see my first post.  At some point,
> you might ask him why he thinks that pos() would be of any help at all!

Thanks jake and 7stud for replying. I tried this in irb for your first 
post:

>> e = File.open("test/test.fasta").enum_for(:each)
=> #<Enumerable::Enumerator:0x1005777a8>
>> $/ = "\n\n"
=> "\n\n"

>Before doing the sub() on buffer2, you will have to check if it's nil:

 >if buffer2.nil?
 >   #don't do a sub()
 > else
 >   #do the sub()
 >end

>> e.each_slice(2) do |buf1, buf2|
?> p buf1, buf2
>> if buf2.nil?
>> puts "Done"
>> else
?> buf2.sub(/\n+ \z/xms, "")
>> end
>> end

Output:
">gi|329299107|ref|NM_2005745.3Acc1| Def1 zgc:65895 (zgc:65895), 
mRNA\nAGCTCGGGGGCTCTAGCGATTTAAGGAGCGATGCGATCGAGCTGACCGTCGCG\n\n"
">gi|329299107|ref|NM_2342343.3Acc2| Def2 zgc:65895 (zgc:65895), 
mRNA\nGTCGCTGGGTCGAAAAGTGGTGCTATATCGCGGCTCGCGTCGATGTCGCGATG\nCGTGCGCGCGAGAGCGCGCTATGATGAAAGGATGAGAGAG\n\n"
">gi|329299107|ref|NM_7453343.5Acc3| Def3 zgc:65895 (zgc:65895), 
mRNA\nCGTGCGGGGABCCGTACGTGCCGTGGGGGTTTAATAGCGCGCCATCTGAGCAG\nTTAGTCGCTGACGCATGCACG\n"
nil
Done
=> nil

It still returns nil, am I doing what you suggested wrong?

-- 
Posted via http://www.ruby-forum.com/.