Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!news.mixmin.net!feeds.phibee-telecom.net!talisker.lacave.net!lacave.net!not-for-mail From: Cee Joe Newsgroups: comp.lang.ruby Subject: Re: File position and buffers Date: Fri, 29 Apr 2011 10:20:29 -0500 Organization: Service de news de lacave.net Lines: 45 Message-ID: <8279ca181d004aab4664d4fe4e1fc33c@ruby-forum.com> References: <10d8ae57765e21626a7c64873dcba807@ruby-forum.com> <1d5c91d93983445a08235be2797f7f0b@ruby-forum.com> NNTP-Posting-Host: bristol.highgroove.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: talisker.lacave.net 1304090440 95715 65.111.164.187 (29 Apr 2011 15:20:40 GMT) X-Complaints-To: abuse@lacave.net NNTP-Posting-Date: Fri, 29 Apr 2011 15:20:40 +0000 (UTC) In-Reply-To: <1d5c91d93983445a08235be2797f7f0b@ruby-forum.com> X-Received-From: This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway X-Mail-Count: 382386 X-Ml-Name: ruby-talk X-Rubymirror: Yes X-Ruby-Talk: <8279ca181d004aab4664d4fe4e1fc33c@ruby-forum.com> Xref: x330-a1.tempe.blueboxinc.net comp.lang.ruby:3701 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) => # >> $/ = "\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/.