Help: Newbie Question

Help: Newbie Question

am 10.08.2007 13:55:43 von Amy Lee

Hi, all

I'm a newbie in Perl, and I have to make a Perl script that can solve the
question.

In our Bioinformatics Department, we need to convert some files into a
suitable formation.

The original formation is:

>16jh_0101.b1.abi Chromat File {descriptions......}
ATCCGTACTGC............................................

I hope that it can be this:

>16>jh_0101>ATCCGTACTGC..................................... .......

In one file, there are many template like above, so I need a script can
solve the problem.

Thank you very much~

Regards,

Amy Lee

Re: Help: Newbie Question

am 10.08.2007 14:19:27 von Josef Moellers

Amy Lee wrote:
> Hi, all
>=20
> I'm a newbie in Perl,

Yes ... and?

> and I have to make a Perl script that can solve the
> question.

Yes ... and? What have you tried so far? You write "_I_ have to make ..."=

The department for ready-made scripts is at www.cpan.org, although they=20
only stock off-the shelf scripts and script snippets called modules.=20
Tailor-made scripts can be obtained by hiring a developer.

This department only serves to help when you have problems with a=20
certain script ("I tried and expected but=20
got ") or it keeps people entangled in endless debates=20
about The True Way ;-)

Josef
--=20
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html

Re: Help: Newbie Question

am 10.08.2007 18:03:14 von Ted Zlatanov

On Fri, 10 Aug 2007 14:19:27 +0200 Josef Moellers wrote:

JM> Amy Lee wrote:
>> Hi, all
>>
>> I'm a newbie in Perl,

JM> Yes ... and?

>> and I have to make a Perl script that can solve the
>> question.

JM> Yes ... and? What have you tried so far? You write "_I_ have to make ...".
JM> The department for ready-made scripts is at www.cpan.org, although
JM> they only stock off-the shelf scripts and script snippets called
JM> modules. Tailor-made scripts can be obtained by hiring a developer.

JM> This department only serves to help when you have problems with a
JM> certain script ("I tried and expected but
JM> got ") or it keeps people entangled in endless debates
JM> about The True Way ;-)

I think this was fairly rude (not that it's unusual on c.l.p.m in the
last few years). At least point the OP in the right direction. I'll
follow up to her question separately.

Ted

Re: Help: Newbie Question

am 10.08.2007 18:06:23 von Ted Zlatanov

On Fri, 10 Aug 2007 19:55:43 +0800 Amy Lee wrote:

AL> The original formation is:

AL> >> 16jh_0101.b1.abi Chromat File {descriptions......}
AL> ATCCGTACTGC............................................

AL> I hope that it can be this:

AL> 16> jh_0101>ATCCGTACTGC......................................... ...

AL> In one file, there are many template like above, so I need a script can
AL> solve the problem.

Hi,

you're trying to do data transformations. Perl is good at this. You
need to look at regular expressions (perldoc perlretut) to extract the
interesting data from the line you showed. Then you can print out the
data you extracted in a new format.

Start with "perldoc perlintro" if you don't have any previous Perl
experience.

Good luck
Ted

Re: Help: Newbie Question

am 10.08.2007 20:56:46 von Mirco Wahab

Amy Lee wrote:
> In our Bioinformatics Department, we need to convert some files into a
> suitable formation.
> The original formation is:
>> 16jh_0101.b1.abi Chromat File {descriptions......}
> ATCCGTACTGC............................................

