Re: Scripting problem when launching links using mech.

2011-04-23 Thread Shlomi Fish
Hi Sean,

On Saturday 23 Apr 2011 02:59:12 Sean Murphy wrote:
 Hi All.
 
 I have a script that goes to google. Performs a search. 

Google does not allow you to do that using WWW-Mechanize and LWP-UserAgent 
(legally). You should use their web-search API and:

http://search.cpan.org/dist/Google-Search/

 I have a regular
 expression that gets all the links. 

You shouldn't parse HTML with regular expressions:

http://www.codinghorror.com/blog/2009/11/parsing-html-the-cthulhu-way.html

 The first link in the array I return
 is ment to open the next page. But it keeps failing with an error stating
 it is illegal page. When I try and use lwp, it says you cannot use an
 absolute link. But the link looks fine to myself.
 
 Below is the code, any help on resolving this issue would be great. The
 goal of the script is to input a movie name. find the details of the movie
 from imbd.com. Then save it as a text file. Eventually this Information
 will be turned into a web page.
 

Please re-implement the code with the Google Search API, and peace will come 
upon the land.

Regards,

Shlomi Fish

-- 
-
Shlomi Fish   http://www.shlomifish.org/
Star Trek: We, the Living Dead - http://shlom.in/st-wtld

Chuck Norris is the ghost author of the entire Debian GNU/Linux distribution.
And he wrote it in 24 hours, while taking snack breaks.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Nature of this list

2011-04-23 Thread Lali
Hi everyone,
Sorry for intruding, I just recently joined this list, I have the list
messages usually skip my inbox, but somehow this one did not and as I read,
I thought I might contribute by letting you know that there are different
types of Perl beginners, particularly one type, which is not a programmer
and is never going to be one. I am in that group.
I am a forensic geneticist. I have studied medicine, human biology and now I
am doing my PhD in forensic genetics. I like programming, I remember being 8
years old sitting on my T84 making silly programs in Basic, then on the
Apple II, following a Pascal tutorial, then in 1994, taking a shot at HTML.
And that was it, my life went in another direction and I didn't do anymore
of that.
Now as a PhD student, I am supposed to have my hands on everything including
high throughput sequencing data analysis. I started last year by learning R
by myself, for statistical analysis, doing some tutorials so I could do
basic stuff with bash and learning my way around in Ubuntu. But that was not
enough, so recently, I took the Unix and Perl for Biologists (
http://korflab.ucdavis.edu/Unix_and_Perl/) course. I do not program
everyday, which makes remembering and getting better at it very hard, I have
never taken a real live course with instructors in anything programming
related, I have no background in it. After taking the Unix and Perl course I
was able to solve a problem with a simple Perl script, which seemed
monumental if done manually and I am really proud of myself for that. But
reality is that I wont get much better at it than this, I have no time for
that, I have to learn about other things too that are part of my PhD, and
maybe someday when I am done, I might be able to work with a programmer.
The thing is, that having my background it is hard to research a question
before you post it, because you don't know where to look, or there are
simply too many options and lack the knowledge to discern which one is the
right one.
I am always terrified of posting any question in a list, because I don't
want to be put down (it is not a matter of thick skin, but who in their
right mind, unless they are masochists wants to be put down?), and mainly I
don't want to waste my time, if someone answers me: you should read the
manual, has that person considered that sometimes these manuals are written
by/for programmers, and its like reading klingon for us regular people?

It took me several tries, and lots of tears of frustration to really get
into R, because I just could not understand the manual and the tutorial was
not helpful either (I finally tracked down a programmer friend of mine who
recommended R in a Nutshell and that was what got me over the first hurdle
-learning to read the manual!-).
In the beginning when I started learning, I looked for answers in the help
lists and it was very intimidating, I saw similar questions to mine which
were answered so rudely and were of no help at all, I started thinking that
these lists seemed like a medium for people who know their stuff to feel
superior and good about themselves while putting down others. I finally
gathered the courage to post a question and was told to read the manual,
the end. Not helpful at all, and also patronizing.

Now posting in lists is truly my very, very last resort, I really think
about what I am going to write, research all I can, and proof read my
message 1000 times and gather the courage to press 'send', sometimes only to
be ignored (and I can't decide what is worse, being put down or ignored).
For me this is a very bad thing, because there is no one else in my
department I can ask questions, if I Google stuff, there is a gazillion
pages to check in order to sift out moderately useful stuff, this means a
lot of time spent in a wild goose chase, time I don't have.

Not all of it is bad, of course, I have made 'friends' in some lists, who
have been kind and patient and have helped me become better at what I am
doing, and in the end I am really grateful the lists exists and that there
is people out there willing to share their knowledge, so when I read the
statement of purpose of this list, I was very impressed to find out that
there were others aware of the problem and wanted to create a list with a
friendly environment, thank you for that.

So please, think about this before answering harshly and being patronizing.
Not all of us Perl Beginners have a programming background, anyone who is a
beginner to programming needs to learn how to read the documentation/manuals
first, sometimes a silly question with an obvious answer, is there because
the person does not have someone next to them to discuss out loud beginner
stuff, and once the question is written and posted, the answer sometimes
might come by itself. Lastly, if someone out there is thinking: well, if
you are not a programmer, you shouldn't be here, all I have to say is: I am
not a programmer and I will never be one, but reality dictates that I learn

Re: Scripting problem when launching links using mech.

2011-04-23 Thread Sean Murphy

HI Shlomi

Thanks, I will check that out. Peace on the land is the best of course.  :-)

Sean
- Original Message - 
From: Shlomi Fish shlo...@iglu.org.il

To: beginners@perl.org
Cc: Sean Murphy mhysnm1...@gmail.com
Sent: Saturday, April 23, 2011 4:54 PM
Subject: Re: Scripting problem when launching links using mech.



Hi Sean,

On Saturday 23 Apr 2011 02:59:12 Sean Murphy wrote:

Hi All.

I have a script that goes to google. Performs a search.


Google does not allow you to do that using WWW-Mechanize and LWP-UserAgent
(legally). You should use their web-search API and:

http://search.cpan.org/dist/Google-Search/


I have a regular
expression that gets all the links.


You shouldn't parse HTML with regular expressions:

http://www.codinghorror.com/blog/2009/11/parsing-html-the-cthulhu-way.html


The first link in the array I return
is ment to open the next page. But it keeps failing with an error stating
it is illegal page. When I try and use lwp, it says you cannot use an
absolute link. But the link looks fine to myself.

Below is the code, any help on resolving this issue would be great. The
goal of the script is to input a movie name. find the details of the 
movie

from imbd.com. Then save it as a text file. Eventually this Information
will be turned into a web page.



Please re-implement the code with the Google Search API, and peace will 
come

upon the land.

Regards,

Shlomi Fish

--
-
Shlomi Fish   http://www.shlomifish.org/
Star Trek: We, the Living Dead - http://shlom.in/st-wtld

Chuck Norris is the ghost author of the entire Debian GNU/Linux 
distribution.

And he wrote it in 24 hours, while taking snack breaks.

Please reply to list if it's a mailing list post - http://shlom.in/reply .




--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Creating web pages using Perl.

2011-04-23 Thread Sean Murphy
Hi all.

I am starting another project and I wish to know the best method of creating a 
web page via Perl. I don't want to reinvent the wheel here. The perl script 
must generate plain 4.0 HTML code. I am not after any bells or whistles on the 
page.

The Perl script will go through all my Audio books and group them by author, 
title and titles in series. I was thinking a table with the below columns:

Author, Series, Title, stream, category  and rating. Rating is Adult, Junior, 
etc. Category is SiFi, thriller, etc. 

If the person clicks on the title, a brief description would pop-up. This would 
be a text file that it would show. Stream it would send the audio directly to 
the browser.

So is there any simple modules that would achieve this? I am not after a 
complex tool like the Ruby Rail project.

the info would come from the directory structure of the audio books. I would 
run the script and it would build the web pages. So the HTML pages would be 
semi-static.

Ideas and thoughts would be welcomed

Sean 
If they click on the 

Re: Creating web pages using Perl.

2011-04-23 Thread Shlomi Fish
Hi Sean,

On Saturday 23 Apr 2011 11:14:46 Sean Murphy wrote:
 Hi all.
 
 I am starting another project and I wish to know the best method of
 creating a web page via Perl. I don't want to reinvent the wheel here. The
 perl script must generate plain 4.0 HTML code. I am not after any bells or
 whistles on the page.
 
 The Perl script will go through all my Audio books and group them by
 author, title and titles in series. I was thinking a table with the below
 columns:
 
 Author, Series, Title, stream, category  and rating. Rating is Adult,
 Junior, etc. Category is SiFi, thriller, etc.
 
 If the person clicks on the title, a brief description would pop-up. This
 would be a text file that it would show. Stream it would send the audio
 directly to the browser.
 
 So is there any simple modules that would achieve this? I am not after a
 complex tool like the Ruby Rail project.
 
 the info would come from the directory structure of the audio books. I
 would run the script and it would build the web pages. So the HTML pages
 would be semi-static.
 
 Ideas and thoughts would be welcomed
 

There are several solutions:

1. Template Toolkit:

http://perl-begin.org/uses/text-generation/#template-toolkit

The end-all and be-all of templating systems for Perl. Very powerful, but a 
little quirky.

2. You can also output XML and generate HTML (or XHTML) from it using XSLT.
«All problems in computer science can be solved by another level of 
indirection;» -- http://en.wikipedia.org/wiki/Indirection

3. Also see the other resources about text-generation on the link, and if 
you're interested in more complex directory structures, then look at IO::All ( 
http://search.cpan.org/dist/IO-All/ ) and similar modules. 

-

Some of these tools are complex and a bit error-prone, but they could be tamed 
(for example using http://search.cpan.org/dist/Template-Stash-AutoEscaping/ ). 
As I recently talked with a friend, I think that minimalist tools (i.e: ones 
that are kept minimal and useless on purpose) are not something we like, and 
that it's important that a tool will have a low-barrier for entry, and then 
have many dark corners, which users can find if they want that. But most 
programmers and power users want and need a lot of features.

Regards,

Shlomi Fish

-- 
-
Shlomi Fish   http://www.shlomifish.org/
Stop Using MSIE - http://www.shlomifish.org/no-ie/

Every successful open-source project will eventually spawn a sub-project.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Nature of this list

2011-04-23 Thread Raymond Wan
On Sat, Apr 23, 2011 at 04:56, Randal L. Schwartz mer...@stonehenge.com wrote:
 Ian == Ian  pcs...@gmail.com writes:
 Ian Randal is arrogant and a bully and is the reason why I moved on from this
 Ian list years ago.

 You misunderstood something I said, which when taken in context, was
 appropriate then and I would say it again today.  It was a reaction to
 something you said, which had I known *more* about the situation, might
 have come out differently, but it wasn't clear from the post you made.

 See http://www.nntp.perl.org/group/perl.beginners/2009/08/msg108709.html

 I'll let my words stand for themselves.


It is interesting that you two are talking about this thread way back
in 2009.  I was not involved but was contributing as a third party.  I
can't say I'm anywhere near as hurt as Ian, but I will say that *this*
particular thread made me realize that I'd probably ought to step away
from the list, too.  My activity on the list dropped right after.  Of
course, given the number of people on this list and my relatively
little contribution, it surely wasn't a big dent on the list's
traffic.  :-)

But, if both sides (both of you) and third-party-people like me still
remember exchanges on this list from almost 2 years ago, isn't it time
to ask if any of us should approaching this list differently...  I'm
sure the majority of the nastiness of the postings would be gone if
these discussions were done face-to-face.  Imagine reading some of the
things said in that 2009 thread and this one to someone sitting in
right front of you...  Especially the parts in upper case
characters...

Ray

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Help with indentation

2011-04-23 Thread Dermot

 I have been trying to follow one of code indentation guidelines from
 wikipedia, but I have some questions that I can find answers, I would
 appreciate if someone could help me or point me towards better references.

 No. The indentation should provide a visual clue as to where the loop begins
 and ends. Once the loop has ended, the indentation should return to what it
 was at the start of the loop.


A lot of text editors, especially the command-lines [0], provide a
syntax checker. One of the features of these syntax checkers is their
ability to pair up curly braces. So when you get the dreaded Missing
braces on... error you can put your cursor on a end brace and it
shows you were it starts. This can save you a lot of time.

HTH,
Dp.

[0] http://vimdoc.sourceforge.net/htmldoc/syntax.html

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Creating web pages using Perl.

2011-04-23 Thread Peter Scott
On Sat, 23 Apr 2011 18:14:46 +1000, Sean Murphy wrote:
 
 I am starting another project and I wish to know the best method of
 creating a web page via Perl. I don't want to reinvent the wheel here.
 The perl script must generate plain 4.0 HTML code. I am not after any
 bells or whistles on the page.
 
 The Perl script will go through all my Audio books and group them by
 author, title and titles in series. I was thinking a table with the
 below columns:
 
 Author, Series, Title, stream, category  and rating. Rating is Adult,
 Junior, etc. Category is SiFi, thriller, etc.
 
 If the person clicks on the title, a brief description would pop-up.
 This would be a text file that it would show. Stream it would send the
 audio directly to the browser.

I find HTML::Template a good solution for the beginner who knows HTML. 
The Template Toolkit is awesome in its power but takes longer to learn 
for basic jobs like what you describe.  If and when you learn the 
Template Toolkit for some other reason then you're likely to use it for 
everything including tasks like this one.

The CGI.pm module can generate HTML via functions or methods with the 
same names as the elements.  It was very popular at one time although 
templating makes a lot more sense.

-- 
Peter Scott
http://www.perlmedic.com/ http://www.perldebugged.com/
http://www.informit.com/store/product.aspx?isbn=0137001274
http://www.oreillyschool.com/courses/perl3/

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Creating web pages using Perl.

2011-04-23 Thread Shawn H Corey

On 11-04-23 09:09 AM, Peter Scott wrote:

It was very popular at one time although
templating makes a lot more sense.


It was very popular at one time because at one time, it was all there 
was.  :)



