Skip to content

Commit

Permalink
Jgrapht adopt
Browse files Browse the repository at this point in the history
  • Loading branch information
hbai98 committed Aug 3, 2020
1 parent 9132f51 commit 7d50ca8
Show file tree
Hide file tree
Showing 274 changed files with 2,873 additions and 11,369 deletions.
2 changes: 1 addition & 1 deletion .idea/deployment.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/webServers.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1,137 changes: 362 additions & 775 deletions .idea/workspace.xml

Large diffs are not rendered by default.

443 changes: 443 additions & 0 deletions HGALog.txt

Large diffs are not rendered by default.

328 changes: 0 additions & 328 deletions HGALogFile.log

This file was deleted.

328 changes: 0 additions & 328 deletions HGALogFile.log.1

This file was deleted.

Binary file added README.assets/image-20200608121805358.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added README.assets/image-20200608122736345.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added README.assets/image-20200608122828935.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
143 changes: 8 additions & 135 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,153 +6,26 @@ This is a repository written in my experiments for several algorithms.

Obtain reliable and optimal mapping between networks concerning about protein sequences and topological similarity


![image-20200608121805358](README.assets/image-20200608121805358.png)

<img src="README.assets/image-20200608122144302.png" alt="image-20200608122144302" style="zoom: 67%;" />

Please refer to An Adaptive Hybrid Algorithm for Global Network Alignment[http://dx.doi.org/10.1109/TCBB.2015.2465957] for the design of the algorithm.

### case 1 : biomolecular network

Get the mapping subgraph across species.

http://dx.doi.org/10.1109/TCBB.2015.2465957

### case 2: drug repurposing by alignment

<img src="README.assets/image-20200608122510098.png" alt="image-20200608122510098" style="zoom: 50%;" />

### How to run

First you have to build by maven

```
mvn compile
```

Then, please navigate to the pom.xml file from the root, and comment the < skipTests > line in the plugin, then your tests could work.

```
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<!-- <skipTests>true</skipTests> -->
</configuration>
</plugin>
```

In your server command line, input the follow command

```
nohup mvn clean test -Dtest=Algorithms.Graph.HGA.HGARunSpec#<test> &
```

< test > can be any junit test class method, for example, < test > can be run_yeast like example below:

```java
@Test
void run_yeast() throws IOException {
// reader for reading undirected graphs and the similarity matrix
GraphFileReader reader = new GraphFileReader(true, false, false);
// read graphs with the file path
undG1 = reader.readToUndirectedGraph("src/test/java/resources/TestModule/HGATestData/Human-YeastSub38N/net-38n.txt", false);
undG2 = reader.readToUndirectedGraph("src/test/java/resources/TestModule/HGATestData/Human-YeastSub38N/HumanNet.txt", false);
// undirected graphs don't have to record neighbors
reader.setRecordNeighbors(false);
// read the simMat
simMat = reader.readToSimMat("src/test/java/resources/TestModule/HGATestData/Human-YeastSub38N/fasta/yeastHumanSimList_EvalueLessThan1e-10.txt",
undG1.getAllNodes(), undG2.getAllNodes(), true);
// hga init
hga = new HGA(simMat, undG1, undG2, 0.4,true,0.5,0.01);
// specify where you want the log matrix, score, and mapping result.
HGA.debugOutputPath = "src\\test\\java\\resources\\Jupiter\\data\\";
hga.run();
}
```

Notice: the similarity matrix is consist of the index graph's nodes as its rows, and the target graph's as its columns.

The matrix's size should be equal to or more than m*n as it has to cover all pairs.



It's flexible for you to write a new test method for your customized design and purpose.



If you would like to check the status of the current mapping, there is a HGALogFile.log in the root path.

```
Jul 12, 2020 10:59:22 AM Internal.Algorithms.Graph.HGA.HGA logInfo
INFO: Init mapping...
Jul 12, 2020 10:59:22 AM Internal.Algorithms.Graph.HGA.HGA logInfo
INFO: ------------Iteration 0/1000------------
Jul 12, 2020 10:59:22 AM Internal.Algorithms.Graph.HGA.HGA logInfo
INFO: Remapping...
Jul 12, 2020 10:59:22 AM Internal.Algorithms.Graph.HGA.HGA logInfo
INFO: Selecting 50.0% of rows for Hungarian allocation, and the left 50.0% for Greedy mapping.
Jul 12, 2020 10:59:22 AM Internal.Algorithms.Graph.HGA.HGA logInfo
INFO: Hungarian mapping...
Jul 12, 2020 10:59:22 AM Internal.Algorithms.Graph.HGA.HGA logInfo
INFO: Scoring for mapping ...
Jul 12, 2020 10:59:22 AM Internal.Algorithms.Graph.HGA.HGA logInfo
INFO: output matrix
Jul 12, 2020 10:59:22 AM Internal.Algorithms.Graph.HGA.HGA logInfo
INFO: output scores
Jul 12, 2020 10:59:22 AM Internal.Algorithms.Graph.HGA.HGA logInfo
INFO: output mapping
Jul 12, 2020 10:59:22 AM Internal.Algorithms.Graph.HGA.HGA logInfo
INFO: adjust neighborhood similarity based on mapping result...
Jul 12, 2020 10:59:22 AM Internal.Algorithms.Graph.HGA.HGA logInfo
INFO: AddTopology for all nodes pairs in two graphs:
Jul 12, 2020 10:59:22 AM Internal.Algorithms.Graph.HGA.HGA logInfo
```

When the matrix has converged, it will be an output information to denote that all iterations needed have been finished.

```
Jul 12, 2020 10:59:22 AM Internal.Algorithms.Graph.HGA.HGA logInfo
INFO: HGA mapping finish!With iteration 14 times.
Jul 12, 2020 10:59:22 AM Internal.Algorithms.Graph.HGA.HGA logInfo
INFO: output mapping
Jul 12, 2020 10:59:22 AM Internal.Algorithms.Graph.HGA.HGA logInfo
INFO: output matrix
Jul 12, 2020 10:59:22 AM Internal.Algorithms.Graph.HGA.HGA logInfo
INFO: output scores
```

### GPU acceleration

The algorithm is still complicated as updating the matrix with topological information will be tedious. The time complexity will be (n*m)^2, for more information on how to implement this method, please visit my blog [here](http://www.haotian.life/2020/07/28/new-feature-gpu-for-hga/).

```
@Test
void run_test_GPU() throws IOException {
GraphFileReader reader = new GraphFileReader(true, false, false);
undG1 = reader.readToUndirectedGraph("src/test/java/resources/AlgTest/HGA/graph1.txt", false);
undG2 = reader.readToUndirectedGraph("src/test/java/resources/AlgTest/HGA/graph2.txt", false);
reader.setRecordNeighbors(false);
simMat = reader.readToSimMat("src/test/java/resources/AlgTest/HGA/simMat.txt", undG1.getAllNodes(), undG2.getAllNodes(), true);
hga = new HGA(simMat, undG1, undG2, 0.5,true,0.5,0.01);
HGA.GPU = true;
hga.run();
}
```

To enable GPU, just set HGA.GPU to true, but you should firstly make sure both drivers and environments have been properly set up. There are ample resources on the topic of how to make GPU work, and I will not explain it further.



You could contact me by [email protected] if there is some thorny problems you encounter.

### Applications

* BNMatch
* parameters

A Cytoscape app to reach optimized global mapping in biological networks, it will visualize the result returned from HGA.
* h

![panel](README.assets/panel.png)
<img src="README.assets/image-20200608122736345.png" alt="image-20200608122736345" style="zoom: 67%;" />

Please visit https://apps.cytoscape.org/apps/bnmatch2 for more information.
* E-value

<img src="README.assets/image-20200608122828935.png" alt="image-20200608122828935" style="zoom: 50%;" />
76 changes: 32 additions & 44 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<!--properties-->
<bundle.symbolicName>BHT.Algorithm</bundle.symbolicName>
<bundle.namespace>Internal.Algorithms</bundle.namespace>
<!--dependencies versions-->
<junit.platform.version>1.6.2</junit.platform.version>
<junit.jupiter.version>5.6.2</junit.jupiter.version>
<assertj.core.version>3.15.0</assertj.core.version>
<jgrapht.core.version>1.5.0</jgrapht.core.version>
Expand All @@ -20,26 +16,38 @@
<Apache-Commons-Collections.version>3.2.2</Apache-Commons-Collections.version>
<commons-io.version>2.5</commons-io.version>
<tablesaw.version>LATEST</tablesaw.version>
<commons-csv.version>1.8</commons-csv.version>
<aparapi.version>2.0.0</aparapi.version>
<commons-lang3.version>3.11</commons-lang3.version>
<MS>4.1.2</MS>
<!--plugins versions-->
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<maven-surefire-plugin.version>3.0.0-M3</maven-surefire-plugin.version>
<exec-maven-plugin.version>3.0.0</exec-maven-plugin.version>
<MS>4.1.2</MS>
<maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
</properties>
<groupId>BHT</groupId>
<artifactId>Algorithms</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<repositories>
<repository>
<id>oss.sonatype.org-snapshot</id>
<url>http://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>nexus-aliyun</id>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</repository>

<repository>
<id>ebi-repo</id>
<name>ebi-repo</name>
<url>http://www.ebi.ac.uk/~maven/m2repo</url>
</repository>
</repositories>

<build>
Expand All @@ -50,50 +58,27 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<release>11</release>
<source>14</source>
<target>14</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<argLine>--enable-preview</argLine>
<skipTests>true</skipTests>
<forkCount>1</forkCount>
<reuseForks>true</reuseForks>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${maven-bundle-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${bundle.symbolicName}</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
<Export-Package>!${bundle.namespace}.*</Export-Package>
<Private-Package>${bundle.namespace}.*</Private-Package>
<Import-Package>*;resolution:=optional</Import-Package>
<Embed-Dependency>*;</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<!-- JUNIT5 for unit testing-->
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>${junit.platform.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
Expand All @@ -108,39 +93,45 @@
<groupId>org.jblas</groupId>
<artifactId>jblas</artifactId>
<version>${jblas.version}</version>
<optional>true</optional>
</dependency>
<!--java data science and visualize package-->
<dependency>
<groupId>tech.tablesaw</groupId>
<artifactId>tablesaw-core</artifactId>
<version>${tablesaw.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>tech.tablesaw</groupId>
<artifactId>tablesaw-jsplot</artifactId>
<version>${tablesaw.version}</version>
<optional>true</optional>
</dependency>
<!--network data structure base-->
<dependency>
<groupId>org.jgrapht</groupId>
<artifactId>jgrapht-core</artifactId>
<version>${jgrapht.core.version}</version>
<optional>true</optional>
</dependency>
<!--tree UI-->
<dependency>
<groupId>org.swinglabs</groupId>
<artifactId>swingx</artifactId>
<version>${swingx.version}</version>
<optional>true</optional>
</dependency>
<!--java GPU programming-->

<dependency>
<groupId>com.aparapi</groupId>
<artifactId>aparapi</artifactId>
<version>${aparapi.version}</version>
</dependency>
<!--some tools-->
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>${Apache-Commons-Collections.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>commons-io</groupId>
Expand All @@ -160,15 +151,12 @@
<version>${MS}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.aparapi</groupId>
<artifactId>aparapi</artifactId>
<version>${aparapi.version}</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
<optional>true</optional>
</dependency>
</dependencies>

Expand Down
Loading

0 comments on commit 7d50ca8

Please sign in to comment.