import mesquite.lib.characters.CharacterData; //导入方法依赖的package包/类
public boolean exportFile(MesquiteFile file, String arguments) { //if file is null, consider whole project open to export
writeTaxaWithAllMissing = false;
CharacterData data = findDataToExport(file, arguments);
Taxa t = null;
if (data != null)
t = data.getTaxa();
if (data ==null) {
showLogWindow(true);
logln("WARNING: No suitable data available for export to a file of format \"" + getName() + "\". The file will not be written.\n");
return false;
}
CharacterPartition partition = (CharacterPartition)data.getCurrentSpecsSet(CharacterPartition.class);
Taxa taxa = data.getTaxa();
boolean dataAnySelected = false;
if (data != null)
dataAnySelected =data.anySelected();
if (!MesquiteThread.isScripting())
if (!getExportOptions(dataAnySelected, taxa.anySelected()))
return false;
if (partition==null && !separateCodPos) {
discreetAlert("The data cannot be exported because partitions (character groups) are not assigned, and use of codon positions is not requested.");
return false;
}
int numTaxa = taxa.getNumTaxa();
int numTaxaWrite;
int countTaxa = 0;
for (int it = 0; it
if ((!writeOnlySelectedTaxa || taxa.getSelected(it)) && (writeTaxaWithAllMissing || data.hasDataForTaxon(it)))
countTaxa++;
numTaxaWrite = countTaxa;
int numChars = 0;
StringBuffer outputBuffer = new StringBuffer(numTaxa*(20 + numChars));
if (data != null){
numChars = data.getNumChars();
int numCharWrite = data.numberSelected(this.writeOnlySelectedData);
outputBuffer.append(Integer.toString(numTaxaWrite)+" ");
outputBuffer.append(Integer.toString(numCharWrite)+this.getLineEnding());
int blockSize=50;
exportBlock(taxa, data, outputBuffer, 0, numChars);
}
saveExportedFileWithExtension(outputBuffer, arguments, "phy");
String cfgString = getPartitionFinderCFGText(data, partition, getExportedFileName());
String cfgFilePath = getExportedFilePath();
cfgFilePath=StringUtil.getAllButLastItem(cfgFilePath, MesquiteFile.fileSeparator)+MesquiteFile.fileSeparator+"partition_finder.cfg";
MesquiteFile.putFileContents(cfgFilePath, cfgString, true);
return true;
}