> When I feel like programming defensively, I'll ensure that the last character is LF (and remove any CRs) like this:
This is done by freads, unlike fread which returns the raw data. On Tue, Nov 25, 2014 at 7:44 AM, Devon McCormick <devon...@gmail.com> wrote: > I usually split on the last character using "cut" like this: > > <;._2 fread 'some.file' > > When I feel like programming defensively, I'll ensure that the last > character is LF (and remove any CRs) like this: > > <;._2 LF (],[#~[~:[:{:]) CR-.~]0 : 0 > Four-score and seven years ago, > our fathers brought forth upon this continent > a new nation, > conceived in liberty > and dedicated to the proposition > that all men are created equal. > ) > > > On Tue, Nov 25, 2014 at 10:26 AM, 'Pascal Jasmin' via Programming < > programm...@jsoftware.com> wrote: > > > The spec (Fasta) can be revised to splitting on all LFs, where the first > > box is the control data, and subsequent boxes are the package. > > > > http://rosalind.info/glossary/fasta-format/ > > > > If so, you can grab all of the records from the sample link with this > > expression (copy records on clipboard, uses j8 clipboard access) > > > > cutLF each '>' cut wdclippaste '' > > > > The reason for the LFs in the payload as I understand it is to separate > it > > into processing chunks. Having them boxed works for this, but if you > ever > > need to put the LFs back, or join them into a single string > > > > LF joinstring ;/ 'abc' > > a > > b > > c > > > > '' joinstring ;/ 'abc' > > ; ;/ 'abc' NB. or this > > abc > > > > > > to extend Joe's solution > > > > (>@:{. ; ;@}.)@:cutLF each '>' cut > > > > > > > > > > ----- Original Message ----- > > From: Joe Bogner <joebog...@gmail.com> > > To: programm...@jsoftware.com > > Cc: > > Sent: Tuesday, November 25, 2014 6:00 AM > > Subject: Re: [Jprogramming] Split on first found character > > > > I might do it this way: > > > > (>@:{. ; ;@}.)@(LF&cut) x > > > > ┌───────┬─────────────┐ > > > > │case_id│GCTAGTCGACGTC│ > > > > └───────┴─────────────┘ > > > > > > > > > > On Tue, Nov 25, 2014 at 5:47 AM, Jan-Pieter Jacobs < > > janpieter.jac...@gmail.com> wrote: > > > > > I think I would solve it like this (with intermediate steps): > > > > > > x=: 'case_id', LF, 'GCTAGTCG', LF, 'ACGTC', LF > > > > > > NB. Find the locations of LF's in the string > > > (LF = ]) x > > > > > > NB. assign 0 to everything before the LF, assign 1 to everything after > it > > > ([: +./\ LF = ]) x > > > > > > NB. The wonderful "key" adverb lets you apply verbs based on it's key > > > (another array), eg. box > > > (</.~ [: +./\ LF =]) x > > > > > > NB. Get rid of the LF's by replacing < by a version removing LF: > > > ((<@#~ LF~:])/.~ [: +./\ LF = ]) x > > > > > > This is what I came up with, but smarter people will probably suggest > > more > > > elegant ways. > > > > > > I hope this is useful. > > > Jan-Pieter > > > > > > 2014-11-25 11:00 GMT+01:00 Ryan <rec...@bwh.harvard.edu>: > > > > > > > I have a character array with LF's, and want to split it on the > > > > first LF, and remove the remaining LF's. I'm wondering if there's a > > > > simpler > > > > way than what I'm doing now: > > > > > > > > x=: 'case_id', LF, 'GCTAGTCG', LF, 'ACGTC', LF > > > > > > > > filterLF=: #~ ~:&LF > > > > headLF=: {.~ i.&LF > > > > tailLF=: }.~ i.&LF > > > > (headLF ; filterLF@tailLF) x > > > > ┌────────┬─────────────┐ > > > > │>case_id│GCTAGTCGACGTC│ > > > > └────────┴─────────────┘ > > > > > > > > (I'm reading text files in fasta format: > > http://rosalind.info/glossary/ > > > > fasta-format/) > > > > > > > > Thanks for any suggestions, > > > > Ryan > > > > > > > > > > > > > > > > The information in this e-mail is intended only for the person to > whom > > it > > > > is > > > > addressed. If you believe this e-mail was sent to you in error and > the > > > > e-mail > > > > contains patient information, please contact the Partners Compliance > > > > HelpLine at > > > > http://www.partners.org/complianceline . If the e-mail was sent to > you > > > in > > > > error > > > > but does not contain patient information, please contact the sender > and > > > > properly > > > > dispose of the e-mail. > > > > > ---------------------------------------------------------------------- > > > > For information about J forums see > http://www.jsoftware.com/forums.htm > > > > > ---------------------------------------------------------------------- > > > For information about J forums see http://www.jsoftware.com/forums.htm > > > > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > > > > > -- > Devon McCormick, CFA > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm