Multiple lines String problem

ynnr85

New member
I have a multiple lines String like:

>name 1
zzzzzzzzzzzzzzzzzzzz
zzzzzzzzzzzzzzzzzzzz
zzzzzzzzzzzzzzzzzzzz
>name 2
zzzzzzzzzzzzzzzzzzzz
zzzzzzzzzzzzzzzzzzzz
zzzzzzzzzzzzzzzzzzzz

line that contains > is the name of something, and other lines down contains data of something. My String is very big, I want to return the name of something without > and its data (ZZZZZ) separate and access to it after that. which structure is best to do this and how I can implement that. I'm new using groovy
Please help:confused:
 

WillK

New member
Looks like you're parsing a FASTA sequence file which you can do easily with a mix of java and groovy
so iterate through the file using the eachLine closure of File . Have a class that stores name and sequence separately.
go through each line testing for the > and completing the previous object when it is encountered, peeling off the >
from the name variable with regular expression substituting.

There's a lot of info out there about all these concepts and I wouldn't be surprised at all if someone doesn't have a freely available fasta parser.
Will

Programming Groovy by Subramaniam, and Groovy In Action by Konig are both excellent resources as well as the Core Java
I and II books.
 
Top