--
Just my 0.0002 million dollars worth,
  Shawn

Confusion is the first step of understanding.

Programming is as much about organization and communication
as it is about coding.

The secret to great software:  Fail early  often.

Eliminate software piracy:  use only FLOSS.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




parse complicated table

2011-04-23 Thread galeb abu-ali
Hi,

I'm trying to parse a table containing information about genes in a
bacterial chromosome. Below is a sample for several genes, and there's about
4500 such blocks in a file:

gene_oidLocus TagSourceCluster InformationGene
InformationE-value
642745051SeSA_B0001COG_category[T] Signal transduction
mechanisms
642745051SeSA_B0001COG_category[K] Transcription
642745051SeSA_B0001COG1974SOS-response transcriptional
repressors (RecA-mediated autopeptidases)2.0e-29
642745051SeSA_B0001pfam00717Peptidase_S241.7e-13
642745051SeSA_B0001EC:3.4.21.-Hydrolases. Acting on peptide
bonds (peptide hydrolases). Serine endopeptidases.
642745051SeSA_B0001KO:K03503DNA polymerase V [EC:3.4.21.-]
0.0e+00
642745051SeSA_B0001ITERM:03797SOS response UmuD protein. Serine
peptidase. MEROPS family S24
642745051SeSA_B0001Locus_typeCDS
642745051SeSA_B0001NCBI_accessionYP_002112883
642745051SeSA_B0001Product_nameprotein SamA
642745051SeSA_B0001ScaffoldNC_011092
642745051SeSA_B0001Coordinates34..459(+)
642745051SeSA_B0001DNA_length426bp
642745051SeSA_B0001Protein_length141aa
642745051SeSA_B0001GC.52

642745052SeSA_B0002COG_category[L] Replication, recombination
and repair
642745052SeSA_B0002COG0389Nucleotidyltransferase/DNA polymerase
involved in DNA repair4.0e-71
642745052SeSA_B0002pfam00817IMS2.7e-36
642745052SeSA_B0002pfam11798IMS_HHH6.8e-06
642745052SeSA_B0002pfam11799IMS_C4.0e-11
642745052SeSA_B0002KO:K03502DNA polymerase V0.0e+00
642745052SeSA_B0002Locus_typeCDS
642745052SeSA_B0002NCBI_accessionYP_002112884
642745052SeSA_B0002Product_nameprotein UmuC
642745052SeSA_B0002ScaffoldNC_011092
642745052SeSA_B0002Coordinates459..1730(+)
642745052SeSA_B0002DNA_length1272bp
642745052SeSA_B0002Protein_length423aa
642745052SeSA_B0002GC.57
642745052SeSA_B0002Fused_geneYes

642745053SeSA_B0003pfam02604PhdYeFM6.0e-07
642745053SeSA_B0003Locus_typeCDS
642745053SeSA_B0003NCBI_accessionYP_002112885
642745053SeSA_B0003Product_nameantitoxin of toxin-antitoxin
stability system, StbD family
642745053SeSA_B0003ScaffoldNC_011092
642745053SeSA_B0003Coordinates1809..2060(+)
642745053SeSA_B0003DNA_length252bp
642745053SeSA_B0003Protein_length83aa
642745053SeSA_B0003GC.51

I want to parse information for Locus_Tag, Source, and Cluster Info for each
gene so that the output table looks like this


locusCOG_categoryCOG_categoryCOGIDCluster_Information

SeSA_B0001[K] TranscriptionCOG1974SOS-response transcriptional
repressors (RecA-mediated autopeptidases)
SeSA_B0002[L] Replication, recombination and repairCOG0389
Nucleotidyltransferase/DNA polymerase involved in DNA repair


My problem is that some genes have 2 entries for COG_category, some only one
and others none. I took a look at perldsc and tried to fit the table into
one of the complex structures but didn't get far. Below is the code I came
up with so far:

#!/usr/bin/perl
# parse_IMG_gene_info.pl
use strict; use warnings;


open( IN, , @ARGV ) or die Failed to open: $!\n;

print locus\tCOG_category\tCOG_category\tCOGID\tCluster_Information\n\n;

my( %locus, @cogs, %cog_cat, %cog_id, $oid, $locus, $source, $cluster_info,
$e );

while( IN ) {
if( $_=~ /COG_category/ ) {
( $oid, $locus, $source, $cluster_info ) = split \t, $_;
$cog_cat{ $locus } =  $cluster_info;
push( @cogs, { %cog_cat } );
} elsif ( $_=~ /COG\d+/ ) {
( $oid, $locus, $source, $cluster_info ) = split \t, $_;
$cog_id{ $locus } =  $cluster_info;
}
}

close IN;

#print scalar @cogs, \n;

for my $test( sort keys %cog_cat ) {
print $test\t$cog_cat{ $test }\t$cog_id{ $test }\n;
}
print \n;



Your insight is greatly appreciated!

galeb


Fwd: parse complicated table

2011-04-23 Thread galeb abu-ali
Hi,

I'm trying to parse a table containing information about genes in a
bacterial chromosome. Below is a sample for several genes, and there's about
4500 such blocks in a file:

gene_oidLocus TagSourceCluster InformationGene
InformationE-value
642745051SeSA_B0001COG_category[T] Signal transduction
mechanisms
642745051SeSA_B0001COG_category[K] Transcription
642745051SeSA_B0001COG1974SOS-response transcriptional
repressors (RecA-mediated autopeptidases)2.0e-29
642745051SeSA_B0001pfam00717Peptidase_S241.7e-13
642745051SeSA_B0001EC:3.4.21.-Hydrolases. Acting on peptide
bonds (peptide hydrolases). Serine endopeptidases.
642745051SeSA_B0001KO:K03503DNA polymerase V [EC:3.4.21.-]
0.0e+00
642745051SeSA_B0001ITERM:03797SOS response UmuD protein. Serine
peptidase. MEROPS family S24
642745051SeSA_B0001Locus_typeCDS
642745051SeSA_B0001NCBI_accessionYP_002112883
642745051SeSA_B0001Product_nameprotein SamA
642745051SeSA_B0001ScaffoldNC_011092
642745051SeSA_B0001Coordinates34..459(+)
642745051SeSA_B0001DNA_length426bp
642745051SeSA_B0001Protein_length141aa
642745051SeSA_B0001GC.52

642745052SeSA_B0002COG_category[L] Replication, recombination
and repair
642745052SeSA_B0002COG0389Nucleotidyltransferase/DNA polymerase
involved in DNA repair4.0e-71
642745052SeSA_B0002pfam00817IMS2.7e-36
642745052SeSA_B0002pfam11798IMS_HHH6.8e-06
642745052SeSA_B0002pfam11799IMS_C4.0e-11
642745052SeSA_B0002KO:K03502DNA polymerase V0.0e+00
642745052SeSA_B0002Locus_typeCDS
642745052SeSA_B0002NCBI_accessionYP_002112884
642745052SeSA_B0002Product_nameprotein UmuC
642745052SeSA_B0002ScaffoldNC_011092
642745052SeSA_B0002Coordinates459..1730(+)
642745052SeSA_B0002DNA_length1272bp
642745052SeSA_B0002Protein_length423aa
642745052SeSA_B0002GC.57
642745052SeSA_B0002Fused_geneYes



I want to parse information for Locus_Tag, Source, and Cluster Info for each
gene so that the output table looks like this


locusCOG_categoryCOG_categoryCOGIDCluster_Information

SeSA_B0001   [T] Signal transduction mechanisms[K] Transcription
COG1974SOS-response transcriptional repressors (RecA-mediated
autopeptidases)
SeSA_B0002[L] Replication, recombination and repairCOG0389
Nucleotidyltransferase/DNA polymerase involved in DNA repair


My problem is that some genes have 2 entries for COG_category, some only one
and others none. I took a look at perldsc and tried to fit the table into
one of the complex structures but didn't get far. Below is the code I came
up with so far:

#!/usr/bin/perl
# parse_IMG_gene_info.pl
use strict; use warnings;


open( IN, , @ARGV ) or die Failed to open: $!\n;

print locus\tCOG_category\tCOG_category\tCOGID\tCluster_Information\n\n;

my( %locus, @cogs, %cog_cat, %cog_id, $oid, $locus, $source, $cluster_info,
$e );

while( IN ) {
if( $_=~ /COG_category/ ) {
( $oid, $locus, $source, $cluster_info ) = split \t, $_;
$cog_cat{ $locus } =  $cluster_info;
push( @cogs, { %cog_cat } );
} elsif ( $_=~ /COG\d+/ ) {
( $oid, $locus, $source, $cluster_info ) = split \t, $_;
$cog_id{ $locus } =  $cluster_info;
}
}

close IN;

#print scalar @cogs, \n;

for my $test( sort keys %cog_cat ) {
print $test\t$cog_cat{ $test }\t$cog_id{ $test }\n;
}
print \n;



Your insight is greatly appreciated!

galeb


Fwd: parse complicated table

2011-04-23 Thread galeb abu-ali
Hi,

I'm trying to parse a table containing information about genes in a
bacterial chromosome. Below is a sample for several genes, and there's about
4500 such blocks in a file:

gene_oidLocus TagSourceCluster InformationGene
InformationE-value
642745051SeSA_B0001COG_category[T] Signal transduction
mechanisms
642745051SeSA_B0001COG_category[K] Transcription
642745051SeSA_B0001COG1974SOS-response transcriptional
repressors (RecA-mediated autopeptidases)2.0e-29
642745051SeSA_B0001pfam00717Peptidase_S241.7e-13
642745051SeSA_B0001EC:3.4.21.-Hydrolases. Acting on peptide
bonds (peptide hydrolases). Serine endopeptidases.
642745051SeSA_B0001KO:K03503DNA polymerase V [EC:3.4.21.-]
0.0e+00
642745051SeSA_B0001ITERM:03797SOS response UmuD protein. Serine
peptidase. MEROPS family S24
642745051SeSA_B0001Locus_typeCDS
642745051SeSA_B0001NCBI_accessionYP_002112883
642745051SeSA_B0001Product_nameprotein SamA
642745051SeSA_B0001ScaffoldNC_011092
642745051SeSA_B0001Coordinates34..459(+)
642745051SeSA_B0001DNA_length426bp
642745051SeSA_B0001Protein_length141aa
642745051SeSA_B0001GC.52

