Fwd: Delete lines containing a specific word

Discussion in 'Python' started by Francesco Pietra, Jan 6, 2008.

  1. I forgot to add that the lines to strip are in present case of the type of the
    following block

    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
    containing :WAT".

    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".

    thanks
    francesco


    --- Francesco Pietra <> wrote:

    > Date: Sun, 6 Jan 2008 09:21:33 -0800 (PST)
    > From: Francesco Pietra <>
    > Subject: Delete lines containing a specific word
    > To:
    >
    > 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:
    > line=line.rstrip()
    > if line:
    > print line
    > f.close()
    >
    > If python in Linux accepts lines beginning with # as comment lines, please
    > also
    > a script to comment lines containing a specific word, or words, and back, to
    > remove #.
    >
    > Thanks
    > francesco pietra
    >
    >
    >
    >

    ____________________________________________________________________________________
    > Looking for last minute shopping deals?
    > Find them fast with Yahoo! Search.
    > http://tools.search.yahoo.com/newsearch/category.php?category=shopping
    >




    ____________________________________________________________________________________
    Looking for last minute shopping deals?
    Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
    Francesco Pietra, Jan 6, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Davide Carboni
    Replies:
    0
    Views:
    350
    Davide Carboni
    Dec 18, 2003
  2. Murali
    Replies:
    2
    Views:
    544
    Jerry Coffin
    Mar 9, 2006
  3. Francesco Pietra

    Delete lines containing a specific word

    Francesco Pietra, Jan 6, 2008, in forum: Python
    Replies:
    3
    Views:
    765
  4. Matt Nordhoff

    Re: Delete lines containing a specific word

    Matt Nordhoff, Jan 6, 2008, in forum: Python
    Replies:
    1
    Views:
    324
    Grant Edwards
    Jan 6, 2008
  5. Francesco Pietra

    Re: Delete lines containing a specific word

    Francesco Pietra, Jan 6, 2008, in forum: Python
    Replies:
    6
    Views:
    273
    Steven D'Aprano
    Jan 7, 2008
Loading...

Share This Page