Sponsored Content
Full Discussion: Problem with variable type
Top Forums Shell Programming and Scripting Problem with variable type Post 39963 by siavoush on Saturday 6th of September 2003 01:12:13 AM
Old 09-06-2003
Question Problem with variable type

Dear All,

I am trying to write an script to calculate geometric centre of selected residues of a protein structure. Say I have a PDB file (a text containing the x, y, and z coordinates of atoms of a protein). I want to extract the X coordinates of the atoms belonging to the interested residues and get the Max and Min values for X coordinates and then calculate the X coordinate for the geometric centre as followings: X(cent) = (X(max) - X(min))/2. The same will go for Y(cent) and Z(cent). To do this it is better to have something to read in the X coordinates for the interested atoms from the X coordinate column in the PDB file and find the X(max) and X(min). The way that I do this is to read these values and put them in a file (say temp.dat). Then I sort the file ascending and descending based on different columns (i.e., x, y, and z colunms) and extract the max and min for X, Y and Z as you can see below:

****************************************************

#/bin/csh
echo -n "name of file (full path; incl. extension):"
set INFILE = $<
echo -n "name of output file (full path):"
set OUTFILE = $<
echo -n "Specify the starting residue number:"
set START = $<
echo -n "Specify the last residue number:"
set END = $<
@ END ++
@ START --
#
#
#
#
awk ' ($1 == "ATOM" && ( $5 > '$START' ) && ( $5 < '$END' )){{printf("%10.3f%10.3f%10.3f\n", $6, $7, $8)}};' $INFILE >>! $OUTFILE
#
sort $OUTFILE | set Xmin = `head -1 | awk '{printf("%10.3f\n", $1)};'`

sort -n +1 $OUTFILE | set Ymin = `head -1 | awk '{printf("%10.3f\n", $2)};'`

sort -n +2 $OUTFILE | set Zmin = `head -1 | awk '{printf("%10.3f\n", $3)};'`

sort -r $OUTFILE | set Xmax = `head -1 | awk '{printf("%10.3f\n", $1)};'`

sort -rn +1 $OUTFILE | set Ymax = `head -1 | awk '{printf("%10.3f\n", $2)};'`

sort -rn +2 $OUTFILE | set Zmax = `head -1 | awk '{printf("%10.3f\n", $3)};'`

echo $Xmin $Xmax $Ymin $Ymax $Zmin $Zmax
exit 1
**************************************************

The problem is that I can't use the Xmin, Xmax, Ymin, ... to calculate X(cent), Y(cent), and Z(cent), using "expr" command. E.g., for the following command, I get the following error:

>expr $Xmin - $Xmin

non-numeric argument

I guess there is something wrong with these variables and they are character strings and not numbers. I will appreciate it if you give me some input.

Cheers, Siavoush
Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to get type of variable in perl

hello all how can i get the type of variable in perl like typeof(var); in javascript for instance ? to know if the variable is int or string ? (2 Replies)
Discussion started by: umen
2 Replies

2. Shell Programming and Scripting

getting type of variable

Hello: Is there any way to tell the type of a passed or entered variable, if it is a string or integer,...etc. Thanks a lot (2 Replies)
Discussion started by: aladdin
2 Replies

3. Shell Programming and Scripting

Stuck on a matching, copying type problem

Hi all, I am new to these forum and to scripting in general for that matter. i have been looking through the forums for something that could explain my problem. I have be come pretty familiar with sed and awk but I can not seem to figure this out... I am trying to match data from 3 files but every... (4 Replies)
Discussion started by: derek3131
4 Replies

4. Programming

Need help in storing command line argument argv[2] to a variable of int type

The following program takes two command line arguments. I want the second argument (fileCount) to be stored/printed as a int value. I tried my best to typecast the char to int (check the printf statement at last) but is not working...the output is some junk value. This program is in its... (3 Replies)
Discussion started by: frozensmilz
3 Replies

5. Shell Programming and Scripting

Perl variable type assessment

Hello experts, How we can find out,that what is type of a scalar variable? i.e a scalar var contain a number or a string. Thanks in advance. (8 Replies)
Discussion started by: Zaxon
8 Replies

6. Shell Programming and Scripting

Problem with type-casting in awk

Hi I'm trying to write a script which takes an integer as input and checks for files with size > input and displays it on screen. The code I've tried : echo 'Enter the min file size expected' read filesize du -ah <folder name> | awk -F: '$1>int(filesize) {print $1,$2)' is always... (28 Replies)
Discussion started by: vivek.bharadwaj
28 Replies

7. Programming

C++ type-casting a member variable in const methods

Is it permitted to type-cast a member variable passed in as a parameter in a member const method .. I am doing something like : in a return-type method () const { variable other = long(member variable) } this other assigned variable is not updating and I wonder if type-casting in such... (1 Reply)
Discussion started by: shriyer123
1 Replies

8. Shell Programming and Scripting

What is a type of this variable?

I have a question about the type of this variable checkU= sudo cat /etc/passwd: grep $uname: wc -l I write a script to check the existent of username that get from the keyboard. If there is no username,it will create the username else it show the 'Duplicate name" message. The problem is it... (4 Replies)
Discussion started by: thsecmaniac
4 Replies

9. Shell Programming and Scripting

Type casting problem

hi guys, i m new to shell script.. i dont know how to type cast string into integers and i mention my problem below.. date="21091988" month=$((${date:2:2})) # extract the month from previous date variable temp=$(($month*23)) when i am trying to calculate the temp value i got the... (5 Replies)
Discussion started by: raadhaakrishnan
5 Replies

10. Programming

Strange value of the double type variable: -nan(0x8000000000000)

I am confused by the value of "currdisk->currangle" after adding operation. Initially the value of "currdisk->currangle" is 0.77500000000000013, but after adding operation, it's changed to "-nan(0x8000000000000)", Can anyone explain ? Thanks! The following is the occasion of gdb debugging. 3338 ... (8 Replies)
Discussion started by: 915086731
8 Replies
RIBBON(1)						      General Commands Manual							 RIBBON(1)

NAME
ribbon - Raster3D molecular graphics package ribbon-drawer SYNOPSIS
"ribbon" [-h] [-d[0123456]] pdbfile or "ribbon" [-h] -d[0123456] - (to take PDB records from stdin) Ribbon reads a PDB coordinate file and produces a file on stdout containing Raster3D descriptor records for a ribbon representation con- structed from a triangular mesh. The file produced by ribbon may be fed directly to render or it may be combined with descriptor files produced by other Raster3D utilities. EXAMPLES
To describe a the entire protein chain as a single ribbon colored smoothly from blue at the N-terminus to red at the C-terminus: ribbon -d2 protein.pdb | render > chain_picture.png To color a multi-chain protein with specified colors for each chain: cat chaincolors.pdb protein.pdb | ribbon -d5 - > chains.r3d OPTIONS
-h Suppress header records in output. By default ribbon 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 triangle 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. -d[0123456] By default ribbon requires interactive input to select ribbon parameters and coloring information. Five default coloring schemes are implemented, however, and these may be selected as a command line option to bypass any interactive input. -d or -d0 same as -d2 below -d1 solid color ribbon (defaults to blue) -d2 shade from blue at N-terminus to red at C-terminus -d3 one surface of ribbon is blue, other surface is grey -d4 shade front surface from blue to red, back surface is grey -d5 color separate chains using successive color cards from input stream. Note that pattern matching on the color records is _not_ done; colors are simply taken sequentially as new chains are encountered. -d6 Color by nearest CA atom as taken from the COLOUR records at the head of the input file DESCRIPTION
The input to ribbon consists of a single text file containing colour information [optional] and atomic coordinates in PDB data bank format. Only CA and carbonyl O atom records are required; all other input atoms are ignored. Ribbon parameters and colouring specified interac- tively when the program is run. Keyboard interaction may be bypassed by selecting one of the default colouring schemes using the -d flag. A triangular mesh ribbon is output as Raster3D descriptor records. 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). Ribbon produces a continuous smooth trace of the protein backbone. For more complicated representations of protein secondary structure it is better to use a different program, e.g. MOLSCRIPT, rather than ribbon. ENVIRONMENT
The files setup.matrix and setup.angles, if they exist, affect the header records produced by ribbon. 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
MOLSCRIPT(l), render(l), rods(l), balls(l) AUTHORS
Original ribbon code written by Phil Evans for the CCP4 version of FRODO. Modification to describe solid ribbons as triangular mesh for Phong shading in Raster3D package by Ethan A Merritt. Raster3D 8 May 1999 RIBBON(1)
All times are GMT -4. The time now is 10:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy