Sponsored Content
Top Forums Shell Programming and Scripting Remove a block of Text at regular intervals Post 302468334 by marcozd on Tuesday 2nd of November 2010 11:42:56 AM
Old 11-02-2010
Question Remove a block of Text at regular intervals

Hello all,

I have a text files that consists of blocks of text. Each block of text represents a set of Cartesian coordinates for a molecule. Each block of text starts with a line that has a only a number, which is equal to the total number of atoms in the molecule. After this number is a line with "Frame #" where the # symbol is the number of the frame i.e. 1, 2, 3... This is line are the Cartesian coordinates, one set (x, y, z) per line. There are the same number of Cartesian coordinates as the number of atoms in the molecule.

Here is a sample:

Code:
14
Frame 1
Ir 0.4482 -1.2980 -0.2902
P 1.8759 -2.1654 1.4038
P -1.2305 -0.8418 -1.9134
H -2.5605 -0.7775 -1.4067
H -1.3820 -1.8515 -2.9058
H -1.1987 0.3321 -2.7223
H 2.5359 -3.3920 1.1065
H 1.2161 -2.5072 2.6182
H 2.9669 -1.3899 1.8960
C 1.3685 0.2571 -0.5341
O 1.9671 1.2795 -0.7004
Cl -0.8142 -3.4101 0.0318
H -0.8380 -0.5636 2.1141
H -1.0869 -0.4380 2.8141
14
Frame 2
Ir 0.4490 -1.2978 -0.2903
P 1.8738 -2.1613 1.4076
P -1.2367 -0.8359 -1.9047
H -2.5634 -0.7722 -1.3897
H -1.3955 -1.8409 -2.9008
H -1.2083 0.3415 -2.7087
H 2.5186 -3.3989 1.1226
H 1.2155 -2.4815 2.6289
H 2.9753 -1.3923 1.8863
C 1.3731 0.2542 -0.5394
O 1.9771 1.2723 -0.7122
Cl -0.8091 -3.4129 0.0288
H -0.9491 -0.6267 2.0929
H -1.2309 -0.4996 2.7795
.
.
.
14
Frame 72
Ir 0.2799 -1.1423 -0.0744
P 1.5830 -2.0634 1.6851
P -1.4956 -0.6824 -1.5757
H -2.5240 0.2145 -1.1716
H -2.2321 -1.8577 -1.8841
H -1.2106 -0.1808 -2.8791
H 2.8807 -2.5381 1.3446
H 0.9971 -3.2308 2.2364
H 1.8734 -1.3013 2.8541
C 1.7346 -0.5673 -1.1992
O 2.6174 -0.1436 -1.8621
Cl 0.2051 -3.5805 -0.9057
H 0.1695 0.2982 0.6158
H -0.9713 -1.5095 0.9427

I would like to be able to remove every other frame (which corresponds to a block of text that starts with number of atoms in the molecule, followed by the "Frame #" followed by the coordinates.

The trick is that not every file has the same number of atoms, so the script has to have a variable such that the user can tell it how many atoms are in the coordinates section and then it should remove every other block of data.

So I am trying to remove Frames 2, 4, 6, 8 and so on.

Thus the above sample would become:
Code:
14
Frame 1
Ir 0.4482 -1.2980 -0.2902
P 1.8759 -2.1654 1.4038
P -1.2305 -0.8418 -1.9134
H -2.5605 -0.7775 -1.4067
H -1.3820 -1.8515 -2.9058
H -1.1987 0.3321 -2.7223
H 2.5359 -3.3920 1.1065
H 1.2161 -2.5072 2.6182
H 2.9669 -1.3899 1.8960
C 1.3685 0.2571 -0.5341
O 1.9671 1.2795 -0.7004
Cl -0.8142 -3.4101 0.0318
H -0.8380 -0.5636 2.1141
H -1.0869 -0.4380 2.8141
.
.
.
Frame 71
Ir 0.2798 -1.1422 -0.0743
P 1.5833 -2.0636 1.6848
P -1.4955 -0.6824 -1.5761
H -2.5237 0.2149 -1.1727
H -2.2322 -1.8577 -1.8839
H -1.2099 -0.1819 -2.8797
H 2.8810 -2.5379 1.3438
H 0.9977 -3.2312 2.2359
H 1.8739 -1.3017 2.8539
C 1.7345 -0.5673 -1.1991
O 2.6175 -0.1439 -1.8621
Cl 0.2052 -3.5805 -0.9056
H 0.1693 0.2983 0.6159
H -0.9714 -1.5096 0.9427

Also, if possible, I would like also to be able to remove every 3rd frame as well.

i.e. remove frame 3, 6, 9, 12, 15... and so on.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

mailing myself at regular intervals...

hi all, i wrote a script to mail myself using pine (modified) to keep remind of b'days. #!/bin/bash grep "`date +%D |awk -F/ '{print $2+1, $1+0}'`" dataFile >/home/username/mailme if test -s /home/username/mailme then pine -I '^X,y' -subject "Birthday Remainder" username... (4 Replies)
Discussion started by: timepassman
4 Replies

2. Programming

performing a task at regular intervals

hi! i m tryin to write a program that will perform a specific tasks after fixed interval of time.say every 1 min. i jus donno how to go abt it.. which functions to use and so on... i wud like to add that i am dont want to use crontab over here. ny lead is appreciated. thanx. (2 Replies)
Discussion started by: mridula
2 Replies

3. Shell Programming and Scripting

Pls Help me out ... I want to check process status at regular intervals of time

I want to check process status at regular interval of time ... so i ha wirtten this BUT its not working when i placed this peace of code in .sh .. please help me out #!/bin/sh w = ps -ef|grep processname | wc - l echo $w if ; then Banner "Proceesname Problem" else Banner " Running... (5 Replies)
Discussion started by: srinivasvandana
5 Replies

4. Shell Programming and Scripting

Grouping data numbers in a text file into prescribed intervals and count

I have a text file that contains numbers (listed from the smallest to the largest). For ex. 34 817 1145 1645 1759 1761 3368 3529 4311 4681 5187 5193 5199 5417 5682 . . (5 Replies)
Discussion started by: Lucky Ali
5 Replies

5. Shell Programming and Scripting

Need perl regular expression to remove the comment

I need a perl substitution to remove only the comment in the line . That line may have '#' with in double quotes .I used the following , s/(^.*\".+?#.+?\".+?)(#.*)/$1/g It works for , print " not a comment # not a comment " . "not a comment # not a comment" ; # It is a comment ... (3 Replies)
Discussion started by: karthigayan
3 Replies

6. UNIX for Advanced & Expert Users

awk - remove block of text, multiple actions for 'if', inline edit

I'm having a couple of issues. I'm trying to edit a nagios config and remove a host definition if a certain "host_name" is found. My thought is I would find host definition block containing the host_name I'm looking for and output the line numbers for the first and last lines. Using set, I will... (9 Replies)
Discussion started by: mglenney
9 Replies

7. Shell Programming and Scripting

Filter or remove duplicate block of text without distinguishing marks or fields

Hello, Although I have found similar questions, I could not find advice that could help with our problem. The issue: We have several hundreds text files containing repeated blocks of text (I guess back at the time they were prepared like that to optmize printing). The block of texts... (13 Replies)
Discussion started by: samask
13 Replies

8. Programming

Selecting files in regular intervals from a folder

Hi, I need your expertise in selecting files from a folder. I have files named with convention: filename.i.j where j is an interger from 1 to 16, for each i which is an integer from 1 to 2000. I would like to select the files with i in regular interval of 50 like filename.1.j,... (2 Replies)
Discussion started by: rpd25
2 Replies

9. Shell Programming and Scripting

perl regular expression to remove the special characters

I had a string in perl script as below. Tue Augáá7 03:54:12 2012 Now I need to replace the special character with space. After removing the special chaacters Tue Aug 7 03:54:12 2012 Could anyone please help me here for writing the regular expression? Thanks in advance.. Regards, GS (1 Reply)
Discussion started by: giridhar276
1 Replies

10. UNIX for Dummies Questions & Answers

Bulk load testing in regular intervals

I need to write a script which can send files via sftp communication continously for half an hour or any given duration of time. I have already written a batch file to send multiple file via SFTP. but I need to know how can we set a duration of half an hour through shell script. Can we use sleep... (2 Replies)
Discussion started by: talk1234
2 Replies
molecule(6x)							XScreenSaver manual						      molecule(6x)

NAME
molecule - draws 3D molecular structures SYNOPSIS
molecule [-display host:display.screen] [-window] [-root] [-visual visual] [-delay microseconds] [-wander] [-no-wander] [-spin axes] [-no- spin] [-timeout seconds] [-labels] [-no-labels] [-titles] [-no-titles] [-atoms] [-no-atoms] [-bonds] [-no-bonds] [-shells] [-no-shells] [-molecule file-or-directory] [-verbose] [-wireframe] [-fps] DESCRIPTION
The molecule program draws several different representations of molecules. Some common molecules are built in, and it can read PDB (Pro- tein Data Base) files as input. OPTIONS
molecule accepts the following options: -window Draw on a newly-created window. This is the default. -root Draw on the root window. -install Install a private colormap for the window. -visual visual Specify which visual to use. Legal values are the name of a visual class, or the id number (decimal or hex) of a specific visual. -fps Display the current frame rate, CPU load, and polygon count. -verbose Print debugging info on stderr about files being loaded, etc. -wander Move the molecules around the screen. -no-wander Keep the molecule centered on the screen. This is the default. -spin Which axes around which the molecule should spin. The default is "XYZ", meaning rotate it freely in space. "-spin Z" would rotate the molecule in the plane of the screen while not rotating it into or out of the screen; etc. -no-spin Don't spin it at all: the same as -spin "". -labels Draw labels on the atoms (or the spot where the atoms would be.) This is the default. -no-labels Do not draw labels on the atoms. -titles Print the name of the molecule and its chemical formula at the top of the screen. -no-titles Do not print the molecule name. -atoms Represent the atoms as shaded spheres of appropriate sizes. This is the default. -no-atoms Do not draw spheres for the atoms: only draw bond lines. -bonds Represent the atomic bonds as solid tubes of appropriate thicknesses. This is the default. -no-bonds Do not draw the bonds: instead, make the spheres for the atoms be larger, for a "space-filling" representation of the molecule. -shells Draw transparent electron shells around the atoms. This only works if bonds are also being drawn. -no-shells Do not draw electron shells. This is the default. -shell-alpha When drawing shells, how transparent to make them. Default 0.4. -wireframe Draw a wireframe rendition of the molecule: this will consist only of single-pixel lines for the bonds, and text labels where the atoms go. This will be very fast. -timeout seconds When using the built-in data set, change to a new molecule every this-many seconds. Default is 20 seconds. -molecule file-or-directory Instead of using the built-in molecules, read one from the given file. This file must be in PDB (Protein Data Base) format. (Note that it's not uncommon for PDB files to contain only the atoms, with no (or little) information about the atomic bonds.) This can also be a directory, in which case, all of the .pdb files in that directory will be loaded. A new one will be displayed at random every few seconds (as per the -timeout option.) When the molecule is too large (bigger than about 30 angstroms from side to side), the -label option will be automatically turned off, because otherwise, the labels would overlap and completely obscure the display. When the molecule is around 150 angstroms from side to side, wireframe mode will be turned on (because otherwise it would be too slow.) ENVIRONMENT
DISPLAY to get the default host and display number. XENVIRONMENT to get the name of a resource file that overrides the global resources stored in the RESOURCE_MANAGER property. SEE ALSO
X(1), xscreensaver(1) Documentation on the PDB file format: http://www.wwpdb.org/docs.html http://www.rcsb.org/pdb/docs/format/pdbguide2.2/guide2.2_frame.html A good source of PDB files: http://www.umass.edu/microbio/rasmol/whereget.htm http://www.wwpdb.org/docs.html COPYRIGHT
Copyright (C) 2001-2005 by Jamie Zawinski. Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. No representations are made about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. AUTHOR
Jamie Zawinski <jwz@jwz.org> X Version 11 5.15 (28-Sep-2011) molecule(6x)
All times are GMT -4. The time now is 06:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy