Skip to content
Snippets Groups Projects
Commit 46a777e6 authored by tjc's avatar tjc
Browse files

add option to create features from graph trough

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@10991 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent 64af34d6
Branches
Tags
No related merge requests found
......@@ -20,7 +20,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/BasePlot.java,v 1.15 2009-04-07 09:43:48 tjc Exp $
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/BasePlot.java,v 1.16 2009-06-05 10:29:31 tjc Exp $
**/
package uk.ac.sanger.artemis.components;
......@@ -54,7 +54,7 @@ import org.apache.log4j.Level;
* scale is tied to a FeatureDisplay component.
*
* @author Kim Rutherford
* @version $Id: BasePlot.java,v 1.15 2009-04-07 09:43:48 tjc Exp $
* @version $Id: BasePlot.java,v 1.16 2009-06-05 10:29:31 tjc Exp $
**/
public class BasePlot extends Plot
......@@ -341,15 +341,8 @@ public class BasePlot extends Plot
/**
* Recalculate the values in value_array_array, step_size, min_value and
* max_value.
* @throws OutOfRangeException
* @throws EntryInformationException
* @throws ReadOnlyException
* @throws OutOfRangeException
* @throws EntryInformationException
* @throws ReadOnlyException
**/
protected void calculateFeatures()
throws ReadOnlyException, EntryInformationException, OutOfRangeException
protected void calculateFeatures(boolean fromPeak)
{
GridBagLayout gridbag = new GridBagLayout();
JPanel pane = new JPanel(gridbag);
......@@ -446,8 +439,10 @@ public class BasePlot extends Plot
int averageCount = 0;
final String noteField = "Auto-generated from "+getAlgorithm().getAlgorithmName()+
" plot;"+" window size="+getWindowSize()+
"; score cut-off="+cutoffField.getText();
"; score cut-off="+cutoffField.getText()+
(fromPeak ? "; from the peaks" : "; from the trough");
int lastPos = 0;
for(int i = 0 ; i < number_of_values ; ++i)
{
getBaseAlgorithm().getValues((i * step_size) + 1,
......@@ -457,6 +452,8 @@ public class BasePlot extends Plot
final float current_value = temp_values[0];
int pos = getWindowSize()/2 + (i * step_size) + 1;
if(i == 0)
lastPos = pos;
if(current_value > cutoff)
{
......@@ -464,13 +461,40 @@ public class BasePlot extends Plot
averageCount++;
}
if(current_value > cutoff && featureStart == -1)
try
{
if (fromPeak && current_value > cutoff && featureStart == -1)
featureStart = pos;
else if (!fromPeak && current_value < cutoff && featureStart == -1)
featureStart = pos;
else if (fromPeak && current_value < cutoff && featureStart > -1)
{
if (lastPos - featureStart < minFeatureSize)
{
average = 0.f;
averageCount = 0;
featureStart = -1;
continue;
}
else if(current_value <= cutoff && featureStart > -1)
// create feature
MarkerRange range = new MarkerRange(
getBaseAlgorithm().getStrand(), featureStart,lastPos);
final Location new_location = range.createLocation();
average = average / averageCount;
QualifierVector qualifiers = new QualifierVector();
qualifiers.add(new Qualifier("score", Float.toString(average)));
qualifiers.add(new Qualifier("note", noteField));
new_entry.createFeature(key, new_location, qualifiers);
featureStart = -1;
average = 0.f;
averageCount = 0;
}
else if (!fromPeak && current_value > cutoff && featureStart > -1)
{
if(pos-featureStart < minFeatureSize)
if (lastPos - featureStart < minFeatureSize)
{
average = 0.f;
averageCount = 0;
......@@ -479,8 +503,8 @@ public class BasePlot extends Plot
}
// create feature
MarkerRange range = new MarkerRange(getBaseAlgorithm().getStrand(),
featureStart, pos);
MarkerRange range = new MarkerRange(
getBaseAlgorithm().getStrand(), featureStart, lastPos);
final Location new_location = range.createLocation();
average = average / averageCount;
......@@ -494,6 +518,24 @@ public class BasePlot extends Plot
averageCount = 0;
}
}
catch (OutOfRangeException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (ReadOnlyException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (EntryInformationException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
lastPos = pos;
}
return;
}
......
......@@ -20,7 +20,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/FeaturePlot.java,v 1.7 2009-02-25 11:10:41 tjc Exp $
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/FeaturePlot.java,v 1.8 2009-06-05 10:29:31 tjc Exp $
*/
package uk.ac.sanger.artemis.components;
......@@ -38,7 +38,7 @@ import java.awt.*;
* particular feature.
*
* @author Kim Rutherford
* @version $Id: FeaturePlot.java,v 1.7 2009-02-25 11:10:41 tjc Exp $
* @version $Id: FeaturePlot.java,v 1.8 2009-06-05 10:29:31 tjc Exp $
**/
public class FeaturePlot extends Plot
......@@ -391,7 +391,7 @@ public class FeaturePlot extends Plot
**/
private int width_in_bases;
protected void calculateFeatures() throws ReadOnlyException, EntryInformationException, OutOfRangeException
protected void calculateFeatures(boolean fromPeak)
{
// TODO Auto-generated method stub
}
......
......@@ -20,17 +20,14 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/Plot.java,v 1.18 2009-04-07 09:43:26 tjc Exp $
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/components/Plot.java,v 1.19 2009-06-05 10:29:31 tjc Exp $
**/
package uk.ac.sanger.artemis.components;
import uk.ac.sanger.artemis.Options;
import uk.ac.sanger.artemis.circular.TextFieldFloat;
import uk.ac.sanger.artemis.io.EntryInformationException;
import uk.ac.sanger.artemis.plot.*;
import uk.ac.sanger.artemis.util.OutOfRangeException;
import uk.ac.sanger.artemis.util.ReadOnlyException;
import java.awt.*;
import java.awt.event.*;
......@@ -54,7 +51,7 @@ import javax.swing.JPopupMenu;
* This class implements a simple plot component.
*
* @author Kim Rutherford
* @version $Id: Plot.java,v 1.18 2009-04-07 09:43:26 tjc Exp $
* @version $Id: Plot.java,v 1.19 2009-06-05 10:29:31 tjc Exp $
**/
public abstract class Plot extends JPanel
......@@ -115,8 +112,7 @@ public abstract class Plot extends JPanel
**/
protected abstract int getPointPosition(final int canvas_x_position);
protected abstract void calculateFeatures()
throws ReadOnlyException, EntryInformationException, OutOfRangeException;
protected abstract void calculateFeatures(boolean fromPeak);
protected abstract void showAveragesForRange();
......@@ -452,38 +448,35 @@ public abstract class Plot extends JPanel
if(numPlots == 1 && getAlgorithm() instanceof BaseAlgorithm)
{
popup.addSeparator();
final JMenuItem createFeatures =
new JMenuItem("Create features from graph peaks...");
popup.add(createFeatures);
createFeatures.addActionListener(new ActionListener()
final JMenu createFeaturesFrom = new JMenu("Create features from graph");
popup.add(createFeaturesFrom);
final JMenuItem createFeaturesFromPeak =
new JMenuItem("peaks...");
createFeaturesFrom.add(createFeaturesFromPeak);
createFeaturesFromPeak.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
try
{
calculateFeatures();
calculateFeatures(true);
}
catch(ReadOnlyException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
catch(EntryInformationException e1)
});
final JMenuItem createFeaturesFromDip =
new JMenuItem("trough...");
createFeaturesFrom.add(createFeaturesFromDip);
createFeaturesFromDip.addActionListener(new ActionListener()
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
catch(OutOfRangeException e1)
public void actionPerformed(ActionEvent e)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
calculateFeatures(false);
}
});
}
///
if(Plot.this instanceof BasePlot)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment