Help: Newbie Question

A

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
 
J

Josef Moellers

Amy said:
Hi, all

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
only stock off-the shelf scripts and script snippets called modules.
Tailor-made scripts can be obtained by hiring a developer.

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

Josef
 
T

Ted Zlatanov

JM> Yes ... and?

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 <thisandthat> and expected <suchandsuch> but
JM> got <somethingelse>") 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
 
T

Ted Zlatanov

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
 
M

Mirco Wahab

Amy said:
In our Bioinformatics Department, we need to convert some files into a
suitable formation.
The original formation is:
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:

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.
 
A

Amy Lee

Amy said:
In our Bioinformatics Department, we need to convert some files into a
suitable formation.
The original formation is:
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:

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
 
A

Amy Lee

JM> Yes ... and?


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 <thisandthat> and expected <suchandsuch> but
JM> got <somethingelse>") 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
 
T

Ted Zlatanov

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
 
A

Amy Lee

Amy said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,610
Members
45,254
Latest member
Top Crypto TwitterChannel

Latest Threads

Top