Search in sources :

Example 1 with AnnotationTagValue

use of uk.ac.babraham.SeqMonk.DataTypes.Genome.AnnotationTagValue in project SeqMonk by s-andrews.

the class FindFeatureDialog method actionPerformed.

/* (non-Javadoc)
	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
	 */
public void actionPerformed(ActionEvent ae) {
    if (ae.getActionCommand().equals("close")) {
        setVisible(false);
        dispose();
    } else if (ae.getActionCommand().equals("search")) {
        Thread t = new Thread(this);
        t.start();
    } else if (ae.getActionCommand().equals("save_annotation_all")) {
        // Find a name for the type of feature they want to create
        String name = (String) JOptionPane.showInputDialog(this, "Feature type", "Make Annotation Track", JOptionPane.QUESTION_MESSAGE, null, null, search.getText() + " " + featureType.getSelectedItem() + " search");
        // They cancelled
        if (name == null)
            return;
        // Now we can go ahead and make the new annotation set
        AnnotationSet searchAnnotations = new AnnotationSet(dataCollection.genome(), search.getText() + " " + featureType.getSelectedItem() + " search");
        for (int f = 0; f < lastHits.length; f++) {
            Feature feature = new Feature(name, lastHits[f].chromosomeName());
            feature.setLocation(lastHits[f].location());
            AnnotationTagValue[] tags = lastHits[f].getAnnotationTagValues();
            for (int t = 0; t < tags.length; t++) {
                feature.addAttribute(tags[t].tag(), tags[t].value());
            }
            searchAnnotations.addFeature(feature);
        }
        dataCollection.genome().annotationCollection().addAnnotationSets(new AnnotationSet[] { searchAnnotations });
    } else if (ae.getActionCommand().equals("save_annotation_selected")) {
        Feature[] selectedHits = viewer.getSelectedFeatures();
        if (selectedHits.length == 0) {
            JOptionPane.showMessageDialog(this, "There are no selected features from which to make a track", "Can't make track", JOptionPane.INFORMATION_MESSAGE);
            return;
        }
        // Find a name for the type of feature they want to create
        String name = (String) JOptionPane.showInputDialog(this, "Feature type", "Make Annotation Track", JOptionPane.QUESTION_MESSAGE, null, null, "selected " + search.getText());
        // They cancelled
        if (name == null)
            return;
        // Now we can go ahead and make the new annotation set
        AnnotationSet searchAnnotations = new AnnotationSet(dataCollection.genome(), search.getText() + " search results");
        for (int f = 0; f < selectedHits.length; f++) {
            Feature feature = new Feature(name, selectedHits[f].chromosomeName());
            feature.setLocation(selectedHits[f].location());
            AnnotationTagValue[] tags = selectedHits[f].getAnnotationTagValues();
            for (int t = 0; t < tags.length; t++) {
                feature.addAttribute(tags[t].tag(), tags[t].value());
            }
            searchAnnotations.addFeature(feature);
        }
        dataCollection.genome().annotationCollection().addAnnotationSets(new AnnotationSet[] { searchAnnotations });
    }
}
Also used : AnnotationTagValue(uk.ac.babraham.SeqMonk.DataTypes.Genome.AnnotationTagValue) AnnotationSet(uk.ac.babraham.SeqMonk.DataTypes.Genome.AnnotationSet) Feature(uk.ac.babraham.SeqMonk.DataTypes.Genome.Feature)

Example 2 with AnnotationTagValue

use of uk.ac.babraham.SeqMonk.DataTypes.Genome.AnnotationTagValue in project SeqMonk by s-andrews.

the class FindFeaturesByNameDialog method actionPerformed.

/* (non-Javadoc)
	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
	 */
public void actionPerformed(ActionEvent ae) {
    if (ae.getActionCommand().equals("close")) {
        setVisible(false);
        dispose();
    } else if (ae.getActionCommand().equals("search")) {
        Thread t = new Thread(this);
        t.start();
    } else if (ae.getActionCommand().equals("save_annotation_all")) {
        // Find a name for the type of feature they want to create
        String name = (String) JOptionPane.showInputDialog(this, "Feature type", "Make Annotation Track", JOptionPane.QUESTION_MESSAGE, null, null, "Name matched features");
        // They cancelled
        if (name == null)
            return;
        // Now we can go ahead and make the new annotation set
        AnnotationSet searchAnnotations = new AnnotationSet(dataCollection.genome(), "Named features search results");
        for (int f = 0; f < lastHits.length; f++) {
            Feature feature = new Feature(name, lastHits[f].chromosomeName());
            feature.setLocation(lastHits[f].location());
            AnnotationTagValue[] tags = lastHits[f].getAnnotationTagValues();
            for (int t = 0; t < tags.length; t++) {
                feature.addAttribute(tags[t].tag(), tags[t].value());
            }
            searchAnnotations.addFeature(feature);
        }
        dataCollection.genome().annotationCollection().addAnnotationSets(new AnnotationSet[] { searchAnnotations });
    } else if (ae.getActionCommand().equals("save_annotation_selected")) {
        Feature[] selectedHits = viewer.getSelectedFeatures();
        if (selectedHits.length == 0) {
            JOptionPane.showMessageDialog(this, "There are no selected features from which to make a track", "Can't make track", JOptionPane.INFORMATION_MESSAGE);
            return;
        }
        // Find a name for the type of feature they want to create
        String name = (String) JOptionPane.showInputDialog(this, "Feature type", "Make Annotation Track", JOptionPane.QUESTION_MESSAGE, null, null, "Selected name matched features");
        // They cancelled
        if (name == null)
            return;
        // Now we can go ahead and make the new annotation set
        AnnotationSet searchAnnotations = new AnnotationSet(dataCollection.genome(), "Named features search results");
        for (int f = 0; f < selectedHits.length; f++) {
            Feature feature = new Feature(name, selectedHits[f].chromosomeName());
            feature.setLocation(selectedHits[f].location());
            AnnotationTagValue[] tags = selectedHits[f].getAnnotationTagValues();
            for (int t = 0; t < tags.length; t++) {
                feature.addAttribute(tags[t].tag(), tags[t].value());
            }
            searchAnnotations.addFeature(feature);
        }
        dataCollection.genome().annotationCollection().addAnnotationSets(new AnnotationSet[] { searchAnnotations });
    }
}
Also used : AnnotationTagValue(uk.ac.babraham.SeqMonk.DataTypes.Genome.AnnotationTagValue) AnnotationSet(uk.ac.babraham.SeqMonk.DataTypes.Genome.AnnotationSet) Feature(uk.ac.babraham.SeqMonk.DataTypes.Genome.Feature)

Aggregations

AnnotationSet (uk.ac.babraham.SeqMonk.DataTypes.Genome.AnnotationSet)2 AnnotationTagValue (uk.ac.babraham.SeqMonk.DataTypes.Genome.AnnotationTagValue)2 Feature (uk.ac.babraham.SeqMonk.DataTypes.Genome.Feature)2