642745052SeSA_B0002COG_category[L] Replication, recombination
and repair
642745052SeSA_B0002COG0389Nucleotidyltransferase/DNA polymerase
involved in DNA repair4.0e-71
642745052SeSA_B0002pfam00817IMS2.7e-36
642745052SeSA_B0002pfam11798IMS_HHH6.8e-06
642745052SeSA_B0002pfam11799IMS_C4.0e-11
642745052SeSA_B0002KO:K03502DNA polymerase V0.0e+00
642745052SeSA_B0002Locus_typeCDS
642745052SeSA_B0002NCBI_accessionYP_002112884
642745052SeSA_B0002Product_nameprotein UmuC
642745052SeSA_B0002ScaffoldNC_011092
642745052SeSA_B0002Coordinates459..1730(+)
642745052SeSA_B0002DNA_length1272bp
642745052SeSA_B0002Protein_length423aa
642745052SeSA_B0002GC.57
642745052SeSA_B0002Fused_geneYes



I want to parse information for Locus_Tag, Source, and Cluster Info for each
gene so that the output table looks like this


locusCOG_categoryCOG_categoryCOGIDCluster_Information

SeSA_B0001   [T] Signal transduction mechanisms[K] Transcription
COG1974SOS-response transcriptional repressors (RecA-mediated
autopeptidases)
SeSA_B0002\t [L] Replication, recombination and repairCOG0389
Nucleotidyltransferase/DNA polymerase involved in DNA repair


My problem is that some genes have 2 entries for COG_category, some only one
and others none. I took a look at perldsc and tried to fit the table into
one of the complex structures but didn't get far. Below is the code I came
up with so far:

#!/usr/bin/perl
# parse_IMG_gene_info.pl
use strict; use warnings;


open( IN, , @ARGV ) or die Failed to open: $!\n;

print locus\tCOG_category\tCOG_category\tCOGID\tCluster_Information\n\n;

my( %locus, @cogs, %cog_cat, %cog_id, $oid, $locus, $source, $cluster_info,
$e );

while( IN ) {
if( $_=~ /COG_category/ ) {
( $oid, $locus, $source, $cluster_info ) = split \t, $_;
$cog_cat{ $locus } =  $cluster_info;
push( @cogs, { %cog_cat } );
} elsif ( $_=~ /COG\d+/ ) {
( $oid, $locus, $source, $cluster_info ) = split \t, $_;
$cog_id{ $locus } =  $cluster_info;
}
}

close IN;

#print scalar @cogs, \n;

for my $test( sort keys %cog_cat ) {
print $test\t$cog_cat{ $test }\t$cog_id{ $test }\n;
}
print \n;



Your insight is greatly appreciated!

galeb


Re: Ten Years of Considerate Help

2011-04-23 Thread Peter Scott
On Fri, 22 Apr 2011 13:39:15 -0400, Casey West wrote:
 Shortly after this mailing list got off the ground I wrote an article
 trying to instigate the Perl community to embrace the idea of a safe
 place for newcomers, both to Perl and programming. It's been pointed out
 I was marginally hyperbolic, but only a little. My abuse of the comma,
 however, has no justification. I quoted from the preface of a popular
 Perl book at the time, closing my argument thusly:
 
   But, paradoxically, the way in which Perl helps you the most has
almost nothing to do with Perl, and everything to do with the people
who use Perl. Perl folks are, frankly, some of the most helpful folks
on earth. If there's a religious quality to the Perl movement, then
this is at the heart of it. Larry wanted the Perl community to
function like a little bit of heaven, and he seems to have gotten his
wish, so far. Please do your part to keep it that way.
  -- Preface, Programming Perl 2nd Edition
 http://www.perl.com/pub/2001/05/29/tides.html

Thanks, Casey, for coming back and demonstrating that intelligence and 
politeness are not mutually exclusive. I encourage people who haven't 
read your article linked above to do so; it contains some excellent and 
concise explanations of the rationale for civil treatment of beginners.

One more explanation that might help was given to me by the founder of 
the O'Reilly School of Technology, who I am creating courses for.  He is 
very enthusiastic and inspiring about education, and wants to make sure 
all the OST courses follow his vision, and he recognizes that expertise 
is not the same thing as teaching ability, so he impressed upon his 
authors the following model.  

He breaks down students into a bell curve.  On the right tail are the 
early adopters like Randal, me, Uri, Casey, and other experts we could 
all name.  These people will learn something, anything, and everything 
without any external prodding; they just go off and hunt down the 
resources, read the manual, experiment.  They're completely self-starting.

The middle of the bell curve - where the most students are - contains 
people who learn better with varying levels of help and encouragement, 
ranging from a point in the right direction to more directed help from a 
mentor.  OST courses (and Stonehenge, etc, courses) are for them.  They'd 
be a waste of time for the people on the right tail.

People out on the right tail are particularly prone to thinking that the 
best or only way to learn is the same way they did - self-motivated 
figuring things out from the manual and experimentation - and that any 
other approach is inferior or wrong.  But it's simply not going to work 
for the folk in the middle of the curve, who learn a different way.  Some 
folk on the right tail think that if they beat up the people in the 
middle enough, they'll migrate to the right tail - where the right 
people are.  Any instances of this actually working are so rare as to be 
the exceptions that prove the rule.

Note that this is a bell curve of learning types, *not* intelligence or 
ability.  And as other posters have pointed out, someone can be in the 
right tail in one discipline, like bioinformatics, and in the middle in 
another - like Perl.

-- 
Peter Scott
http://www.perlmedic.com/ http://www.perldebugged.com/
http://www.informit.com/store/product.aspx?isbn=0137001274
http://www.oreillyschool.com/courses/perl3/

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




how to parse complex table

2011-04-23 Thread galeb abu-ali
Hi,

I'm trying to parse a table containing information about genes in a
bacterial chromosome. Below is a sample for one gene, and there's about 4500
such blocks in a file:

gene_oidLocus TagSourceCluster InformationGene
InformationE-value
642745051SeSA_B0001COG_category[T] Signal transduction
mechanisms
642745051SeSA_B0001COG_category[K] Transcription
642745051SeSA_B0001COG1974SOS-response transcriptional
repressors (RecA-mediated autopeptidases)2.0e-29
642745051SeSA_B0001pfam00717Peptidase_S241.7e-13
642745051SeSA_B0001EC:3.4.21.-Hydrolases. Acting on peptide
bonds (peptide hydrolases). Serine endopeptidases.
642745051SeSA_B0001KO:K03503DNA polymerase V [EC:3.4.21.-]
0.0e+00
642745051SeSA_B0001ITERM:03797SOS response UmuD protein. Serine
peptidase. MEROPS family S24
642745051SeSA_B0001Locus_typeCDS
642745051SeSA_B0001NCBI_accessionYP_002112883
642745051SeSA_B0001Product_nameprotein SamA
642745051SeSA_B0001ScaffoldNC_011092
642745051SeSA_B0001Coordinates34..459(+)
642745051SeSA_B0001DNA_length426bp
642745051SeSA_B0001Protein_length141aa
642745051SeSA_B0001GC.52




I want to parse information for Locus_Tag, Source, and Cluster Info for each
gene so that the output table looks like this


locusCOG_categoryCOG_categoryCOGIDCluster_Information

SeSA_B0001   [T] Signal transduction mechanisms[K] Transcription
COG1974SOS-response transcriptional repressors (RecA-mediated
autopeptidases)
SeSA_B0002\t [L] Replication, recombination and repairCOG0389
Nucleotidyltransferase/DNA polymerase involved in DNA repair


My problem is that some genes have 2 entries for COG_category, some only one
and others none. I took a look at perldsc and tried to fit the table into
one of the complex structures but didn't get far. Below is the code I came
up with so far:

#!/usr/bin/perl
# parse_IMG_gene_info.pl
use strict; use warnings;


open( IN, , @ARGV ) or die Failed to open: $!\n;

print locus\tCOG_category\tCOG_category\tCOGID\tCluster_Information\n\n;

my( %locus, @cogs, %cog_cat, %cog_id, $oid, $locus, $source, $cluster_info,
$e );

while( IN ) {
if( $_=~ /COG_category/ ) {
( $oid, $locus, $source, $cluster_info ) = split \t, $_;
$cog_cat{ $locus } =  $cluster_info;
push( @cogs, { %cog_cat } );
} elsif ( $_=~ /COG\d+/ ) {
( $oid, $locus, $source, $cluster_info ) = split \t, $_;
$cog_id{ $locus } =  $cluster_info;
}
}

close IN;

#print scalar @cogs, \n;

for my $test( sort keys %cog_cat ) {
print $test\t$cog_cat{ $test }\t$cog_id{ $test }\n;
}
print \n;



Your insight is greatly appreciated!

galeb


Re: Nature of this list

2011-04-23 Thread Randal L. Schwartz
 Raymond == Raymond Wan r@aist.go.jp writes:

Raymond But, if both sides (both of you) and third-party-people like me still
Raymond remember exchanges on this list from almost 2 years ago,

I didn't remember it at all.  I had to google for my name and his.  I
*moved on*.  I had to re-read the entire thread for context to respond
(burning about 20 minutes of what would have been otherwise productive
time) just to have a response to his allegation.  And in the light of
having reviewed the thread, the key element (that his solution actually
*was* proper) came to me, even though it didn't at that point.

But it's why I wrote the response as I did.  I said here are the
preconditions, and if this is all true, then you are lying. What he
fails to understand (and I wish he would) is that the preconditions
didn't apply, and therefore you are lying doesn't apply to him.  He
failed to read the whole letter.  He failed to understand that the last
few paragraphs clearly didn't apply to him.

I wished I had had time to read the whole thread the first time.  But I
don't have time for that anymore here. I only have a few moments from
time to time to check the answers, not the questions.

And now I've burned another hour on this issue, when I could have been
productively helping other people.  {sigh} That's the *real* cost of
this.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
mer...@stonehenge.com URL:http://www.stonehenge.com/merlyn/
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.posterous.com/ for Smalltalk discussion

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Nature of this list

2011-04-23 Thread Randal L. Schwartz
 Lali == Lali  laur...@gmail.com writes:

Lali So please, think about this before answering harshly and being
Lali patronizing.  Not all of us Perl Beginners have a programming
Lali background, anyone who is a beginner to programming needs to learn
Lali how to read the documentation/manuals first, sometimes a silly
Lali question with an obvious answer, is there because the person does
Lali not have someone next to them to discuss out loud beginner stuff,
Lali and once the question is written and posted, the answer sometimes
Lali might come by itself. Lastly, if someone out there is thinking:
Lali well, if you are not a programmer, you shouldn't be here, all I
Lali have to say is: I am not a programmer and I will never be one, but
Lali reality dictates that I learn some of this stuff and there is no
Lali other way to this, and besides in my case, I enjoy it very much --
Lali which makes it very hard to manage the time I waste on
Lali programming :)

Thank you for that post.  I just realized something this morning.  If
you go back through my complaints here and elsewhere over the years,
they fall into two main camps:

(1) people who answer someone else's question badly
(2) people who are clearly cheating on their homework

I have no issue with people asking genuine questions, and have answered
many of those over the years (nicely :).  I also have no issue with
ptople who *answer* properly.

But I will not tolerate these two camps.

This thread makes that clear.  I took someone to task for answering
badly.  (Turns out they hadn't, but that wasn't clear from their post.)

Therefore, you're safe from my wrath since you'd only be asking
questions and not trying to answer someone else.

No promises about Uri though. :)
-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
mer...@stonehenge.com URL:http://www.stonehenge.com/merlyn/
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.posterous.com/ for Smalltalk discussion

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: how to parse complex table

2011-04-23 Thread shawn wilson
now, here's a homework question!! :)

On Sat, Apr 23, 2011 at 10:27 AM, galeb abu-ali abuali...@gmail.com wrote:
 Hi,

 I'm trying to parse a table containing information about genes in a
 bacterial chromosome. Below is a sample for one gene, and there's about 4500
 such blocks in a file:

 gene_oid    Locus Tag    Source    Cluster Information    Gene
 Information    E-value
 642745051    SeSA_B0001    COG_category    [T] Signal transduction
 mechanisms
 642745051    SeSA_B0001    COG_category    [K] Transcription
 642745051    SeSA_B0001    COG1974    SOS-response transcriptional
 repressors (RecA-mediated autopeptidases)        2.0e-29
 642745051    SeSA_B0001    pfam00717    Peptidase_S24        1.7e-13
 642745051    SeSA_B0001    EC:3.4.21.-    Hydrolases. Acting on peptide
 bonds (peptide hydrolases). Serine endopeptidases.
 642745051    SeSA_B0001    KO:K03503    DNA polymerase V [EC:3.4.21.-]
    0.0e+00
 642745051    SeSA_B0001    ITERM:03797    SOS response UmuD protein. Serine
 peptidase. MEROPS family S24
 642745051    SeSA_B0001    Locus_type        CDS
 642745051    SeSA_B0001    NCBI_accession        YP_002112883
 642745051    SeSA_B0001    Product_name        protein SamA
 642745051    SeSA_B0001    Scaffold        NC_011092
 642745051    SeSA_B0001    Coordinates        34..459(+)
 642745051    SeSA_B0001    DNA_length        426bp
 642745051    SeSA_B0001    Protein_length        141aa
 642745051    SeSA_B0001    GC        .52




 I want to parse information for Locus_Tag, Source, and Cluster Info for each
 gene so that the output table looks like this


 locus    COG_category    COG_category    COGID    Cluster_Information

 SeSA_B0001   [T] Signal transduction mechanisms    [K] Transcription
 COG1974    SOS-response transcriptional repressors (RecA-mediated
 autopeptidases)
 SeSA_B0002    \t [L] Replication, recombination and repair    COG0389
 Nucleotidyltransferase/DNA polymerase involved in DNA repair


 My problem is that some genes have 2 entries for COG_category, some only one
 and others none. I took a look at perldsc and tried to fit the table into
 one of the complex structures but didn't get far. Below is the code I came
 up with so far:

 #!/usr/bin/perl
 # parse_IMG_gene_info.pl
 use strict;
use warnings;

good, but no need to save space - you have a return key, put different
things on different lines unless you *really* fell it looks / reads
better to do otherwise.



 open( IN, , @ARGV ) or die Failed to open: $!\n;

open( my $file, , $ARGV[ 0 ]) or die  $!\n;


 print locus\tCOG_category\tCOG_category\tCOGID\tCluster_Information\n\n;

 my( %locus, @cogs, %cog_cat, %cog_id, $oid, $locus, $source, $cluster_info,
 $e );

 while( IN ) {
    if( $_=~ /COG_category/ ) {
        ( $oid, $locus, $source, $cluster_info ) = split \t, $_;
        $cog_cat{ $locus } =  $cluster_info;
        push( @cogs, { %cog_cat } );
    } elsif ( $_=~ /COG\d+/ ) {
        ( $oid, $locus, $source, $cluster_info ) = split \t, $_;
        $cog_id{ $locus } =  $cluster_info;
    }
 }


i don't really have the knowledge to help here, nor really want to
parse this. instead, i'll suggest using Text::CSV_XS, it's much easier
and will give you a good data structure, all you do to figure out a
column is there is 'if( $csv-[ $col ] ) { ..column has data.. }'

 close IN;

close $file;
or just let it go out of scope and close one its own.


 #print scalar @cogs, \n;

 for my $test( sort keys %cog_cat ) {
    print $test\t$cog_cat{ $test }\t$cog_id{ $test }\n;
 }
 print \n;

can i suggest a database? it isn't that hard and will help tons in
future processing of the data and manipulation. also, a quick google
brought up some interesting results on your field:

http://oreilly.com/catalog/begperlbio/chapter/ch10.html
http://search.cpan.org/~mingyiliu/Bio-ASN1-EntrezGene-1.10-withoutworldwriteables/lib/Bio/ASN1/EntrezGene.pm

it might help to look at this (though, i think that Text::CSV will
suite your needs just fine):
http://oreilly.com/catalog/perlsysadm/chapter/ch09.html

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Nature of this list

2011-04-23 Thread Shawn H Corey

On 11-04-23 11:01 AM, Randal L. Schwartz wrote:

Therefore, you're safe from my wrath since you'd only be asking
questions and not trying to answer someone else.


Anyone can be safe from your wrath simply by setting up a message filter 
that deletes your posts unread.


Or they can unsubsrcibe from the list and learn Python or Ruby.


--
Just my 0.0002 million dollars worth,
  Shawn

Confusion is the first step of understanding.

Programming is as much about organization and communication
as it is about coding.

The secret to great software:  Fail early  often.

Eliminate software piracy:  use only FLOSS.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Nature of this list

2011-04-23 Thread Tiago Hori
Hi All,

Initially I didn't feel like getting into this discussion, because for
starters I am really new here, but I also I generally don't like to argue. I
spend most of days arguing about some or other scientific question, that
when I come home I just want to learn perl. I think one think that I haven't
seen here is this, programming is fun! At least it is for me, it is like a
game, you are given a problem and you have to solve it. The first time you
solve it, it is usually ugly but functional, than you try to make it more
elegant. Science used to be like that, I don know if it is anymore.

I actually can't complain about this list, the times I posted, I got very
positive feedback and more importantly I learned a lot. Which brings me to
Peter's early post. See, I have been using perl for years now, but I don
know perl. I cau use it under a very specific set of circumstances where
BioPerl does its magic. So I decided to learn it and I had to start from the
beginning. Now, I spent a good chucnk of early career in Science studying
exactly what Peter was talking about: how do people learn? One thing that
most camps in this area (and there are many: cognitive learning,
behavioristic learning, Vigostkyian and so forth) agree is that most people
have no idea of how they learn and that's why most people make horrible
teachers. That happens in Science all the time. A lot of the most brilliant
minds in the world, turn out to be the worst teacher's ever. Partly, I
believe, because they are brilliant. I think part of being very good in
something is not in understanding the details, but understand the
generalities. If you understand the main concepts of filed, the general
ones, than you can apply that knowledge anywhere and you won't be like me. I
only understand a little speck of perl. I understand it quite well, but
outside of its scope I am useless. That's where sometimes we (and I
personally do it a lot) fail, because the logic behind our field to damn
obvious, that how can anyone miss it? It is only obvious however, because at
some point we mastered those general concepts. And more often than not one
can only master the general concepts of related fields, of course that is
unless your are brilliant, and some people just are. So I think, it is more
than the case of the bell curve Peter described, some people just don't know
the obvious, but sometimes we forget that the obvious is only obvious to
some. Hence the comment: go and read the documentation. If you don't
understand some basics any man page could be written in greek and it may be
more clear than in english. :)

I haven't been in this list for long, but I got to say I like it. The human
conflict is never going to go away and that brings me to my last point. I
think some peole wish they were their code as some scientists wish they were
their science. Because your code can be debugged, improved, can be made
almost perfect, but as Larry put it so well: People get really annoyed when
you try to debug them. By my 0.0001 million dollar worth is that
sometimes we have to go beyond the words and look for the intentions, cause
words, especially in the internet are flawed and often disconnected from
their context. And I kind of understand both sides, it is hard to be harshly
criticized, but at the same time when I see pseudoscience it makes me want
to just go out and kill someone. The discussions may never end and some
people will always be offended by critic and some people will always be
offended by ugly code. But here I tend to agree with Randal, we must
remember that the individual value of the human-been is in who we are and
not what you code or write. And who we are is beyond the scope not only of
this list, but of the whole Internet I believe, because you don really
relate to people here, you relate to emails and posts. That not who we are
or at least it doesn't have to be.

I am here, because I enjoy learning perl, and I giggle like a little boy
every time my programs work and I know that weather in a nice or a rough
way, people here will help me improve. So it is my gain and I can live with
the occasional your code sucks or the capital letters.

And Lali, you better get a thick skin, because weather you like or not, in
science you going to get nastiness all of the time. I don think it is the
correct way to be, but it is the way it is. It will help you stay sane,
specially during your quals :)

Cheers,

T.



On Sat, Apr 23, 2011 at 12:45 PM, Shawn H Corey shawnhco...@ncf.ca wrote:

 On 11-04-23 11:01 AM, Randal L. Schwartz wrote:

 Therefore, you're safe from my wrath since you'd only be asking
 questions and not trying to answer someone else.


 Anyone can be safe from your wrath simply by setting up a message filter
 that deletes your posts unread.

 Or they can unsubsrcibe from the list and learn Python or Ruby.



 --
 Just my 0.0002 million dollars worth,
  Shawn

 Confusion is the first step of understanding.

 Programming is as much about 

Re: how to parse complex table

2011-04-23 Thread galeb abu-ali
thank you for the advice Shawn, I'll try what you suggest!
BTW, it's not homework, It's supporting metadata for my research and I'm
trying to parse it in a format that will be easier to lookup later.

thanks again

galeb

On Sat, Apr 23, 2011 at 11:10 AM, shawn wilson ag4ve...@gmail.com wrote:

 now, here's a homework question!! :)

 On Sat, Apr 23, 2011 at 10:27 AM, galeb abu-ali abuali...@gmail.com
 wrote:
  Hi,
 
  I'm trying to parse a table containing information about genes in a
  bacterial chromosome. Below is a sample for one gene, and there's about
 4500
  such blocks in a file:
 
  gene_oidLocus TagSourceCluster InformationGene
  InformationE-value
  642745051SeSA_B0001COG_category[T] Signal transduction
  mechanisms
  642745051SeSA_B0001COG_category[K] Transcription
  642745051SeSA_B0001COG1974SOS-response transcriptional
  repressors (RecA-mediated autopeptidases)2.0e-29
  642745051SeSA_B0001pfam00717Peptidase_S241.7e-13
  642745051SeSA_B0001EC:3.4.21.-Hydrolases. Acting on peptide
  bonds (peptide hydrolases). Serine endopeptidases.
  642745051SeSA_B0001KO:K03503DNA polymerase V [EC:3.4.21.-]
 0.0e+00
  642745051SeSA_B0001ITERM:03797SOS response UmuD protein.
 Serine
  peptidase. MEROPS family S24
  642745051SeSA_B0001Locus_typeCDS
  642745051SeSA_B0001NCBI_accessionYP_002112883
  642745051SeSA_B0001Product_nameprotein SamA
  642745051SeSA_B0001ScaffoldNC_011092
  642745051SeSA_B0001Coordinates34..459(+)
  642745051SeSA_B0001DNA_length426bp
  642745051SeSA_B0001Protein_length141aa
  642745051SeSA_B0001GC.52
 
 
 
 
  I want to parse information for Locus_Tag, Source, and Cluster Info for
 each
  gene so that the output table looks like this
 
 
  locusCOG_categoryCOG_categoryCOGIDCluster_Information
 
  SeSA_B0001   [T] Signal transduction mechanisms[K] Transcription
  COG1974SOS-response transcriptional repressors (RecA-mediated
  autopeptidases)
  SeSA_B0002\t [L] Replication, recombination and repairCOG0389
  Nucleotidyltransferase/DNA polymerase involved in DNA repair
 
 
  My problem is that some genes have 2 entries for COG_category, some only
 one
  and others none. I took a look at perldsc and tried to fit the table into
  one of the complex structures but didn't get far. Below is the code I
 came
  up with so far:
 
  #!/usr/bin/perl
  # parse_IMG_gene_info.pl
  use strict;
 use warnings;

 good, but no need to save space - you have a return key, put different
 things on different lines unless you *really* fell it looks / reads
 better to do otherwise.

 
 
  open( IN, , @ARGV ) or die Failed to open: $!\n;

 open( my $file, , $ARGV[ 0 ]) or die  $!\n;

 
  print
 locus\tCOG_category\tCOG_category\tCOGID\tCluster_Information\n\n;
 
  my( %locus, @cogs, %cog_cat, %cog_id, $oid, $locus, $source,
 $cluster_info,
  $e );
 
  while( IN ) {
 if( $_=~ /COG_category/ ) {
 ( $oid, $locus, $source, $cluster_info ) = split \t, $_;
 $cog_cat{ $locus } =  $cluster_info;
 push( @cogs, { %cog_cat } );
 } elsif ( $_=~ /COG\d+/ ) {
 ( $oid, $locus, $source, $cluster_info ) = split \t, $_;
 $cog_id{ $locus } =  $cluster_info;
 }
  }
 

 i don't really have the knowledge to help here, nor really want to
 parse this. instead, i'll suggest using Text::CSV_XS, it's much easier
 and will give you a good data structure, all you do to figure out a
 column is there is 'if( $csv-[ $col ] ) { ..column has data.. }'

  close IN;

 close $file;
 or just let it go out of scope and close one its own.

 
  #print scalar @cogs, \n;
 
  for my $test( sort keys %cog_cat ) {
 print $test\t$cog_cat{ $test }\t$cog_id{ $test }\n;
  }
  print \n;

 can i suggest a database? it isn't that hard and will help tons in
 future processing of the data and manipulation. also, a quick google
 brought up some interesting results on your field:

 http://oreilly.com/catalog/begperlbio/chapter/ch10.html

 http://search.cpan.org/~mingyiliu/Bio-ASN1-EntrezGene-1.10-withoutworldwriteables/lib/Bio/ASN1/EntrezGene.pm

 it might help to look at this (though, i think that Text::CSV will
 suite your needs just fine):
 http://oreilly.com/catalog/perlsysadm/chapter/ch09.html

 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/





