Sponsored Content
Top Forums Shell Programming and Scripting how I can add a constant to a field without changing the file format Post 302424959 by Scott on Wednesday 26th of May 2010 06:25:11 PM
Old 05-26-2010
Quote:
Originally Posted by curleb
I'm guessing at field defs here, but something like-a-dis:
Code:
$ awk '{printf "%-4s%7d  %-4s%-4s%-2s%3.d\n",$1,$2,$3,$4,$5,($6-34)}' Edit8
ATOM    918  N   GLY B  69
ATOM    919  CA  GLY B  69
ATOM    920  C   GLY B  69
ATOM    921  O   GLY B  69
ATOM    922  H   GLY B  69
ATOM    923  HA2 GLY B  69
ATOM    924  HA3 GLY B  69
ATOM    925  N   MET B  70
ATOM    926  CA  MET B  70
ATOM    927  C   MET B  70
ATOM    928  O   MET B  70
ATOM    929  CB  MET B  70
ATOM    930  CG  MET B  70
ATOM    931  SD  MET B  70
ATOM    932  CE  MET B  70
ATOM    933  H   MET B  70
ATOM    934  HA  MET B  70
ATOM    935  HB2 MET B  70
ATOM    936  HB3 MET B  70
ATOM    937  HG2 MET B  70
ATOM    938  HG3 MET B  70
ATOM    939  HE1 MET B  70
ATOM    940  HE2 MET B  70
ATOM    941  HE3 MET B  70

or, if you prefer concise and/or succinct...scottn posted something short and sweet. Only seems to shift $6 just a tad left...
Code:
$ awk '{X = $6 - 34; sub($6, X)}1' Edit8
ATOM    918  N   GLY B 69     -11.855   8.675 -11.404  1.00  0.00           N
ATOM    919  CA  GLY B 69     -13.297   8.831 -11.189  1.00  0.00           C
ATOM    920  C   GLY B 69     -13.977   7.468 -11.253  1.00  0.00           C
ATOM    921  O   GLY B 69     -14.817   7.213 -12.116  1.00  0.00           O
ATOM    922  H   GLY B 69     -11.342   7.827 -11.132  1.00  0.00           H
ATOM    923  HA2 GLY B 69     -13.483   9.303 -10.207  1.00  0.00           H
ATOM    924  HA3 GLY B 69     -13.734   9.500 -11.952  1.00  0.00           H
ATOM    925  N   MET B 70     -13.601   6.588 -10.332  1.00  0.00           N
ATOM    926  CA  MET B 70     -14.127   5.222 -10.341  1.00  0.00           C
ATOM    927  C   MET B 70     -15.232   5.094  -9.286  1.00  0.00           C
ATOM    928  O   MET B 70     -16.396   4.872  -9.620  1.00  0.00           O
ATOM    929  CB  MET B 70     -12.929   4.298 -10.093  1.00  0.00           C
ATOM    930  CG  MET B 70     -13.316   2.824 -10.092  1.00  0.00           C
ATOM    931  SD  MET B 70     -14.028   2.373 -11.684  1.00  0.00           S
ATOM    932  CE  MET B 70     -14.384   0.636 -11.368  1.00  0.00           C
ATOM    933  H   MET B 70     -12.859   6.880  -9.688  1.00  0.00           H
ATOM    934  HA  MET B 70     -14.557   4.991 -11.333  1.00  0.00           H
ATOM    935  HB2 MET B 70     -12.161   4.469 -10.870  1.00  0.00           H
ATOM    936  HB3 MET B 70     -12.447   4.551  -9.131  1.00  0.00           H
ATOM    937  HG2 MET B 70     -12.421   2.209  -9.894  1.00  0.00           H
ATOM    938  HG3 MET B 70     -14.041   2.627  -9.283  1.00  0.00           H
ATOM    939  HE1 MET B 70     -15.076   0.527 -10.513  1.00  0.00           H
ATOM    940  HE2 MET B 70     -14.852   0.168 -12.252  1.00  0.00           H
ATOM    941  HE3 MET B 70     -13.456   0.082 -11.135  1.00  0.00           H

Ah.. good point Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Changing particular field in fixed width file

I have a fixed width file and i need to change 36th field to "G" in for about random 20 records? How can I do it? (4 Replies)
Discussion started by: dsravan
4 Replies

2. UNIX for Dummies Questions & Answers

how to add a constant value to a column in a file using unix command

I have a file like this 1 chr1 3661579 3662579 2 chr1 4350395 4351395 3 chr1 4399322 4400322 4 chr1 4486494 4487494 5 chr1 4775807 4776807 6 chr1 4775807 4776807 7 chr1 4775807 4776807 8 chr1 4796973 4797973 9 chr1 4846774 4847774... (3 Replies)
Discussion started by: sunsnow86
3 Replies

3. Shell Programming and Scripting

Problem with changing field separators in a file

I have a file with content as shown below. cat t2 : 100,100,"X",1234,"12A",,,"ab,c" Comma is the field seperator, however string fields will be within double quotes and comma within double quotes should not be treated as field seperator. I am trying to replace this field seperator to a... (7 Replies)
Discussion started by: mk1216
7 Replies

4. Shell Programming and Scripting

Howto add a constant column to the text file

Hi, I am converting a .DBF file to pipe delimited file my requirement is like lets say my .DBF is residing in path /a/b/c/d/f/abc.DBF I need my .txt file as having a column with source _cd =f sample data in .DBF in folder "f" c1 c2 c3 1 2 3 in txt file it should be... (4 Replies)
Discussion started by: angel12345
4 Replies

5. Shell Programming and Scripting

[Solved] Need help changing a field from MM/DD/YY to DD/MM/YY format

Hi, I need help changing a field from MM/DD/YY to DD/MM/YY format. Suppose a file a.csv. The record is "11/16/09","ABC"," 1","EU","520892414","1","600","31351000","1234567","ANR BANK CO. LTD" "11/16/09","PQR"," 2","EU","520892427","1","600","31351000","5467897","ANR BANK CO.... (4 Replies)
Discussion started by: Gangadhar Reddy
4 Replies

6. Shell Programming and Scripting

Changing field X in file

/etc/newsyslog.conf on a Mac OSX system contains: # configuration file for newsyslog # $FreeBSD: /repoman/r/ncvs/src/etc/newsyslog.conf,v 1.50 2005/03/02 00:40:55 brooks Exp $ # # Entries which do not specify the '/pid_file' field will cause the # syslogd process to be signalled when that... (3 Replies)
Discussion started by: jnojr
3 Replies

7. Linux

How do I format a Date field of a .CSV file with multiple commas in a string field?

I have a .CSV file (file.csv) whose data are all enclosed in double quotes. Sample format of the file is as below: column1,column2,column3,column4,column5,column6, column7, Column8, Column9, Column10 "12","B000QRIGJ4","4432","string with quotes, and with a comma, and colon: in... (3 Replies)
Discussion started by: dhruuv369
3 Replies

8. Shell Programming and Scripting

Rows to columns with first field constant

Hi Friends, I have tried many options to convert rows to column in below fashion. Can you help me pls? input file: kamal|1,2,3|4,5,6|7,8,9 mich|4,7,4|6,7,9 jose|1,1,2|3,3,2|5,5,0 output required: kamal|1,2,3 kamal|4,5,6 kamal|7,8,9 mich|4,7,4 mich|6,7,9 jose|1,1,2 jose|3,3,2... (2 Replies)
Discussion started by: suresh3566
2 Replies

9. UNIX for Dummies Questions & Answers

Changing the file name format

Hello all, I am tryign to change the format of files (which are many in numbers). They at present are named like this: SomeProcess_M-130_100_1_3BR.root SomeProcess_M-130_101_2_3BX.root SomeProcess_M-130_103_3_3RY.root SomeProcess_M-130_105_1_3GH.root SomeProcess_M-130_99_1_3LF.root... (7 Replies)
Discussion started by: emily
7 Replies

10. UNIX for Advanced & Expert Users

Help changing date format in the nth field

Hi, I have two (2) things that I want to do. First is to change the date format that is in the nth field from MM/DD/YY to YY/MM/DD. Preferably, I wish I know how to make it a 4-digit year but I don't. Problem is I can only assume it is a 20 century Second is somehow know how to figure out... (1 Reply)
Discussion started by: newbie_01
1 Replies
BALLS(1)						      General Commands Manual							  BALLS(1)

NAME
balls - preprocessor for space-filling models in Raster3D molecular graphics package SYNOPSIS
balls [-h] Balls reads a file describing atom colours and/or a PDB coordinate file and produces a file containing Raster3D descriptor records for each atom in the input file. The file produced by balls may be fed directly to render or it may be combined with descriptor files produced by other Raster3D utilities. EXAMPLES
To describe a simple space-filling model coloured by residue type: cat mycolours.pdb protein.pdb | balls | render > mypicture.png To include a pre-selected view matrix with the same model: cp view1.matrix setup.matrix cat mycolours.pdb protein.pdb | balls | render > mypicture.png To prepend header records describing a pre-selected scale and view: cat mycolours.pdb protein.pdb | balls -h > balls.r3d cat header.r3d balls.r3d | render > mypicture.png OPTIONS
-h Suppress header records in output. By default balls will produce an output file which starts with header records containing a default set of scaling and processing options. The -h flag will suppress these header records so that the output file contains only sphere descrip- tors. This option is useful for producing files which describe only part of a scene, and which are to be later combined with descriptor files produced by other programs. DESCRIPTION
The input to balls consists of a single text file containing colour information and atomic coordinates in PDB data bank format. Coordi- nates are output as Raster3D descriptor records with colours and sphere radii assigned according to the COLO records described below. By default atoms are assigned CPK colours. By default the output file contains a set of header records as required by the render program. The header is constructed to include a TMAT matrix corresponding to the transformation matrix contained in file setup.matrix (if it exists), or to the Eulerian angles contained in file setup.angles (if it exists). Colours are assigned to atoms using a matching process, using COLOUR records prepended to the input PDB file. Raster3D uses a pseudo-PDB record type with with COLO in the first 4 columns: Columns 1 - 4 COLO 7 - 30 Mask (described below) 31 - 38 Red component 39 - 46 Green component 47 - 54 Blue component 55 - 60 van der Waals radius in Angstroms 61 - 80 Comments Note that the Red, Green, and Blue components are in the same positions as the X, Y, and Z components of an ATOM or HETA record, and the van der Waals radius goes in place of the Occupancy. The Red, Green, and Blue components must all be in the range 0 to 1. The Mask field is used in the matching process as follows. First the program reads in and stores all the ATOM, HETA, and COLOUR records in input order. Then it goes through each stored ATOM/HETA record in turn, and searches for a COLOUR record that matches the ATOM/HETA record in all of columns 7 through 30. The first such COLOUR record to be found determines the colour and radius of the atom. In order that one COLOUR record can provide colour and radius specifications for more than one atom (e.g., based on residue or atom type, or any other criterion for which labels can be given somewhere in columns 7 through 30), the "#" symbol is used as a wildcard. I.e. a # in a COLOUR record matches any character in the corresponding column in an ATOM or HETA record. All other characters must match literally to count as a match. Note that the very last COLO record in the input should have # symbols in all of columns 7 through 30 in order to pro- vide a colour for any atom whose ATOM/HETA record fails to match any previous COLOUR record. This idea of matching masks for colour speci- fications is due to Colin Broughton. Several files of COLOUR records, including one based on Bob Fletterick's "Shapely Models" and another mimicking CPK model parts, are pro- vided as samples. ENVIRONMENT
The files setup.matrix and setup.angles, if they exist, affect the header records produced by balls. SOURCE
anonymous ftp site: ftp.bmsc.washington.edu web URL: http://www.bmsc.washington.edu/raster3d/raster3d.html contact: Ethan A Merritt University of Washington, Seattle WA 98195 merritt@u.washington.edu SEE ALSO
render(l), rods(l), ribbon(l) AUTHORS
Originally written by David J Bacon and Wayne F Anderson. Extensions and revisions by Ethan A Merritt. Raster3D 8 May 1999 BALLS(1)
All times are GMT -4. The time now is 11:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy