Need help with a program

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Fri Jan 29 05:04:33 EST 2010


On Fri, 29 Jan 2010 11:23:54 +0200, Johann Spies wrote:

> On Thu, Jan 28, 2010 at 07:07:04AM -0800, evilweasel wrote:
>> Hi folks,
>> 
>> I am a newbie to python, and I would be grateful if someone could point
>> out the mistake in my program. Basically, I have a huge text file
>> similar to the format below:
>> 
>> AAAAAGACTCGAGTGCGCGGA	0
>> AAAAAGATAAGCTAATTAAGCTACTGG	0
>> AAAAAGATAAGCTAATTAAGCTACTGGGTT	 1
>> AAAAAGGGGGCTCACAGGGGAGGGGTAT	 1
>> AAAAAGGTCGCCTGACGGCTGC	0
> 
> I know this is a python list but if you really want to get the job done
> quickly this is one method without writing python code:
> 
> $ cat /tmp/y
> AAAAAGACTCGAGTGCGCGGA   0
> AAAAAGATAAGCTAATTAAGCTACTGG     0
> AAAAAGATAAGCTAATTAAGCTACTGGGTT   1
> AAAAAGGGGGCTCACAGGGGAGGGGTAT     1
> AAAAAGGTCGCCTGACGGCTGC  0
> $ grep -v 0 /tmp/y > tmp/z
> $ cat /tmp/z
> AAAAAGATAAGCTAATTAAGCTACTGGGTT   1
> AAAAAGGGGGCTCACAGGGGAGGGGTAT     1

That will do the wrong thing for lines like:

AAAAAGATAAGCTAATTAAGCTACTGGGTT   10


-- 
Steven



More information about the Python-list mailing list