Need help with a program
nn
pruebauno at latinmail.com
Fri Jan 29 09:41:27 EST 2010
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
>
> Regards
> Johann
> --
> Johann Spies Telefoon: 021-808 4599
> Informasietegnologie, Universiteit van Stellenbosch
>
> "My son, if sinners entice thee, consent thou not."
> Proverbs 1:10
I would rather use awk for this:
awk 'NF==2 && $2!~/^0$/ {printf("seq%s\n%s\n",NR,$1)}' dnain.dat
but I think that is getting a bit off topic...
More information about the Python-list
mailing list