Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Initial Commit
- Loading branch information
ajt06004
committed
Jan 19, 2018
1 parent
ca1cdcd
commit e37ee19
Showing
30 changed files
with
3,134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> | ||
<attributes> | ||
<attribute name="owner.project.facets" value="java"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="lib" path="C:/Users/Asa/Documents/wikiimport/quinlibrary.jar"/> | ||
<classpathentry kind="lib" path="C:/Users/Asa/Documents/wikiimport/GraphletCounter-1.2.jar"/> | ||
<classpathentry kind="lib" path="C:/Users/Asa/Documents/wikiimport/REngine.jar"/> | ||
<classpathentry kind="lib" path="C:/Users/Asa/Documents/wikiimport/RserveEngine.jar"/> | ||
<classpathentry kind="output" path="build/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>TriPOINT</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.wst.common.project.facet.core.builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 | ||
org.eclipse.jdt.core.compiler.compliance=1.8 | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<faceted-project> | ||
<installed facet="java" version="1.8"/> | ||
</faceted-project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package edu.uconn.tripoint.export; | ||
|
||
public abstract class CytoscapeEdge { | ||
|
||
private int _id; | ||
private CytoscapeNode _n1, _n2; | ||
|
||
public CytoscapeEdge(int id, CytoscapeNode n1, CytoscapeNode n2){ | ||
_id = id; | ||
_n1 = n1; | ||
_n2 = n2; | ||
} | ||
|
||
public int getId(){ | ||
return _id; | ||
} | ||
|
||
public CytoscapeNode getN1(){ | ||
return _n1; | ||
} | ||
|
||
public CytoscapeNode getN2(){ | ||
return _n2; | ||
} | ||
|
||
|
||
public abstract String toJSON(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
package edu.uconn.tripoint.export; | ||
|
||
import java.io.BufferedWriter; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.util.Iterator; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.TreeMap; | ||
|
||
import quin.network.Location; | ||
import edu.uconn.tripoint.graph.Edge; | ||
import edu.uconn.tripoint.graph.Node; | ||
import edu.uconn.tripoint.pathway.Gene; | ||
import edu.uconn.tripoint.pathway.Pathway; | ||
import edu.uconn.tripoint.pathway.PathwayEdge; | ||
import edu.uconn.tripoint.triangulation.TriangulatedGene; | ||
|
||
/** | ||
* | ||
* Exports the pathways into a cytoscape format. | ||
* | ||
*/ | ||
public class CytoscapeExport { | ||
|
||
/** | ||
* | ||
* @param p | ||
* @param genes | ||
* @param noncoding | ||
* @param outdir | ||
*/ | ||
public void exportToCytoscapeJSON(Pathway p, Map<Gene, TriangulatedGene> genes, Map<Gene, List<Location>> noncoding, String outdir, String prefix){ | ||
Map<Gene, Integer> geneids = new TreeMap<Gene, Integer>(); | ||
int nindex = 0; | ||
Map<Integer, CytoscapeNode> nl = new TreeMap<Integer, CytoscapeNode>(); | ||
for(Iterator<Node<Gene,PathwayEdge>> it = p.getNodes().iterator(); it.hasNext();){ | ||
Node<Gene,PathwayEdge> next = it.next(); | ||
int curnindex = nindex++; | ||
Gene curgene = next.getData(); | ||
geneids.put(curgene, curnindex); | ||
int nccount = 0; | ||
if(noncoding.get(curgene) != null){ | ||
nccount = noncoding.get(curgene).size(); | ||
} | ||
nl.put(curnindex,new PathwayGeneCytoscapeNode(curnindex, p.getId(), genes.get(curgene), nccount)); | ||
} | ||
|
||
int eindex = 0; | ||
List<CytoscapeEdge> el = new LinkedList<CytoscapeEdge>(); | ||
for(Iterator<Edge<Gene,PathwayEdge>> it = p.getEdges().iterator(); it.hasNext();){ | ||
Edge<Gene,PathwayEdge> edge = it.next(); | ||
Gene src = edge.getSource().getData(); | ||
Gene dest = edge.getDestination().getData(); | ||
String type = getStringType(edge.getData().getType()); | ||
el.add(new PathwayCytoscapeEdge(eindex, nl.get(geneids.get(src)), nl.get(geneids.get(dest)), type)); | ||
} | ||
|
||
for(Iterator<Gene> git = geneids.keySet().iterator(); git.hasNext();){ | ||
Gene next = git.next(); | ||
List<Location> l = noncoding.get(next); | ||
if(l != null){ | ||
for(Iterator<Location> lit = l.iterator(); lit.hasNext();){ | ||
int curnindex = nindex++; | ||
CytoscapeNode n = new NonCodingCytoscapeNode(curnindex, lit.next()); | ||
nl.put(curnindex,n); | ||
el.add(new PathwayCytoscapeEdge(eindex++, nl.get(geneids.get(next)), n, "NonCoding")); | ||
} | ||
} | ||
} | ||
|
||
String outdir2 = outdir; | ||
if(!outdir.endsWith("/")){ | ||
outdir2 += "/"; | ||
} | ||
|
||
String filename = p.getId(); | ||
filename = filename.substring(filename.indexOf(":")+1).replaceAll("[^A-Za-z0-9]", ""); | ||
filename = filename.substring(0, Math.min(filename.length(), 16)); | ||
|
||
try { | ||
writeJSONFile(outdir2+prefix+"_"+filename+".json", p, nl, el); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
private String getStringType(int type){ | ||
if(type == PathwayEdge.ACTIVATION){ | ||
return "Activation"; | ||
} | ||
else if(type == PathwayEdge.INHIBITION){ | ||
return "Inhibition"; | ||
} | ||
else{ | ||
return "Association"; | ||
} | ||
} | ||
|
||
private void writeJSONFile(String outfile, Pathway p, Map<Integer, CytoscapeNode> nodes, List<CytoscapeEdge> edges) throws IOException{ | ||
BufferedWriter bw = new BufferedWriter(new FileWriter(outfile)); | ||
bw.write("{\n"); | ||
bw.write("\"data\": {\"name\": \""+p.getId()+"\"},\n"); | ||
bw.write("\"elements\" : {\n"); | ||
bw.write("\"nodes\" : ["); | ||
Iterator<CytoscapeNode> it = nodes.values().iterator(); | ||
if(it.hasNext()){ | ||
bw.write(it.next().toJSON()+"\n"); | ||
} | ||
while(it.hasNext()){ | ||
bw.write(","+it.next().toJSON()+"\n"); | ||
} | ||
bw.write("],\n"); | ||
bw.write("\"edges\" : [\n"); | ||
Iterator<CytoscapeEdge> ite = edges.iterator(); | ||
if(ite.hasNext()){ | ||
bw.write(ite.next().toJSON()+"\n"); | ||
} | ||
while(ite.hasNext()){ | ||
bw.write(","+ite.next().toJSON()+"\n"); | ||
} | ||
bw.write("]\n"); | ||
bw.write("}\n"); | ||
bw.write("}\n"); | ||
bw.flush(); | ||
bw.close(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package edu.uconn.tripoint.export; | ||
|
||
public abstract class CytoscapeNode { | ||
|
||
private int _id; | ||
|
||
public CytoscapeNode(int id){ | ||
_id = id; | ||
} | ||
|
||
public int getId(){ | ||
return _id; | ||
} | ||
|
||
|
||
public abstract String toJSON(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package edu.uconn.tripoint.export; | ||
|
||
import quin.network.Location; | ||
|
||
public class NonCodingCytoscapeNode extends CytoscapeNode{ | ||
|
||
public Location _l; | ||
public NonCodingCytoscapeNode(int id, Location l) { | ||
super(id); | ||
_l = l; | ||
} | ||
|
||
@Override | ||
public String toJSON(){ | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append("{\n"); | ||
sb.append("\"data\" : {\n"); | ||
sb.append("\"id\" : \""+getId()+"\",\n"); | ||
sb.append("\"type\" : \"NonCoding Target\",\n"); | ||
sb.append("\"name\" : \""+_l.getChr()+":"+_l.getStart()+"-"+_l.getEnd()+"\"\n"); | ||
sb.append("}\n"); | ||
sb.append("}\n"); | ||
return sb.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package edu.uconn.tripoint.export; | ||
|
||
import java.io.BufferedWriter; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.util.Collection; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import quin.network.Location; | ||
import edu.uconn.tripoint.pathway.Gene; | ||
import edu.uconn.tripoint.pathway.Pathway; | ||
import edu.uconn.tripoint.triangulation.TriangulatedGene; | ||
|
||
public class NonCodingTargetExport { | ||
|
||
public void ExportNonCodingTargets(Pathway globalpathway, Pathway[] pathways, Collection<TriangulatedGene> genes, Map<Gene, List<Location>> noncoding, String outdir, String prefix) throws IOException{ | ||
String outdir2 = outdir; | ||
if(!outdir.endsWith("/")){ | ||
outdir2 += "/"; | ||
} | ||
|
||
BufferedWriter bw = new BufferedWriter(new FileWriter(outdir2+prefix+"_noncoding.txt")); | ||
bw.write("Gene ID"+"\t"+ | ||
"Chr"+"\t"+"Start"+"\t"+"End"+"\n"); | ||
for(Iterator<TriangulatedGene> it = genes.iterator(); it.hasNext();){ | ||
TriangulatedGene next = it.next(); | ||
writeLine(bw,next, noncoding); | ||
} | ||
|
||
bw.flush(); | ||
bw.close(); | ||
} | ||
|
||
private void writeLine(BufferedWriter bw, TriangulatedGene g, Map<Gene, List<Location>> noncoding) throws IOException{ | ||
Gene gene = g.getGene(); | ||
List<Location> nc = noncoding.get(gene); | ||
if(nc.size() > 0){ | ||
String id = gene.getId(); | ||
for(Iterator<Location> it = nc.iterator(); it.hasNext();){ | ||
Location next = it.next(); | ||
bw.write(id+"\t"+ | ||
next.getChr()+"\t"+next.getStart()+"\t"+next.getEnd()+"\n"); | ||
} | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package edu.uconn.tripoint.export; | ||
|
||
public class PathwayCytoscapeEdge extends CytoscapeEdge{ | ||
|
||
private String _type; | ||
|
||
public PathwayCytoscapeEdge(int id, CytoscapeNode n1, CytoscapeNode n2, String type){ | ||
super(id, n1, n2); | ||
_type = type; | ||
} | ||
|
||
public String toJSON(){ | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append("{\n"); | ||
sb.append("\"data\" : {\n"); | ||
sb.append("\"id\" : \""+getId()+"\",\n"); | ||
sb.append("\"source\" : \""+getN1().getId()+"\",\n"); | ||
sb.append("\"target\" : \""+getN2().getId()+"\",\n"); | ||
sb.append("\"type\" : \""+_type+"\"\n"); | ||
sb.append("}\n"); | ||
sb.append("}\n"); | ||
return sb.toString(); | ||
} | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
src/edu/uconn/tripoint/export/PathwayGeneCytoscapeNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package edu.uconn.tripoint.export; | ||
|
||
import edu.uconn.tripoint.triangulation.TriangulatedGene; | ||
|
||
public class PathwayGeneCytoscapeNode extends CytoscapeNode { | ||
|
||
private String _pathway; | ||
private TriangulatedGene _tg; | ||
private int _noncodingcount; | ||
|
||
public PathwayGeneCytoscapeNode(int id, String pathway, TriangulatedGene tg, int nccount){ | ||
super(id); | ||
_pathway = pathway; | ||
_tg = tg; | ||
_noncodingcount = nccount; | ||
} | ||
|
||
@Override | ||
public String toJSON(){ | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append("{\n"); | ||
sb.append("\"data\" : {\n"); | ||
sb.append("\"id\" : \""+getId()+"\",\n"); | ||
sb.append("\"type\" : \"Pathway Gene\",\n"); | ||
sb.append("\"name\" : \""+_tg.getGene().getId()+"\",\n"); | ||
sb.append("\"pathway\" : \""+_pathway+"\",\n"); | ||
sb.append("\"expression\" : "+_tg.getGene().getValue()+",\n"); | ||
sb.append("\"inconsistency\" : "+_tg.getInconsistencyScore(_pathway)+",\n"); | ||
sb.append("\"inconsistency_pval\" : "+_tg.getInconsistencyPValue(_pathway)+",\n"); | ||
sb.append("\"inconsistency_qval\" : "+_tg.getInconsistencyFDR(_pathway)+",\n"); | ||
sb.append("\"support\" : "+_tg.getSupportScore(_pathway)+",\n"); | ||
sb.append("\"support_pval\" : "+_tg.getSupportPValue(_pathway)+",\n"); | ||
sb.append("\"support_qval\" : "+_tg.getSupportFDR(_pathway)+",\n"); | ||
sb.append("\"consistency\" : "+_tg.getConsistencyScore(_pathway)+",\n"); | ||
sb.append("\"consistency_pval\" : "+_tg.getConsistencyPValue(_pathway)+",\n"); | ||
sb.append("\"consistency_qval\" : "+_tg.getConsistencyFDR(_pathway)+",\n"); | ||
sb.append("\"impact\" : "+_tg.getImpactScore(_pathway)+",\n"); | ||
sb.append("\"impact_pval\" : "+_tg.getImpactPValue(_pathway)+",\n"); | ||
sb.append("\"impact_qval\" : "+_tg.getImpactFDR(_pathway)+",\n"); | ||
sb.append("\"noncoding_count\" : "+_noncodingcount+"\n"); | ||
sb.append("}\n"); | ||
sb.append("}\n"); | ||
return sb.toString(); | ||
} | ||
|
||
} |
Oops, something went wrong.