Re: Nature of this list

2011-04-23 Thread Shawn H Corey

On 11-04-23 11:55 AM, Tiago Hori wrote:

And Lali, you better get a thick skin, because weather you like or not, in
science you going to get nastiness all of the time. I don think it is the
correct way to be, but it is the way it is. It will help you stay sane,
specially during your quals:)


One editor of the New York Times said that 9 out of 10 letters to the 
editor are nothing but complaints...and the other 10% have a compliment 
to go with their complaints.


People complain; it's the nature of the beast.  But that doesn't mean 
they have to be rude about it.  Calling someone stupid is rude.  Calling 
their best efforts stupid is an indirect way of calling them stupid and 
if anything, even ruder.  Generally, I just ignore the rudeness and if 
it becomes too much, I go somewhere else.  After all, the first rule of 
the internet is:  You can be ignored in less than 5 seconds.


If the Perl community wants to grow and become more relevant, it is 
going to have to call people to task when they are rude, especially in a 
beginners group.



--
Just my 0.0002 million dollars worth,
  Shawn

Confusion is the first step of understanding.

Programming is as much about organization and communication
as it is about coding.

The secret to great software:  Fail early  often.

Eliminate software piracy:  use only FLOSS.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Nature of this list

2011-04-23 Thread Tiago Hori
 People complain; it's the nature of the beast.  But that doesn't mean they
 have to be rude about it.  Calling someone stupid is rude.  Calling their
 best efforts stupid is an indirect way of calling them stupid and if
 anything, even ruder.  Generally, I just ignore the rudeness and if it
 becomes too much, I go somewhere else.  After all, the first rule of the
 internet is:  You can be ignored in less than 5 seconds.

 If the Perl community wants to grow and become more relevant, it is going
 to have to call people to task when they are rude, especially in a beginners
 group.


No, no one needs to be rude, but some people are. Some people are rude
because they are just stupid, but I like to believe that the vast majority
is rude because they don't know any better. I just think that getting a
thick skin is not synonymous with accepting the rudeness. I try to very hard
(and sometimes fail) not to be rude when reviewing scientific articles for
publications for example, but I had to learn to get a thick skin, cause more
often than not the reviews I get are just nasty! :)

T.

-- 
Education is not to be used to promote obscurantism. - Theodonius
Dobzhansky.

Gracias a la vida que me ha dado tanto
Me ha dado el sonido y el abecedario
Con él, las palabras que pienso y declaro
Madre, amigo, hermano
Y luz alumbrando la ruta del alma del que estoy amando

Gracias a la vida que me ha dado tanto
Me ha dado la marcha de mis pies cansados
Con ellos anduve ciudades y charcos
Playas y desiertos, montañas y llanos
Y la casa tuya, tu calle y tu patio

Violeta Parra - Gracias a la Vida

Tiago S. F. Hori
PhD Candidate - Ocean Science Center-Memorial University of Newfoundland


Re: Nature of this list

2011-04-23 Thread Chap Harrison
Tangential to the topic, but related to the traditional programming culture 
some have described -- I've programmed professionally since 1978, although I 
haven't come anywhere close to Randal's heights.  In the early '90s I was a 
developer at a DBMS vendor in Kendall Square, Cambridge, which was founded by, 
and employed, some of MIT and Boston College's Best and Brightest - people with 
a rather high opinion of themselves, as the office mom mildly said.  After 
the first few times the Principal Software Architect (whisperingly referred to 
as God) reviewed my code, I finally went to his office and had a private chat 
with him.  (Poor guy apparently hadn't heard anyone tell him they felt 
belittled or scorned by his tone before.)  Given that we were face to face, and 
I was using a calm voice, and he *couldn't* actually just sock me in the nose, 
or fire me, he had to listen to me.  He had no problem, nor lost any face, 
dropping the attitude real quick.  I was happier; he got to spend a bit less 
time being pissed off and severe; I really learned a LOT of excellent practical 
engineering from him; and I talked him up to those I later mentored.  I see 
nothing of value that was lost.  

That's all just to say that, while the traditional sci/tech culture may still 
be rife with big shots and ass-hattery, it's worth summoning the guts to look 
straight into someone's eyes and quietly insist upon being treated with common 
courtesy.  They're actually not as dumb as they act! :D

Chap
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Nature of this list

2011-04-23 Thread Shawn H Corey

On 11-04-23 12:33 PM, Tiago Hori wrote:

Some people are rude
because they are just stupid, but I like to believe that the vast majority
is rude because they don't know any better.


I met some stupid people and they're a not rude.  In fact, they're often 
nicer than most people with more brains.


The problem is that some people see things that irritate them and decide 
to take out their angry and frustration on complete strangers.  But 
there's no excuse for their behaviour.


As the turtle says, Mellow out, dude.


--
Just my 0.0002 million dollars worth,
  Shawn

Confusion is the first step of understanding.

Programming is as much about organization and communication
as it is about coding.

The secret to great software:  Fail early  often.

Eliminate software piracy:  use only FLOSS.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Nature of this list

2011-04-23 Thread Tiago Hori
   I met some stupid people and they're a not rude.  In fact, they're often
nicer than most people with more brains.


 The problem is that some people see things that irritate them and decide to
 take out their angry and frustration on complete strangers.  But there's no
 excuse for their behaviour.

 As the turtle says, Mellow out, dude.


:) I love it!

T.

-- 
Education is not to be used to promote obscurantism. - Theodonius
Dobzhansky.

Gracias a la vida que me ha dado tanto
Me ha dado el sonido y el abecedario
Con él, las palabras que pienso y declaro
Madre, amigo, hermano
Y luz alumbrando la ruta del alma del que estoy amando

Gracias a la vida que me ha dado tanto
Me ha dado la marcha de mis pies cansados
Con ellos anduve ciudades y charcos
Playas y desiertos, montañas y llanos
Y la casa tuya, tu calle y tu patio

Violeta Parra - Gracias a la Vida

Tiago S. F. Hori
PhD Candidate - Ocean Science Center-Memorial University of Newfoundland


Re: how to parse complex table

2011-04-23 Thread shawn wilson
On Sat, Apr 23, 2011 at 11:56 AM, galeb abu-ali abuali...@gmail.com wrote:

 BTW, it's not homework, It's supporting metadata for my research and I'm
 trying to parse it in a format that will be easier to lookup later.


it was a joke. i figured you were either a graduate student,
researcher, or hacking around with large data sets for the heck of it.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Nature of this list

2011-04-23 Thread Casey West
On Sat, Apr 23, 2011 at 12:40 PM, Chap Harrison c...@pobox.com wrote:

 That's all just to say that, while the traditional sci/tech culture may
 still be rife with big shots and ass-hattery, it's worth summoning the guts
 to look straight into someone's eyes and quietly insist upon being treated
 with common courtesy.  They're actually not as dumb as they act! :D


Chap, that's an excellent point and your story is a great teaching story.
I've been in your shoes before. You know, at my children's school they have
a rigid anti-bullying policy. If you, as a child, have been called out for
bullying you're required to fill out this worksheet (fair warning: comic
sans ahead):
  http://www.mtlsd.org/lincoln_elementary/stuff/bully%20think-about-it.pdf

I'll copy for those without PDF readers.

1. What did you do that doesn’t fit with our Lincoln School Rules? (Be
specific and start with “I”)

2. Why was this behavior wrong or hurtful to others?  (Who did you hurt? How
do you know you hurt that person?)

3. What problem were you trying to solve?  (Think about it…were you trying
to have fun? Did you want someone to listen to you or leave you alone? Were
you trying to impress your friends? Were you angry about something else?)

4. Next time you have that problem, how will you solve it without hurting
someone else? (Please list at least three ways and choose one)

I'd say this worksheet applies to our experiences on the beginners mailing
list. If you've been called out for bullying, whatever the form, it would be
prudent to fill out this worksheet. The skill of accepting constructive
criticism is a learned one; not everyone has it. If you do, though, it means
your effectiveness within *this* group dynamic will not diminish on account
of failing to hear your audience's feedback.

Cheers,

-- 
Casey West


Re: Nature of this list

2011-04-23 Thread Shlomi Fish
On Saturday 23 Apr 2011 17:53:30 Randal L. Schwartz wrote:
  Raymond == Raymond Wan r@aist.go.jp writes:
 Raymond But, if both sides (both of you) and third-party-people like me
 still Raymond remember exchanges on this list from almost 2 years ago,
 
 I didn't remember it at all.  I had to google for my name and his.  I
 *moved on*.  I had to re-read the entire thread for context to respond
 (burning about 20 minutes of what would have been otherwise productive
 time) just to have a response to his allegation.  And in the light of
 having reviewed the thread, the key element (that his solution actually
 *was* proper) came to me, even though it didn't at that point.
 
 But it's why I wrote the response as I did.  I said here are the
 preconditions, and if this is all true, then you are lying. What he
 fails to understand (and I wish he would) is that the preconditions
 didn't apply, and therefore you are lying doesn't apply to him.  He
 failed to read the whole letter.  He failed to understand that the last
 few paragraphs clearly didn't apply to him.

Just a note about etymology and semantics - it is a good idea to *never* 
accuse someone of lying in an online forum. Avoid using this word. To quote 
some definitionf of to lie:

«To give false information intentionally. » 
-- http://en.wiktionary.org/wiki/lie#Verb_2

«to make an untrue statement with intent to deceive »
-- http://www.merriam-webster.com/dictionary/lie%5B3%5D

In short it is a very strong accusation, a deliberate act of dishonesty, that 
to many Israeli Jews bring associations of various Biblical passages with a 
lot of fire and brimstone and what not. Most honest people will never lie in 
this way,  or excluding the natural http://en.wikipedia.org/wiki/White_lies or 
the natural acceptable lies when under threat of force, etc., but these are 
beyond the scope of this.

When someone is saying something that's false or incorrect, they are likely 
not saying it deliberately. They may be misled or too clueless about it. They 
may believe that their way is superior (after weighing all the arguments) - 
like XML::Simple is great. vs. XML::Simple should be called XML::Evil 
(things that are a matter of choice rather than absolute ethics and morality). 
Or it could be other forms of ignorance that I forgot.

So it's a good rule of thumb to *never* accuse someone of lying. There are 
many other words That's not true, you are misleading wrong , etc.

 
 I wished I had had time to read the whole thread the first time.  But I
 don't have time for that anymore here. I only have a few moments from
 time to time to check the answers, not the questions.
 
 And now I've burned another hour on this issue, when I could have been
 productively helping other people.  {sigh} That's the *real* cost of
 this.

My psychotherapist told me that I should try to maximise pleasure (without 
getting into http://en.wikipedia.org/wiki/Hedonism , naturlaly), and not 
productivity, because I have an obsession with being productive most of the 
time and it can make me stressed. It's a good advice to follow - it's OK to 
waste time. Maybe sometimes you should even do something that is a waste of 
time.

Regards,

Shlomi Fish

-- 
-
Shlomi Fish   http://www.shlomifish.org/
Rethinking CPAN - http://shlom.in/rethinking-cpan

95% of Programmers consider 95% of the code they did not write, in the bottom
5%.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Nature of this list

2011-04-23 Thread Shawn H Corey

On 11-04-23 12:53 PM, Casey West wrote:

1. What did you do that doesn’t fit with our Lincoln School Rules? (Be
specific and start with “I”)


Wow.  The very first thing they have to think about is their contempt 
for the school authorities and not their victims' feelings.  No wonder 
why they tought they could get away with it.  All they had to do is hide 
their actions from the authorities.  You know, there's something a 
little bit sick about a society that insists that the authorities are 
the only ones capable of deciding right and wrong.



--
Just my 0.0002 million dollars worth,
  Shawn

Confusion is the first step of understanding.

Programming is as much about organization and communication
as it is about coding.

The secret to great software:  Fail early  often.

Eliminate software piracy:  use only FLOSS.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Nature of this list

2011-04-23 Thread Raymond Wan
On Sat, Apr 23, 2011 at 23:53, Randal L. Schwartz mer...@stonehenge.com wrote:
 Raymond == Raymond Wan r@aist.go.jp writes:

 Raymond But, if both sides (both of you) and third-party-people like me still
 Raymond remember exchanges on this list from almost 2 years ago,

 I didn't remember it at all.  I had to google for my name and his.  I


Fair enough -- I stand corrected.  :-)  Definitely underestimated the
ability of Google.  ;-)



 But it's why I wrote the response as I did.  I said here are the
 preconditions, and if this is all true, then you are lying. What he
 fails to understand (and I wish he would) is that the preconditions
 didn't apply, and therefore you are lying doesn't apply to him.  He
 failed to read the whole letter.  He failed to understand that the last
 few paragraphs clearly didn't apply to him.


