Fwd: Delete lines containing a specific word
chiendarret at yahoo.com
Sun Jan 6 18:44:43 CET 2008
I forgot to add that the lines to strip are in present case of the type of the
HETATM 7007 O WAT 446 27.622 34.356 55.205 1.00 0.00 O
HETATM 7008 H1 WAT 446 27.436 34.037 56.145 1.00 0.00 H
HETATM 7009 H2 WAT 446 27.049 33.827 54.563 1.00 0.00 H
occurring in a 300MB file.
In present case each three-lines block is followed by line renumbering (7007,
7008, 7009 are line numbers). So, the script is simply to strip the lines
In other cases the block is intermediate. Therefore, a second script would be
useful where the line that follow the block are renumbered, e.g, line "HETATM
7010" following the above block renumbered "HEATM 7006".
--- Francesco Pietra <chiendarret at yahoo.com> wrote:
> Date: Sun, 6 Jan 2008 09:21:33 -0800 (PST)
> From: Francesco Pietra <chiendarret at yahoo.com>
> Subject: Delete lines containing a specific word
> To: python-list at python.org
> Please, how to adapt the following script (to delete blank lines) to delete
> lines containing a specific word, or words?
> f=open("output.pdb", "r")
> for line in f:
> if line:
> print line
> If python in Linux accepts lines beginning with # as comment lines, please
> a script to comment lines containing a specific word, or words, and back, to
> remove #.
> francesco pietra
> Looking for last minute shopping deals?
> Find them fast with Yahoo! Search.
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
More information about the Python-list