{
public static final String RESNUM_FEATURE = "RESNUM";
-- /**
-- * SequenceFeature group for PDB File features added to sequences
-- */
-- private static final String PDBFILEFEATURE = "PDBFile";
--
private static final String IEASTATUS = "IEA:jalview";
public String id;
public String pdbid = "";
-- public PDBChain(String pdbid, String id)
++ public PDBChain(String thePdbid, String theId)
{
-- this.pdbid = pdbid == null ? pdbid : pdbid.toLowerCase();
-- this.id = id;
++ this.pdbid = thePdbid == null ? thePdbid : thePdbid.toLowerCase();
++ this.id = theId;
}
/**
{
status = PDBChain.IEASTATUS;
}
- SequenceFeature[] features = sequence.getSequenceFeatures();
- if (features == null)
- {
- return null;
- }
- for (int i = 0; i < features.length; i++)
+
+ List<SequenceFeature> features = sequence.getSequenceFeatures();
+ for (SequenceFeature feature : features)
{
- if (features[i].getFeatureGroup() != null
- && features[i].getFeatureGroup().equals(pdbid))
+ if (feature.getFeatureGroup() != null
+ && feature.getFeatureGroup().equals(pdbid))
{
- SequenceFeature tx = new SequenceFeature(features[i]);
- tx.setBegin(1 + residues.elementAt(tx.getBegin() - offset).atoms
- .elementAt(0).alignmentMapping);
- tx.setEnd(1 + residues.elementAt(tx.getEnd() - offset).atoms
- .elementAt(0).alignmentMapping);
+ int newBegin = 1 + residues.elementAt(feature.getBegin() - offset).atoms
+ .elementAt(0).alignmentMapping;
+ int newEnd = 1 + residues.elementAt(feature.getEnd() - offset).atoms
+ .elementAt(0).alignmentMapping;
+ SequenceFeature tx = new SequenceFeature(feature, newBegin, newEnd,
+ feature.getFeatureGroup(), feature.getScore());
tx.setStatus(status
- + ((tx.getStatus() == null || tx.getStatus().length() == 0) ? ""
+ + ((tx.getStatus() == null || tx.getStatus().length() == 0)
+ ? ""
: ":" + tx.getStatus()));
if (tx.begin != 0 && tx.end != 0)
{
// Add inserted residues as features to the base residue
Atom currAtom = resAtoms.get(0);
- if (currAtom.insCode != ' '
- && !residues.isEmpty()
- && residues.lastElement().atoms.get(0).resNumber == currAtom.resNumber)
+ if (currAtom.insCode != ' ' && !residues.isEmpty()
+ && residues.lastElement().atoms
+ .get(0).resNumber == currAtom.resNumber)
{
- SequenceFeature sf = new SequenceFeature("INSERTION",
- currAtom.resName + ":" + currAtom.resNumIns + " " + pdbid
- + id,
- "", offset + count - 1, offset + count - 1, "PDB_INS");
+ String desc = currAtom.resName + ":" + currAtom.resNumIns + " "
+ + pdbid + id;
+ SequenceFeature sf = new SequenceFeature("INSERTION", desc, offset
+ + count - 1, offset + count - 1, "PDB_INS");
resFeatures.addElement(sf);
residues.lastElement().atoms.addAll(resAtoms);
}
{
if (sequences[row] == null)
{
- System.err
- .println("WARNING: Consensus skipping null sequence - possible race condition.");
+ System.err.println(
+ "WARNING: Consensus skipping null sequence - possible race condition.");
continue;
}
- char[] seq = sequences[row].getSequence();
- if (seq.length > column)
+ if (sequences[row].getLength() > column)
{
- char c = seq[column];
+ char c = sequences[row].getCharAt(column);
residueCounts.add(c);
if (Comparison.isNucleotide(c))
{
public static String FEATURE_DENSITY = "density";
- private static boolean containsIgnoreCase(final String lab,
- final List<String> labs)
- {
- if (labs == null)
- {
- return true;
- }
- if (lab == null)
- {
- return false;
- }
- for (String label : labs)
- {
- if (lab.equalsIgnoreCase(label))
- {
- return true;
- }
- }
- return false;
- }
-
/**
- * sort the alignment using the features on each sequence found between start
- * and stop with the given featureLabel (and optional group qualifier)
+ * Sort sequences by feature score or density, optionally restricted by
+ * feature types, feature groups, or alignment start/end positions.
+ * <p>
+ * If the sort is repeated for the same combination of types and groups, sort
+ * order is reversed.
*
- * @param featureLabel
- * (may not be null)
- * @param groupLabel
- * (may be null)
- * @param start
- * (-1 to include non-positional features)
- * @param stop
- * (-1 to only sort on non-positional features)
+ * @param featureTypes
+ * a list of feature types to include (or null for all)
+ * @param groups
+ * a list of feature groups to include (or null for all)
+ * @param startCol
+ * start column position to include (base zero)
+ * @param endCol
+ * end column position to include (base zero)
* @param alignment
- * - aligned sequences containing features
+ * the alignment to be sorted
* @param method
- * - one of the string constants FEATURE_SCORE, FEATURE_LABEL,
- * FEATURE_DENSITY
+ * either "average_score" or "density" ("text" not yet implemented)
*/
- public static void sortByFeature(String featureLabel, String groupLabel,
- int start, int stop, AlignmentI alignment, String method)
- {
- sortByFeature(
- featureLabel == null ? null : Arrays.asList(new String[]
- { featureLabel }),
- groupLabel == null ? null : Arrays.asList(new String[]
- { groupLabel }), start, stop, alignment, method);
- }
-
- private static boolean containsIgnoreCase(final String lab,
- final List<String> labs)
- {
- if (labs == null)
- {
- return true;
- }
- if (lab == null)
- {
- return false;
- }
- for (String label : labs)
- {
- if (lab.equalsIgnoreCase(label))
- {
- return true;
- }
- }
- return false;
- }
-
- public static void sortByFeature(List<String> featureLabels,
- List<String> groupLabels, int start, int stop,
+ public static void sortByFeature(List<String> featureTypes,
+ List<String> groups, final int startCol, final int endCol,
AlignmentI alignment, String method)
{
if (method != FEATURE_SCORE && method != FEATURE_LABEL
*/
if (seqMap.getTo() == fromSeq.getDatasetSequence())
{
- seqMap = new Mapping(seq.getDatasetSequence(), seqMap.getMap()
- .getInverse());
+ seqMap = new Mapping(seq.getDatasetSequence(),
+ seqMap.getMap().getInverse());
}
- char[] fromChars = fromSeq.getSequence();
int toStart = seq.getStart();
- char[] toChars = seq.getSequence();
/*
* traverse [start, end, start, end...] ranges in fromSeq
*/
String getTooltip(int column)
{
- char[] sequence = getConsSequence().getSequence();
- char val = column < sequence.length ? sequence[column] : '-';
+ SequenceI cons = getConsSequence();
+ char val = column < cons.getLength() ? cons.getCharAt(column) : '-';
boolean hasConservation = val != '-' && val != '0';
int consp = column - start;
- String tip = (hasConservation && consp > -1 && consp < consSymbs.length) ? consSymbs[consp]
+ String tip = (hasConservation && consp > -1 && consp < consSymbs.length)
+ ? consSymbs[consp]
: "";
return tip;
}
{
EditCommand editCommand = (EditCommand) command;
al = editCommand.getAlignment();
- Vector comps = (Vector) PaintRefresher.components.get(viewport
- .getSequenceSetId());
- Vector comps = (Vector) PaintRefresher.components
++ Vector comps = PaintRefresher.components
+ .get(viewport.getSequenceSetId());
for (int i = 0; i < comps.size(); i++)
{
if (comps.elementAt(i) instanceof AlignmentPanel)
PaintRefresher.Register(newaf.alignPanel.seqPanel.seqCanvas,
newaf.alignPanel.av.getSequenceSetId());
- Vector comps = (Vector) PaintRefresher.components.get(viewport
- .getSequenceSetId());
- Vector comps = (Vector) PaintRefresher.components
++ Vector comps = PaintRefresher.components
+ .get(viewport.getSequenceSetId());
int viewSize = -1;
for (int i = 0; i < comps.size(); i++)
{
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.Vector;
- public class FeatureSettings extends Panel implements ItemListener,
- MouseListener, MouseMotionListener, ActionListener,
- AdjustmentListener, FeatureSettingsControllerI
+ public class FeatureSettings extends Panel
+ implements ItemListener, MouseListener, MouseMotionListener,
+ ActionListener, AdjustmentListener, FeatureSettingsControllerI
{
FeatureRenderer fr;
}
}
- // now add checkboxes which should be visible,
- // if they have not already been added
- Enumeration<String> en = visibleChecks.elements();
-
- while (en.hasMoreElements())
+ /*
+ * now add checkboxes which should be visible,
+ * if they have not already been added
+ */
+ for (String type : displayableTypes)
{
- addCheck(groupsChanged, en.nextElement().toString());
+ addCheck(groupsChanged, type);
}
- featurePanel.setLayout(new GridLayout(featurePanel.getComponentCount(),
- 1, 10, 5));
+ featurePanel.setLayout(
+ new GridLayout(featurePanel.getComponentCount(), 1, 10, 5));
featurePanel.validate();
if (scrollPane != null)
int seq = alignPanel.seqPanel.findSeq(e);
- if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK)
+ if ((e.getModifiers()
+ & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK)
{
- Sequence sq = (Sequence) av.getAlignment().getSequenceAt(seq);
+ SequenceI sq = av.getAlignment().getSequenceAt(seq);
- // build a new links menu based on the current links + any non-positional
- // features
+ /*
+ * build a new links menu based on the current links
+ * and any non-positional features
+ */
List<String> nlinks;
if (urlProvider != null)
{
}
// DETECT RIGHT MOUSE BUTTON IN AWT
- if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK)
+ if ((evt.getModifiers()
+ & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK)
{
- List<SequenceFeature> allFeatures = findFeaturesAtRes(sequence,
- sequence.findPosition(res));
+ List<SequenceFeature> allFeatures = findFeaturesAtColumn(sequence,
+ sequence.findPosition(column + 1));
Vector<String> links = null;
for (SequenceFeature sf : allFeatures)
if (entry.getSequenceFeatures() != null)
{
- SequenceFeature[] sfs = entry.getSequenceFeatures();
- for (int si = 0; si < sfs.length; si++)
+ List<SequenceFeature> sfs = entry.getSequenceFeatures();
+ for (SequenceFeature feature : sfs)
{
- SequenceFeature sf[] = (mp != null) ? mp.locateFeature(feature)
- SequenceFeature sf[] = (mp != null) ? mp.locateFeature(sfs[si])
- : new SequenceFeature[]
- { new SequenceFeature(sfs[si]) };
- if (sf != null && sf.length > 0)
++ SequenceFeature sf[] = (mp != null) ? mp.locateFeature(feature)
+ : new SequenceFeature[] { new SequenceFeature(feature) };
+ if (sf != null)
{
for (int sfi = 0; sfi < sf.length; sfi++)
{
* workaround until we handle dna location for CDS sequence
* e.g. location="X53828.1:60..1058" correctly
*/
- System.err
- .println("Implementation Notice: EMBLCDS records not properly supported yet - Making up the CDNA region of this sequence... may be incorrect ("
+ System.err.println(
+ "Implementation Notice: EMBLCDS records not properly supported yet - Making up the CDNA region of this sequence... may be incorrect ("
+ sourceDb + ":" + getAccession() + ")");
- if (translationLength
- * 3 == (1 - codonStart + dna.getSequence().length))
+ int dnaLength = dna.getLength();
+ if (translationLength * 3 == (1 - codonStart + dnaLength))
{
- System.err
- .println("Not allowing for additional stop codon at end of cDNA fragment... !");
+ System.err.println(
+ "Not allowing for additional stop codon at end of cDNA fragment... !");
// this might occur for CDS sequences where no features are marked
exons = new int[] { dna.getStart() + (codonStart - 1),
dna.getEnd() };
- dnaToProteinMapping = new Mapping(product, exons, new int[] { 1,
- translationLength }, 3, 1);
+ dnaToProteinMapping = new Mapping(product, exons,
+ new int[]
+ { 1, translationLength }, 3, 1);
}
- if ((translationLength + 1)
- * 3 == (1 - codonStart + dna.getSequence().length))
+ if ((translationLength + 1) * 3 == (1 - codonStart + dnaLength))
{
- System.err
- .println("Allowing for additional stop codon at end of cDNA fragment... will probably cause an error in VAMSAs!");
+ System.err.println(
+ "Allowing for additional stop codon at end of cDNA fragment... will probably cause an error in VAMSAs!");
exons = new int[] { dna.getStart() + (codonStart - 1),
dna.getEnd() - 3 };
- dnaToProteinMapping = new Mapping(product, exons, new int[] { 1,
- translationLength }, 3, 1);
+ dnaToProteinMapping = new Mapping(product, exons,
+ new int[]
+ { 1, translationLength }, 3, 1);
}
}
else
/**
* Helper method to construct a SequenceFeature for one cds range
*
- * @param exons
- * array of cds [start, end, ...] positions
- * @param exonStartIndex
- * offset into the exons array
- * @param proteinName
- * @param proteinAccessionId
+ * @param type
+ * feature type ("CDS")
+ * @param desc
+ * description
+ * @param begin
+ * start position
+ * @param end
+ * end position
+ * @param group
+ * feature group
* @param vals
* map of 'miscellaneous values' for feature
- * @param codonStart
- * codon start position for CDS (1/2/3, normally 1)
* @return
*/
- protected SequenceFeature makeCdsFeature(int[] exons, int exonStartIndex,
- String proteinName, String proteinAccessionId,
- Map<String, String> vals, int codonStart)
+ protected SequenceFeature makeCdsFeature(String type, String desc,
+ int begin, int end, String group, Map<String, String> vals)
{
- int exonNumber = exonStartIndex / 2 + 1;
- SequenceFeature sf = new SequenceFeature();
- sf.setBegin(Math.min(exons[exonStartIndex], exons[exonStartIndex + 1]));
- sf.setEnd(Math.max(exons[exonStartIndex], exons[exonStartIndex + 1]));
- sf.setDescription(String.format("Exon %d for protein '%s' EMBLCDS:%s",
- exonNumber, proteinName, proteinAccessionId));
- sf.setPhase(String.valueOf(codonStart - 1));
- sf.setStrand(
- exons[exonStartIndex] <= exons[exonStartIndex + 1] ? "+" : "-");
- sf.setValue(FeatureProperties.EXONPOS, exonNumber);
- sf.setValue(FeatureProperties.EXONPRODUCT, proteinName);
+ SequenceFeature sf = new SequenceFeature(type, desc, begin, end, group);
-
if (!vals.isEmpty())
{
StringBuilder sb = new StringBuilder();
* a final sort is needed since Ensembl returns CDS sorted within source
* (havana / ensembl_havana)
*/
- Collections.sort(regions, new RangeComparator(direction == 1));
+ Collections.sort(regions, direction == 1 ? IntRangeComparator.ASCENDING
+ : IntRangeComparator.DESCENDING);
- List<int[]> to = Arrays.asList(new int[] { start,
- start + mappedLength - 1 });
+ List<int[]> to = Arrays
+ .asList(new int[]
+ { start, start + mappedLength - 1 });
return new MapList(regions, to, 1, 1);
}
+ /*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview 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 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview 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 Jalview. If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.ext.rbvi.chimera;
-import jalview.util.RangeComparator;
+import jalview.util.IntRangeComparator;
import java.util.ArrayList;
import java.util.Collections;
*/
gridPanel = new JPanel(new GridLayout(4, 1));
JPanel choosePanel = new JPanel();
- choosePanel.add(new JLabel(MessageManager
- .getString("label.select_feature")
- + ":"));
+ choosePanel.add(new JLabel(
+ MessageManager.getString("label.select_feature") + ":"));
final JComboBox<String> overlaps = new JComboBox<String>();
+ List<String> added = new ArrayList<>();
for (SequenceFeature sf : features)
{
- String text = sf.getType() + "/" + sf.getBegin() + "-" + sf.getEnd()
- + " (" + sf.getFeatureGroup() + ")";
+ String text = String.format("%s/%d-%d (%s)", sf.getType(),
+ sf.getBegin(), sf.getEnd(), sf.getFeatureGroup());
+ while (added.contains(text))
+ {
+ text += " ";
+ }
overlaps.addItem(text);
+ added.add(text);
}
choosePanel.add(overlaps);
highlight.addResult(sequences.get(0), sf.getBegin(),
sf.getEnd());
- alignPanel.getSeqPanel().seqCanvas
- .highlightSearchResults(highlight);
-
+ alignPanel.getSeqPanel().seqCanvas.highlightSearchResults(
+ highlight, false);
-
}
FeatureColourI col = getFeatureStyle(name.getText());
if (col == null)
data[dataIndex][0] = type;
data[dataIndex][1] = fr.getFeatureStyle(type);
- data[dataIndex][2] = new Boolean(af.getViewport()
- .getFeaturesDisplayed().isVisible(type));
+ data[dataIndex][2] = new Boolean(
+ af.getViewport().getFeaturesDisplayed().isVisible(type));
dataIndex++;
- visibleChecks.removeElement(type);
+ displayableTypes.remove(type);
}
}
*/
if (!seqs.isEmpty())
{
- if (ap.getSeqPanel().seqCanvas.getFeatureRenderer().amendFeatures(
- seqs, features, true, ap))
+ if (ap.getSeqPanel().seqCanvas.getFeatureRenderer()
+ .amendFeatures(seqs, features, true, ap))
{
ap.alignFrame.setShowSeqFeatures(true);
- ap.highlightSearchResults(null);
+ ap.av.setSearchResults(null); // clear highlighting
+ ap.repaint(); // draw new/amended features
}
}
}
if (value != -1)
{
- int x = LABEL_WEST - fm.stringWidth(String.valueOf(value))
+ int x = labelWidthWest - fm.stringWidth(String.valueOf(value))
- charWidth / 2;
- g.drawString(value + "", x, (ypos + (i * charHeight))
- - (charHeight / 5));
+ g.drawString(value + "", x,
+ (ypos + (i * charHeight)) - (charHeight / 5));
}
}
}
if (av.isShowSequenceFeatures())
{
- fr.drawSequence(g, nextSeq, startRes, endRes, offset
- + ((i - startSeq) * charHeight), false);
+ fr.drawSequence(g, nextSeq, startRes, endRes,
+ offset + ((i - startSeq) * charHeight), false);
}
- // / Highlight search Results once all sequences have been drawn
- // ////////////////////////////////////////////////////////
+ /*
+ * highlight search Results once sequence has been drawn
+ */
if (av.hasSearchResults())
{
- int[] visibleResults = av.getSearchResults().getResults(nextSeq,
+ SearchResultsI searchResults = av.getSearchResults();
+ int[] visibleResults = searchResults.getResults(nextSeq,
startRes, endRes);
if (visibleResults != null)
{
// Find the next gap before the end
// of the visible region boundary
boolean blank = false;
-- for (fixedRight = fixedRight; fixedRight > lastres; fixedRight--)
++ for (; fixedRight > lastres; fixedRight--)
{
blank = true;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
- import java.util.Comparator;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
/**
* Constructor which does not parse the file immediately
*
-- * @param inFile
++ * @param file
* @param paste
* @throws IOException
*/
-- public FeaturesFile(String inFile, DataSourceType paste)
++ public FeaturesFile(String file, DataSourceType paste)
throws IOException
{
-- super(false, inFile, paste);
++ super(false, file, paste);
}
/**
* Constructor that optionally parses the file immediately
*
* @param parseImmediately
-- * @param inFile
++ * @param file
* @param type
* @throws IOException
*/
-- public FeaturesFile(boolean parseImmediately, String inFile,
- DataSourceType type)
- throws IOException
++ public FeaturesFile(boolean parseImmediately, String file,
+ DataSourceType type) throws IOException
{
-- super(parseImmediately, inFile, type);
++ super(parseImmediately, file, type);
}
/**
// private AlignmentI jvdset;
public Datasetsequence(VamsasAppDatastore vamsasAppDatastore,
-- SequenceI sq, String dict, DataSet dataset)
++ SequenceI sq, String theDict, DataSet theDataset)
{
super(vamsasAppDatastore, sq, uk.ac.vamsas.objects.core.Sequence.class);
-- this.dataset = dataset;
++ this.dataset = theDataset;
// this.jvdset = jvdset;
-- this.dict = dict;
++ this.dict = theDict;
doSync();
}
return modifiedtheseq;
}
+ @Override
public void conflict()
{
- log.warn("Conflict in dataset sequence update to document. Overwriting document");
+ log.warn(
+ "Conflict in dataset sequence update to document. Overwriting document");
// TODO: could try to import from document data to jalview first. and then
updateToDoc();
}
}
/**
++<<<<<<< HEAD
++=======
+ * Answers true if the feature belongs to a feature group which is not
+ * currently displayed, else false
+ *
+ * @param sequenceFeature
+ * @return
+ */
++ @Override
+ protected boolean featureGroupNotShown(
+ final SequenceFeature sequenceFeature)
+ {
+ return featureGroups != null && sequenceFeature.featureGroup != null
+ && sequenceFeature.featureGroup.length() != 0
+ && featureGroups.containsKey(sequenceFeature.featureGroup)
+ && !featureGroups.get(sequenceFeature.featureGroup)
+ .booleanValue();
+ }
+
+ /**
++>>>>>>> refs/heads/develop
* Called when alignment in associated view has new/modified features to
* discover and display.
*
AlignFrame af;
public AADisorderClient(Jws2Instance sh, AlignFrame alignFrame,
-- WsParamSetI preset, List<Argument> paramset)
++ WsParamSetI thePreset, List<Argument> paramset)
{
-- super(sh, alignFrame, preset, paramset);
++ super(sh, alignFrame, thePreset, paramset);
af = alignFrame;
typeName = sh.action;
methodName = sh.serviceType;