Well, I think it's safe to say that there are certain words that have
a good chance of being misinterpretted and lying is perhaps one of
them, especially if the reader cannot see the word I before and a
smiley face afterwards...  By this I mean that if it's reached a level
where it is preceeded by you, it is hard to expect anyone to see the
entire context clearly anymore.  For better or for worse, I'd probably
be the same...


 And now I've burned another hour on this issue, when I could have been
 productively helping other people.  {sigh} That's the *real* cost of
 this.


Well, IMHO, spending an hour to reflect on what was said to someone is
never a waste of time...

Ray

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Nature of this list

2011-04-23 Thread Chap Harrison

On Apr 23, 2011, at 12:22 PM, Shlomi Fish wrote:

 Just a note about etymology and semantics - it is a good idea to *never* 
 accuse someone of lying in an online forum. 

But Shlomi - don't you remember?  He #ifdef'd it out!  :-p

Hee hee.

/facetious

Chap

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Nature of this list

2011-04-23 Thread Raymond Wan
Hi Tiago,


On Sun, Apr 24, 2011 at 01:33, Tiago Hori tiago.h...@gmail.com wrote:
 No, no one needs to be rude, but some people are. Some people are rude
 because they are just stupid, but I like to believe that the vast majority
 is rude because they don't know any better. I just think that getting a
 thick skin is not synonymous with accepting the rudeness. I try to very hard
 (and sometimes fail) not to be rude when reviewing scientific articles for
 publications for example, but I had to learn to get a thick skin, cause more
 often than not the reviews I get are just nasty! :)


I'm not so sure about this last point.  Yes there are nasty scientific
reviewers out there and the reason is that no one is taught to review
nicely.  They've learned to be nasty either from someone they worked
with or, more than likely, from someone else who was nasty to them.

Perhaps people in the scientific community and here on this list
should grow a thicker skin...but then one day, things degenerate and
get out of hand.  And you end up potentially losing good scientists or
good Perl programmers...as Shawn quipped, to Python or Ruby.  :-)  Is
that good for Perl?  Ok...for Perl is an exaggeration.  How about,
is it good for this mailing list?

As for the nasty scientific reviewers, IMHO, you should mention it to
the editor of the journal.  No, you won't get your paper accepted --
that shouldn't be the point.  But as long as you have a good argument
and are *polite* and *constructive* in your response, the editor might
at least take a note of this nasty person and if many complaints come
in, s/he will no longer be asked to review.  Again, IMHO, it is
perhaps better than feeling that being nasty is part of the peer
review process and then taking it out on someone else -- a vicious
cycle...

Ray

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Creating web pages using Perl.

2011-04-23 Thread David Christensen

On 04/23/2011 01:14 AM, Sean Murphy wrote:
 The perl script must generate plain 4.0 HTML code. I am not after any 
bells or whistles on the page.
 The Perl script will go through all my Audio books and group them by 
author, title and titles in series. I was thinking a table with the 
below columns:
 Author, Series, Title, stream, category  and rating. Rating is Adult, 
Junior, etc. Category is SiFi, thriller, etc.
 If the person clicks on the title, a brief description would pop-up. 
This would be a text file that it would show. Stream it would send the 
audio directly to the browser.
 the info would come from the directory structure of the audio books. 
I would run the script and it would build the web pages. So the HTML 
pages would be semi-static.


Compiled static HTML sites have distinct advantages, but if the site is 
low-bandwidth (e.g. personal/ LAN use) and/or you're library isn't too 
big, you might be able to accomplish your goal with a single CGI script. 
One advantage of a purely dynamic site is that you can create/ update/ 
delete data in the back end via whatever means and the current 
information will automagically appear via the front-end.



HTH,

David

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Nature of this list

2011-04-23 Thread Tiago Hori
 I'm not so sure about this last point.  Yes there are nasty scientific
 reviewers out there and the reason is that no one is taught to review
 nicely.  They've learned to be nasty either from someone they worked
 with or, more than likely, from someone else who was nasty to them.

 Perhaps people in the scientific community and here on this list
 should grow a thicker skin...but then one day, things degenerate and
 get out of hand.  And you end up potentially losing good scientists or
 good Perl programmers...as Shawn quipped, to Python or Ruby.  :-)  Is
 that good for Perl?  Ok...for Perl is an exaggeration.  How about,
 is it good for this mailing list?

 As for the nasty scientific reviewers, IMHO, you should mention it to
 the editor of the journal.  No, you won't get your paper accepted --
 that shouldn't be the point.  But as long as you have a good argument
 and are *polite* and *constructive* in your response, the editor might
 at least take a note of this nasty person and if many complaints come
 in, s/he will no longer be asked to review.  Again, IMHO, it is
 perhaps better than feeling that being nasty is part of the peer
 review process and then taking it out on someone else -- a vicious
 cycle...

 Ray


Ray,

That is an excellent point. It is a vicious cycle, you grow a thick skin to
protect yourself from the nastiness and the nastiness stops mattering, at
which point you are likely to become nasty yourself.

I still believe that one needs to protect oneself from the world, but not,
as you said, at the cost of becoming a jerk. I also believe that it is
possible to do so.

As Che Guevara once said: Hay que endurecese, pero sin perder la ternuara
jamais. One has to make once self stronger, but never at the cost of one's
tenderness.

Cheers,

T.






-- 
Education is not to be used to promote obscurantism. - Theodonius
Dobzhansky.

Gracias a la vida que me ha dado tanto
Me ha dado el sonido y el abecedario
Con él, las palabras que pienso y declaro
Madre, amigo, hermano
Y luz alumbrando la ruta del alma del que estoy amando

Gracias a la vida que me ha dado tanto
Me ha dado la marcha de mis pies cansados
Con ellos anduve ciudades y charcos
Playas y desiertos, montañas y llanos
Y la casa tuya, tu calle y tu patio

Violeta Parra - Gracias a la Vida

Tiago S. F. Hori
PhD Candidate - Ocean Science Center-Memorial University of Newfoundland


Re: Nature of this list

2011-04-23 Thread Lali
I agree with you Ray, a nasty reply in a professional setting is easy to
fend with a well thought answer.
 Having a thick skin, what does that mean? I don't run and throw myself on
my bed and cry my eyes out when I get a harsh critique, but I won't lie and
say that it sits well on me right away, after the bad feelings are sorted
out, a harsh critique usually motivates me to be better. But it has to be a
harsh critique with substance, and those are usually the ones that hurt the
most, if you are convinced you have done a good job, or if you are not aware
you made a mistake, an omission or something of the sorts. On the other
hand, an empty nasty comment really doesn't help anyone, specially a
beginner. But maybe I am a little inexperienced, I have never received a
nasty review for any of my articles, but I did have a particularly nasty
supervisor, and I did speak out and it did have consequences for me, far
more serious than getting an article rejected.

L

On Sat, Apr 23, 2011 at 7:44 PM, Raymond Wan r@aist.go.jp wrote:

 Hi Tiago,


 On Sun, Apr 24, 2011 at 01:33, Tiago Hori tiago.h...@gmail.com wrote:
  No, no one needs to be rude, but some people are. Some people are rude
  because they are just stupid, but I like to believe that the vast
 majority
  is rude because they don't know any better. I just think that getting a
  thick skin is not synonymous with accepting the rudeness. I try to very
 hard
  (and sometimes fail) not to be rude when reviewing scientific articles
 for
  publications for example, but I had to learn to get a thick skin, cause
 more
  often than not the reviews I get are just nasty! :)


 I'm not so sure about this last point.  Yes there are nasty scientific
 reviewers out there and the reason is that no one is taught to review
 nicely.  They've learned to be nasty either from someone they worked
 with or, more than likely, from someone else who was nasty to them.

 Perhaps people in the scientific community and here on this list
 should grow a thicker skin...but then one day, things degenerate and
 get out of hand.  And you end up potentially losing good scientists or
 good Perl programmers...as Shawn quipped, to Python or Ruby.  :-)  Is
 that good for Perl?  Ok...for Perl is an exaggeration.  How about,
 is it good for this mailing list?

 As for the nasty scientific reviewers, IMHO, you should mention it to
 the editor of the journal.  No, you won't get your paper accepted --
 that shouldn't be the point.  But as long as you have a good argument
 and are *polite* and *constructive* in your response, the editor might
 at least take a note of this nasty person and if many complaints come
 in, s/he will no longer be asked to review.  Again, IMHO, it is
 perhaps better than feeling that being nasty is part of the peer
 review process and then taking it out on someone else -- a vicious
 cycle...

 Ray

 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/





Re: Nature of this list

2011-04-23 Thread Tiago Hori
On Sat, Apr 23, 2011 at 3:24 PM, Lali laur...@gmail.com wrote:

 I agree with you Ray, a nasty reply in a professional setting is easy to
 fend with a well thought answer.
  Having a thick skin, what does that mean? I don't run and throw myself on
 my bed and cry my eyes out when I get a harsh critique, but I won't lie and
 say that it sits well on me right away, after the bad feelings are sorted
 out, a harsh critique usually motivates me to be better. But it has to be a
 harsh critique with substance, and those are usually the ones that hurt the
 most, if you are convinced you have done a good job, or if you are not aware
 you made a mistake, an omission or something of the sorts. On the other
 hand, an empty nasty comment really doesn't help anyone, specially a
 beginner. But maybe I am a little inexperienced, I have never received a
 nasty review for any of my articles, but I did have a particularly nasty
 supervisor, and I did speak out and it did have consequences for me, far
 more serious than getting an article rejected.

 L

 Lali,

To me a thick skin is learning to distance yourself from your work and it
took me a really long time to learn how to do it. It is to step back and see
harsh criticism for what it is, it is an attack, substantiated or not on the
work, not on you. Whatever anyone says about what you do, is not a final
judgment not on you not on your work. Step back, take what you can, learn
what you can and move on. I think it will keep you sane, but take care not
to become jaded and if you don't enjoy hard criticism, try really hard not
to it yourself. In that way, maybe one day soon, we won't need thich skins.

Cheers,

T.


-- 
Education is not to be used to promote obscurantism. - Theodonius
Dobzhansky.

Gracias a la vida que me ha dado tanto
Me ha dado el sonido y el abecedario
Con él, las palabras que pienso y declaro
Madre, amigo, hermano
Y luz alumbrando la ruta del alma del que estoy amando

Gracias a la vida que me ha dado tanto
Me ha dado la marcha de mis pies cansados
Con ellos anduve ciudades y charcos
Playas y desiertos, montañas y llanos
Y la casa tuya, tu calle y tu patio

Violeta Parra - Gracias a la Vida

Tiago S. F. Hori
PhD Candidate - Ocean Science Center-Memorial University of Newfoundland


Re: how to parse complex table

2011-04-23 Thread galeb abu-ali
i guess the sensitivity stemmed from reading random snippets from the thread
'the nature of this list' and how using it do homework is considered abuse,
so i didn't want to fall in that category.
thanks again

galeb

On Sat, Apr 23, 2011 at 12:51 PM, shawn wilson ag4ve...@gmail.com wrote:

 On Sat, Apr 23, 2011 at 11:56 AM, galeb abu-ali abuali...@gmail.com
 wrote:

  BTW, it's not homework, It's supporting metadata for my research and I'm
  trying to parse it in a format that will be easier to lookup later.
 

 it was a joke. i figured you were either a graduate student,
 researcher, or hacking around with large data sets for the heck of it.

 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/





