Skip to content
Snippets Groups Projects
Commit e930678a authored by tcarver's avatar tcarver
Browse files

add the ability to find features contained by ranges defined by selected

features as well as selected base ranges
parent 1d18975c
No related branches found
No related tags found
No related merge requests found
......@@ -1000,37 +1000,65 @@ public class SelectMenu extends SelectionMenu
}
}
}
/**
* If there are some selected bases select the features that are
* If there are some selected bases or features select the features that are
* fully contained within that selection.
**/
private void selectContainedFeatures () {
final MarkerRange selected_marker_range =
getSelection ().getMarkerRange ();
if (selected_marker_range == null) {
new MessageDialog (getParentFrame (), "sequence range is not selected");
return;
} else {
try {
final FeatureVector featuresInRange =
getEntryGroup ().getFeaturesInRange (selected_marker_range.getRawRange ());
final FeatureVector featuresContainedByRange = new FeatureVector();
for(int i=0; i<featuresInRange.size(); i++)
{
Feature f = featuresInRange.elementAt(i);
Range maxR = f.getMaxRawRange();
if(selected_marker_range.getRawStart().getRawPosition() <= maxR.getStart() &&
selected_marker_range.getRawEnd().getRawPosition() >= maxR.getEnd())
featuresContainedByRange.add(f);
final FeatureVector featuresContainedByRange;
try
{
if (selected_marker_range == null) {
final FeatureVector selected_features = getSelection ().getAllFeatures ();
if (selected_features.size () == 0) {
new MessageDialog (getParentFrame (), "nothing selected");
return;
}
getSelection ().set (featuresContainedByRange);
} catch (OutOfRangeException e) {
throw new Error ("internal error - unexpected exception: " + e);
featuresContainedByRange = new FeatureVector();
for(int i=0; i<selected_features.size(); i++) {
Range r = selected_features.elementAt(i).getMaxRawRange();
final FeatureVector featuresContained = getFeaturesContainedByRange(r);
for(int j=0; j<featuresContained.size(); j++) {
final Feature f = featuresContained.elementAt(j);
if(!featuresContainedByRange.contains(f) && !selected_features.contains(f))
featuresContainedByRange.add(f);
}
}
} else {
featuresContainedByRange = getFeaturesContainedByRange(
selected_marker_range.getRawRange());
}
} catch (OutOfRangeException e) {
throw new Error ("internal error - unexpected exception: " + e);
}
getSelection ().set (featuresContainedByRange);
}
/**
* Return the features that are contained by a given range
* @param r
* @return
* @throws OutOfRangeException
*/
private FeatureVector getFeaturesContainedByRange(Range r) throws OutOfRangeException
{
final FeatureVector featuresInRange =
getEntryGroup ().getFeaturesInRange (r);
final FeatureVector featuresContainedByRange = new FeatureVector();
for(int i=0; i<featuresInRange.size(); i++)
{
Feature f = featuresInRange.elementAt(i);
Range maxR = f.getMaxRawRange();
if(r.getStart() <= maxR.getStart() &&
r.getEnd() >= maxR.getEnd())
featuresContainedByRange.add(f);
}
return featuresContainedByRange;
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment