Newer
Older
/* ViewMenu.java
*
* created: Tue Dec 29 1998
*
* This file is part of Artemis
*
* Copyright (C) 1998,1999,2000,2002 Genome Research Limited
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* 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/ViewMenu.java,v 1.15 2009-04-22 08:50:13 tjc Exp $
*/
package uk.ac.sanger.artemis.components;
import uk.ac.sanger.artemis.*;
import uk.ac.sanger.artemis.sequence.*;
import uk.ac.sanger.artemis.util.*;
import uk.ac.sanger.artemis.components.filetree.FileList;
import uk.ac.sanger.artemis.components.filetree.RemoteFileNode;
import uk.ac.sanger.artemis.components.genebuilder.GeneUtils;
import uk.ac.sanger.artemis.io.InvalidRelationException;
import uk.ac.sanger.artemis.io.Key;
import uk.ac.sanger.artemis.io.Qualifier;
import uk.ac.sanger.artemis.j2ssh.FTProgress;
import uk.ac.sanger.artemis.j2ssh.FileTransferProgressMonitor;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* A popup menu with viewing commands.
*
* @author Kim Rutherford
* @version $Id: ViewMenu.java,v 1.15 2009-04-22 08:50:13 tjc Exp $
public class ViewMenu extends SelectionMenu
{
/** */
private static final long serialVersionUID = 1L;
/**
* The EntryGroup that was passed to the constructor.
**/
private EntryGroup entry_group = null;
/**
* The Selection that was passed to the constructor.
**/
private Selection selection = null;
/**
* The GotoEventSource that was passed to the constructor.
**/
//private GotoEventSource goto_event_source = null;
private BasePlotGroup base_plot_group;
/**
* Create a new ViewMenu object.
* @param frame The JFrame that owns this JMenu.
* @param selection The Selection that the commands in the menu will
* operate on.
* @param entry_group The EntryGroup object where new features/entries will
* be added.
* @param goto_event_source The object that we will call makeBaseVisible()
* on.
* @param base_plot_group The BasePlotGroup associated with this JMenu -
* needed to call getCodonUsageAlgorithm()
* @param menu_name The name of the new menu.
**/
public ViewMenu(final JFrame frame,
final Selection selection,
final GotoEventSource goto_event_source,
final EntryGroup entry_group,
final BasePlotGroup base_plot_group,
final String menu_name)
{
super(frame, menu_name, selection);
this.entry_group = entry_group;
this.selection = selection;
this.base_plot_group = base_plot_group;
final JMenuItem plot_features_item = new JMenuItem("Feature Plots");
plot_features_item.setAccelerator(PLOT_FEATURES_KEY);
plot_features_item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
plotSelectedFeatures(getParentFrame(), getSelection());
final JMenuItem view_feature_item = new JMenuItem("Selected Features");
view_feature_item.setAccelerator(VIEW_FEATURES_KEY);
view_feature_item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
viewSelectedFeatures(getParentFrame(), getSelection());
final JMenuItem view_selection_item = new JMenuItem("Selection");
view_selection_item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
new SelectionViewer(getSelection(), entry_group);
final JMenuItem feature_info_item = new JMenuItem("Feature Statistics");
feature_info_item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
viewSelectedFeatureInfo();
final JMenuItem view_bases_item = new JMenuItem("Bases Of Selection");
view_bases_item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
viewSelectedBases(true);
view_bases_as_fasta_item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
viewSelectedBases(false);
final JMenuItem view_aa_item = new JMenuItem("Amino Acids Of Selection");
view_aa_item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
viewSelectedAminoAcids(true);
view_aa_as_fasta_item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
viewSelectedAminoAcids(false);
overview_item.setAccelerator(OVERVIEW_KEY);
overview_item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
new EntryGroupInfoDisplay(getParentFrame(), entry_group);
final JMenuItem forward_overview_item = new JMenuItem("Forward Strand Overview");
forward_overview_item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
new EntryGroupInfoDisplay(getParentFrame(), entry_group,
Bases.FORWARD);
final JMenuItem reverse_overview_item = new JMenuItem("Reverse Strand Overview");
reverse_overview_item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
new EntryGroupInfoDisplay(getParentFrame(), entry_group,
Bases.REVERSE);
final JMenuItem view_cds_item = new JMenuItem("CDS Genes And Products");
if(GeneUtils.isDatabaseEntry(entry_group))
view_cds_item.setEnabled(false);
view_cds_item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
final String filter_name =
"CDS features (filtered from: " +
new FilteredEntryGroup(entry_group, feature_predicate, filter_name);
selection, goto_event_source,
filtered_entry_group,
base_plot_group);
feature_list_frame.getFeatureList().setShowGenes(true);
feature_list_frame.getFeatureList().setShowProducts(true);
Options.getOptions().getPropertyTruthValue("sanger_options");
final StringVector external_program_names = new StringVector();
for(int i = 0 ; i < external_programs.size() ; ++i)
{
if(!external_program_names.contains(new_name))
external_program_names.add(new_name);
for(int i = 0 ; i < external_program_names.size() ; ++i)
{
makeSearchResultsMenu(external_program_name, false, sanger_options);
search_results_menu.add(new_menu);
if(sanger_options)
{
search_results_menu.addSeparator();
for(int i = 0 ; i < external_program_names.size() ; ++i)
{
makeSearchResultsMenu(external_program_name, true, sanger_options);
search_results_menu.add(new_menu);
final JMenu feature_filters_menu = new JMenu("Feature Filters");
new JMenuItem("Suspicious Start Codons ...");
bad_start_codons_item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
if(checkEntryGroupSize(MAX_FILTER_FEATURE_COUNT))
showBadStartCodons(getParentFrame(), selection,
entry_group, goto_event_source,
base_plot_group);
new JMenuItem("Suspicious Stop Codons ...");
bad_stop_codons_item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
if(checkEntryGroupSize(MAX_FILTER_FEATURE_COUNT))
showBadStopCodons(getParentFrame(), selection,
entry_group, goto_event_source,
base_plot_group);
new JMenuItem("Stop Codons In Translation ...");
stop_codons_in_translation.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
if(checkEntryGroupSize(MAX_FILTER_FEATURE_COUNT))
showStopsInTranslation(getParentFrame(), selection,
entry_group, goto_event_source,
base_plot_group);
new JMenuItem("Non EMBL Keys ...");
bad_feature_keys_item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
if(checkEntryGroupSize(MAX_FILTER_FEATURE_COUNT))
showNonEMBLKeys(getParentFrame(), selection,
entry_group, goto_event_source,
base_plot_group);
new JMenuItem("Duplicated Features ...");
duplicated_keys_item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
if(checkEntryGroupSize(MAX_FILTER_FEATURE_COUNT))
showDuplicatedFeatures(getParentFrame(), selection,
entry_group, goto_event_source,
base_plot_group);
final JMenuItem overlapping_cds_features_item;
if(GeneUtils.isDatabaseEntry(entry_group))
overlapping_cds_features_item =
new JMenuItem("Overlapping "+DatabaseDocument.EXONMODEL+" Features ...");
else
overlapping_cds_features_item =
new JMenuItem("Overlapping CDS Features ...");
overlapping_cds_features_item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
if(checkEntryGroupSize(MAX_FILTER_FEATURE_COUNT))
showOverlappingCDSs(getParentFrame(), selection,
entry_group, goto_event_source,
base_plot_group);
final JMenuItem same_stop_cds_features_item;
if(GeneUtils.isDatabaseEntry(entry_group))
same_stop_cds_features_item = new JMenuItem(
DatabaseDocument.EXONMODEL+"s Sharing Stop Codons ...");
else
same_stop_cds_features_item = new JMenuItem("CDSs Sharing Stop Codons ...");
same_stop_cds_features_item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
if(checkEntryGroupSize(MAX_FILTER_FEATURE_COUNT))
showFeaturesWithSameStopCodons(getParentFrame(),
selection, entry_group,
goto_event_source,
base_plot_group);
new JMenuItem("Features Missing Required Qualifiers ...");
missing_qualifier_features_item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
if(checkEntryGroupSize(MAX_FILTER_FEATURE_COUNT))
showMissingQualifierFeatures(getParentFrame(), selection,
entry_group, goto_event_source,
base_plot_group);
new JMenuItem("Filter By Key ...");
filter_by_key_item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
if(checkEntryGroupSize(MAX_FILTER_FEATURE_COUNT))
showFilterByKey(getParentFrame(), selection,
entry_group, goto_event_source,
base_plot_group);
final JMenuItem filter_by_multiple_sys_id =
new JMenuItem("Duplicate Systematic Name Qualifier ...");
filter_by_multiple_sys_id.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
showFilterByMultipleID(getParentFrame(), selection,
entry_group, goto_event_source,
base_plot_group);
}
});
new JMenuItem("Selected Features ...");
filter_by_selection_item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
showFilterBySelection(getParentFrame(),
selection, entry_group, goto_event_source,
base_plot_group);
feature_filters_menu.add(bad_start_codons_item);
feature_filters_menu.add(bad_stop_codons_item);
feature_filters_menu.add(stop_codons_in_translation);
feature_filters_menu.add(bad_feature_keys_item);
feature_filters_menu.add(duplicated_keys_item);
feature_filters_menu.add(overlapping_cds_features_item);
feature_filters_menu.add(same_stop_cds_features_item);
feature_filters_menu.add(missing_qualifier_features_item);
feature_filters_menu.add(filter_by_multiple_sys_id);
feature_filters_menu.addSeparator();
feature_filters_menu.add(filter_by_key_item);
feature_filters_menu.add(filter_by_selection_item);
add(view_feature_item);
add(view_selection_item);
addSeparator();
if(search_results_menu != null)
add(search_results_menu);
add(view_cds_item);
add(feature_filters_menu);
addSeparator();
add(overview_item);
add(forward_overview_item);
add(reverse_overview_item);
addSeparator();
add(view_bases_item);
add(view_bases_as_fasta_item);
add(view_aa_item);
add(view_aa_as_fasta_item);
addSeparator();
add(feature_info_item);
add(plot_features_item);
}
/**
* Create a new ViewMenu object.
* @param entry_edit The EntryEdit that owns this JMenu.
* @param selection The Selection that the commands in the menu will
* operate on.
* @param entry_group The EntryGroup object where new features/entries will
* be added.
* @param goto_event_source The object that we will call makeBaseVisible()
* on.
* @param base_plot_group The BasePlotGroup associated with this JMenu -
* needed to call getCodonUsageAlgorithm()
**/
public ViewMenu(final JFrame frame,
final Selection selection,
final GotoEventSource goto_event_source,
final EntryGroup entry_group,
final BasePlotGroup base_plot_group)
{
this(frame, selection, goto_event_source, entry_group,
base_plot_group, "View");
}
/**
* The shortcut for Show Feature Plots.
**/
final static KeyStroke PLOT_FEATURES_KEY =
KeyStroke.getKeyStroke (KeyEvent.VK_W,
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); //InputEvent.CTRL_MASK);
final static public int PLOT_FEATURES_KEY_CODE = KeyEvent.VK_W;
/**
* The shortcut for View Selected Features.
**/
final static KeyStroke VIEW_FEATURES_KEY =
KeyStroke.getKeyStroke (KeyEvent.VK_V,
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); //InputEvent.CTRL_MASK);
final static public int VIEW_FEATURES_KEY_CODE = KeyEvent.VK_V;
/**
* The shortcut for Show Overview.
**/
final static KeyStroke OVERVIEW_KEY =
KeyStroke.getKeyStroke (KeyEvent.VK_O,
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); //InputEvent.CTRL_MASK);
final static public int OVERVIEW_KEY_CODE = KeyEvent.VK_O;
/**
* The shortcut for View FASTA in browser.
**/
final static KeyStroke FASTA_IN_BROWSER_KEY =
KeyStroke.getKeyStroke (KeyEvent.VK_F,
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); //InputEvent.CTRL_MASK);
final static public int FASTA_IN_BROWSER_KEY_CODE = KeyEvent.VK_F;
/**
* The shortcut for View FASTA.
**/
final static KeyStroke VIEW_FASTA_KEY =
KeyStroke.getKeyStroke (KeyEvent.VK_R,
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); //InputEvent.CTRL_MASK);
final static public int VIEW_FASTA_KEY_CODE = KeyEvent.VK_R;
/**
* The shortcut for View BLASTP in browser.
**/
final static KeyStroke BLASTP_IN_BROWSER_KEY =
KeyStroke.getKeyStroke (KeyEvent.VK_B,
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); //InputEvent.CTRL_MASK);
final static public int BLASTP_IN_BROWSER_KEY_CODE = KeyEvent.VK_B;
/**
* The shortcut for View BLASTP.
**/
final static KeyStroke VIEW_BLASTP_KEY =
KeyStroke.getKeyStroke (KeyEvent.VK_BACK_QUOTE ,
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); //InputEvent.CTRL_MASK);
final static public int VIEW_BLASTP_KEY_CODE = KeyEvent.VK_BACK_QUOTE;
/**
* The shortcut for View HTH.
**/
final static KeyStroke VIEW_HTH_KEY =
KeyStroke.getKeyStroke (KeyEvent.VK_H,
Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); //InputEvent.CTRL_MASK);
final static public int VIEW_HTH_KEY_CODE = KeyEvent.VK_H;
/**
* Make a JMenuItem for viewing the results of running the given program.
* @param send_to_browser if true the results should be sent straight to
* the web browser rather than using a SearchResultViewer object.
* @param sanger_options true if the sanger_options is set to true in the
* options file.
**/
private JMenuItem makeSearchResultsMenu(final String program_name,
final boolean sanger_options)
{
final String suffix;
if(send_to_browser)
suffix = new String(" results (in browser)");
else
suffix = new String(" results");
final JMenuItem new_menu = new JMenuItem(program_name + suffix);
else if(program_name.equals("blastp"))
new_menu.setAccelerator (VIEW_BLASTP_KEY);
else if(program_name.equals("hth"))
new_menu.setAccelerator (VIEW_HTH_KEY);
new_menu.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
viewExternalResults(getParentFrame(), getSelection(),
program_name, send_to_browser);
}
});
return new_menu;
}
/**
* Popup a FeatureListFrame containing the non-pseudo CDS features that
* have invalid start codons.
* @param parent_frame The parent JFrame.
* @param selection The Selection to pass to the FeatureList.
* @param entry_group The EntryGroup to pass to the FilteredEntryGroup.
* @param goto_source The GotoEventSource to pass to the FeatureList.
* @param base_plot_group The BasePlotGroup associated with this JMenu -
* needed to call getCodonUsageAlgorithm()
**/
protected static void showBadStartCodons (final JFrame parent_frame,
final Selection selection,
final EntryGroup entry_group,
final GotoEventSource goto_source,
final BasePlotGroup base_plot_group)
{
final FeaturePredicate cds_predicate;
if(GeneUtils.isDatabaseEntry(entry_group))
cds_predicate = new FeatureKeyPredicate(new Key(DatabaseDocument.EXONMODEL));
else
cds_predicate =
new FeatureKeyQualifierPredicate (Key.CDS, "pseudo", false);
final FeaturePredicate feature_predicate = new FeaturePredicate ()
{
public boolean testPredicate (final Feature feature)
{
if(!cds_predicate.testPredicate (feature))
return false;
if(feature.hasValidStartCodon (true))
return false;
else
return true;
}
};
final String filter_name;
if(GeneUtils.isDatabaseEntry(entry_group))
filter_name =
DatabaseDocument.EXONMODEL+" features with suspicious start codons (filtered from: " +
parent_frame.getTitle () + ")";
else
filter_name =
"CDS features with suspicious start codons (filtered from: " +
parent_frame.getTitle () + ")";
final FilteredEntryGroup filtered_entry_group =
new FilteredEntryGroup (entry_group, feature_predicate, filter_name);
final FeatureListFrame feature_list_frame =
new FeatureListFrame (filter_name,
selection, goto_source, filtered_entry_group,
base_plot_group);
feature_list_frame.setVisible (true);
}
/**
* Popup a FeatureListFrame containing the non-pseudo CDS features that
* have invalid stop codons.
* @param parent_frame The parent JFrame.
* @param selection The Selection to pass to the FeatureList.
* @param entry_group The EntryGroup to pass to the FilteredEntryGroup.
* @param goto_source The GotoEventSource to pass to the FeatureList.
* @param base_plot_group The BasePlotGroup associated with this JMenu -
* needed to call getCodonUsageAlgorithm()
**/
protected static void showBadStopCodons (final JFrame parent_frame,
final Selection selection,
final EntryGroup entry_group,
final GotoEventSource goto_source,
final BasePlotGroup
base_plot_group)
{
final FeaturePredicate cds_predicate;
if(GeneUtils.isDatabaseEntry(entry_group))
cds_predicate = new FeatureKeyPredicate(new Key(DatabaseDocument.EXONMODEL));
else
cds_predicate =
new FeatureKeyQualifierPredicate (Key.CDS, "pseudo", false);
final FeaturePredicate feature_predicate = new FeaturePredicate ()
{
public boolean testPredicate (final Feature feature)
{
if(!cds_predicate.testPredicate (feature))
return false;
if(feature.hasValidStopCodon (true))
return false;
else
return true;
}
};
final String filter_name;
if(GeneUtils.isDatabaseEntry(entry_group))
filter_name=
DatabaseDocument.EXONMODEL+" features with suspicious stop codons (filtered from: " +
parent_frame.getTitle () + ")";
else
filter_name =
"CDS features with suspicious stop codons (filtered from: " +
parent_frame.getTitle () + ")";
final FilteredEntryGroup filtered_entry_group =
new FilteredEntryGroup (entry_group, feature_predicate, filter_name);
final FeatureListFrame feature_list_frame =
new FeatureListFrame (filter_name,
selection, goto_source, filtered_entry_group,
base_plot_group);
feature_list_frame.setVisible (true);
}
/**
* Popup a FeatureListFrame containing the non-pseudo CDS features that
* contain a stop codon in the translation.
* @param parent_frame The parent Frame.
* @param selection The Selection to pass to the FeatureList.
* @param entry_group The EntryGroup to pass to the FilteredEntryGroup.
* @param goto_source The GotoEventSource to pass to the FeatureList.
* @param base_plot_group The BasePlotGroup associated with this Menu -
* needed to call getCodonUsageAlgorithm()
**/
private static void showStopsInTranslation(final Frame parent_frame,
final Selection selection,
final EntryGroup entry_group,
final GotoEventSource goto_source,
final BasePlotGroup
base_plot_group)
{
final FeaturePredicate cds_predicate;
if(GeneUtils.isDatabaseEntry(entry_group))
cds_predicate = new FeatureKeyPredicate(new Key(DatabaseDocument.EXONMODEL));
else
cds_predicate =
new FeatureKeyQualifierPredicate(Key.CDS, "pseudo", false);
final FeaturePredicate feature_predicate = new FeaturePredicate ()
{
public boolean testPredicate (final Feature feature)
{
if(!cds_predicate.testPredicate (feature))
return false;
final AminoAcidSequence amino_acids = feature.getTranslation ();
if(amino_acids.containsStopCodon ())
return true;
else
return false;
}
};
final String filter_name;
if(GeneUtils.isDatabaseEntry(entry_group))
filter_name =
DatabaseDocument.EXONMODEL+" features with stop codon(s) in translation (filtered from: " +
parent_frame.getTitle () + ")";
else
filter_name =
"CDS features with stop codon(s) in translation (filtered from: " +
parent_frame.getTitle () + ")";
final FilteredEntryGroup filtered_entry_group =
new FilteredEntryGroup (entry_group, feature_predicate, filter_name);
final FeatureListFrame feature_list_frame =
new FeatureListFrame (filter_name,
selection, goto_source, filtered_entry_group,
base_plot_group);
feature_list_frame.setVisible (true);
}
/**
* Popup a FeatureListFrame containing the features that have non-EMBL keys.
* @param parent_frame The parent JFrame.
* @param selection The Selection to pass to the FeatureList.
* @param entry_group The EntryGroup to pass to the FilteredEntryGroup.
* @param goto_source The GotoEventSource to pass to the FeatureList.
* @param base_plot_group The BasePlotGroup associated with this JMenu -
* needed to call getCodonUsageAlgorithm()
**/
protected static void showNonEMBLKeys(final JFrame parent_frame,
final Selection selection,
final EntryGroup entry_group,
final GotoEventSource goto_source,
final BasePlotGroup
base_plot_group)
{
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
final FeaturePredicate feature_predicate =
new FeaturePredicate () {
public boolean testPredicate (final Feature feature) {
if (feature.hasValidEMBLKey ()) {
return false;
} else {
return true;
}
}
};
final String filter_name =
"features with a non-EMBL key (filtered from: " +
parent_frame.getTitle () + ")";
final FilteredEntryGroup filtered_entry_group =
new FilteredEntryGroup (entry_group, feature_predicate, filter_name);
final FeatureListFrame feature_list_frame =
new FeatureListFrame (filter_name,
selection, goto_source, filtered_entry_group,
base_plot_group);
feature_list_frame.setVisible (true);
}
/**
* Popup a FeatureListFrame containing the features that have the same key
* and location as another features (ie. duplicates).
* @param parent_frame The parent JFrame.
* @param selection The Selection to pass to the FeatureList.
* @param entry_group The EntryGroup to pass to the FilteredEntryGroup.
* @param goto_source The GotoEventSource to pass to the FeatureList.
* @param base_plot_group The BasePlotGroup associated with this JMenu -
* needed to call getCodonUsageAlgorithm()
**/
protected static void showDuplicatedFeatures (final JFrame parent_frame,
final Selection selection,
final EntryGroup entry_group,
final GotoEventSource goto_source,
final BasePlotGroup
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
final FeaturePredicate feature_predicate =
new FeaturePredicate () {
public boolean testPredicate (final Feature feature) {
final Entry feature_entry = feature.getEntry ();
final int feature_index = feature_entry.indexOf (feature);
if (feature_index + 1 == feature_entry.getFeatureCount ()) {
// last in the Entry
return false;
}
final Feature next_feature =
feature_entry.getFeature (feature_index + 1);
if (feature.getKey ().equals (next_feature.getKey ()) &&
feature.getLocation ().equals (next_feature.getLocation ())) {
return true;
} else {
return false;
}
}
};
final String filter_name =
"duplicated Features (filtered from: " +
parent_frame.getTitle () + ")";
final FilteredEntryGroup filtered_entry_group =
new FilteredEntryGroup (entry_group, feature_predicate, filter_name);
final FeatureListFrame feature_list_frame =
new FeatureListFrame (filter_name,
selection, goto_source, filtered_entry_group,
base_plot_group);
feature_list_frame.setVisible (true);
}
/**
* Popup a FeatureListFrame containing those CDS features that overlap with
* the next feature.
* @param parent_frame The parent JFrame.
* @param selection The Selection to pass to the FeatureList.
* @param entry_group The EntryGroup to pass to the FilteredEntryGroup.
* @param goto_source The GotoEventSource to pass to the FeatureList.
* @param base_plot_group The BasePlotGroup associated with this JMenu -
* needed to call getCodonUsageAlgorithm()
**/
protected static void showOverlappingCDSs(final JFrame parent_frame,
final Selection selection,
final EntryGroup entry_group,
final GotoEventSource goto_source,
final BasePlotGroup base_plot_group)
{
final Key key;
if(GeneUtils.isDatabaseEntry(entry_group))
key = new Key(DatabaseDocument.EXONMODEL);
else
key = Key.CDS;
final FeatureKeyPredicate cds_predicate = new FeatureKeyPredicate (key);
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
final FeaturePredicate feature_predicate =
new FeaturePredicate () {
public boolean testPredicate (final Feature test_feature) {
if (!cds_predicate.testPredicate (test_feature)) {
return false;
}
final Range feature_range = test_feature.getMaxRawRange ();
final FeatureVector overlapping_features;
try {
overlapping_features =
entry_group.getFeaturesInRange (feature_range);
} catch (OutOfRangeException e) {
throw new Error ("internal error - unexpected exception: " + e);
}
for (int i = 0 ; i < overlapping_features.size () ; ++i) {
final Feature current_feature = overlapping_features.elementAt (i);
if (current_feature != test_feature &&
cds_predicate.testPredicate (current_feature)) {
return true;
}
}
return false;
}
};
final String filter_name =
"overlapping "+key.getKeyString()+" features (filtered from: " +
parent_frame.getTitle () + ")";
final FilteredEntryGroup filtered_entry_group =
new FilteredEntryGroup (entry_group, feature_predicate, filter_name);
final FeatureListFrame feature_list_frame =
new FeatureListFrame (filter_name,
selection, goto_source, filtered_entry_group,
base_plot_group);
feature_list_frame.setVisible (true);
}
/**
* Popup a FeatureListFrame containing those CDS features that overlap with
* the next feature.
* @param parent_frame The parent JFrame.
* @param selection The Selection to pass to the FeatureList.
* @param entry_group The EntryGroup to pass to the FilteredEntryGroup.
* @param goto_source The GotoEventSource to pass to the FeatureList.
* @param base_plot_group The BasePlotGroup associated with this JMenu -
* needed to call getCodonUsageAlgorithm()
**/
showFeaturesWithSameStopCodons(final JFrame parent_frame,
final Selection selection,
final EntryGroup entry_group,
final GotoEventSource goto_source,
final BasePlotGroup base_plot_group)
{
final Key key;
if(GeneUtils.isDatabaseEntry(entry_group))
key = new Key(DatabaseDocument.EXONMODEL);
else
key = Key.CDS;
final FeatureKeyPredicate cds_predicate = new FeatureKeyPredicate (key);