LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-17-2010, 10:45 AM   #1
elsuccia
LQ Newbie
 
Registered: May 2010
Posts: 1

Rep: Reputation: 0
Lightbulb distance between two points with x, y and z coordinates


Hi everybody,
i have some problem to calculate the distance between two points, in my case i have a file with 16 columns and i'm interesting to 6th, 7th, 8th column that are rispectively the x, y and z coordinates of several atoms belonging to a protein, instead in 14th 15th and 16th columns there are the x,y and z coordinates of different several atoms belonging to another protein (like a pdb files if you know)

3240 N MET A 1 28.380 -10.546 120.002 1498 N LEU H 4 -12.083 17.613 122.020
3241 CA MET A 1 29.328 -10.809 118.887 1499 CA LEU H 4 -12.112 18.585 120.929
3242 C MET A 1 28.980 -10.032 117.607 1500 C LEU H 4 -13.580 18.662 120.622
3243 O MET A 1 29.840 -9.812 116.757 1501 O LEU H 4 -14.132 17.698 120.083
3244 CB MET A 1 29.374 -12.303 118.574 1502 CB LEU H 4 -11.228 18.108 119.770
3245 CG MET A 1 28.072 -13.044 118.849 1503 CG LEU H 4 -9.718 18.157 120.038
3246 SD MET A 1 27.002 -12.164 120.004 1504 CD1 LEU H 4 -8.958 17.586 118.848
3247 CE MET A 1 27.900 -12.386 121.536 1505 CD2 LEU H 4 -9.296 19.593 120.309
3248 H MET A 1 27.742 -10.369 120.752 1506 H LEU H 4 -12.063 16.948 122.767
3249 HA MET A 1 30.330 -10.481 119.166 1507 HA LEU H 4 -11.740 19.545 121.285

i guess to need all the combinations, for example i have to calculate all the possible values (X1– Xk)^2 k from 1 to n, (X2– Xk) ....also for y and z, necessary to calculate the euclidean distance.
if you have best idea please help me I don't know how realize this project.
Thanks a lot
Elsa

Last edited by elsuccia; 05-17-2010 at 10:47 AM.
 
Old 05-17-2010, 11:04 AM   #2
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
No one here will do your homework for you. And if you want help with it, you will have to start by showing what it is that you have already done and what specifically you don't understand or need help with.

You also are going to have to specify what language you are using. And you are going to have to be a lot more clear about what is going on with two sets of coordinates in one field and how that factors into your consideration of all possible cases.
 
Old 05-17-2010, 11:12 AM   #3
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
I assume that is an assignment in a programming class.

So you are supposed to already have more of an idea of what you need to do.

Do not describe the whole assignment and ask for general help.

If you want help with homework, ask about a specific part of the problem after making some attempt yourself and demonstrating some understanding of how to do other parts of the problem.

Also make sure you understand what the program is supposed to do. Your description of the problem is at least ambiguous and I think self contradictory concerning which atoms you want distances between and what you're supposed to do with all those distances after computing them.

Also, make sure you find out how to use CODE tags when posting. You posted sample data consisting of long lines with the positions of the line breaks significant to the meaning of the data. That is never a good idea in ordinary text in a post, even if you tweaked the font to make it look right in your browser. If you post it inside CODE tags, we can see the accurate positions of original line breaks. That is even more important when you want to post some sample code to ask why it doesn't work.

Long before you got this assignment, you should have learned enough beginning programming that computing the distance between a pair of points should be trivial. I don't know how to guess which parts of the assignment aren't trivial:

Reading the assignment and figuring out exactly what the instructor wants you to accomplish?

Writing the code to parse each line of input into its meaningful parts?

Organizing storage for combinations of distances (depending on which distances you're supposed to compute and what you're supposed to do with the result).

Last edited by johnsfine; 05-17-2010 at 11:18 AM.
 
Old 05-17-2010, 07:31 PM   #4
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Maybe it's just me, but this sounds more like something a PI would assign to a new lab tech rather than homework for a class. In any case...

Are you saying you need distances for all possible pairs of atoms? What languages are available to you? In most languages you'll need two loops, one nested in the other, where each iterates over the first and second atoms, respectively. Within the inner loop, calculate your distance metric using a 2-norm in 3D space. If you have N lines, you don't actually have to calculate all N^2 possibilities; just N(N-1)/2. If you picture it as a matrix where each element represents the distance between the atoms for the respective row and column, you would calculate the lower half only, then transpose it into the upper half. If you use a language that supports matrices, you might be able to save steps using them.
Kevin Barry
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there an easy way of drawing a polygon from some xyz coordinates. sniff Programming 8 03-01-2010 06:15 AM
Finding on-screen coordinates of colored rectangle aravind137 Linux - General 0 06-23-2008 12:01 PM
Visual Python: problem changing coordinates of cylinder raskol Programming 1 04-03-2008 01:10 PM
Anyone know how to capture mouse click x and y coordinates? aatwell Programming 1 12-01-2007 03:28 PM
GIMP does not negative coordinates in a .eps leontini Linux - Software 1 12-18-2005 01:46 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration