On Jul 27, 1:41�am, Peter Otten <[EMAIL PROTECTED]> wrote:
> Mensanator wrote:
> > I don't know why you're using stdin if you're reading from a file.
>
> From Francesco's initial post in his previous thread I inferred that he had
> a script like
>
> f = open("xxx.pdb")
> for line in f:
> � � # process line
> � � print line
>
> and was calling it
>
> python script.py >outfile
>
> My hope was that
>
> import sys
> for line in sys.stdin:
> � � # process line
> � � sys.stdout.write(line)
>
> invoked as
>
> python script.py <xxx.pdb >outfile
>
> would be an improvement as it avoids hardcoding the filename, but instead
> chaos ensued...
>
> Francesco: Mensanator's script looks like you can take it "as is".Well, I didn't bother to insert the serial number into the extra line as the extra line wasn't given. Hopefully, it's obvious how to do that. > If you > want to use Python to do other interesting things I highly recommend that > you work your way through a tutorial of your choice. This will make > subsequent trial-and-error much more fun. > > Following Roy's suggestion I also had a brief look at Biopython's PDB parser > which has the advantage that it "understands" the file format. > Unfortunately it is probably too complex for you to use at this point of > your career as a pythonista ;) > > By the way, are you trying to modify the chain ID? Biopython locates that at > position 21, so take this as a reminder that indices in Python start at 0, > i. e. line[21] gives you the 22nd character in the line. > > Peter -- http://mail.python.org/mailman/listinfo/python-list
