Sponsored Content
Top Forums Shell Programming and Scripting add a column and match two files Post 302344059 by rockytodd on Friday 14th of August 2009 12:43:48 PM
Old 08-14-2009
add a column and match two files

I have two files:
File #1:
Code:
...... 
ATOM     91 H2'' G   A   3      17.357   8.753 -30.401  1.00   0.00           A 
ATOM     92  O2' G   A   3      16.590   9.059 -28.495  1.00   0.00           A 
ATOM     93  H2' G   A   3      16.670   9.792 -27.880  1.00   0.00           A 
ATOM     94  O3' G   A   3      16.875  11.895 -29.146  1.00   0.00           A 
ATOM     95    P U   A   4      17.646  13.251 -28.975  1.00   0.00           A 
ATOM     96  O1P U   A   4      18.619  13.509 -30.118  1.00   0.00           A 
ATOM     97  O2P U   A   4      18.188  13.245 -27.547  1.00   0.00           A 
.......


File #2:
Code:
...... 
H3'   T     1.32 
C2'   T     2.01 
H2''  T     1.34 
H2'   T     1.34 
O3'   T     1.77 
P     G     2.15 
O1P   G     1.70 
O2P   G     1.70 
O5'   G     1.77 
H2''  G     1.34 
......

For File#1, I want to add a column. The content of this column is from File#2.
The procedure is, for each line in File#1,
first, search the line in File#2 satisfies: $1(in File#2) == $3(in File#1), $2(in File#2) == $4(in File#1),
e.g., for line#1 in File#1, find the line in File#2 satisfy $1==H2'' and $2==G ;
then, add $3 of File#2 to the end of the line in File#1, e.g., add 1.34 to the end of line#1 in File#1.

Thank you!

Last edited by rockytodd; 08-14-2009 at 02:38 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

two files.say a and b.both have long columns.i wanna match the column fron 1st file w

ex: a file has : 122323 123456456 125656879 678989965t635 234323432 b has : this is finance no. this is phone no this is extn ajkdgag idjsidj i want the o/p as: 122323 his is finance no. 123456456 this is phone no 123456456 ... (4 Replies)
Discussion started by: TRUPTI
4 Replies

2. Shell Programming and Scripting

Match column 3 in file1 to column 1 in file 2 and replace with column 2 from file2

Match column 3 in file1 to column 1 in file 2 and replace with column 2 from file2 file 1 sample SNDK 80004C101 AT XLNX 983919101 BB NETL 64118B100 BS AMD 007903107 CC KLAC 482480100 DC TER 880770102 KATS ATHR 04743P108 KATS... (7 Replies)
Discussion started by: rydz00
7 Replies

3. Shell Programming and Scripting

Comparing two files and printing 2nd column if match found

Hi guys, I'm rather new at using UNIX based systems, and when it comes to scripting etc I'm even newer. I have two files which i need to compare. file1: (some random ID's) 451245 451288 136588 784522 file2: (random ID's + e-mail assigned to ID) 123888 xc@xc.com 451245 ... (21 Replies)
Discussion started by: spirm8
21 Replies

4. UNIX for Dummies Questions & Answers

Comparing two text files by a column and printing values that do not match

I have two text files where the first three columns are exactly the same. I want to compare the fourth column of the text files and if the values are different, print that row into a new output file. How do I go about doing that? File 1: 100 rs3794811 0.01 0.3434 100 rs8066551 0.01... (8 Replies)
Discussion started by: evelibertine
8 Replies

5. UNIX for Dummies Questions & Answers

Match values/IDs from column and text files

Hello, I am trying to modify 2 files, to yield results in a 3rd file. File-1 is a 8-columned file, separted with tab. 1234:1 xyz1234 blah blah blah blah blah blah 1234:1 xyz1233 blah blah blah blah blah blah 1234:1 abc1234 blah blah blah blah blah blah n/a RRR0000 blah blah blah... (1 Reply)
Discussion started by: ad23
1 Replies

6. Shell Programming and Scripting

Column content match and add suffix

My input chr3 galGal3_xenoRefFlat CDS 4178235 4178264 0.000000 + 0 gene_id "T6J4.19; T6J4_19"; transcript_id "T6J4.19; T6J4_19"; chr3 galGal3_xenoRefFlat exon 4178235 4178264 0.000000 + . gene_id "T6J4.19; T6J4_19"; transcript_id "T6J4.19;... (2 Replies)
Discussion started by: jacobs.smith
2 Replies

