Protein text to csv?

2020-07-24 Thread Stephen Taylor
Hi, first time poster but long-time BBEdit user. I have a text file of a 
protein, which I'd like to convert to csv by inserting a comma between each 
character, like so:

MADEEKLP  -> M,A,D,E,E,K,L,P, ...

And some lines (for secondary structure) have lots of spaces:

  S TTE ->  , , S, , , ,T,T,E,E,E,E, ...

Is there a way to do this in BBEdit? I hacked together a simple javascript 
to do it, but then I have to run that as a local webpage; it would be great 
just to do it within BBEdit. Sorry if this is a dumb question, and thanks 
for any responses!

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "supp...@barebones.com" rather than 
posting here. Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/3ac47c55-6030-46fb-b9f1-a315b3538dedn%40googlegroups.com.


Re: Protein text to csv?

2020-07-24 Thread Jan Erik Moström

On 24 Jul 2020, at 18:36, Stephen Taylor wrote:

Hi, first time poster but long-time BBEdit user. I have a text file of 
a protein, which I'd like to convert to csv by inserting a comma 
between each character, like so:



Find pattern: (.)
Replace pattern: \1,

Done (if I understood you correctly)

This makes
MADE EKLP
become
M,A,D,E, , , , , ,E,K,L,P,

= jem

--
This is the BBEdit Talk public discussion group. If you have a feature request or need 
technical support, please email "supp...@barebones.com" rather than posting here. 
Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/978EECAD-FA7F-4F13-9278-5CE2188F8474%40mostrom.pp.se.


Re: Protein text to csv?

2020-07-24 Thread Bruce Van Allen

On 7/24/20 at 9:36 AM, stephenatay...@gmail.com (Stephen Taylor) wrote:

Is there a way to do this in BBEdit? I hacked together a simple 
javascript to do it, but then I have to run that as a local webpage;



MADEEKLP  -> M,A,D,E,E,K,L,P, ...



Looks like a fairly simple thing to do with Find/Replace, e.g.,

Find:
([A-Z])

Replace:
\1,

[A-Z] matches a single upper case ascii letter.
The parens capture that matched letter.
The \1 in the replacement is that captured value (the first one, 
and in this case the only captured value).


This will do most of your work, although you might not want the 
comma at the very end after the the very last letter. And there 
might be other edge cases.


If your JS script works well, note that BBEdit can run scripts 
written with Apple's script editor, and - unknown to many - 
Apple's Script Editor accepts scripts written in javascript as 
well as those written in AppleScript. So you might want to check 
that out. A script can often be more versatile and robust than 
using find/replace.


HTH
--

  - Bruce

_bruce__van_allen__santa_cruz__ca_

--
This is the BBEdit Talk public discussion group. If you have a feature request or need 
technical support, please email "supp...@barebones.com" rather than posting here. 
Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/r480Ps-10146i-E42AE4044793418DACD1660623B8CCFB%40Forest.local.


Re: Protein text to csv?

2020-07-24 Thread Stephen Taylor
Perfect, this has been driving me crazy for months! Thanks so much!

On Friday, July 24, 2020 at 11:46:34 AM UTC-5 Jan Erik Moström wrote:

> On 24 Jul 2020, at 18:36, Stephen Taylor wrote:
>
> > Hi, first time poster but long-time BBEdit user. I have a text file of 
> > a protein, which I'd like to convert to csv by inserting a comma 
> > between each character, like so:
>
>
> Find pattern: (.)
> Replace pattern: \1,
>
> Done (if I understood you correctly)
>
> This makes
> MADE EKLP
> become
> M,A,D,E, , , , , ,E,K,L,P,
>
> = jem
>

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "supp...@barebones.com" rather than 
posting here. Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/e71a13a9-2bc8-49ba-80eb-ec89180d56a4n%40googlegroups.com.


Re: Protein text to csv?

2020-07-24 Thread Bucky Junior
It seems to me to be a simple regex (Regular Expressions) search and
replace with BBEdit’s Find.
First you want to look for upper-case letters A-Z or a space. That would be
[A-Z ] note the space after Z.

Then you want to capture that for later use.
([A-Z ])

Replace it with \1 and a comma
\1,

Turn on Grep and Replace All.
Someone can correct me if I'm wrong.
Bucky

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "supp...@barebones.com" rather than 
posting here. Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/CAJu31_O7sBfhg2xT-cdVz_29NK1WYRj%3DAPZFFk0wjf0s0m5N1w%40mail.gmail.com.