[Biojava-l] RE: clustalw-C to Java

Russell Smithies russell_smithies@hotmail.com
Sun, 12 Jan 2003 20:27:37 +0000


I guess lots of people will answer this so I hope I get it right :-)
This isn't the exact answer but I hope it helps.

structs in C can be thought of class objects in Java (done the hard way)
so your tree node becomes:

class Stree implements Comparable{
   Stree left = null;
   Stree right = null;
   Stree parent = null;
   float dist;
   short leaf;
   int order;
   char[] name;
}

//then a few constructors as required

Stree(){
}

Stree(Stree l, Stree r, Stree p, float d, short l, int o, char[] n){
   left = l;
   right = r;
   parent = p;
   dist = d;
   leaf = l;
   order = o;
   name = n; // might need to clone it??
}

//and accessors and modifiers (getters and setters) as required

Stree getLeft(Stree st){
   return st.left;
}

float setDist(float d){
   dist = d;
}

//and implement Comparable somehow
public int compareTo( Object o ){
    int retVal;
    Stree n = (Stree) o;

   retVal = dist - n.dist;
    // something like this???
    if ( retVal == 0 )
        if ( this == n )
            retVal = 0;
        else
            retVal = -1;
    return retVal;
}




>Message: 1
>Date: Sun, 12 Jan 2003 04:01:16 -0800 (PST)
>From: suyee <leesuyee@yahoo.com>
>To: biojava <biojava-l@biojava.org>
>Subject: [Biojava-l] clustalw-C to Java
>
>can anybody teach me how to convert this (in C) into Java.
>this is taken from ClustalW1.8.1
>
>typedef struct node { /* phylogenetic tree structure */
>         struct node *left;
>         struct node *right;
>         struct node *parent;
>         float dist;
>         sint  leaf;
>         int order;
>         char name[64];
>} stree, *treeptr;
>
>thanks
>


_________________________________________________________________
The new MSN 8 is here: Try it free* for 2 months 
http://join.msn.com/?page=dept/dialup