7. Shell Programming and Scripting

Compare 2 files and match column data and align data from 3 column

Hello experts, Please help me in achieving this in an easier way possible. I have 2 csv files with following data: File1 08/23/2012 12:35:47,JOB_5330 08/23/2012 12:35:47,JOB_5330 08/23/2012 12:36:09,JOB_5340 08/23/2012 12:36:14,JOB_5340 08/23/2012 12:36:22,JOB_5350 08/23/2012... (5 Replies)
Discussion started by: asnandhakumar
5 Replies

8. Shell Programming and Scripting

awk Print New Column For Every Two Lines and Match On Multiple Column Values to print another column

Hi, My input files is like this axis1 0 1 10 axis2 0 1 5 axis1 1 2 -4 axis2 2 3 -3 axis1 3 4 5 axis2 3 4 -1 axis1 4 5 -6 axis2 4 5 1 Now, these are my following tasks 1. Print a first column for every two rows that has the same value followed by a string. 2. Match on the... (3 Replies)
Discussion started by: jacobs.smith
3 Replies

9. Shell Programming and Scripting

Match string in two files and add data to one file

Gents, file1 S 65733.00 19793.00 1 0 318592.8 2792489.5 29.1063000008 S 65733.00 19801.00 1 0 323120.8 2789153.6 13.3063000044 S 66009.00 19713.00 1 0 318672.7 2792538.2 30.6063000120 S 65801.00 19799.00 1 ... (2 Replies)
Discussion started by: jiam912
2 Replies

10. UNIX for Dummies Questions & Answers

Match sum of values in each column with the corresponding column value present in trailer record

Hi All, I have a requirement where I need to find sum of values from column D through O present in a CSV file and check whether the sum of each Individual column matches with the value present for that corresponding column present in the trailer record. For example, let's assume for column D... (9 Replies)
Discussion started by: tpk
9 Replies
RODS(1) 						      General Commands Manual							   RODS(1)

NAME
rods - Raster3D preprocessor for ball-and-stick models SYNOPSIS
rods [-h] [-b] [-radius R] [-Bcolor Bmin Bmax] Rods reads a file describing atom colours and/or a PDB coordinate file and produces a file containing Raster3D descriptor records. The file produced by rods may be fed directly to render or it may be combined with descriptor files produced by other Raster3D utilities. EXAMPLES
To describe a simple bonds-only model coloured by residue type: cat mycolours.pdb protein.pdb | rods | render > mypicture.png To render the same molecule as ball-and-stick: cat mycolours.pdb protein.pdb | rods -b | render > mypicture.png OPTIONS
-h Suppress header records in output. By default rods 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 object 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. -b By default rods will describe bonds only; the -b flag will cause it to include spheres at the atom positions also, yielding a ball-and- stick representation. -radius R By default rods will draw bonds as cylinders with a 0.2A radius. The radius option allows you to change this cylindrical radius. -Bcolor Bmin Bmax Assign colors based on B values rather than from atom or residue types. Atoms with B <= Bmin will be colored dark blue; atoms with B >= Bmax will be colored light red; atoms with Bmin < B < Bmax will be assigned colors shading smoothly through the spectrum from blue to red. DESCRIPTION
The input to rods consists of a single text file containing colour information and atomic coordinates in PDB data bank format. Coordinates are output as Raster3D descriptor records with colours and sphere radii assigned according to the COLO records described below. Ball-and- stick figures have atoms drawn at 0.2 * VanderWaals radius, connected by rods with a default 0.2A cylindrical radius. Bonds are drawn for atoms which lie closer to each other than 0.6 * (sum of VanderWaals radii). 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. If no COLOUR records are present in the input file, atoms will receive default CPK colors (C=grey, O=red, N=blue, S=yellow, P=green, other=magenta). Raster3D uses a pseudo-PDB record type with the same basic layout as the above but 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 COLO records in input order. Then it goes through each stored ATOM/HETA record in turn, and searches for a COLO record that matches the ATOM/HETA record in all of columns 7 through 30. The first such COLO record to be found determines the colour and radius of the atom. In order that one COLO 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 COLO 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 COLO record. This idea of matching masks for colour specifi- cations is due to Colin Broughton. ENVIRONMENT
The files setup.matrix and setup.angles, if they exist, affect the header records produced by rods. SOURCE
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), ribbon(l), balls(l) AUTHORS
Ethan A Merritt Raster3D 8 May 1999 RODS(1)
All times are GMT -4. The time now is 03:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy