programming-boun...@forums.jsoftware.com] On Behalf Of Marc Bourassa
Sent: Tuesday, November 25, 2014 7:51 PM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] Split on first found character
first_found=. 13 : 'CR-.~ y{.~ y i.LF'
first_found
(13{a.) -.~ ]
or join them into a single string
> > >
> > > LF joinstring ;/ 'abc'
> > > a
> > > b
> > > c
> > >
> > > '' joinstring ;/ 'abc'
> > > ; ;/ 'abc' NB. or this
> > > abc
> >
'
> > ; ;/ 'abc' NB. or this
> > abc
> >
> >
> > to extend Joe's solution
> >
> > (>@:{. ; ;@}.)@:cutLF each '>' cut
> >
> >
> >
> >
> > - Original Message -
> &g
t; 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 ;/ 'ab
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 '>'
nstring ;/ 'abc'
a
b
c
'' joinstring ;/ 'abc'
; ;/ 'abc' NB. or this
abc
to extend Joe's solution
(>@:{. ; ;@}.)@:cutLF each '>' cut
- Original Message -
From: Joe Bogner
To: programm...@jsoftware.com
Cc:
In case it is of interest there is an implementation here:
http://rosettacode.org/wiki/FASTA_format#J
You could simplify it a bit to generate results similar to others here:
parseFasta=: ( LF&taketo ; (LF -.~ LF&takeafter));._1
As Mike suggests, you will probably want to chunk and buffer if you
c =. 'case_id', LF, 'GCTAGTCG', LF, 'ACGTC', LF
(({. ; LF -.~ }.)~ LF&(i.&1@:=)) c
+---+-+
|case_id|GCTAGTCGACGTC|
+---+-+
Henry Rich
On 11/25/2014 5:00 AM, Ryan wrote:
I have a character array with LF's, and want to split it on the
first LF, and remove the
That's quite nice.
Looking at the genetic coding examples on the website Jan-Pieter
mentioned, and bearing in mind that "cut" is a provided verb,
this might be the sort of thing he would like:
NB. script version of defining some taxons:
sample =: 0 : 0 NB. truncated lines from web example
>Tax
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
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
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@
12 matches
Mail list logo