Re: Nature of this list

2011-04-23 Thread Chap Harrison
On Apr 23, 2011, at 10:01 AM, Randal L. Schwartz wrote:

 I just realized something this morning.  If
 you go back through my complaints here and elsewhere over the years,
 they fall into two main camps:
 
 (1) people who answer someone else's question badly

[snip]

This raises for me the question, who may submit *answers* on this list?  

It's my perception that most of protracted flaming is among the answerers.  The 
asker (such as Jyotishmaan Ray in the 2009 thread Ian and Randal refer to, 
http://www.nntp.perl.org/group/perl.beginners/2009/08/msg108616.html) often 
disappears from the thread and is forgotten entirely, as the expert debate 
rages on.

I've read the list FAQ, and the links that Casey provided recently, and 
couldn't find an answer to this question.

Chap
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Nature of this list

2011-04-23 Thread Brian Fraser
Please people. I urge you all to kindly fuck off.

This is getting ridiculous. You are arguing about *tone*. Who gives a flying
fuck about tone if the post has substance? Are we fucking two? Are our egos
so fragile that we can't take the slightest of drubbings? So sensitive that
a word in caps can start this kind of shitstorm?

(Apparently yes, but bear with me for a sec)

Tone trolls, the lot of you. Yes, being nice is fine and all, and it's a
beginners list, so handholding should be the aim. And rudeness for rudeness
sake is utterly counterproductive. But I've been on this list for a while
now, and I can't recall a single instance of someone being rude when
replying a question.

...I'll be the first to admit that my memory is crap, but nevertheless,
until someone has provided links to substantiate these claims, please drop
the strawman.

On the topic of tone, if an error is so egregious that it must be corrected,
strong language sometimes is needed to drive the point. Personally, I still
wouldn't condone that kind terseness... When directly answering the
beginner. But answers themselves? That's an entirely different domain. By
answering, you are claiming to be an expert; As an expert, you are opening
your answer and code to full scrutiny.
If you choose to be the kind of teacher who will always answer with a smile
and kindly nudge people into enlightenment, good for you. But spare the rest
of us of the lecture. You'll find that not wasting your time trying to
control how others communicate can be quite freeing. :)

(A side note for Tiago and Lali and any other PhD student and/or scientist
out there: Just mention your situation and you are assured, to the best of
my ability, a hand-holding reply from me. Which may turn out to be
respectful silence as I'm not an expert, but well. I have a soft spot for
science, which can probably be traced back to a math or science teacher
(or blogger) that I appreciate :p)

Brian.


Re: Nature of this list

2011-04-23 Thread Marilyn Sander, Ken Armstrong
The F-bomb is totally unnecessary.  Such language is for teenagers who do not 
yet know how to communicate displeasure effectively.  Please grow up.
Personally, I am finding this discussion fascinating.  I have often wondered 
why the academics at IBM would attack each other's presentations.  It appears 
that part of the process of getting a PhD is learning to give and take intense 
attacks.  This discussion is most enlightening.
Marilyn
On Apr 23, 2011, at 12:00 PM, Brian Fraser wrote:

 Please people. I urge you all to kindly fuck off.
 
 This is getting ridiculous. You are arguing about *tone*. Who gives a flying
 fuck about tone if the post has substance? Are we fucking two? Are our egos
 so fragile that we can't take the slightest of drubbings? So sensitive that
 a word in caps can start this kind of shitstorm?
 
 (Apparently yes, but bear with me for a sec)
 
 Tone trolls, the lot of you. Yes, being nice is fine and all, and it's a
 beginners list, so handholding should be the aim. And rudeness for rudeness
 sake is utterly counterproductive. But I've been on this list for a while
 now, and I can't recall a single instance of someone being rude when
 replying a question.
 
 ...I'll be the first to admit that my memory is crap, but nevertheless,
 until someone has provided links to substantiate these claims, please drop
 the strawman.
 
 On the topic of tone, if an error is so egregious that it must be corrected,
 strong language sometimes is needed to drive the point. Personally, I still
 wouldn't condone that kind terseness... When directly answering the
 beginner. But answers themselves? That's an entirely different domain. By
 answering, you are claiming to be an expert; As an expert, you are opening
 your answer and code to full scrutiny.
 If you choose to be the kind of teacher who will always answer with a smile
 and kindly nudge people into enlightenment, good for you. But spare the rest
 of us of the lecture. You'll find that not wasting your time trying to
 control how others communicate can be quite freeing. :)
 
 (A side note for Tiago and Lali and any other PhD student and/or scientist
 out there: Just mention your situation and you are assured, to the best of
 my ability, a hand-holding reply from me. Which may turn out to be
 respectful silence as I'm not an expert, but well. I have a soft spot for
 science, which can probably be traced back to a math or science teacher
 (or blogger) that I appreciate :p)
 
 Brian.


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Nature of this list

2011-04-23 Thread Brian Fraser
On Sat, Apr 23, 2011 at 4:15 PM, Marilyn Sander, Ken Armstrong 
marilyn-san...@earthlink.net wrote:

 The F-bomb is totally unnecessary.  Such language is for teenagers who do
 not yet know how to communicate displeasure effectively.  Please grow up.
 Personally, I am finding this discussion fascinating.  I have often
 wondered why the academics at IBM would attack each other's presentations.
  It appears that part of the process of getting a PhD is learning to give
 and take intense attacks.  This discussion is most enlightening.
 Marilyn

 There ought to be a room in every house to swear in. It's dangerous to
have to repress an emotion like that. Mark Twain.

It's part of the language, whenever you like it or not. Again, please look
beyond the tone and see the substance of the psot - The swearing was there
exactly to demonstrate that a few strong words shouldn't matter in your
appreciation of a message.

I guess that misfired, though.

Brian.


Re: how to parse complex table

2011-04-23 Thread Shawn H Corey

On 11-04-23 02:54 PM, galeb abu-ali wrote:

using it do homework is considered abuse


Using to do your homework is abuse.  Using it to ask about homework 
isn't.  The difference how much effort you put in.  Some guidelines:


1.  Say it's homework from the start.

2.  Include the code you have so far.

3.  Include some input data.

4.  State what you want for the output.  Those who are interested can 
run the code with the data to see what goes wrong.


5.  Don't expect an immediate response.  Everyone here is a volunteer 
and are often busy doing other things.


Please note that everything posted is advice; it may not work and you 
are not force to take it.



--
Just my 0.0002 million dollars worth,
  Shawn

Confusion is the first step of understanding.

Programming is as much about organization and communication
as it is about coding.

The secret to great software:  Fail early  often.

Eliminate software piracy:  use only FLOSS.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Help with indentation

2011-04-23 Thread Brian Fraser
On Fri, Apr 22, 2011 at 10:08 PM, Tiago Hori tiago.h...@gmail.com wrote:

 Hi List,

 Howdy. Before we start, instead of using wikipedia, if you can get your
hands on it and feel like spending a few hours of your time, Perl Best
Practices[0] is the way to go.

