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

Francois Pepin francois.pepin@mail.mcgill.ca
Sun, 12 Jan 2003 16:24:39 -0500


I'd suggest a slight modification:

use String instead of char[].

It's the usual way to handle strings and you don't have to worry about
references and making a copy of the array, because Strings are immutable
(they never change so no need to make another copy).

François

-----Original Message-----
From: biojava-l-admin@biojava.org [mailto:biojava-l-admin@biojava.org]
On Behalf Of Russell Smithies
Sent: 12 janvier, 2003 15:28
To: biojava-l@biojava.org
Subject: [Biojava-l] RE: clustalw-C to Java


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

_______________________________________________
Biojava-l mailing list  -  Biojava-l@biojava.org
http://biojava.org/mailman/listinfo/biojava-l