[_REQ_](https://research.pasteur.fr/fr/tool/r%CE%B5q-assessing-branch-supports-o%C6%92-a-distance-based-phylogenetic-tree-with-the-rate-o%C6%92-elementary-quartets/) is a command line program written in [Java](https://docs.oracle.com/javase/8/docs/technotes/guides/language/index.html) that estimates the rate of elementary quartets (REQ) for each internal branch of an unrooted binary phylogenetic tree from a distance matrix, as described by [Guénoche and Garreta (2001)](https://doi.org/10.1007/3-540-45727-5_5).
[_REQ_](https://research.pasteur.fr/fr/tool/r%CE%B5q-assessing-branch-supports-o%C6%92-a-distance-based-phylogenetic-tree-with-the-rate-o%C6%92-elementary-quartets/) is a command line program written in [Java](https://docs.oracle.com/javase/8/docs/technotes/guides/language/index.html) that estimates the rate of elementary quartets (REQ) for each internal branch of an unrooted binary phylogenetic tree from a distance matrix, as described by [Guénoche and Garreta (2001)](https://doi.org/10.1007/3-540-45727-5_5).
## Installation
Clone this repository using the following command line:
```bash
git clone https://gitlab.pasteur.fr/GIPhy/REQ.git
```
## Compilation and execution
## Compilation and execution
The source code of _REQ_ is inside the _src_ directory and can be compiled and executed in two different ways.
The source code of _REQ_ is inside the _src_ directory and can be compiled and executed in two different ways.
#### Building an executable jar file
#### Building an executable jar file
On computers with [Oracle JDK](http://www.oracle.com/technetwork/java/javase/downloads/index.html)(6 or higher) installed, a Java executable jar file can be created.
On computers with [Oracle JDK](http://www.oracle.com/technetwork/java/javase/downloads/index.html)(6 or higher) installed, a Java executable jar file can be created by typing the following command lines inside the _src/_ directory:
In a command-line window, go to the _src_ directory and type:
```bash
```bash
javac REQ.java
javac REQ.java
echo Main-Class: REQ > MANIFEST.MF
echo Main-Class: REQ > MANIFEST.MF
jar -cmvf MANIFEST.MF REQ.jar REQ.class
jar -cmvf MANIFEST.MF REQ.jar REQ.class
rm MANIFEST.MF REQ.class
rm MANIFEST.MF REQ.class
```
```
This will create the executable jar file `REQ.jar` that can be run with the following command line model:
This will create the executable jar file `REQ.jar` that can be run with the following command line model:
```bash
```bash
...
@@ -23,12 +30,12 @@ java -jar REQ.jar [files]
...
@@ -23,12 +30,12 @@ java -jar REQ.jar [files]
#### Building a native executable
#### Building a native executable
On computers with [GraalVM](hhttps://www.graalvm.org/downloads/) installed, a native executable can also be built.
On computers with [GraalVM](hhttps://www.graalvm.org/downloads/) installed, a native executable can be built.
In a command-line window, go to the _src_ directory, and type:
In a command-line window, go to the _src_ directory, and type:
```bash
```bash
javac REQ.java
javac REQ.java
native-image REQ REQ
native-image REQ REQ
rm REQ.class
rm-f REQ.build_artifacts.txt REQ.class
```
```
This will create the native executable `REQ` that can be launched with the following command line model:
This will create the native executable `REQ` that can be launched with the following command line model:
+ fixed bug when a leaf is not present in the distance matrix
+ no change in the quite obfuscated code style
### v2.0.200528ac
### v2.0.200528ac
+ verify that the input tree is unrooted and fully binary
+ verify that the input tree is unrooted and fully binary
+ faster running times by minimizing String conversion
+ faster running times by minimizing String conversion
...
@@ -41,7 +58,7 @@ import java.text.*;
...
@@ -41,7 +58,7 @@ import java.text.*;
publicclassREQ{
publicclassREQ{
// constants
// constants
finalstaticStringVERSION="v2.0.200528ac";
finalstaticStringVERSION="v2.1 (240328ac)";
finalstaticintMAX=32760;
finalstaticintMAX=32760;
finalstaticintINF=Integer.MAX_VALUE;
finalstaticintINF=Integer.MAX_VALUE;
...
@@ -75,7 +92,10 @@ public class REQ {
...
@@ -75,7 +92,10 @@ public class REQ {
//### man ############################################################################################################################################################################
//### man ############################################################################################################################################################################
if(j!=-1)tip[--i]=(short)j;else{System.err.println(tr.substring(u,v)+" is not inside distance matrix");System.exit(1);}}
if(j!=-1)tip[--i]=(short)j;else{System.err.println(line+" does not belong to the distance matrix labels");System.exit(1);}}
v=--u;break;
v=--u;break;
case')':++d;v=u;break;
case')':++d;v=u;break;
}
}
...
@@ -143,8 +163,8 @@ public class REQ {
...
@@ -143,8 +163,8 @@ public class REQ {
//# sup last
//# sup last
tr=tr.insert(0,'(');sup=apc(tr,tr.lastIndexOf(")"));tr=tr.insert(sup,')');//# NOTE: closing parenthesis at index 'sup' should not be considered for REQ calculations
tr=tr.insert(0,'(');sup=apc(tr,tr.lastIndexOf(")"));tr=tr.insert(sup,')');//# NOTE: closing parenthesis at index 'sup' should not be considered for REQ calculations
last=tr.lastIndexOf(")");
last=tr.lastIndexOf(")");
//# NOTE: totip[x] = id in tip[] of the taxon at or right after position x in tr //# tr = "( ( 1 , 3 ) , ( 0 , 2 ) ) ;" tip = [1,3,0,2]
//# NOTE: totip[x] = id in tip[] of the taxon right after position x in tr //# tr = "( ( 1 , 3 ) , ( 0 , 2 ) ) ;" tip = [1,3,0,2]