[Bioperl-l] convert xyz coordinates to distance

Boris Steipe boris.steipe at utoronto.ca
Wed Mar 22 20:28:41 UTC 2006


Here's a bit of cut-and-paste code: this routine works with two  
strings, each containing an ATOM record. No checking is done, the  
logic which records to select is up to you. Use as, for example:

my $distance = PDB_dist($coord_1, $coord_2);


sub PDB_dist {
   my ($s1, $s2) = @_;

   my $dx = substr($s1,30,8) - substr($s2,30,8);
   my $dy = substr($s1,38,8) - substr($s2,38,8);
   my $dz = substr($s1,46,8) - substr($s2,46,8);

   return sqrt( $dx*$dx + $dy*$dy + $dz*$dz );
}


HTH

Boris


On 22 Mar 2006, at 11:42, ni_psis wrote:

>
> Hi,
>
> I am new to perl, but I would like write a perl script that can  
> convert xyz
> cordinates from a pdb file to distances using the formula:  distance =
> SQRT[(X1-X2)^2  +  (Y1-Y2)^2 + (Z1-Z2)^2]
>
> eg: The atoms of HELIX 1 with all the atoms of HELIX 2 and 3
>
> the atom[0] of  1 with the atom[0] of 2
> the atom[0] of  1 with the atom[1] of 2
> the atom[0] of  1 with the atom[2] of 2
> the atom[0] of  1 with the atom[3] of 2
> .
> .
> .
> .
> .
> .
> the atom[1] of  1 with the atom[0] of 2
> the atom[1] of  1 with the atom[1] of 2
> the atom[1] of  1 with the atom[2] of 2
> the atom[1] of  1 with the atom[3] of 2
>
>
> I want a good idea of how to do it
> Please HELP ME
> thanks
>
>
> The pdb file format look like this
>
> HEADER    PHEROMONE                               20-DEC-95   2ERL
> HELIX 1	H1		ASP	1	GLN	9
> HELIX 2	H2		GLU	12	LEU	18
> HELIX 3	H3		GLU	23	ASN	35
> ATOM      1  N   ASP     1      -1.115   8.537   7.075

[snip !]


>
> --
> View this message in context: http://www.nabble.com/convert-xyz- 
> coordinates-to-distance-t1325102.html#a3535971
> Sent from the Perl - Bioperl-L forum at Nabble.com.
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l




More information about the Bioperl-l mailing list