Hi all,

I need to do a translation using 2D arrays for my Superposition algorithm.

Translation:

I plan to use the CA(Alpha carbon) as my invariant point which is usually the 2nd line in the pdb.txt file. So how go about doing that? Must I use an orthogonal matrix? Or can I just subtract the coordinates of file1 from file 2 for X, Y & Z to get the rest of the ATOMS to move by that difference? You help is greatly appreciated! :) This program is in JAVA.

while ((text1 = br1.readLine()) != null)   {  //Read File Line By Line

    if(text1.trim().startsWith("ATOM")) {
        StringTokenizer s1 = new StringTokenizer(text1," ");

        int counter1=0;
        String line1="";

        while(s1.hasMoreTokens()) {

            String ss1 = s1.nextToken();
            counter1++;

            if(counter1 == 3){
                line1 += ss1;
                arrayM1[i] = ss1;
            }
        }

        coordinates1[i][0]= Double.parseDouble(text1.substring(30,38));//X
        coordinates1[i][1]= Double.parseDouble(text1.substring(38,46));//Y
        coordinates1[i][2]= Double.parseDouble(text1.substring(46,56));//Z



        i+=1;
    }//end of if


} //end of while.

Edited 3 Years Ago by mike_2000_17: Fixed formatting

A suggestion, test text1 string is long enough before doing:
coordinates1[2]= Double.parseDouble(text1.substring(46,56));

A suggestion, test text1 string is long enough before doing:
coordinates1[2]= Double.parseDouble(text1.substring(46,56));

Could you advice me how to do that? Thank you! :)

Use the String length method:
if(text1.length() < MaxSubStringIndexUsed) { // test string long enough
.. the string is too short, substring will fail
}

Edited 6 Years Ago by NormR1: n/a

This article has been dead for over six months. Start a new discussion instead.