Skip to content

Commit

Permalink
Merge pull request #82 from MesquiteProject/development
Browse files Browse the repository at this point in the history
3.51 development into master
  • Loading branch information
DMaddison authored Jun 28, 2018
2 parents 3c4e034 + b8ff2d7 commit 15c4f35
Show file tree
Hide file tree
Showing 97 changed files with 767 additions and 273 deletions.
10 changes: 5 additions & 5 deletions Source/mesquite/Mesquite.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,24 @@ public class Mesquite extends MesquiteTrunk
{
/*.................................................................................................................*/
public String getCitation() {
return "Maddison, W.P. & D.R. Maddison. 2018. Mesquite: A modular system for evolutionary analysis. Version 3.5. http://www.mesquiteproject.org";
return "Maddison, W.P. & D.R. Maddison. 2018. Mesquite: A modular system for evolutionary analysis. Version 3.51. http://www.mesquiteproject.org";
}
/*.................................................................................................................*/
public String getVersion() {
return "3.5";
return "3.51";
}

/*.................................................................................................................*/
public int getVersionInt() {
return 350;
return 351;
}
/*.................................................................................................................*/
public double getMesquiteVersionNumber(){
return 3.50;
return 3.51;
}
/*.................................................................................................................*/
public String getDateReleased() {
return "May 2018"; //"April 2007";
return "June 2018"; //"April 2007";
}

/*.................................................................................................................*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,17 @@ public String getKeywords(){

Color containedBranchColor;
MesquiteString containedBrColorName;
Color containingBranchColor =null; //WideTreeDrawing.defaultBranchColor;
MesquiteString containingBrColorName;

Color containingBranchColor = WideTreeDrawing.defaultBranchColor;
MesquiteString containingBrColorName = new MesquiteString(WideTreeDrawing.defaultBranchColorName);
MesquiteMenuSpec containedMenu = null;
/*.................................................................................................................*/
public boolean startJob(String arguments, Object condition, boolean hiredByName) {
containedMenu = makeMenu("Contained");
startedUnderScripting = MesquiteThread.isScripting();
if (getProject().getNumberTaxas()<=1) {
return sorry("Sorry, you can't use the Contained Associates tree drawing if there is only a single set of taxa available. It is designed to show contained trees within containing trees (e.g. genes within species)");
}
nodeLocsTask= (NodeLocsVH)hireCompatibleEmployee(NodeLocsVH.class, new boolean[]{true}, "Calculator of node locations");
nodeLocsTask= (NodeLocsVH)hireCompatibleEmployee(NodeLocsVH.class, new boolean[]{false}, "Calculator of node locations"); //if "true" passed, then restricts branch length drawing options
if (nodeLocsTask == null) {
return sorry(getName() + " couldn't start because node locator module not obtained");
}
Expand All @@ -108,9 +109,9 @@ public boolean startJob(String arguments, Object condition, boolean hiredByName)
if (treeSourceTask == null) {
return sorry(getName() + " couldn't start because no source of contained trees obtained");
}
addMenuItem( "-", null);
tstC = makeCommand("setTreeSource", this);
treeSourceTask.setHiringCommand(tstC);
makeMenu("Contained");
treeSourceName = new MesquiteString(treeSourceTask.getName());
if (numModulesAvailable(TreeSource.class)>1) {
MesquiteSubmenuSpec mss = addSubmenu(null, "Contained Tree Source", tstC, TreeSource.class);
Expand Down Expand Up @@ -503,6 +504,7 @@ class WideTreeDrawing extends TreeDrawing {
Color migratedColor = Color.yellow;
static Color defaultBranchColor = ColorDistribution.burlyWood;
Color containingColor = defaultBranchColor;
static String defaultBranchColorName = "Wood";
AssociationSource associationTask;
TaxaAssociation association;
MesquiteModule treeSourceTask;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3482,7 +3482,8 @@ public void actUponDroppedFileContents(FileInterpreter fileInterpreter, String p
if (fileInterpreter != null) {

data.setCharNumChanging(true);
((ReadFileFromString) fileInterpreter).readFileFromString(data, taxa, MesquiteFile.getFileContentsAsString(path), "");
String fileName = MesquiteFile.getFileNameFromFilePath(path);
((ReadFileFromString) fileInterpreter).readFileFromString(data, taxa, MesquiteFile.getFileContentsAsString(path), fileName, "");
data.setCharNumChanging(false);

taxa.notifyListeners(this, new Notification(MesquiteListener.PARTS_ADDED));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
public class CompileProcessedMatrices extends FileProcessor {
String saveFile = null;
String tempFile = null;
TaxonNameAlterer nameAlterer;
/*.................................................................................................................*/
public boolean startJob(String arguments, Object condition, boolean hiredByName) {
return true;
Expand Down Expand Up @@ -53,8 +52,6 @@ public boolean pleaseLeaveMeOn(){
void checkTaxonList(CharacterData data, String saveFile){
Taxa taxa = data.getTaxa();
boolean added = false;
if (nameAlterer != null)
nameAlterer.alterTaxonNames(taxa, null);
for (int it = 0; it<taxa.getNumTaxa(); it++){

if (taxonNames.indexOfByName(taxa.getTaxonName(it))<0){
Expand All @@ -71,7 +68,7 @@ void checkTaxonList(CharacterData data, String saveFile){
String block = "#NEXUS" + StringUtil.lineEnding() + "BEGIN TAXA;" + StringUtil.lineEnding() + " DIMENSIONS NTAX=" + taxonNames.size() + ";" + StringUtil.lineEnding() + " TAXLABELS" + StringUtil.lineEnding() + " ";
for (int it = 0; it<taxonNames.size(); it++){
MesquiteString n = (MesquiteString)taxonNames.elementAt(it);
block += n.getName() + " ";
block += ParseUtil.tokenize(n.getName()) + " ";
}
block += ";" + StringUtil.lineEnding() + "END;" + StringUtil.lineEnding() + StringUtil.lineEnding();
MesquiteFile.putFileContents(saveFile, block + matrices, true);
Expand Down Expand Up @@ -108,9 +105,6 @@ public boolean processFile(MesquiteFile file){
return false;
saveFile = MesquiteFile.composePath(directory, fileName);
tempFile = MesquiteFile.composePath(directory, MesquiteFile.massageStringToFilePathSafe(MesquiteTrunk.getUniqueIDBase() + fileName)) ;
if (AlertDialog.query(containerOfModule(), "Alter names?", "The matrices found in the files of the selected folder will be accumulated into a single NEXUS file. All taxa will be accumulated into a single block."
+"In case the different files have variants of taxon names, do you want to alter the names of each matrix as it is read?", "Alter Names", "No"))
nameAlterer = (TaxonNameAlterer) hireEmployee(TaxonNameAlterer.class, "How do you want to alter the names of taxa in each matrix?");
}
if (saveFile == null)
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ private MCharactersDistribution condense(MCharactersDistribution mData){
weightSet.setValue(ic,1);

for (int ic = 0; ic< numChars; ic++){
if (ic % 1000 == 0)
logln("Scanning character " + (ic+1));

for (int oic = ic+1; oic< numChars; oic++){
if (weightSet.getInt(oic)!=0 && condensedData.samePattern(oic, ic)){ //if weight zero already been here and found it
int curWeight = weightSet.getInt(ic);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,22 @@ public boolean processFile(MesquiteFile file){
if (test == null || test.isCompatible(data.getStateClass(), getProject(), this)) {
taxa = data.getTaxa();

String path = file.getPath();
String filePath = file.getPath();
String fileName = file.getFileName();
if (path.endsWith(".nex") || path.endsWith(".fas")){
path = path.substring(0, path.length()-4);
if (filePath.endsWith(".nex") || filePath.endsWith(".fas")){
filePath = filePath.substring(0, filePath.length()-4);
fileName = fileName.substring(0, fileName.length()-4);

}
String path = directoryPath;
if (path == null)
path = filePath;
path= path + MesquiteFile.fileSeparator + fileName;
if (multiple){
path = path + (im + 1);
fileName = fileName + (im + 1);
}

path = path + "." + exporterTask.preferredDataFileExtension();
if (!StringUtil.blank(exporterTask.preferredDataFileExtension()) && !fileName.endsWith(exporterTask.preferredDataFileExtension()))
fileName = fileName + "." + exporterTask.preferredDataFileExtension();
Expand Down Expand Up @@ -238,11 +242,11 @@ public void saveFile(String exporterName, MesquiteFile file, String fileName, St
if (exporterName.equals("NEXUS file"))
coord.writeFile(file);
else if (exporterTask instanceof FileInterpreterI) {
String s = "file = " + StringUtil.tokenize(fileName) + " directory = " + StringUtil.tokenize(directoryPath) + " noTrees";
if (usePrevious)
s += " usePrevious";
coord.export((FileInterpreterI)exporterTask, file, s);
}
String s = "file = " + StringUtil.tokenize(fileName) + " directory = " + StringUtil.tokenize(directoryPath) + " noTrees";
if (usePrevious)
s += " usePrevious";
coord.export((FileInterpreterI)exporterTask, file, s);
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ public boolean alterName(Taxa taxa, int it){
}
/*.................................................................................................................*/
public String getNameForMenuItem() {
return "Keep Prefix/Suffix of Taxon Name...";
return "Keep Only Prefix/Suffix of Taxon Name...";
}
/*.................................................................................................................*/
public String getName() {
return "Keep Prefix/Suffix of Taxon Name";
return "Keep Only Prefix/Suffix of Taxon Name";
}

/*.................................................................................................................*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/* Mesquite source code. Copyright 1997 and onward, W. Maddison and D. Maddison.
Disclaimer: The Mesquite source code is lengthy and we are few. There are no doubt inefficiencies and goofs in this code.
The commenting leaves much to be desired. Please approach this source code with the spirit of helping out.
Perhaps with your help we can be more than a few, and make Mesquite better.
Mesquite is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.
Mesquite's web site is http://mesquiteproject.org
This source code and its compiled class files are free and modifiable under the terms of
GNU Lesser General Public License. (http://www.gnu.org/copyleft/lesser.html)
*/
package mesquite.dmanager.RemoveTaxonPrefixSuffix;

import java.util.*;
import java.awt.*;

import mesquite.lib.*;
import mesquite.lib.duties.*;
import mesquite.lib.table.*;


public class RemoveTaxonPrefixSuffix extends TaxonNameAlterer {
String searchText=".";
MesquiteBoolean suffix = new MesquiteBoolean(true);

/*.................................................................................................................*/
public boolean startJob(String arguments, Object condition, boolean hiredByName){
return true;
}
/*.................................................................................................................*/
public int getVersionOfFirstRelease(){
return 351;
}
/*.................................................................................................................*/
public boolean getOptions(Taxa taxa, int firstSelected){
if (MesquiteThread.isScripting())
return true;
MesquiteInteger buttonPressed = new MesquiteInteger(1);
ExtensibleDialog queryDialog = new ExtensibleDialog(containerOfModule(), "Remove Prefix or Suffix", buttonPressed);
queryDialog.addLabel("Remove the prefix or suffix of taxon name", Label.CENTER);
SingleLineTextField searchField = queryDialog.addTextField("Delimiter:", searchText, 12, true);
Checkbox suffixBox = queryDialog.addCheckBox("Remove Suffix (otherwise Prefix)", suffix.getValue());
queryDialog.completeAndShowDialog(true);

boolean ok = (queryDialog.query()==0);

if (ok) {
searchText = searchField.getText();
suffix.setValue(suffixBox.getState());
}

queryDialog.dispose();

return ok;
}
/*.................................................................................................................*/
/** Called to alter the taxon name in a single cell. If you use the alterContentOfCells method of this class,
then you must supply a real method for this, not just this stub. */
public boolean alterName(Taxa taxa, int it){
boolean nameChanged = false;
String name = taxa.getTaxonName(it);
if (name!=null){
String s = "";
if (suffix.getValue()){ //removing suffix
int delim = name.lastIndexOf(searchText);
if (delim>=0){
name = name.substring(0, delim);
taxa.setTaxonName(it, name, false);
nameChanged = true;
}
}
else {
int delim = name.indexOf(searchText);
if (delim>=0){
name = name.substring(delim+1, name.length());
taxa.setTaxonName(it, name, false);
nameChanged = true;
}
}
}
return nameChanged;
}
/*.................................................................................................................*/
public String getNameForMenuItem() {
return "Remove Prefix/Suffix of Taxon Name...";
}
/*.................................................................................................................*/
public String getName() {
return "Remove Prefix/Suffix of Taxon Name";
}

/*.................................................................................................................*/
public String getExplanation() {
return "Remove Prefix or Suffix of Taxon Name.";
}
}





Loading

0 comments on commit 15c4f35

Please sign in to comment.