<!-- JAL-2535 -->Posterior probability annotation from
Stockholm files imported as sequence associated annotation
</li>
+ <li>
+ <!-- JAL-2533 -->Sequence names don't include file
+ extension when importing structure files without embedded
+ names or PDB accessions
+ </li>
</ul>
<em>Application</em>
<ul>
<li><!-- JAL-2464 -->Tree Viewer's Print Dialog doesn't get shown again after pressing 'Cancel'</li>
<li><!-- JAL-2461 -->DAS registry not found exceptions removed from console output</li>
<li><!-- JAL-2383 -->Above PID colour threshold not recovered when alignment view imported from project</li>
-
+ <li><!-- JAL-2465 -->No mappings generated between structure and sequences extracted from structure files imported via URL</li>
+ <li>
+ <!-- JAL-2520 -->Structures loaded via URL are saved in
+ Jalview Projects rather than fetched via URL again when
+ the project is loaded and the structure viewed
+ </li>
</ul>
<em>Applet</em>
<ul>
// ////////////////////////////////
// /StructureListener
@Override
- public String[] getPdbFile()
+ public String[] getStructureFiles()
{
return new String[] { pdbentry.getFile() };
}
// ////////////////////////////////
// /StructureListener
@Override
- public String[] getPdbFile()
+ public String[] getStructureFiles()
{
return new String[] { pdbentry.getFile() };
}
@Override
public void mouseReleased(MouseEvent evt)
{
+ boolean didDrag = mouseDragging; // did we come here after a drag
mouseDragging = false;
mouseWheelPressed = false;
- ap.paintAlignment(true);
if (!editingSeqs)
{
- doMouseReleasedDefineMode(evt);
+ doMouseReleasedDefineMode(evt, didDrag);
return;
}
}
}
- public void doMouseReleasedDefineMode(MouseEvent evt)
+ public void doMouseReleasedDefineMode(MouseEvent evt, boolean afterDrag)
{
if (stretchGroup == null)
{
// but defer colourscheme update until hidden sequences are passed in
boolean vischange = stretchGroup.recalcConservation(true);
// here we rely on stretchGroup == av.getSelection()
- needOverviewUpdate |= vischange && av.isSelectionDefinedGroup();
+ needOverviewUpdate |= vischange && av.isSelectionDefinedGroup()
+ && afterDrag;
if (stretchGroup.cs != null)
{
stretchGroup.cs.alignmentChanged(stretchGroup,
groups = Collections.synchronizedList(new ArrayList<SequenceGroup>());
hiddenSequences = new HiddenSequences(this);
hiddenCols = new HiddenColumns();
- codonFrameList = new ArrayList<AlignedCodonFrame>();
+ codonFrameList = new ArrayList<>();
nucleotide = Comparison.isNucleotide(seqs);
@Override
public SequenceGroup[] findAllGroups(SequenceI s)
{
- ArrayList<SequenceGroup> temp = new ArrayList<SequenceGroup>();
+ ArrayList<SequenceGroup> temp = new ArrayList<>();
synchronized (groups)
{
return;
}
}
- sg.setContext(this);
+ sg.setContext(this, true);
groups.add(sg);
}
}
}
for (SequenceGroup sg : groups)
{
- sg.setContext(null);
+ sg.setContext(null, false);
}
groups.clear();
}
{
removeAnnotationForGroup(g);
groups.remove(g);
- g.setContext(null);
+ g.setContext(null, false);
}
}
}
{
return;
}
- List<SequenceI> toProcess = new ArrayList<SequenceI>();
+ List<SequenceI> toProcess = new ArrayList<>();
toProcess.add(currentSeq);
while (toProcess.size() > 0)
{
return;
}
// try to avoid using SequenceI.equals at this stage, it will be expensive
- Set<SequenceI> seqs = new LinkedIdentityHashSet<SequenceI>();
+ Set<SequenceI> seqs = new LinkedIdentityHashSet<>();
for (int i = 0; i < getHeight(); i++)
{
{
return null;
}
- List<AlignedCodonFrame> cframes = new ArrayList<AlignedCodonFrame>();
+ List<AlignedCodonFrame> cframes = new ArrayList<>();
for (AlignedCodonFrame acf : getCodonFrames())
{
if (acf.involvesSequence(seq))
if (sqs != null)
{
// avoid self append deadlock by
- List<SequenceI> toappendsq = new ArrayList<SequenceI>();
+ List<SequenceI> toappendsq = new ArrayList<>();
synchronized (sqs)
{
for (SequenceI addedsq : sqs)
@Override
public Iterable<AlignmentAnnotation> findAnnotation(String calcId)
{
- List<AlignmentAnnotation> aa = new ArrayList<AlignmentAnnotation>();
+ List<AlignmentAnnotation> aa = new ArrayList<>();
AlignmentAnnotation[] alignmentAnnotation = getAlignmentAnnotation();
if (alignmentAnnotation != null)
{
public Iterable<AlignmentAnnotation> findAnnotations(SequenceI seq,
String calcId, String label)
{
- ArrayList<AlignmentAnnotation> aa = new ArrayList<AlignmentAnnotation>();
+ ArrayList<AlignmentAnnotation> aa = new ArrayList<>();
for (AlignmentAnnotation ann : getAlignmentAnnotation())
{
if ((calcId == null || (ann.getCalcId() != null && ann.getCalcId()
@Override
public Set<String> getSequenceNames()
{
- Set<String> names = new HashSet<String>();
+ Set<String> names = new HashSet<>();
for (SequenceI seq : getSequences())
{
names.add(seq.getName());
boolean colourText = false;
/**
+ * True if the group is defined as a group on the alignment, false if it is
+ * just a selection.
+ */
+ boolean isDefined = false;
+
+ /**
* after Olivier's non-conserved only character display
*/
boolean showNonconserved = false;
/**
* group members
*/
- private List<SequenceI> sequences = new ArrayList<SequenceI>();
+ private List<SequenceI> sequences = new ArrayList<>();
/**
* representative sequence for this group (if any)
*/
private boolean normaliseSequenceLogo;
- /**
- * @return the includeAllConsSymbols
+ /*
+ * visibility of rows or represented rows covered by group
*/
- public boolean isShowSequenceLogo()
- {
- return showSequenceLogo;
- }
+ private boolean hidereps = false;
+
+ /*
+ * visibility of columns intersecting this group
+ */
+ private boolean hidecols = false;
+
+ AlignmentAnnotation consensus = null;
+
+ AlignmentAnnotation conservation = null;
+
+ private boolean showConsensusHistogram;
+
+ private AnnotatedCollectionI context;
/**
* Creates a new SequenceGroup object.
this();
if (seqsel != null)
{
- sequences = new ArrayList<SequenceI>();
+ sequences = new ArrayList<>();
sequences.addAll(seqsel.sequences);
if (seqsel.groupName != null)
{
colourText = seqsel.colourText;
startRes = seqsel.startRes;
endRes = seqsel.endRes;
- cs = seqsel.cs;
+ cs = new ResidueShader(seqsel.getColourScheme());
if (seqsel.description != null)
{
description = new String(seqsel.description);
}
hidecols = seqsel.hidecols;
hidereps = seqsel.hidereps;
+ showNonconserved = seqsel.showNonconserved;
+ showSequenceLogo = seqsel.showSequenceLogo;
+ normaliseSequenceLogo = seqsel.normaliseSequenceLogo;
+ showConsensusHistogram = seqsel.showConsensusHistogram;
idColour = seqsel.idColour;
outlineColour = seqsel.outlineColour;
seqrep = seqsel.seqrep;
}
}
+ public boolean isShowSequenceLogo()
+ {
+ return showSequenceLogo;
+ }
+
public SequenceI[] getSelectionAsNewSequences(AlignmentI align)
{
int iSize = sequences.size();
}
else
{
- List<SequenceI> allSequences = new ArrayList<SequenceI>();
+ List<SequenceI> allSequences = new ArrayList<>();
for (SequenceI seq : sequences)
{
allSequences.add(seq);
}
/**
- * visibility of rows or represented rows covered by group
- */
- private boolean hidereps = false;
-
- /**
* set visibility of sequences covered by (if no sequence representative is
* defined) or represented by this group.
*
}
/**
- * visibility of columns intersecting this group
- */
- private boolean hidecols = false;
-
- /**
* set intended visibility of columns covered by this group
*
* @param visibility
{
SequenceGroup sgroup = new SequenceGroup(this);
SequenceI[] insect = getSequencesInOrder(alignment);
- sgroup.sequences = new ArrayList<SequenceI>();
+ sgroup.sequences = new ArrayList<>();
for (int s = 0; insect != null && s < insect.length; s++)
{
if (map == null || map.containsKey(insect[s]))
this.showNonconserved = displayNonconserved;
}
- AlignmentAnnotation consensus = null, conservation = null;
-
- /**
- * flag indicating if consensus histogram should be rendered
- */
- private boolean showConsensusHistogram;
-
/**
* set this alignmentAnnotation object as the one used to render consensus
* annotation
{
// TODO add in other methods like 'getAlignmentAnnotation(String label),
// etc'
- ArrayList<AlignmentAnnotation> annot = new ArrayList<AlignmentAnnotation>();
+ ArrayList<AlignmentAnnotation> annot = new ArrayList<>();
synchronized (sequences)
{
for (SequenceI seq : sequences)
@Override
public Iterable<AlignmentAnnotation> findAnnotation(String calcId)
{
- List<AlignmentAnnotation> aa = new ArrayList<AlignmentAnnotation>();
+ List<AlignmentAnnotation> aa = new ArrayList<>();
if (calcId == null)
{
return aa;
public Iterable<AlignmentAnnotation> findAnnotations(SequenceI seq,
String calcId, String label)
{
- ArrayList<AlignmentAnnotation> aa = new ArrayList<AlignmentAnnotation>();
+ ArrayList<AlignmentAnnotation> aa = new ArrayList<>();
for (AlignmentAnnotation ann : getAlignmentAnnotation())
{
if ((calcId == null || (ann.getCalcId() != null && ann.getCalcId()
}
}
- private AnnotatedCollectionI context;
+ /**
+ * Sets the alignment or group context for this group, and whether it is
+ * defined as a group
+ *
+ * @param ctx
+ * the context for the group
+ * @param defined
+ * whether the group is defined on the alignment or is just a
+ * selection
+ * @throws IllegalArgumentException
+ * if setting the context would result in a circular reference chain
+ */
+ public void setContext(AnnotatedCollectionI ctx, boolean defined)
+ {
+ setContext(ctx);
+ this.isDefined = defined;
+ }
/**
* Sets the alignment or group context for this group
*
* @param ctx
+ * the context for the group
* @throws IllegalArgumentException
* if setting the context would result in a circular reference chain
*/
return context;
}
+ public boolean isDefined()
+ {
+ return isDefined;
+ }
+
public void setColourScheme(ColourSchemeI scheme)
{
if (cs == null)
public void closeViewer()
{
// remove listeners for all structures in viewer
- getSsm().removeStructureViewerListener(this, this.getPdbFile());
+ getSsm().removeStructureViewerListener(this, this.getStructureFiles());
viewer.dispose();
lastCommand = null;
viewer = null;
* get the distinct structure files modelled
* (a file with multiple chains may map to multiple sequences)
*/
- String[] files = getPdbFile();
+ String[] files = getStructureFiles();
if (!waitForFileLoad(files))
{
return null;
private int getModelNum(String modelFileName)
{
- String[] mfn = getPdbFile();
+ String[] mfn = getStructureFiles();
if (mfn == null)
{
return -1;
// ////////////////////////////////
// /StructureListener
- @Override
- public synchronized String[] getPdbFile()
+ // @Override
+ public synchronized String[] getPdbFilex()
{
if (viewer == null)
{
return modelFileNames;
}
+ @Override
+ public synchronized String[] getStructureFiles()
+ {
+ List<String> mset = new ArrayList<String>();
+ if (viewer == null)
+ {
+ return new String[0];
+ }
+
+ if (modelFileNames == null)
+ {
+ int modelCount = viewer.ms.mc;
+ String filePath = null;
+ for (int i = 0; i < modelCount; ++i)
+ {
+ filePath = viewer.ms.getModelFileName(i);
+ if (!mset.contains(filePath))
+ {
+ mset.add(filePath);
+ }
+ }
+ modelFileNames = mset.toArray(new String[mset.size()]);
+ }
+
+ return modelFileNames;
+ }
/**
* map from string to applet
*/
chainNames = new ArrayList<String>();
chainFile = new Hashtable<String, String>();
boolean notifyLoaded = false;
- String[] modelfilenames = getPdbFile();
+ String[] modelfilenames = getStructureFiles();
// first check if we've lost any structures
if (oldmodels != null && oldmodels.length > 0)
{
*/
public void closeViewer(boolean closeChimera)
{
- getSsm().removeStructureViewerListener(this, this.getPdbFile());
+ getSsm().removeStructureViewerListener(this, this.getStructureFiles());
if (closeChimera)
{
viewer.exitChimera();
int[] _refStructure, HiddenColumns[] _hiddenCols)
{
StringBuilder allComs = new StringBuilder(128);
- String[] files = getPdbFile();
+ String[] files = getStructureFiles();
if (!waitForFileLoad(files))
{
* to the Chimera command 'list models type molecule', see
* ChimeraManager.getModelList().
*/
- List<ChimeraModel> maps = chimeraMaps.get(getPdbFile()[pdbfnum]);
+ List<ChimeraModel> maps = chimeraMaps.get(getStructureFiles()[pdbfnum]);
boolean hasSubModels = maps != null && maps.size() > 1;
return "#" + String.valueOf(pdbfnum) + (hasSubModels ? ".1" : "");
}
// ////////////////////////////////
// /StructureListener
@Override
- public synchronized String[] getPdbFile()
+ public synchronized String[] getStructureFiles()
{
if (viewer == null)
{
// TODO refactor as required to pull up to an interface
AlignmentI alignment = avp.getAlignment();
- String[] files = getPdbFile();
+ String[] files = getStructureFiles();
if (files == null)
{
return 0;
int waitFor = 35;
int waitTotal = 0;
while (addingStructures ? lastnotify >= jmb.getLoadNotifiesHandled()
- : !(jmb.isFinishedInit() && jmb.getPdbFile() != null && jmb
- .getPdbFile().length == files.size()))
+ : !(jmb.isFinishedInit() && jmb.getStructureFiles() != null && jmb
+ .getStructureFiles().length == files.size()))
{
try
{
// System.err.println("finished: " + jmb.isFinishedInit()
// + "; loaded: " + Arrays.toString(jmb.getPdbFile())
// + "; files: " + files.toString());
- jmb.getPdbFile();
+ jmb.getStructureFiles();
break;
}
}
String pdbid = "";
try
{
- String[] filesInViewer = jmb.getPdbFile();
+ String[] filesInViewer = jmb.getStructureFiles();
// TODO: replace with reference fetching/transfer code (validate PDBentry
// as a DBRef?)
Pdb pdbclient = new Pdb();
}
@Override
- public String[] getPdbFile()
+ public String[] getStructureFiles()
{
return null;
}
StructureFile pdb = null;
try
{
- String[] curfiles = jmb.getPdbFile(); // files currently in viewer
+ String[] curfiles = jmb.getStructureFiles(); // files currently in viewer
// TODO: replace with reference fetching/transfer code (validate PDBentry
// as a DBRef?)
for (int pi = 0; pi < jmb.getPdbCount(); pi++)
@Override
public void mouseReleased(MouseEvent evt)
{
+ boolean didDrag = mouseDragging; // did we come here after a drag
mouseDragging = false;
mouseWheelPressed = false;
if (!editingSeqs)
{
- doMouseReleasedDefineMode(evt);
+ doMouseReleasedDefineMode(evt, didDrag);
return;
}
List<SequenceFeature> allFeatures = ap.getFeatureRenderer()
.findFeaturesAtRes(sequence.getDatasetSequence(),
sequence.findPosition(res));
- List<String> links = new ArrayList<String>();
+ List<String> links = new ArrayList<>();
for (SequenceFeature sf : allFeatures)
{
if (sf.links != null)
}
/**
- * DOCUMENT ME!
+ * Update the display after mouse up on a selection or group
*
* @param evt
- * DOCUMENT ME!
+ * mouse released event details
+ * @param afterDrag
+ * true if this event is happening after a mouse drag (rather than a
+ * mouse down)
*/
- public void doMouseReleasedDefineMode(MouseEvent evt)
+ public void doMouseReleasedDefineMode(MouseEvent evt, boolean afterDrag)
{
if (stretchGroup == null)
{
// always do this - annotation has own state
// but defer colourscheme update until hidden sequences are passed in
boolean vischange = stretchGroup.recalcConservation(true);
- needOverviewUpdate |= vischange && av.isSelectionDefinedGroup();
+ needOverviewUpdate |= vischange && av.isSelectionDefinedGroup()
+ && afterDrag;
if (stretchGroup.cs != null)
{
stretchGroup.cs.alignmentChanged(stretchGroup,
ap.getCalculationDialog().validateCalcTypes();
}
- // process further ?
- if (!av.followSelection)
- {
- return;
- }
+ return;
+ }
+
+ // process further ?
+ if (!av.followSelection)
+ {
+ return;
}
/*
{
// TODO: cope with multiple PDB files in view
in = new BufferedReader(
- new FileReader(getBinding().getPdbFile()[0]));
+ new FileReader(getBinding().getStructureFiles()[0]));
File outFile = chooser.getSelectedFile();
PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
* enable 'Superpose with' if more than one mapped structure
*/
viewSelectionMenu.setEnabled(false);
- if (getBinding().getPdbFile().length > 1
+ if (getBinding().getStructureFiles().length > 1
&& getBinding().getSequence().length > 1)
{
viewSelectionMenu.setEnabled(true);
import jalview.schemes.ColourSchemeI;
import jalview.structure.StructureSelectionManager;
import jalview.util.MessageManager;
+import jalview.ws.utils.UrlDownloadClient;
+import java.io.File;
+import java.io.IOException;
import java.util.StringTokenizer;
import java.util.Vector;
// refer to it as.
return;
}
+ if (file != null
+ && file.indexOf(System.getProperty("java.io.tmpdir")) > -1)
+ {
+ // ignore files loaded from the system's temporary directory
+ return;
+ }
String type = protocol == DataSourceType.FILE ? "RECENT_FILE"
: "RECENT_URL";
// open a new source and read from it
FormatAdapter fa = new FormatAdapter();
- al = fa.readFile(file, protocol, format);
- source = fa.getAlignFile(); // keep reference for later if
- // necessary.
+ boolean downloadStructureFile = format.isStructureFile()
+ && protocol.equals(DataSourceType.URL);
+ if (downloadStructureFile)
+ {
+ String structExt = format.getExtensions().split(",")[0];
+ String urlLeafName = file.substring(file.lastIndexOf(System
+ .getProperty("file.separator")), file
+ .lastIndexOf("."));
+ String tempStructureFileStr = createNamedJvTempFile(
+ urlLeafName, structExt);
+ UrlDownloadClient.download(file, tempStructureFileStr);
+ al = fa.readFile(tempStructureFileStr, DataSourceType.FILE,
+ format);
+ source = fa.getAlignFile();
+ }
+ else
+ {
+ al = fa.readFile(file, protocol, format);
+ source = fa.getAlignFile(); // keep reference for later if
+ // necessary.
+ }
}
} catch (java.io.IOException ex)
{
}
+ /**
+ * This method creates the file -
+ * {tmpdir}/jalview/{current_timestamp}/fileName.exetnsion using the supplied
+ * file name and extension
+ *
+ * @param fileName
+ * the name of the temp file to be created
+ * @param extension
+ * the extension of the temp file to be created
+ * @return
+ */
+ private static String createNamedJvTempFile(String fileName,
+ String extension) throws IOException
+ {
+ String seprator = System.getProperty("file.separator");
+ String jvTempDir = System.getProperty("java.io.tmpdir") + "jalview"
+ + seprator + System.currentTimeMillis();
+ File tempStructFile = new File(jvTempDir + seprator + fileName + "."
+ + extension);
+ tempStructFile.mkdirs();
+ return tempStructFile.toString();
+ }
+
/*
* (non-Javadoc)
*
* make a friendly ID string.
*
* @param dataName
- * @return truncated dataName to after last '/'
+ * @return truncated dataName to after last '/' and pruned .extension if
+ * present
*/
protected String safeName(String dataName)
{
{
dataName = dataName.substring(p + 1);
}
+ if(dataName.indexOf(".") > -1){
+ dataName = dataName.substring(0, dataName.lastIndexOf("."));
+ }
return dataName;
}
}
@Override
- public String[] getPdbFile()
+ public String[] getStructureFiles()
{
return modelSet;
}
* handles messages for, or null if generic listener (only used by
* removeListener method)
*/
- public String[] getPdbFile();
+ public String[] getStructureFiles();
/**
* Called by StructureSelectionManager to inform viewer to highlight given
import jalview.datamodel.SequenceI;
import jalview.ext.jmol.JmolParser;
import jalview.gui.IProgressIndicator;
+import jalview.io.AppletFormatAdapter;
import jalview.io.DataSourceType;
import jalview.io.StructureFile;
import jalview.util.MappingUtils;
boolean isMapUsingSIFTs = SiftsSettings.isMapWithSifts();
try
{
+ sourceType = AppletFormatAdapter.checkProtocol(pdbFile);
pdb = new JmolParser(pdbFile, sourceType);
if (pdb.getId() != null && pdb.getId().trim().length() > 0
if (listeners.elementAt(i) instanceof StructureListener)
{
sl = (StructureListener) listeners.elementAt(i);
- for (String pdbfile : sl.getPdbFile())
+ for (String pdbfile : sl.getStructureFiles())
{
pdbs.remove(pdbfile);
}
BitSet matched, SuperposeData[] structures)
{
int refStructure = -1;
- String[] files = getPdbFile();
+ String[] files = getStructureFiles();
if (files == null)
{
return -1;
{
return;
}
- String[] files = getPdbFile();
+ String[] files = getStructureFiles();
SequenceRenderer sr = getSequenceRenderer(alignmentv);
FeaturesDisplayedI featuresDisplayed = null;
- protected Deque<CommandI> historyList = new ArrayDeque<CommandI>();
+ protected Deque<CommandI> historyList = new ArrayDeque<>();
- protected Deque<CommandI> redoList = new ArrayDeque<CommandI>();
+ protected Deque<CommandI> redoList = new ArrayDeque<>();
/**
* alignment displayed in the viewport. Please use get/setter
public void setHiddenColumns(HiddenColumns hidden)
{
this.alignment.setHiddenColumns(hidden);
- // this.colSel = colsel;
}
@Override
protected boolean showOccupancy = true;
- private Map<SequenceI, Color> sequenceColours = new HashMap<SequenceI, Color>();
+ private Map<SequenceI, Color> sequenceColours = new HashMap<>();
protected SequenceAnnotationOrder sortAnnotationsBy = null;
if (hiddenRepSequences == null)
{
- hiddenRepSequences = new Hashtable<SequenceI, SequenceCollectionI>();
+ hiddenRepSequences = new Hashtable<>();
}
hiddenRepSequences.put(repSequence, sg);
@Override
public List<int[]> getVisibleRegionBoundaries(int min, int max)
{
- ArrayList<int[]> regions = new ArrayList<int[]>();
+ ArrayList<int[]> regions = new ArrayList<>();
int start = min;
int end = max;
public List<AlignmentAnnotation> getVisibleAlignmentAnnotation(
boolean selectedOnly)
{
- ArrayList<AlignmentAnnotation> ala = new ArrayList<AlignmentAnnotation>();
+ ArrayList<AlignmentAnnotation> ala = new ArrayList<>();
AlignmentAnnotation[] aa;
if ((aa = alignment.getAlignmentAnnotation()) != null)
{
// intersect alignment annotation with alignment groups
AlignmentAnnotation[] aan = alignment.getAlignmentAnnotation();
- List<SequenceGroup> oldrfs = new ArrayList<SequenceGroup>();
+ List<SequenceGroup> oldrfs = new ArrayList<>();
if (aan != null)
{
for (int an = 0; an < aan.length; an++)
selectionIsDefinedGroup = gps.contains(selectionGroup);
}
}
- return selectionGroup.getContext() == alignment
- || selectionIsDefinedGroup;
+ return selectionGroup.isDefined() || selectionIsDefinedGroup;
}
/**
* the name of file to save the URLs to
* @throws IOException
*/
- public void download(String urlstring, String outfile) throws IOException
+ public static void download(String urlstring, String outfile)
+ throws IOException
{
FileOutputStream fos = null;
ReadableByteChannel rbc = null;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNotSame;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import jalview.schemes.NucleotideColourScheme;
+import jalview.schemes.PIDColourScheme;
+
+import java.awt.Color;
import junit.extensions.PA;
PA.setValue(sg2, "context", sg2);
try
{
- sg3.setContext(sg2); // circular reference in sg2
+ sg3.setContext(sg2, false); // circular reference in sg2
fail("Expected exception");
} catch (IllegalArgumentException e)
{
// expected
assertNull(sg3.getContext());
}
+
+ // test isDefined setting behaviour
+ sg2 = new SequenceGroup();
+ sg1.setContext(null, false);
+ assertFalse(sg1.isDefined());
+
+ sg1.setContext(sg2, false);
+ assertFalse(sg1.isDefined());
+
+ sg1.setContext(sg2, true);
+ assertTrue(sg1.isDefined());
+
+ // setContext without defined parameter does not change isDefined
+ sg1.setContext(null);
+ assertTrue(sg1.isDefined());
+
+ sg1.setContext(null, false);
+ sg1.setContext(sg2);
+ assertFalse(sg1.isDefined());
}
@Test(groups = { "Functional" })
assertTrue(sg2.contains(seq2, 8));
sg2.deleteSequence(seq2, false);
assertFalse(sg2.contains(seq2));
+ }
+
+ @Test(groups = { "Functional" })
+ public void testCopyConstructor()
+ {
+ SequenceI seq = new Sequence("seq", "ABC");
+ SequenceGroup sg = new SequenceGroup();
+ sg.addSequence(seq, false);
+ sg.setName("g1");
+ sg.setDescription("desc");
+ sg.setColourScheme(new PIDColourScheme());
+ sg.setDisplayBoxes(false);
+ sg.setDisplayText(false);
+ sg.setColourText(true);
+ sg.isDefined = true;
+ sg.setShowNonconserved(true);
+ sg.setOutlineColour(Color.red);
+ sg.setIdColour(Color.blue);
+ sg.thresholdTextColour = 1;
+ sg.textColour = Color.orange;
+ sg.textColour2 = Color.yellow;
+ sg.setIgnoreGapsConsensus(false);
+ sg.setshowSequenceLogo(true);
+ sg.setNormaliseSequenceLogo(true);
+ sg.setHidereps(true);
+ sg.setHideCols(true);
+ sg.setShowConsensusHistogram(true);
+ sg.setContext(new SequenceGroup());
+
+ SequenceGroup sg2 = new SequenceGroup(sg);
+ assertEquals(sg2.getName(), sg.getName());
+ assertEquals(sg2.getDescription(), sg.getDescription());
+ assertNotSame(sg2.getGroupColourScheme(), sg.getGroupColourScheme());
+ assertSame(sg2.getColourScheme(), sg.getColourScheme());
+ assertEquals(sg2.getDisplayBoxes(), sg.getDisplayBoxes());
+ assertEquals(sg2.getDisplayText(), sg.getDisplayText());
+ assertEquals(sg2.getColourText(), sg.getColourText());
+ assertEquals(sg2.getShowNonconserved(), sg.getShowNonconserved());
+ assertEquals(sg2.getOutlineColour(), sg.getOutlineColour());
+ assertEquals(sg2.getIdColour(), sg.getIdColour());
+ assertEquals(sg2.thresholdTextColour, sg.thresholdTextColour);
+ assertEquals(sg2.textColour, sg.textColour);
+ assertEquals(sg2.textColour2, sg.textColour2);
+ assertEquals(sg2.getIgnoreGapsConsensus(), sg.getIgnoreGapsConsensus());
+ assertEquals(sg2.isShowSequenceLogo(), sg.isShowSequenceLogo());
+ assertEquals(sg2.isNormaliseSequenceLogo(),
+ sg.isNormaliseSequenceLogo());
+ assertEquals(sg2.isHidereps(), sg.isHidereps());
+ assertEquals(sg2.isHideCols(), sg.isHideCols());
+ assertEquals(sg2.isShowConsensusHistogram(),
+ sg.isShowConsensusHistogram());
+
+ /*
+ * copy of sequences
+ */
+ assertNotSame(sg2.getSequences(), sg.getSequences());
+ assertEquals(sg2.getSequences(), sg.getSequences());
+ /*
+ * isDefined should only be set true when a new group is added to
+ * an alignment, not in the copy constructor
+ */
+ assertFalse(sg2.isDefined());
+
+ /*
+ * context should be set explicitly, not by copy
+ */
+ assertNull(sg2.getContext());
}
}
import jalview.gui.StructureViewer.ViewerType;
import jalview.io.DataSourceType;
+import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
}
}
}
+
+ @Test(groups = { "Functional", "Network" })
+ public void testStructureLoadingViaURL()
+ {
+ Cache.setProperty(Preferences.STRUCTURE_DISPLAY, ViewerType.JMOL.name());
+ String inFile = "http://www.jalview.org/builds/develop/examples/3W5V.pdb";
+ AlignFrame af = new jalview.io.FileLoader().LoadFileWaitTillLoaded(
+ inFile, DataSourceType.URL);
+ assertTrue("Didn't read input file " + inFile, af != null);
+ for (SequenceI sq : af.getViewport().getAlignment().getSequences())
+ {
+ SequenceI dsq = sq.getDatasetSequence();
+ while (dsq.getDatasetSequence() != null)
+ {
+ dsq = dsq.getDatasetSequence();
+ }
+ if (dsq.getAllPDBEntries() != null
+ && dsq.getAllPDBEntries().size() > 0)
+ {
+ for (int q = 0; q < dsq.getAllPDBEntries().size(); q++)
+ {
+ final StructureViewer structureViewer = new StructureViewer(af
+ .getViewport().getStructureSelectionManager());
+ structureViewer.setViewerType(ViewerType.JMOL);
+ JalviewStructureDisplayI jmolViewer = structureViewer
+ .viewStructures(dsq.getAllPDBEntries().elementAt(q),
+ new SequenceI[] { sq }, af.getCurrentView()
+ .getAlignPanel());
+ /*
+ * Wait for viewer load thread to complete
+ */
+ try
+ {
+ while (!jmolViewer.getBinding().isFinishedInit())
+ {
+ Thread.sleep(500);
+ }
+ } catch (InterruptedException e)
+ {
+ }
+ // System.out.println(">>>>>>>>>>>>>>>>> "
+ // + jmolViewer.getBinding().getPdbFile());
+ String[] expectedModelFiles = new String[] { "http://www.jalview.org/builds/develop/examples/3W5V.pdb" };
+ String[] actualModelFiles = jmolViewer.getBinding().getStructureFiles();
+ Assert.assertEqualsNoOrder(actualModelFiles, expectedModelFiles);
+ jmolViewer.closeViewer(true);
+ // todo: break here means only once through this loop?
+ break;
+ }
+ break;
+ }
+ }
+ }
}
* (or possibly 52-145 to 1-94 - see JAL-2319)
*/
StructureSelectionManager ssm = binding.getSsm();
- String pdbFile = binding.getPdbFile()[0];
+ String pdbFile = binding.getStructureFiles()[0];
StructureMapping[] mappings = ssm.getMapping(pdbFile);
assertTrue(mappings[0].getMappingDetailsOutput().contains("SIFTS"),
"Failed to perform SIFTS mapping");
acf2.addMap(s1, s1, new MapList(new int[] { 1, 4 }, new int[] { 4, 1 },
1, 1));
- List<AlignedCodonFrame> mappings = new ArrayList<AlignedCodonFrame>();
+ List<AlignedCodonFrame> mappings = new ArrayList<>();
mappings.add(acf1);
mappings.add(acf2);
af1.getViewport().getAlignment().setCodonFrames(mappings);
acf3.addMap(cs2, cs2, new MapList(new int[] { 1, 12 }, new int[] { 1,
12 }, 1, 1));
- List<AlignedCodonFrame> mappings1 = new ArrayList<AlignedCodonFrame>();
+ List<AlignedCodonFrame> mappings1 = new ArrayList<>();
mappings1.add(acf1);
af1.getViewport().getAlignment().setCodonFrames(mappings1);
- List<AlignedCodonFrame> mappings2 = new ArrayList<AlignedCodonFrame>();
+ List<AlignedCodonFrame> mappings2 = new ArrayList<>();
mappings2.add(acf2);
mappings2.add(acf3);
af2.getViewport().getAlignment().setCodonFrames(mappings2);
acf3.addMap(cs2, cs2, new MapList(new int[] { 1, 12 }, new int[] { 1,
12 }, 1, 1));
- List<AlignedCodonFrame> mappings1 = new ArrayList<AlignedCodonFrame>();
+ List<AlignedCodonFrame> mappings1 = new ArrayList<>();
mappings1.add(acf1);
mappings1.add(acf2);
af1.getViewport().getAlignment().setCodonFrames(mappings1);
- List<AlignedCodonFrame> mappings2 = new ArrayList<AlignedCodonFrame>();
+ List<AlignedCodonFrame> mappings2 = new ArrayList<>();
mappings2.add(acf2);
mappings2.add(acf3);
af2.getViewport().getAlignment().setCodonFrames(mappings2);
/**
* Verify that setting the selection group has the side-effect of setting the
- * context on the group, unless it already has one
+ * context on the group, unless it already has one, but does not change
+ * whether the group is defined or not.
*/
@Test(groups = { "Functional" })
public void testSetSelectionGroup()
AlignViewport av = af.getViewport();
SequenceGroup sg1 = new SequenceGroup();
SequenceGroup sg2 = new SequenceGroup();
+ SequenceGroup sg3 = new SequenceGroup();
av.setSelectionGroup(sg1);
assertSame(sg1.getContext(), av.getAlignment()); // context set
+ assertFalse(sg1.isDefined()); // group not defined
- sg2.setContext(sg1);
+ sg2.setContext(sg1, false);
av.setSelectionGroup(sg2);
+ assertFalse(sg2.isDefined()); // unchanged
assertSame(sg2.getContext(), sg1); // unchanged
+
+ // create a defined group
+ sg3.setContext(av.getAlignment(), true);
+ av.setSelectionGroup(sg3);
+ assertTrue(sg3.isDefined()); // unchanged
}
/**
* Verify that setting/clearing SHOW_OCCUPANCY preference adds or omits occupancy row from viewport
--- /dev/null
+package jalview.io;
+
+import org.junit.Assert;
+import org.testng.annotations.Test;
+
+public class FileLoaderTest
+{
+
+ @Test(groups = { "Network" })
+ public void testDownloadStructuresIfInputFromURL()
+ {
+ String urlFile = "http://www.jalview.org/builds/develop/examples/3W5V.pdb";
+ FileLoader fileLoader = new FileLoader();
+ fileLoader.LoadFileWaitTillLoaded(urlFile, DataSourceType.URL,
+ FileFormat.PDB);
+ Assert.assertNotNull(fileLoader.file);
+ // The FileLoader's file is expected to a temporary file different from the
+ // original URL.
+ Assert.assertNotEquals(urlFile, fileLoader.file);
+ // Data source type expected to be updated from DataSourceType.URL to
+ // DataSourceType.FILE
+ Assert.assertEquals(DataSourceType.FILE, fileLoader.protocol);
+ }
+}
testee = new AAStructureBindingModel(ssm, pdbFiles, seqs, null)
{
@Override
- public String[] getPdbFile()
+ public String[] getStructureFiles()
{
return new String[] { "INLINE1YCS", "INLINE3A6S", "INLINE1OOT" };
}
/*
* create a data bean to hold data per structure file
*/
- SuperposeData[] structs = new SuperposeData[testee.getPdbFile().length];
+ SuperposeData[] structs = new SuperposeData[testee.getStructureFiles().length];
for (int i = 0; i < structs.length; i++)
{
structs[i] = testee.new SuperposeData(al.getWidth());