Author: Maital Ashkenazi
Date: 2010-09-20 07:39:50 -0700 (Mon, 20 Sep 2010)
New Revision: 21946
Added:
csplugins/trunk/soc/maital/EnhancedSearch2/lib/lucene-core-3.0.2.jar
csplugins/trunk/soc/maital/EnhancedSearch2/resources/
csplugins/trunk/soc/maital/EnhancedSearch2/resources/plugin.props
Removed:
csplugins/trunk/soc/maital/EnhancedSearch2/lib/lucene-core-3.0.1.jar
csplugins/trunk/soc/maital/EnhancedSearch2/plugin.props
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/util/NumberUtils.java
Modified:
csplugins/trunk/soc/maital/EnhancedSearch2/build.xml
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/EnhancedSearchImpl.java
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/EnhancedSearchPanel.java
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/TestEnhancedSearch.java
Log:
Version 2.0: compatible with Cytoscape 2.7 and 2.8. Based on Lucene 3.0
Modified: csplugins/trunk/soc/maital/EnhancedSearch2/build.xml
===================================================================
--- csplugins/trunk/soc/maital/EnhancedSearch2/build.xml 2010-09-19
21:06:14 UTC (rev 21945)
+++ csplugins/trunk/soc/maital/EnhancedSearch2/build.xml 2010-09-20
14:39:50 UTC (rev 21946)
@@ -4,116 +4,195 @@
Author: Maital Ashkenazi
-->
-<project name="EnhancedSearch" default="run" basedir=".">
+<project name="EnhancedSearch" default="all" basedir="."
xmlns:artifact="antlib:org.apache.maven.artifact.ant">
- <!-- Plugin directories -->
- <property name="build.dir" value="${basedir}/build"/>
- <property name="src.dir" value="${basedir}/src"/>
- <property name="lib.dir" value="${basedir}/lib"/>
- <property name="junit.dir" value="${basedir}/junit"/>
- <property name="testData.dir" value="${basedir}/testData"/>
+ <!--
=================================================================== -->
+ <!-- Initialization target
-->
+ <!--
=================================================================== -->
+ <target name="init">
+ <tstamp />
+ <property name="name" value="EnhancedSearch" />
+ <property name="version" value="2.0" />
- <!-- The cytoscape directory -->
- <property name="cytoscape.dir" value="../cytoscape"/>
+ <echo message="Building ${name} version ${version} ..." />
- <!-- ============ Compilation Control Options =======================
-->
- <property name="compile.debug" value="true"/>
- <property name="compile.deprecation" value="true"/>
- <property name="compile.optimize" value="true"/>
+ <!-- Inheritable properties -->
+ <property name="debug" value="on" />
+ <property name="optimize" value="off" />
+ <property name="deprecation" value="on" />
+ <property name="fork" value="false" />
-
- <!-- ==================== Compilation Classpath ======================
-->
- <!--
- NB: Compilation classpath assumes that main cytoscape project is
checked out,
- and compiled.
- -->
- <path id="compile.classpath">
- <pathelement path="${build.dir}/classes"/>
- <fileset dir="${lib.dir}">
- <include name="*.jar"/>
- </fileset>
- <fileset dir="${cytoscape.dir}/lib">
- <include name="*.jar"/>
- </fileset>
- <fileset dir="${cytoscape.dir}/plugins/core">
- <include name="quick_find.jar"/>
- </fileset>
- <fileset dir="${cytoscape.dir}">
- <include name="cytoscape.jar"/>
- </fileset>
- </path>
+ <!-- Define the directories -->
+ <property name="root.dir" value="." />
+ <property name="resources.dir" value="${root.dir}/resources" />
+ <property name="src.dir" value="${root.dir}/src" />
+ <property name="tests.dir" value="${root.dir}/tests" />
+ <property name="build.dir" value="${root.dir}/build" />
+ <property name="lib.dir" value="${root.dir}/lib" />
+ <property name="log.dir" value="${build.dir}/logs" />
+ <property name="junit.report.dir"
value="${log.dir}/junit-reports" />
- <!-- ==================== Clean Target =============================== -->
- <target name="clean"
- description="Deletes all build files and starts fresh">
- <delete dir="${build.dir}"/>
- <delete file="${basedir}/EnhancedSearch.jar"/>
- </target>
+ <!-- Define the relevant files -->
+ <property name="project.jar" value="${name}.jar" />
+ <property name="test.jar" value="${name}-tests.jar" />
- <!-- ==================== Compile Target ============================= -->
- <target name="compile" depends="prepare"
- description="Compiles all Java source files">
- <mkdir dir="${build.dir}/classes"/>
- <javac srcdir="${src.dir}"
- source="1.5"
- destdir="${build.dir}/classes"
- debug="${compile.debug}"
- deprecation="${compile.deprecation}"
- optimize="${compile.optimize}">
- <classpath refid="compile.classpath"/>
- </javac>
- </target>
+ <artifact:remoteRepository id="cytoscape_releases"
url="http://cytoscape.wodaklab.org/nexus/content/repositories/releases/" />
+ <artifact:remoteRepository id="cytoscape_snapshots"
url="http://cytoscape.wodaklab.org/nexus/content/repositories/snapshots/" />
+ <artifact:dependencies pathId="dependency.classpath">
+ <dependency groupId="cytoscape"
artifactId="application" version="2.8.0-SNAPSHOT" />
+ </artifact:dependencies>
- <!-- ==================== Jar Target ================================= -->
- <target name="jar" depends="compile"
- description="Creates Plugin Jar: EnhancedSearch.jar">
- <unzip dest="${build.dir}/classes">
- <fileset dir="${lib.dir}">
- <include name="*.jar"/>
- </fileset>
- </unzip>
- <copy file="${basedir}/plugin.props"
todir="${build.dir}/classes/csplugins/enhanced/search" />
- <jar destfile="${basedir}/EnhancedSearch.jar"
- basedir="${build.dir}/classes">
- <manifest>
- <attribute name="Cytoscape-Plugin"
-
value="csplugins.enhanced.search.EnhancedSearchPlugin"/>
- </manifest>
+ <!-- Define the class path -->
+ <path id="project.class.path">
+ <fileset dir="/usr/share/ant/lib">
+ <include name="*.jar" />
+ </fileset>
+ <fileset dir="${lib.dir}">
+ <include name="*.jar" />
+ </fileset>
+ <path refid="dependency.classpath" />
+ </path>
+
+ <!-- Define the junit class path - It needs to find what we
just built -->
+ <path id="junit.class.path">
+ <fileset dir="/usr/share/ant/lib">
+ <include name="*.jar" />
+ </fileset>
+ <fileset dir="${root.dir}">
+ <include name="*.jar" />
+ </fileset>
+ <fileset dir="${lib.dir}">
+ <include name="*.jar" />
+ </fileset>
+ <path refid="dependency.classpath" />
+ </path>
+
+ <!-- Make sure tests is in the right place -->
+ <condition property="tests.ok">
+ <and>
+ <available file="${tests.dir}" />
+ </and>
+ </condition>
+
+ </target>
+
+ <!--
=================================================================== -->
+ <!-- Compiles the project
-->
+ <!--
=================================================================== -->
+ <target name="compile" depends="init">
+ <mkdir dir="${build.dir}" />
+ <mkdir dir="${log.dir}" />
+ <javac srcdir="${src.dir}" classpathref="project.class.path"
destdir="${build.dir}" debug="${debug}" deprecation="${deprecation}"
optimize="${optimize}" fork="${fork}">
+ <compilerarg line="-Xlint:unchecked"/>
+ <!--
+ <compilerarg line="-Xlint:all -Xlint:-path"/>
+ -->
+ </javac>
+ <echo message="Successfully ran compile task!" />
+ </target>
+
+
+ <!--
=================================================================== -->
+ <!-- Creates the project jar file
-->
+ <!--
=================================================================== -->
+ <target name="jar" depends="compile">
+
+ <!--copy file="${resources.dir}/plugin.props"
todir="${build.dir}/org/cytoscape/equations/internal/googlechart" /-->
+ <unjar dest="${build.dir}">
+ <fileset dir="${lib.dir}">
+ <include name="*.jar" />
+ </fileset>
+ </unjar>
+
+ <jar destfile="${project.jar}">
+ <fileset dir="${build.dir}" includes="**" />
+ <manifest>
+ <attribute name="Cytoscape-Plugin"
value="csplugins.enhanced.search.EnhancedSearchPlugin" />
+ </manifest>
</jar>
- <copy todir="${cytoscape.dir}/plugins/core">
- <fileset file="${basedir}/EnhancedSearch.jar"/>
- </copy>
- </target>
+ <echo message="Successfully ran jar task!" />
+ </target>
+ <!--
=================================================================== -->
+ <!-- Compiles the tests
-->
+ <!-- Note that this compilation occurs AFTER the distribution jar has
-->
+ <!-- been created, so that the tests aren't distributed.
-->
+ <!--
=================================================================== -->
+ <target name="compile-tests" depends="jar" if="tests.ok">
+ <javac srcdir="${tests.dir}" classpathref="junit.class.path"
destdir="${build.dir}" debug="${debug}" deprecation="${deprecation}"
optimize="${optimize}" fork="${fork}">
+ <compilerarg line="-Xlint:all -Xlint:-path" />
+ </javac>
+ <echo message="Successfully ran compile-tests task!" />
+ </target>
+
+ <!--
=================================================================== -->
+ <!-- Creates the project-tests.jar file
-->
+ <!--
=================================================================== -->
+ <target name="jar-tests" depends="compile-tests" if="tests.ok">
+ <jar jarfile="${test.jar}" basedir="${build.dir}">
+ </jar>
+ <echo message="Successfully ran jar-tests task!" />
+ </target>
+
<!-- ==================== Run Target ================================= -->
<target description="Runs Latest Version of Cytoscape with EnhancedSearch
Plugin"
name="run">
- <java classname="cytoscape.CyMain" classpathref="compile.classpath"
+ <java classname="cytoscape.CyMain" classpathref="project.class.path"
fork="true" maxmemory="1000M">
- <arg line="-p ${cytoscape.dir}/plugins/core"/>
+ <arg line="-p ${root.dir}"/>
</java>
</target>
- <!-- ==================== Build jar and run ==========================
-->
- <target name="all" depends="jar"/>
- <!-- ==================== Prepare Target =============================
-->
- <target name="prepare">
- <!-- Create build directories as needed -->
- <mkdir dir="${build.dir}"/>
- <mkdir dir="${build.dir}/classes"/>
- </target>
+ <!--
=================================================================== -->
+ <!-- Runs the unit tests.
-->
+ <!--
=================================================================== -->
+ <target name="test" depends="jar-tests" if="tests.ok">
+ <junit printsummary="yes" haltonfailure="no" maxmemory="256m">
+ <classpath refid="junit.class.path" />
+ <formatter type="plain" usefile="true" />
+ <formatter type="xml" usefile="true" />
+ <batchtest fork="yes" todir="${log.dir}"
failureProperty="junit.test.failure" errorProperty="junit.test.failure">
+ <fileset dir="${tests.dir}"
includes="**/*Test.java" excludes="**/AllTests.java" />
+ </batchtest>
+ </junit>
+ <mkdir dir="${junit.report.dir}" />
+ <junitreport todir="${junit.report.dir}">
+ <fileset dir="${log.dir}">
+ <include name="TEST-*.xml" />
+ </fileset>
+ <report format="frames" todir="${junit.report.dir}" />
+ </junitreport>
+ <fail message="TEST FAILURE!!! Details:
${junit.report.dir}/index.html" if="junit.test.failure" />
+ <echo message="Successfully ran test task!" />
+ </target>
+ <!-- ==================== JUnit Test Target ===========================
-->
+ <target name="old-test" description="Runs all JUnit tests"
depends="compile">
+ <junit printsummary="yes" fork="yes" haltonfailure="yes">
+ <formatter type="plain" usefile="false" />
+ <test
name="csplugins.enhanced.search.TestEnhancedSearch" />
+ <classpath refid="junit.class.path" />
+ </junit>
+ </target>
- <!-- ==================== JUnit Test Target =========================== -->
- <target name="test" description="Runs all JUnit tests" depends="compile">
- <junit printsummary="yes" fork="yes" haltonfailure="yes">
- <formatter type="plain" usefile="false"/>
- <test name="csplugins.enhanced.search.TestEnhancedSearch"/>
- <classpath refid="compile.classpath"/>
- </junit>
- </target>
-
+ <!--
=================================================================== -->
+ <!-- Do everything
-->
+ <!--
=================================================================== -->
+ <target name="all" depends="jar,old-test,run" />
+
+ <!--
=================================================================== -->
+ <!-- Clean up, get back to original state
-->
+ <!--
=================================================================== -->
+ <target name="clean" depends="init">
+ <delete dir="${build.dir}" />
+ <delete dir="${javadoc.dir}" />
+ <delete file="${project.jar}" />
+ <delete file="${test.jar}" />
+ <echo message="Successfully ran clean task!" />
+ </target>
+
</project>
+
Deleted: csplugins/trunk/soc/maital/EnhancedSearch2/lib/lucene-core-3.0.1.jar
===================================================================
(Binary files differ)
Added: csplugins/trunk/soc/maital/EnhancedSearch2/lib/lucene-core-3.0.2.jar
===================================================================
(Binary files differ)
Property changes on:
csplugins/trunk/soc/maital/EnhancedSearch2/lib/lucene-core-3.0.2.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: csplugins/trunk/soc/maital/EnhancedSearch2/plugin.props
===================================================================
--- csplugins/trunk/soc/maital/EnhancedSearch2/plugin.props 2010-09-19
21:06:14 UTC (rev 21945)
+++ csplugins/trunk/soc/maital/EnhancedSearch2/plugin.props 2010-09-20
14:39:50 UTC (rev 21946)
@@ -1,34 +0,0 @@
-#plugin.props
-
-# This props file should be filled out and included in the plugin jar file.
This props file will be used
-# to put information into the Plugin Manager about the plugin
-
-# -- The following properties are REQUIRED -- #
-
-# The plugin name that will be displayed to users
-pluginName=EnhancedSearch
-
-# Description used to give users information about the plugin such as what it
does.
-# Html tags are encouraged for formatting purposes.
-pluginDescription=Perform search on multiple attribute fields using logical
operators and wildcards. Locate nodes and edges of interest based on their
attributes and highlight them on the network. The simple query syntax is
detailed in the URL below.
-
-# Plugin version number, this must be two numbers separated by a decimlal.
Ex. 0.2, 14.03
-pluginVersion=1.2
-
-# Compatible Cytoscape version
-cytoscapeVersion=2.5,2.6,2.7,2.8
-
-# Category, use one of the categories listed on the website or create your own
-pluginCategory=Analysis
-
-# -- The following properties are OPTIONAL -- #
-
-# URL to a website that gives more information about your plugin, Ex.
http://my-lab-site.org
-projectURL=http://conklinwolf.ucsf.edu/genmappwiki/Google_Summer_of_Code_2007/Maital
-
-# List of authors. Note each author and institution pair are separated by a :
(colon)
-# each additional author institution pair must be separated from other pairs
bye a ; (semicolon)
-pluginAuthorsIntsitutions=Maital Ashkenazi:Evogene
-
-# Date this plugin/plugin version was released
-releaseDate=July 20, 2010
\ No newline at end of file
Copied: csplugins/trunk/soc/maital/EnhancedSearch2/resources/plugin.props (from
rev 21827, csplugins/trunk/soc/maital/EnhancedSearch2/plugin.props)
===================================================================
--- csplugins/trunk/soc/maital/EnhancedSearch2/resources/plugin.props
(rev 0)
+++ csplugins/trunk/soc/maital/EnhancedSearch2/resources/plugin.props
2010-09-20 14:39:50 UTC (rev 21946)
@@ -0,0 +1,34 @@
+#plugin.props
+
+# This props file should be filled out and included in the plugin jar file.
This props file will be used
+# to put information into the Plugin Manager about the plugin
+
+# -- The following properties are REQUIRED -- #
+
+# The plugin name that will be displayed to users
+pluginName=EnhancedSearch
+
+# Description used to give users information about the plugin such as what it
does.
+# Html tags are encouraged for formatting purposes.
+pluginDescription=Perform search on multiple attribute fields using logical
operators and wildcards. Locate nodes and edges of interest based on their
attributes and highlight them on the network. The simple query syntax is
detailed in the URL below.
+
+# Plugin version number, this must be two numbers separated by a decimlal.
Ex. 0.2, 14.03
+pluginVersion=1.2
+
+# Compatible Cytoscape version
+cytoscapeVersion=2.5,2.6,2.7,2.8
+
+# Category, use one of the categories listed on the website or create your own
+pluginCategory=Analysis
+
+# -- The following properties are OPTIONAL -- #
+
+# URL to a website that gives more information about your plugin, Ex.
http://my-lab-site.org
+projectURL=http://conklinwolf.ucsf.edu/genmappwiki/Google_Summer_of_Code_2007/Maital
+
+# List of authors. Note each author and institution pair are separated by a :
(colon)
+# each additional author institution pair must be separated from other pairs
bye a ; (semicolon)
+pluginAuthorsIntsitutions=Maital Ashkenazi:Evogene
+
+# Date this plugin/plugin version was released
+releaseDate=July 20, 2010
\ No newline at end of file
Modified:
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/EnhancedSearchImpl.java
===================================================================
---
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/EnhancedSearchImpl.java
2010-09-19 21:06:14 UTC (rev 21945)
+++
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/EnhancedSearchImpl.java
2010-09-20 14:39:50 UTC (rev 21946)
@@ -51,10 +51,10 @@
public class EnhancedSearchImpl implements EnhancedSearch {
// Keeps the index for each network
- private HashMap networkIndexMap = new HashMap();
+ private HashMap<CyNetwork, RAMDirectory> networkIndexMap = new
HashMap<CyNetwork, RAMDirectory>();
// Keeps indexing status of each network
- private HashMap networkIndexStatusMap = new HashMap();
+ private HashMap<CyNetwork, String> networkIndexStatusMap = new
HashMap<CyNetwork, String>();
private CyNetwork network;
Modified:
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/EnhancedSearchPanel.java
===================================================================
---
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/EnhancedSearchPanel.java
2010-09-19 21:06:14 UTC (rev 21945)
+++
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/EnhancedSearchPanel.java
2010-09-20 14:39:50 UTC (rev 21946)
@@ -48,6 +48,11 @@
import javax.swing.JLabel;
import javax.swing.JPopupMenu;
import javax.swing.JPanel;
+import javax.swing.JFrame;
+import javax.swing.JDialog;
+import javax.swing.JOptionPane;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
import javax.swing.JMenuItem;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
@@ -67,25 +72,22 @@
public class EnhancedSearchPanel extends JPanel {
private JTextField searchField;
-
private JLabel label;
private static final String ESP_LABEL = "Enhanced Search: ";
-
private static final String SEARCH_MENU_ITEM = "Search";
-
private static final String REINDEX_MENU_ITEM = "Re-index and search";
+ private static final String QUERY_SYNTAX_MENU_ITEM = "Quick reference
to query syntax";
private static final String SEARCH_TOOLTIP = "Perform search";
-
private static final String REINDEX_TOOLTIP = "<html>"
- + "Refresh the network index and perform search." +
"<br>"
- + "This option is useful after changes to attributes."
+ "</html>";
+ + "Refresh the network index and perform search." + "<br>"
+ + "This option is useful after changes to attributes." +
"</html>";
+ private static final String QUERY_SYNTAX_TOOLTIP = "Quick reference to
query syntax";
private static final String ESP_ENABLED_TOOLTIP = "<html>"
+ "Enter search query and press return. " + "<br>"
+ "Right click for more options." + "</html>";
-
private static final String ESP_DISABLED_TOOLTIP = "Please select or
load a network to activate search functionality";
/**
@@ -184,6 +186,16 @@
menuItem.setToolTipText(REINDEX_TOOLTIP);
popup.add(menuItem);
+ // Add 'Reindex and search' menu item
+ menuItem = new JMenuItem(QUERY_SYNTAX_MENU_ITEM);
+ menuItem.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ displayQuerySyntax();
+ }
+ });
+ menuItem.setToolTipText(QUERY_SYNTAX_TOOLTIP);
+ popup.add(menuItem);
+
// Add listener to the text area so the popup menu can come up.
MouseListener popupListener = new PopupListener(popup);
searchField.addMouseListener(popupListener);
@@ -248,6 +260,31 @@
}
}
+ private void displayQuerySyntax() {
+
+ String[] columnNames = {"Search criteria", "Example"};
+ Object[][] data = {
+ {"Single term", "\"water channel\""},
+ {"Restrict to a specific attribute",
"annotation:aquaporin"},
+ {"At least one of the terms must exist", "transcription or
factor"},
+ {"First term must exist but second must not",
"transcription not factor"},
+ {"Single character wildcard", "prot?in"},
+ {"Multiple character wildcard", "HSP*"},
+ {"Range search", "degree:[1 to 3]"},
+ {"Control Boolean logic using parenthesis", "(intrinsic or
integral) and membrane"},
+ };
+
+ JTable table = new JTable(data, columnNames);
+
+ JDialog dialog = new JDialog();
+ dialog.setContentPane(new JScrollPane(table));
+ dialog.setSize(500,200);
+ dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
+ dialog.setLocation(600,200);
+ dialog.setVisible(true);
+
+ }
+
/**
* Displays the popup menu on mouse right-click if search field is
enabled
*/
Modified:
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/TestEnhancedSearch.java
===================================================================
---
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/TestEnhancedSearch.java
2010-09-19 21:06:14 UTC (rev 21945)
+++
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/TestEnhancedSearch.java
2010-09-20 14:39:50 UTC (rev 21946)
@@ -36,170 +36,256 @@
package csplugins.enhanced.search;
-import java.io.File;
-import junit.framework.TestCase;
+import cytoscape.CyEdge;
import cytoscape.CyNetwork;
+import cytoscape.CyNode;
import cytoscape.Cytoscape;
+import junit.framework.TestCase;
+import cytoscape.data.CyAttributes;
+import cytoscape.data.Semantics;
import org.apache.lucene.store.RAMDirectory;
import csplugins.enhanced.search.EnhancedSearchQuery;
public class TestEnhancedSearch extends TestCase {
+ protected static final String LOCATION = "location";
+ protected static final String NUCLEUS = "nucleus";
+ protected static final String CYTOPLASM = "cytoplasm";
+ protected static final String CELL_MEMBRANE = "cell membrane";
+ protected static final String RANK = "rank";
+ protected static final String SCORE = "score";
+ protected static final String PMID = "pmid";
+
+ protected CyNetwork cyNetwork;
String query = null;
int hitCount;
- CyNetwork cyNetwork;
+ protected void initNetwork() {
+ cyNetwork = Cytoscape.createNetwork("network1");
+ CyNode node0 = Cytoscape.getCyNode("rain", true);
+ CyNode node1 = Cytoscape.getCyNode("rainbow", true);
+ CyNode node2 = Cytoscape.getCyNode("rabbit", true);
+ CyNode node3 = Cytoscape.getCyNode("yellow", true);
- // Load sample network and attributes into memory
- public TestEnhancedSearch() {
+ cyNetwork.addNode(node0);
+ cyNetwork.addNode(node1);
+ cyNetwork.addNode(node2);
+ cyNetwork.addNode(node3);
+
+ CyEdge edge0 = Cytoscape.getCyEdge(node0, node1,
Semantics.INTERACTION, "pp", true);
+ CyEdge edge1 = Cytoscape.getCyEdge(node0, node2,
Semantics.INTERACTION, "pp", true);
+ CyEdge edge2 = Cytoscape.getCyEdge(node0, node3,
Semantics.INTERACTION, "pp", true);
+ cyNetwork.addEdge(edge0);
+ cyNetwork.addEdge(edge1);
+ cyNetwork.addEdge(edge2);
- cyNetwork =
Cytoscape.createNetworkFromFile("testData/network.sif");
+ // Create Node String Attributes
+ CyAttributes nodeAttributes = Cytoscape.getNodeAttributes();
+ nodeAttributes.setAttribute(node0.getIdentifier(), LOCATION,
CYTOPLASM);
+ nodeAttributes.setAttribute(node1.getIdentifier(), LOCATION,
CYTOPLASM);
+ nodeAttributes.setAttribute(node2.getIdentifier(), LOCATION,
CELL_MEMBRANE);
+ nodeAttributes.setAttribute(node3.getIdentifier(), LOCATION,
NUCLEUS);
- String[] noa = new String[7];
- noa[0] = new
File("testData/GOMolecularFunction.NA").getAbsolutePath();
- noa[1] = new
File("testData/GOCellularComponent.NA").getAbsolutePath();
- noa[2] = new
File("testData/GOBiologicalProcess.NA").getAbsolutePath();
- noa[3] = new File("testData/GeneTitle.NA").getAbsolutePath();
- noa[4] = new
File("testData/DesiccationResponse.NA").getAbsolutePath();
- noa[5] = new File("testData/Chromosome.NA").getAbsolutePath();
- noa[6] = new File("testData/AGI.NA").getAbsolutePath();
+ // Create Sample Integer Attributes
+ nodeAttributes.setAttribute(node0.getIdentifier(), RANK, 4);
+ nodeAttributes.setAttribute(node1.getIdentifier(), RANK, 3);
+ nodeAttributes.setAttribute(node2.getIdentifier(), RANK, 1);
+ nodeAttributes.setAttribute(node3.getIdentifier(), RANK, 2);
- String[] eda = new String[2];
- eda[0] = new File("testData/weight.EA").getAbsolutePath();
- eda[1] = new File("testData/interaction.EA").getAbsolutePath();
+ // Create Sample Double Attributes
+ nodeAttributes.setAttribute(node0.getIdentifier(), SCORE, 45.2);
+ nodeAttributes.setAttribute(node1.getIdentifier(), SCORE,
3.211);
+ nodeAttributes.setAttribute(node2.getIdentifier(), SCORE, 22.2);
+ nodeAttributes.setAttribute(node3.getIdentifier(), SCORE, -2.1);
- Cytoscape.loadAttributes(noa, eda);
+ // Create Edge String Attributes
+ CyAttributes edgeAttributes = Cytoscape.getEdgeAttributes();
+ edgeAttributes.setAttribute(edge0.getIdentifier(), PMID,
"12345");
+ edgeAttributes.setAttribute(edge1.getIdentifier(), PMID,
"12345");
+ edgeAttributes.setAttribute(edge2.getIdentifier(), PMID,
"12355");
+
+ Cytoscape.setCurrentNetwork(cyNetwork.getIdentifier());
}
-
+
// Simple queries
public void testSimpleQueries() throws Exception {
+ initNetwork();
+
EnhancedSearchIndex indexHandler = new
EnhancedSearchIndex(cyNetwork);
RAMDirectory idx = indexHandler.getIndex();
EnhancedSearchQuery queryHandler = new EnhancedSearchQuery(idx);
- query = "Gene_Title:putative";
- queryHandler.executeQuery(query); // 56
+ // Limit to a particular attribute
+ query = "location:cytoplasm";
+ queryHandler.executeQuery(query);
hitCount = queryHandler.getHitCount();
- assertEquals(query, 56, hitCount);
+ assertEquals(query, 2, hitCount);
- query = "gENE_TitlE:putATIVE";
- queryHandler.executeQuery(query); // 56 - tests case
insensitivity
+ // Case insensitivity
+ query = "LOCAtion:CYTOplasm";
+ queryHandler.executeQuery(query);
hitCount = queryHandler.getHitCount();
- assertEquals(query, 56, hitCount);
+ assertEquals(query, 2, hitCount);
- query = "GO_Cellular_Component:\"plasma membrane\"";
- queryHandler.executeQuery(query); // 7
+ // Phrase search
+ query = "location:\"cell membrane\"";
+ queryHandler.executeQuery(query);
hitCount = queryHandler.getHitCount();
- assertEquals(query, 7, hitCount);
+ assertEquals(query, 1, hitCount);
- query = "canonicalName:251155_at";
- queryHandler.executeQuery(query); // 12 - notice it returnes
both nodes and edges.
+ // This query returns both nodes and edges (cannonicalName is a
mutual attribute)
+ query = "canonicalName:rain";
+ queryHandler.executeQuery(query);
hitCount = queryHandler.getHitCount();
- assertEquals(query, 12, hitCount);
+ assertEquals(query, 4, hitCount);
- query = "265480_at";
- queryHandler.executeQuery(query); // 26 - notice: search is
executed on nodes and edges.
+ // Search is executed on nodes and edges
+ query = "rain";
+ queryHandler.executeQuery(query);
hitCount = queryHandler.getHitCount();
- assertEquals(query, 26, hitCount);
+ assertEquals(query, 4, hitCount);
- query = "response";
- queryHandler.executeQuery(query); // Search in all attributes
+ // Search in all attributes
+ query = "cytoplasm";
+ queryHandler.executeQuery(query);
hitCount = queryHandler.getHitCount();
- assertEquals(query, 70, hitCount);
+ assertEquals(query, 2, hitCount);
}
// Queries on multiple attribute fields
public void testComplexQueries() throws Exception {
+ initNetwork();
+
EnhancedSearchIndex indexHandler = new
EnhancedSearchIndex(cyNetwork);
RAMDirectory idx = indexHandler.getIndex();
EnhancedSearchQuery queryHandler = new EnhancedSearchQuery(idx);
- query = "GO_Biological_Process:\"water deprivation\" AND
Gene_Title:aquaporin";
- queryHandler.executeQuery(query); // 3
+ // Default Boolean operator is OR
+ query = "location:cytoplasm rank:2";
+ queryHandler.executeQuery(query);
hitCount = queryHandler.getHitCount();
assertEquals(query, 3, hitCount);
- query = "Desiccation_Response:true NOT Chromosome:5";
- queryHandler.executeQuery(query); // 20
+ // Boolean logic: AND
+ query = "location:cytoplasm AND rank:4";
+ queryHandler.executeQuery(query);
hitCount = queryHandler.getHitCount();
- assertEquals(query, 20, hitCount);
+ assertEquals(query, 1, hitCount);
- query = "GO_Biological_Process:stress AND
(GO_Molecular_Function:peroxidase OR GO_Molecular_Function:catalase)";
- queryHandler.executeQuery(query); // 4
+ // Boolean logic: NOT
+ query = "location:cytoplasm NOT rank:4";
+ queryHandler.executeQuery(query);
hitCount = queryHandler.getHitCount();
- assertEquals(query, 4, hitCount);
+ assertEquals(query, 1, hitCount);
+
+ // Boolean logic: AND / OR
+ query = "location:cytoplasm AND rank:4 OR rank:2";
+ queryHandler.executeQuery(query);
+ hitCount = queryHandler.getHitCount();
+ assertEquals(query, 1, hitCount);
+
+ // Use parenthesis to control Boolean logic
+ query = "location:cytoplasm AND (rank:4 OR rank:2)";
+ queryHandler.executeQuery(query);
+ hitCount = queryHandler.getHitCount();
+ assertEquals(query, 1, hitCount);
}
// Multiple values for same attribute
public void testFieldGrouping() throws Exception {
+ initNetwork();
+
EnhancedSearchIndex indexHandler = new
EnhancedSearchIndex(cyNetwork);
RAMDirectory idx = indexHandler.getIndex();
EnhancedSearchQuery queryHandler = new EnhancedSearchQuery(idx);
- query = "Gene_Title:(+60S +\"ribosomal protein\")";
- queryHandler.executeQuery(query); // 9
+ // Both terms must appear in location attribute
+ query = "location:(+cell +membrane)";
+ queryHandler.executeQuery(query);
hitCount = queryHandler.getHitCount();
- assertEquals(query, 9, hitCount);
+ assertEquals(query, 1, hitCount);
}
// Wildcards queries
public void testWildcardsQueries() throws Exception {
+ initNetwork();
+
EnhancedSearchIndex indexHandler = new
EnhancedSearchIndex(cyNetwork);
RAMDirectory idx = indexHandler.getIndex();
EnhancedSearchQuery queryHandler = new EnhancedSearchQuery(idx);
- query = "Gene_Title:deHYdr*n";
- queryHandler.executeQuery(query); // 4
+ query = "PMID:12?45";
+ queryHandler.executeQuery(query);
hitCount = queryHandler.getHitCount();
- assertEquals(query, 4, hitCount);
+ assertEquals(query, 2, hitCount);
+
+ query = "PMID:123*";
+ queryHandler.executeQuery(query);
+ hitCount = queryHandler.getHitCount();
+ assertEquals(query, 3, hitCount);
+
+ query = "PMID:1*5";
+ queryHandler.executeQuery(query);
+ hitCount = queryHandler.getHitCount();
+ assertEquals(query, 3, hitCount);
}
// Range queries
public void testRangeQueries() throws Exception {
+ initNetwork();
+
EnhancedSearchIndex indexHandler = new
EnhancedSearchIndex(cyNetwork);
RAMDirectory idx = indexHandler.getIndex();
EnhancedSearchQuery queryHandler = new EnhancedSearchQuery(idx);
- query = "Chromosome:5";
- queryHandler.executeQuery(query); // 39
+ // Limit search to a Numeric attribute
+ query = "rank:4";
+ queryHandler.executeQuery(query);
hitCount = queryHandler.getHitCount();
- assertEquals(query, 39, hitCount);
+ assertEquals(query, 1, hitCount);
- query = "Chromosome:[4 TO 5]";
- queryHandler.executeQuery(query); // 79
+ // numeric range
+ query = "rank:[1 TO 4]";
+ queryHandler.executeQuery(query);
hitCount = queryHandler.getHitCount();
- assertEquals(query, 79, hitCount);
+ assertEquals(query, 4, hitCount);
- query = "weight:[0.95 TO 1]";
- queryHandler.executeQuery(query); // 369
+ // Double range
+ query = "score:[1 TO 100]";
+ queryHandler.executeQuery(query);
hitCount = queryHandler.getHitCount();
- assertEquals(query, 369, hitCount);
+ assertEquals(query, 3, hitCount);
- query = "weight:[-1 TO -0.95]";
- queryHandler.executeQuery(query); // 30
+ // Negative double range
+ query = "score:[-100 TO -1]";
+ queryHandler.executeQuery(query);
hitCount = queryHandler.getHitCount();
- assertEquals(query, 30, hitCount);
+ assertEquals(query, 1, hitCount);
- query = "weight:[0.95 TO 1] OR weight:[-1 TO -0.95]";
- queryHandler.executeQuery(query); // 399
+ // Complex query including double range query and Boolean logic
+ query = "score:[10 TO 50] OR weight:[-100 TO -1]";
+ queryHandler.executeQuery(query);
hitCount = queryHandler.getHitCount();
- assertEquals(query, 399, hitCount);
+ assertEquals(query, 2, hitCount);
}
// Queries with no results
public void testNoResultsQueries() throws Exception {
+ initNetwork();
+
EnhancedSearchIndex indexHandler = new
EnhancedSearchIndex(cyNetwork);
RAMDirectory idx = indexHandler.getIndex();
EnhancedSearchQuery queryHandler = new EnhancedSearchQuery(idx);
- query = "interaction:neg AND weight:[0.9 TO 0.95]";
+ // No results
+ query = "location:cytoplasm AND rank:2";
queryHandler.executeQuery(query);
hitCount = queryHandler.getHitCount();
assertEquals(query, 0, hitCount);
Deleted:
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/util/NumberUtils.java
===================================================================
---
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/util/NumberUtils.java
2010-09-19 21:06:14 UTC (rev 21945)
+++
csplugins/trunk/soc/maital/EnhancedSearch2/src/csplugins/enhanced/search/util/NumberUtils.java
2010-09-20 14:39:50 UTC (rev 21946)
@@ -1,159 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package csplugins.enhanced.search.util;
-
-/**
- * @version $Id: NumberUtils.java 555343 2007-07-11 17:46:25Z hossman $
- */
-public class NumberUtils {
-
- public static String int2sortableStr(int val) {
- char[] arr = new char[3];
- int2sortableStr(val, arr, 0);
- return new String(arr, 0, 3);
- }
-
- public static String int2sortableStr(String val) {
- return int2sortableStr(Integer.parseInt(val));
- }
-
- public static String SortableStr2int(String val) {
- int ival = SortableStr2int(val, 0, 3);
- return Integer.toString(ival);
- }
-
- public static String long2sortableStr(long val) {
- char[] arr = new char[5];
- long2sortableStr(val, arr, 0);
- return new String(arr, 0, 5);
- }
-
- public static String long2sortableStr(String val) {
- return long2sortableStr(Long.parseLong(val));
- }
-
- public static String SortableStr2long(String val) {
- long ival = SortableStr2long(val, 0, 5);
- return Long.toString(ival);
- }
-
- //
- // IEEE floating point format is defined so that it sorts correctly
- // when interpreted as a signed integer (or signed long in the case
- // of a double) for positive values. For negative values, all the bits
- // except
- // the sign bit must be inverted.
- // This correctly handles all possible float values including -Infinity
and
- // +Infinity.
- // Note that in float-space, NaN<x is false, NaN>x is false, NaN==x is
- // false, NaN!=x is true
- // for all x (including NaN itself). Internal to Solr, NaN==NaN is true
and
- // NaN
- // sorts higher than Infinity, so a range query of [-Infinity TO
+Infinity]
- // will
- // exclude NaN values, but a query of "NaN" will find all NaN values.
- // Also, -0==0 in float-space but -0<0 after this transformation.
- //
- public static String float2sortableStr(float val) {
- int f = Float.floatToRawIntBits(val);
- if (f < 0)
- f ^= 0x7fffffff;
- return int2sortableStr(f);
- }
-
- public static String float2sortableStr(String val) {
- return float2sortableStr(Float.parseFloat(val));
- }
-
- public static float SortableStr2float(String val) {
- int f = SortableStr2int(val, 0, 3);
- if (f < 0)
- f ^= 0x7fffffff;
- return Float.intBitsToFloat(f);
- }
-
- public static String SortableStr2floatStr(String val) {
- return Float.toString(SortableStr2float(val));
- }
-
- public static String double2sortableStr(double val) {
- long f = Double.doubleToRawLongBits(val);
- if (f < 0)
- f ^= 0x7fffffffffffffffL;
- return long2sortableStr(f);
- }
-
- public static String double2sortableStr(String val) {
- return double2sortableStr(Double.parseDouble(val));
- }
-
- public static double SortableStr2double(String val) {
- long f = SortableStr2long(val, 0, 6);
- if (f < 0)
- f ^= 0x7fffffffffffffffL;
- return Double.longBitsToDouble(f);
- }
-
- public static String SortableStr2doubleStr(String val) {
- return Double.toString(SortableStr2double(val));
- }
-
- // uses binary representation of an int to build a string of
- // chars that will sort correctly. Only char ranges
- // less than 0xd800 will be used to avoid UCS-16 surrogates.
- public static int int2sortableStr(int val, char[] out, int offset) {
- val += Integer.MIN_VALUE;
- out[offset++] = (char) (val >>> 24);
- out[offset++] = (char) ((val >>> 12) & 0x0fff);
- out[offset++] = (char) (val & 0x0fff);
- return 3;
- }
-
- public static int SortableStr2int(String sval, int offset, int len) {
- int val = sval.charAt(offset++) << 24;
- val |= sval.charAt(offset++) << 12;
- val |= sval.charAt(offset++);
- val -= Integer.MIN_VALUE;
- return val;
- }
-
- // uses binary representation of an int to build a string of
- // chars that will sort correctly. Only char ranges
- // less than 0xd800 will be used to avoid UCS-16 surrogates.
- // we can use the lowest 15 bits of a char, (or a mask of 0x7fff)
- public static int long2sortableStr(long val, char[] out, int offset) {
- val += Long.MIN_VALUE;
- out[offset++] = (char) (val >>> 60);
- out[offset++] = (char) (val >>> 45 & 0x7fff);
- out[offset++] = (char) (val >>> 30 & 0x7fff);
- out[offset++] = (char) (val >>> 15 & 0x7fff);
- out[offset] = (char) (val & 0x7fff);
- return 5;
- }
-
- public static long SortableStr2long(String sval, int offset, int len) {
- long val = (long) (sval.charAt(offset++)) << 60;
- val |= ((long) sval.charAt(offset++)) << 45;
- val |= ((long) sval.charAt(offset++)) << 30;
- val |= sval.charAt(offset++) << 15;
- val |= sval.charAt(offset);
- val -= Long.MIN_VALUE;
- return val;
- }
-
-}
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.