However, assuming that you are a busy person (and, as a PhD student, broke
and can't afford books), here's something that will alleviate most of your
style woes: perltidy[1]. perltidy is a nifty utility that will grab your
code and vomit a tidied version. In fact, let's go grab your original post
and run it through perltidy..

http://ideone.com/VAdfe

Which is looking pretty nice already, eh. You can change how it indents too,
so you'll get the braces however you prefer them and sosuch. In any case,
after running a couple of your scripts through perltidy, some of the style
should rub off you and you'll start doing it naturally.

That aside, some corrections to your code..
You are using a bunch of global variables -This is generally a big red flag,
as later on if the program grows or you make a change it might have weird
effects at a distance. For example, all the processing of $seqnum is inside
readFasta, and thenonce outside to print the results. Instead of that, you
might want to declare two versions of $seqnum: One inside of readFasta, and
one outside, to receive the results of that function.

Basically:

my ($seqnum) = readFasta( $ARGV[0] );

sub readFasta {
my $seqnum = 0;
...
return $seqnum;
}

We'll get back to this later.

Then, you are using a lot of bareword filehandles - stuff like TARGETS.
Here's the chance to introduce another nifty utility - perlcritic[2]. You
may recall me mentioning Perl Best Practices before - The book isn't only
about style, but also about avoiding common mistakes in Perl. Bareword
filehandles can occasionally be a big bag of nasty; You'll want a lexical
filehandle instead:

open( my $target, $ARGV[0] );

@targets = $target;

close $target;

But that's not good enough yet : ) That open may be trouble. You are using
the two-argument version, which is magical. For safety's sake, you'll want
the three-argument version:

open my $target, '', $ARGV[0];

But we aren't done with open yet. What if the file wasn't found? Your
program will go on merrily, but without a file to read from, that seems
hardly what you'd like it do you. So make it stop:

  open my $target, '', $ARGV[0] or die File not found: $ARGV[0]: $!;

You could do that, of course, but that's a bunch of extra typing. You could
use the autodie pragma[3] which will do the 'or die's for you.

Beyond that, there's only one big error in what you sent, though. in
readFasta, you do this:

if ( @ARGV == 0 ) {
die No FASTA file specified.\n;
}

But that should be

if ( @_ == 0 ) {
   die No FASTA file specified.\n;
}
 And then this:

open(FILE, @_[0]);

Which should probably be

open my $file, '', $_[0];

A nitpick, but you also have an $index variable that you don't use. You can
probably also let go of that grep and replace it with a smart match:
if ($seqheader[$index] ~~ @targets) {
...

Since I'm kind of bored, here's my shot at your program; I've never had to
deal with FASTA files, so I left some stuff in readFasta untouched:
http://ideone.com/kk0OI


Brian.

[0] http://oreilly.com/catalog/9780596001735/
[1] http://search.cpan.org/~shancock/Perl-Tidy-20101217/bin/perltidy and
http://search.cpan.org/~shancock/Perl-Tidy-20101217/lib/Perl/Tidy.pm
[2] http://search.cpan.org/~elliotjs/Perl-Critic-1.115/bin/perlcritic
[3] http://perldoc.perl.org/autodie.html


Re: Nature of this list

2011-04-23 Thread Shlomi Fish
Hi Brian, and all.

please read my entire response.

On Saturday 23 Apr 2011 22:22:13 Brian Fraser wrote:
 On Sat, Apr 23, 2011 at 4:15 PM, Marilyn Sander, Ken Armstrong 
 
 marilyn-san...@earthlink.net wrote:
  The F-bomb is totally unnecessary.  Such language is for teenagers who do
  not yet know how to communicate displeasure effectively.  Please grow up.
  Personally, I am finding this discussion fascinating.  I have often
  wondered why the academics at IBM would attack each other's
  presentations.
  
   It appears that part of the process of getting a PhD is learning to give
  
  and take intense attacks.  This discussion is most enlightening.
  Marilyn
  
 There ought to be a room in every house to swear in. It's dangerous to
 have to repress an emotion like that. Mark Twain.
 

Well, there's a difference between repressing emotion (which is saying No! I 
am not feeling this way now) and realising you're feeling something and 
acting in a rational manner in accordance or opposite the emotion. I many 
times was frustrated at open source software applications having annoying bugs 
and thought with many F-words and curse words, but when phrasing the bug 
report, I phrased it politely, rationally, and factually (not always though, 
of course). 

Emotions are nature's guidelines, and should not be repressed, and one should 
not feel guilty for feeling anything (Sermon on the Mount/etc. put aside), 
including not a desire for murder and mayhem. But acting based on these 
emotions by words or deed may not be a good idea.

You could have phrased yourself more calmly.

 It's part of the language, whenever you like it or not. Again, please look
 beyond the tone and see the substance of the psot - The swearing was there
 exactly to demonstrate that a few strong words shouldn't matter in your
 appreciation of a message.
 
 I guess that misfired, though.
 

One thing I agree is that this meta-discussion reduces the 
http://en.wikipedia.org/wiki/Signal-to-noise_ratio of beginners@perl.org , 
because it is of little interest to people seeking help with Perl or those 
wanting to help them. As a result, I suggest moving it to advoc...@perl.org 
(or maybe beginners-c...@perl.org or possibly perl-c...@perl.org , if Ask and 
friends will be kind enough to set it up (modelled after the haskell-cafe 
concept, where discussions are moved from the main haskell mailing list). 
Anyone can send an email to advoc...@perl.org , even if they are not 
subscribed and everyone can subscribe to it by sending an email to 
advocacy-subscr...@perl.org . Anyway, it was a good place to discuss social 
issues in the past, and it's very quiet now so I don't think people will mind 
the action. 

So pleaase subscribe to advoc...@perl.org and de-CC beginners@perl.org .

Regards,

Shlomi Fish

-- 
-
Shlomi Fish   http://www.shlomifish.org/
Funny Anti-Terrorism Story - http://shlom.in/enemy

Wikipedia has a page about everything including the
http://en.wikipedia.org/wiki/Kitchen_sink .

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Nature of this list

2011-04-23 Thread Shawn H Corey

On 11-04-23 06:37 PM, Shlomi Fish wrote:

Emotions are nature's guidelines, and should not be repressed, and one should
not feel guilty for feeling anything (Sermon on the Mount/etc. put aside),
including not a desire for murder and mayhem. But acting based on these
emotions by words or deed may not be a good idea.


Yes but the internet is forever.  The words are still attached to your 
name long after the emotions have ebbed.  Be careful what you post.  :)



--
Just my 0.0002 million dollars worth,
  Shawn

Confusion is the first step of understanding.

Programming is as much about organization and communication
as it is about coding.

The secret to great software:  Fail early  often.

Eliminate software piracy:  use only FLOSS.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Nature of this list

2011-04-23 Thread Shlomi Fish
Hi Shawn,

moving to advoc...@perl.org .

On Saturday 23 Apr 2011 20:24:36 Shawn H Corey wrote:
 On 11-04-23 12:53 PM, Casey West wrote:
  1. What did you do that doesn’t fit with our Lincoln School Rules? (Be
  specific and start with “I”)
 
 Wow.  The very first thing they have to think about is their contempt
 for the school authorities and not their victims' feelings.  No wonder
 why they tought they could get away with it.  All they had to do is hide
 their actions from the authorities.  You know, there's something a
 little bit sick about a society that insists that the authorities are
 the only ones capable of deciding right and wrong.

As an Objectivist (both a Randian, and in the meaning of believing that 
absolute Ethics and a shared, objective, reality exist), I agree with such 
sentiments. The whole a criminal is someone who violates the law is quite 
contemptible, and it is my opinion that a criminal is only someone who did 
something that is wrong according to the absolute, objective, Ethics is a 
criminal. A person who violated the law and was convicted as such is a 
felon, but not necessarily a criminal, and we can recall many past heroes 
who were prosecuted by things that we now consider as non-crimes, and it's not 
unlikely that many innocent men still get prosecuted as such.

I think explaining the difference between Laws/Regulations/Rules, Ethos, 
Morality, etc. to schoolchildren is too big of an undertaking. (I had a 
problem explaining the difference between Ethical and Moral to a very 
bright and intelligent programmer, with a smaller amount of intuition and 
knowledge than I do in Philosophy.), so imagine doing it for school children. 
Still I think this question could be demoted because the rules is not the 
worst thing that they could violate, nor should these children be instructed 
to blindly accept the rules, or not challenge them (without rebelling or 
violating them knowingly). See:

http://www.paulgraham.com/gba.html

Regards,

Shlomi Fish

-- 
-
Shlomi Fish   http://www.shlomifish.org/
Original Riddles - http://www.shlomifish.org/puzzles/

Dax: yep, space. Nothing but nothing all around.
-- Star Trek, We, the Living Dead by Shlomi Fish

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Nature of this list

2011-04-23 Thread David Christensen

On 04/19/2011 06:26 PM, David Christensen wrote:

So, my next question is has the complaint resolution process broken
down?.


It's been 4 days, and I haven't seen a reply to the above question.


Right now, per the Beginning Perl mailing list FAQ (FAQ) [1], this 
list is controlled by moderators.



One of the duties of the moderators is to administer justice -- to 
receive complaints, to investigate, to make charges, to judge, and to 
carry out punishment; all in private.  There is no public trial, no jury 
of peers, and no appeal.



I'm not an attorney, but any public disclosure of the proceeding makes 
me think libel. (As I understand it, freedom of speech is not an 
legal defense for publicly denigrating people, whether or not they 
broke the rules).  And, any order for apology, goods, or services 
makes me think extortion. Satirical references to large, yet padded, 
clue-sticks and XQJ-37 nuclear powered pansexual roto-plooker[s] [1] 
are meaningless when it comes time for a moderator to do their work. 
That said, I believe the FAQ correctly identifies two legal means for 
punishment -- (1) terminating the thread and/or (2) banning the 
convicted from posting to the list (with the presumed power to set the 
duration of the ban according to the severity of offense).  I wonder if 
there are more.



In addition to existing tort laws and case precedents, criminal Cyber 
Bullying legislation is coming into effect all around the world [2].  I 
believe we can all understand the necessity of not running afoul of the 
criminal justice system.



If you think about it, acting on a complaint involves risk and failure 
to act on a complaint also involves risk -- it's a Catch-22 situation. 
Whether they know it or not, many interests are currently at risk, and 
will remain at risk, so long as this list is in operation -- 
complainants, witnesses, moderators, Internet Service Providers, the 
Perl Foundation, and likely others.



Assuming that we want this list to continue, then we all have a stake in 
understanding and mitigating the risks.



Other Internet forums, notably Slashdot, use democratic means for 
dealing with undesired posts.  From a technical standpoint, this 
requires infrastructure not normally found on mailing lists.  We're Perl 
programmers, so, technically, that's not a problem.  But, I don't know 
if such processes have a better legal risk assessment and/or mitigation 
cost.



This isn't the only mailing list on the Internet; these issues must have 
been discussed elsewhere.  Is there a canonical forum for discussing such?



Better yet, is there a legally-researched and vetted solution that we 
can adopt?



This issue affects all perl.org mailing lists and/or web forums.  Does 
the Perl Foundation have legal counsel, and does he/ she/ they need to 
be involved?



David

[1] http://learn.perl.org/faq/beginners.html

[2] http://en.wikipedia.org/wiki/Cyber_bullying

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: how to parse complex table

2011-04-23 Thread Mike McClain
On Sat, Apr 23, 2011 at 10:27:07AM -0400, galeb abu-ali wrote:
 Hi,
 
 I'm trying to parse a table containing information about genes in a
 bacterial chromosome. Below is a sample for one gene, and there's about 4500
 such blocks in a file:
snip 
 My problem is that some genes have 2 entries for COG_category, some only one
 and others none. I took a look at perldsc and tried to fit the table into
 one of the complex structures but didn't get far. Below is the code I came
 up with so far:
snip 

#!/usr/bin/perl
# parse_IMG_gene_info.pl
use strict; use warnings;

#   '##' marks the lines of you code I changed/removed.

#   One of these days you're going to want this program 
#   to report on more than one file.
#   So wrap 'for my $file ( @ARGV ) { ... }' around it
#   And open( my $IN, '', $file   or die Failed to open $file: $!\n;

open( IN, , @ARGV ) or die Failed to open: $!\n;

#   Put this print statement down by the other. Keeping functional groups
#   together aids understanding and it'll all be there when you realize
#   the task has grown to the point you want an output routine.

print locus\tCOG_category\tCOG_category\tCOGID\tCluster_Information\n\n;

#   In Perl it's customary to declare your variables just before you 
#   need them and makes it easier to notice that %locus  $e aren't used
my( %locus, @cogs, %cog_cat, %cog_id, $oid, $locus, $source, 
$cluster_info, $e);

#   Keeping functional groups together suggests: 
#   open...; while(...); close;
#   with nothing else intervening.  Again $IN.
#   And while( my $line = $IN ) protects you from the many things
#   that change $_. 
#   If you don't get out of the habit of using $_ it 'will' bite you.
#   BTW, chomp, split, /COG_category/ and several other functions
#   act on $_ by default so 'split \t, $_' and 'split \t
#   are equivalent. note also that 'split /\t/' is preferable.
while( IN ) { 
chomp;  #   remove linefeeds from $cluster_info
if( $_=~ /COG_category/ ) { 
##( $oid, $locus, $source, $cluster_info ) = split \t, $_;

#   the tabs got lost in the email and it was easier for me to
#   change the split than change the data file.
( $oid, $locus, $source, $cluster_info ) = split /  +/, $_;
#   When you found the 2nd cog_cat you overwrote the first
##$cog_cat{ $locus } =  $cluster_info;
push @{ $cog_cat{ $locus } }, $cluster_info if($cluster_info);
#   You never used this and it's an array of hashes when what I think 
#   you need is an array in your hash
##push( @cogs, { %cog_cat } );
} elsif ( $_=~ /COG\d+/ ) {
#( $oid, $locus, $source, $cluster_info ) = split \t, $_;
( $oid, $locus, $source, $cluster_info ) = split /  +/, $_;
$cog_id{ $locus } =  $cluster_info;
}
}
close IN;

#print scalar @cogs, \n;

#   Uncomment and take a look at the output of the next 2 lines
#   and I think you'll see where you could use a single hash
# use Data::Dumper;
# print Dumper \%cog_cat, \%cog_id ;

for my $test( sort keys %cog_cat ) {
##print $test\t$cog_cat{ $test }\t$cog_id{ $test }\n;
print $test, map {\t$_} @{$cog_cat{ $test }}, \t$cog_id{ $test }\n;
}
print \n;
__END__
This is the output I got running this against data from one of your 
earlier posts. I think it's what you're looking for except for
an extra tab that I don't see where is coming from.
Challenge for the student? :)

locus   COG_categoryCOG_categoryCOGID   Cluster_Information

SeSA_B0001  [T] Signal transduction mechanisms  [K] Transcription  
SOS-response transcriptional repressors (RecA-mediated autopeptidases)
SeSA_B0002  [L] Replication, recombination and repair   
Nucleotidyltransferase/DNA polymerase involved in DNA repair

HTH, 
Mike
-- 
Satisfied user of Linux since 1997.
O ascii ribbon campaign - stop html mail - www.asciiribbon.org

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Nature of this list

2011-04-23 Thread Raymond Wan
On Sun, Apr 24, 2011 at 04:00, Brian Fraser frase...@gmail.com wrote:
 Please people. I urge you all to kindly fuck off.

 This is getting ridiculous. You are arguing about *tone*. Who gives a flying
 fuck about tone if the post has substance? Are we fucking two? Are our egos
 so fragile that we can't take the slightest of drubbings? So sensitive that
 a word in caps can start this kind of shitstorm?
 (Apparently yes, but bear with me for a sec)


Honestly, replying to the thread and swearing has the opposite effect
-- one that you probably did not intend.  :-)

Yes, in the interest of Let's stop this and get back to Perl, it
might be a good idea to end this discussion.  On the other hand, what
we're talking about is usually several people versus one person or one
or two well-respected people versus one person.  And if we limit
ourselves to what happens to us and stand idly by when it happens to
someone else, then the problem doesn't get fixed.  It continues, and
one day ... it happens to you.  Perhaps that is the point...


 (A side note for Tiago and Lali and any other PhD student and/or scientist
 out there: Just mention your situation and you are assured, to the best of
 my ability, a hand-holding reply from me. Which may turn out to be


That's great but why should they or any PhD student or student have to
mention their situation in order to get nicer treatment?  The list
says beginners; shouldn't that imply that most people asking
questions are probably in such a situation?  (Granted, some may also
be asking for answers to their homework..)

In the latest message in this thread, David asks that we're 4 days
into this thread and no solution has come up.  Just to throw something
out, what if the list was split to (say),
beginners-to-beginn...@perl.org and beginners-to-expe...@perl.org?
 If there are moderators, then they would only have to ensure that
only newbies (or people who can act like a newbie :-) ) are in the
first list; they don't have to monitor each message...  Maybe with
even cross-posting between the two lists disallowed...

I think message boards like stackoverflow ask people to vote on
answers; sounds like voting on the level of bullying would then mean
moderators are not needed...

Just something to throw out in the interest of people who are probably
tired of this thread...  Like Marilyn, I find this discussion
fascinating since this happens in many aspects of life.  Here in
Japan, I often see cases in the news of primary school children
bullying other primary school children (with sometimes disastrous
consequences).  It's human nature from a very young age across many
cultures...but it doesn't mean that nothing can be done about it...or
maybe I'm wrong...

Ray

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/