This looks like a fairly standard fasta format,
which would look like:
12345678901234567890 . . . . . . . . . . .. . . . . . . . 60c
------------------------------------------------------------
1| > 16jh_0101.b1.abi Chromat File descriptions [\n]
2| ATCCGTACTGCATCCGTACTGCATCCGTACATCCGTACTGCATCCGTACTGCATCCGTAC [\n]
3| (more sequence until the next "\n>" record tag

> I hope that it can be this:
>> 16>jh_0101>ATCCGTACTGC...................................... ......
>
> In one file, there are many template like above, so I need a script can
> solve the problem.

Which problem? To convert the fasta header
from "> 16jh_0101.b1.abi ... \nATCCG..."
to "> 16>jh_0101>ATCCG"


What exactly is the "problem" you are trying to solve?

Regards

M.

Re: Help: Newbie Question

am 11.08.2007 09:30:50 von Amy Lee

On Fri, 10 Aug 2007 20:56:46 +0200, Mirco Wahab wrote:

> Amy Lee wrote:
>> In our Bioinformatics Department, we need to convert some files into a
>> suitable formation.
>> The original formation is:
>>> 16jh_0101.b1.abi Chromat File {descriptions......}
>> ATCCGTACTGC............................................
>
> This looks like a fairly standard fasta format,
> which would look like:
> 12345678901234567890 . . . . . . . . . . .. . . . . . . . 60c
> ------------------------------------------------------------
> 1| > 16jh_0101.b1.abi Chromat File descriptions [\n]
> 2| ATCCGTACTGCATCCGTACTGCATCCGTACATCCGTACTGCATCCGTACTGCATCCGTAC [\n]
> 3| (more sequence until the next "\n>" record tag
>
>> I hope that it can be this:
>>> 16>jh_0101>ATCCGTACTGC...................................... ......
>>
>> In one file, there are many template like above, so I need a script can
>> solve the problem.
>
> Which problem? To convert the fasta header
> from "> 16jh_0101.b1.abi ... \nATCCG..."
> to "> 16>jh_0101>ATCCG"
>
>
> What exactly is the "problem" you are trying to solve?
>
> Regards
>
> M.

Hi,

My problem is how use Perl to convert the fasta header from
> 16jh_0101.b1.abi Chromat File descriptions [\n]
> 2| ATCCGTACTGCATCCGTACTGCATCCGTACATCCGTACTGCATCCGTACTGCATCCGTAC [\n]
> 3| (more sequence until the next "\n>" record tag

to
16>jh_0101>ATCCGTACTGC...................................... ......

Thank you very much, I hope that I can get the code.

Regards,

Amy Lee

Re: Help: Newbie Question

am 11.08.2007 09:33:57 von Amy Lee

On Fri, 10 Aug 2007 11:03:14 -0500, Ted Zlatanov wrote:

> On Fri, 10 Aug 2007 14:19:27 +0200 Josef Moellers wrote:
>
> JM> Amy Lee wrote:
>>> Hi, all
>>>
>>> I'm a newbie in Perl,
>
> JM> Yes ... and?
>
>>> and I have to make a Perl script that can solve the
>>> question.
>
> JM> Yes ... and? What have you tried so far? You write "_I_ have to make ...".
> JM> The department for ready-made scripts is at www.cpan.org, although
> JM> they only stock off-the shelf scripts and script snippets called
> JM> modules. Tailor-made scripts can be obtained by hiring a developer.
>
> JM> This department only serves to help when you have problems with a
> JM> certain script ("I tried and expected but
> JM> got ") or it keeps people entangled in endless debates
> JM> about The True Way ;-)
>
> I think this was fairly rude (not that it's unusual on c.l.p.m in the
> last few years). At least point the OP in the right direction. I'll
> follow up to her question separately.
>
> Ted

Ted,

Thanks your patience. I suppose that I have no brilliant in coding. So if
I post some "stupid" questions, please do not angry.

*^_^*

Thank you very much~

Regards,

Amy Lee

Re: Help: Newbie Question

am 11.08.2007 18:04:02 von Ted Zlatanov

On Sat, 11 Aug 2007 15:33:57 +0800 Amy Lee wrote:

AL> On Fri, 10 Aug 2007 11:03:14 -0500, Ted Zlatanov wrote:
>> I think this was fairly rude (not that it's unusual on c.l.p.m in the
>> last few years). At least point the OP in the right direction. I'll
>> follow up to her question separately.

AL> Thanks your patience. I suppose that I have no brilliant in coding. So if
AL> I post some "stupid" questions, please do not angry.

I was saying the reply to your e-mail was fairly rude, I wasn't angry
with your original post (you're the OP, "original poster"). Your
question was not stupid, it simply showed nothing you have tried
already, and that's what Josef was talking about.

Did you look in the perlinto and perlretut documentation pages? They
will get you started on this task and on your Perl knowledge.

Ted

Re: Help: Newbie Question

am 12.08.2007 08:12:11 von Joe Smith

Amy Lee wrote:

> My problem is how use Perl to convert the fasta header from
>> 16jh_0101.b1.abi Chromat File descriptions [\n]
> 2| ATCCGTACTGCATCCGTACTGCATCCGTACATCCGTACTGCATCCGTACTGCATCCGTAC [\n]
> 3| (more sequence until the next "\n>" record tag
>
> to
> 16>jh_0101>ATCCGTACTGC...................................... ......

Looks like a straight forward process:
1) Tell perl that you want to use a particular record separator,
2) read in the multi-line record,
3) do basic text transformation,
4) print the results.

For step 1, the key is perl's $/ variable. From "perldoc perlvar":

$/ The input record separator, newline by default. This influ-
ences Perl's idea of what a "line" is. Works like awk's RS
variable, including treating empty lines as a terminator if set
to the null string. (An empty line cannot contain any spaces
or tabs.) You may set it to a multi-character string to match
a multi-character terminator, or to "undef" to read through the
end of file.

Step 2 is very easy. After $/="\n>", $_=<> does exactly that.

$\ = "\n>"; # Input record separator
while (<>) { # Read in one record at a time
... # You need to fill out this section
}

> Thank you very much, I hope that I can get the code.

You expect us to do all the work? I'm afraid you'll be disappointed.

This newsgroup does not do other people's homework - you're expected
to take a stab at the problem, then post what you've tried, and we
can help you from there.

Since I showed you steps 1 and 2, you should be able to figure out
the rest of the program on your own.

-Joe

Re: Help: Newbie Question

am 12.08.2007 08:34:50 von Amy Lee

On Sat, 11 Aug 2007 23:12:11 -0700, Joe Smith wrote:

> Amy Lee wrote:
>
>> My problem is how use Perl to convert the fasta header from
>>> 16jh_0101.b1.abi Chromat File descriptions [\n]
>> 2| ATCCGTACTGCATCCGTACTGCATCCGTACATCCGTACTGCATCCGTACTGCATCCGTAC [\n]
>> 3| (more sequence until the next "\n>" record tag
>>
>> to
>> 16>jh_0101>ATCCGTACTGC...................................... ......
>
> Looks like a straight forward process:
> 1) Tell perl that you want to use a particular record separator,
> 2) read in the multi-line record,
> 3) do basic text transformation,
> 4) print the results.
>
> For step 1, the key is perl's $/ variable. From "perldoc perlvar":
>
> $/ The input record separator, newline by default. This influ-
> ences Perl's idea of what a "line" is. Works like awk's RS
> variable, including treating empty lines as a terminator if set
> to the null string. (An empty line cannot contain any spaces
> or tabs.) You may set it to a multi-character string to match
> a multi-character terminator, or to "undef" to read through the
> end of file.
>
> Step 2 is very easy. After $/="\n>", $_=<> does exactly that.
>
> $\ = "\n>"; # Input record separator
> while (<>) { # Read in one record at a time
> ... # You need to fill out this section
> }
>
>> Thank you very much, I hope that I can get the code.
>
> You expect us to do all the work? I'm afraid you'll be disappointed.
>
> This newsgroup does not do other people's homework - you're expected
> to take a stab at the problem, then post what you've tried, and we
> can help you from there.
>
> Since I showed you steps 1 and 2, you should be able to figure out
> the rest of the program on your own.
>
> -Joe

Okay, thank your advice very much.

Regards,

Amy Lee