本文整理汇总了Java中beast.core.BEASTObject类的典型用法代码示例。如果您正苦于以下问题:Java BEASTObject类的具体用法?Java BEASTObject怎么用?Java BEASTObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BEASTObject类属于beast.core包,在下文中一共展示了BEASTObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDescriptions
import beast.core.BEASTObject; //导入依赖的package包/类
/**
* Check all plug-ins have a proper description so that
* everything is at least moderately well documented. *
*/
@Test
public void testDescriptions() {
final List<String> pluginNames = AddOnManager.find(beast.core.BEASTObject.class, AddOnManager.IMPLEMENTATION_DIR);
final List<String> undocumentedPlugins = new ArrayList<String>();
for (final String beastObjectName : pluginNames) {
try {
final Class<?> pluginClass = Class.forName(beastObjectName);
final Annotation[] classAnnotations = pluginClass.getAnnotations();
boolean hasSatisfactoryDescription = false;
for (final Annotation annotation : classAnnotations) {
if (annotation instanceof Description) {
final Description description = (Description) annotation;
final String descriptionString = description.value();
if (isProperDocString(descriptionString)) {
hasSatisfactoryDescription = true;
}
}
}
if (!hasSatisfactoryDescription) {
undocumentedPlugins.add(beastObjectName);
}
} catch (Exception e) {
}
}
assertTrue("No proper description for: " + undocumentedPlugins.toString(), undocumentedPlugins.size() == 0);
}
示例2: testInputTipText
import beast.core.BEASTObject; //导入依赖的package包/类
/**
* Check all inputs of plug-ins have a proper tip text, again
* to facilitate proper documentation. *
*/
@Test
public void testInputTipText() {
final List<String> pluginNames = AddOnManager.find(beast.core.BEASTObject.class, AddOnManager.IMPLEMENTATION_DIR);
final List<String> undocumentedInputs = new ArrayList<String>();
for (final String beastObjectName : pluginNames) {
try {
final BEASTObject beastObject = (BEASTObject) Class.forName(beastObjectName).newInstance();
final List<Input<?>> inputs = beastObject.listInputs();
for (final Input<?> input : inputs) {
boolean hasSatisfactoryDescription = false;
final String tipText = input.getTipText();
if (isProperDocString(tipText)) {
hasSatisfactoryDescription = true;
}
if (!hasSatisfactoryDescription) {
undocumentedInputs.add(beastObjectName + ":" + input.getName());
}
}
} catch (Exception e) {
}
}
assertTrue("No proper input tip text (at least " + N_WORDS + " words and " + N_CHARS + " characters) for: "
+ undocumentedInputs.toString(), undocumentedInputs.size() == 0);
}
示例3: initAndValidate
import beast.core.BEASTObject; //导入依赖的package包/类
@Override
public void initAndValidate() {
// Assemble name->param map
Map<String, Function> functionsMap = new HashMap<>();
for (Function func : functionsInput.get()) {
BEASTObject obj = (BEASTObject)func;
functionsMap.put(obj.getID(), func);
}
// Build AST from expression string
ANTLRInputStream input = new ANTLRInputStream(expressionInput.get());
ExpressionLexer lexer = new ExpressionLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lexer);
ExpressionParser parser = new ExpressionParser(tokens);
parseTree = parser.expression();
// Create new visitor for calculating expression values:
visitor = new ExpCalculatorVisitor(functionsMap);
update();
}
示例4: initAndValidate
import beast.core.BEASTObject; //导入依赖的package包/类
@Override
public void initAndValidate() {
// Assemble name->param map
Map<String, Function> functionsMap = new HashMap<>();
for (Function func : functionsInput.get()) {
BEASTObject obj = (BEASTObject)func;
functionsMap.put(obj.getID(), func);
}
// Build AST from expression string
ANTLRInputStream input = new ANTLRInputStream(expressionInput.get());
ExpressionLexer lexer = new ExpressionLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lexer);
ExpressionParser parser = new ExpressionParser(tokens);
parseTree = parser.expression();
// Create new visitor for calculating expression values:
visitor = new ExpCalculatorVisitor(functionsMap);
update();
if (res.length != 1)
throw new IllegalArgumentException("ExpCalculatorDistribution "
+ "expressions must be single-valued.");
}
示例5: findAlignments
import beast.core.BEASTObject; //导入依赖的package包/类
/**
* Return first alignment object found underneath BEASTObject obj.
*
* @param obj
* @return Alignment object if found, null otherwise.
* @throws IllegalArgumentException
* @throws IllegalAccessException
*/
private static Set<Alignment> findAlignments(BEASTObject obj) throws IllegalArgumentException, IllegalAccessException {
Set<Alignment> alignments = new HashSet<>();
for (Input input : obj.listInputs()) {
if (input.get() != null) {
if (input.get() instanceof Alignment)
alignments.add((Alignment)input.get());
if (input.get() instanceof List) {
for (Object child : (List)input.get()) {
if (child instanceof BEASTObject) {
alignments.addAll(findAlignments((BEASTObject)child));
}
}
}
if (input.get() instanceof BEASTObject) {
alignments.addAll(findAlignments((BEASTObject)(input.get())));
}
}
}
return alignments;
}
示例6: main
import beast.core.BEASTObject; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
XMLParser parser = new XMLParser();
BEASTObject o = parser.parseFile(new File(args[0]));
if (!(o instanceof TreeDrawingGrid)) {
throw new RuntimeException("Expected top level element of type TreeDrawingGrid");
}
TreeDrawingGrid grid = (TreeDrawingGrid) o;
JFrame frame = new JFrame();
TreeDrawPanel panel = new TreeDrawPanel(grid);
frame.add(panel);
frame.setSize(1024, 768);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
示例7: evalFunctionInputs
import beast.core.BEASTObject; //导入依赖的package包/类
public static void evalFunctionInputs(Interpreter interpreter, List<Function> functions) {
try {
for (Function function : functions) {
String id = ((BEASTObject) function).getID();
if (function instanceof NamedFunction) {
id = ((NamedFunction)function).getName();
interpreter.set(id, ((NamedFunction)function).getFunction());
} else {
interpreter.set(id, function);
}
}
} catch (EvalError e) {
throw new RuntimeException("Error in BSHOperator: " + e.getMessage());
}
}
示例8: getParameterIds
import beast.core.BEASTObject; //导入依赖的package包/类
public List<String> getParameterIds() {
List<String> paramIDs = new ArrayList<>();
paramIDs.add(((BEASTObject) popSizes).getID());
paramIDs.add(groupSizes.getID());
return paramIDs;
}
示例9: makeJavaDoc
import beast.core.BEASTObject; //导入依赖的package包/类
/**
* print @Description and Input.description info so that it can
* be inserted in the code before creating Javadoc documentation
* for the Beast II SDK.
*/
void makeJavaDoc() {
for (String beastObjectName : m_beastObjectNames) {
try {
BEASTObject beastObject = (BEASTObject) Class.forName(beastObjectName).newInstance();
Log.info.println(beastObjectName + ":@description:" + beastObject.getDescription());
for (Input<?> input : beastObject.listInputs()) {
Log.info.println(beastObjectName + ":" + input.getName() + ":" + input.getTipText());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例10: getImplementations
import beast.core.BEASTObject; //导入依赖的package包/类
/**
* Find all beastObjects that are derived from given beastObject *
*/
String[] getImplementations(BEASTObject beastObject) {
String name = beastObject.getClass().getName();
List<String> implementations = new ArrayList<>();
for (String beastObjectName : m_beastObjectNames) {
try {
if (!beastObjectName.equals(name) && beastObject.getClass().isAssignableFrom(Class.forName(beastObjectName))) {
implementations.add(beastObjectName);
}
} catch (ClassNotFoundException e) {
}
}
return implementations.toArray(new String[0]);
}
示例11: initAndValidate
import beast.core.BEASTObject; //导入依赖的package包/类
@Override
public void initAndValidate() {
// determine dimension
int dimension = 0;
for (BEASTObject beastObject : m_values.get()) {
if (!(beastObject instanceof Function)) {
throw new IllegalArgumentException("Input does not implement Valuable");
}
dimension += ((Function) beastObject).getDimension();
}
m_fValues = new double[dimension];
}
示例12: recompute
import beast.core.BEASTObject; //导入依赖的package包/类
/**
* collect values of the compounds into an array *
*/
private void recompute() {
int k = 0;
for (BEASTObject beastObject : m_values.get()) {
Function valuable = (Function) beastObject;
if (beastObject instanceof StateNode) {
valuable = ((StateNode) beastObject).getCurrent();
}
int dimension = valuable.getDimension();
for (int i = 0; i < dimension; i++) {
m_fValues[k++] = valuable.getArrayValue(i);
}
}
m_bRecompute = false;
}
示例13: testInputTypeCanBeSet
import beast.core.BEASTObject; //导入依赖的package包/类
@Test
public void testInputTypeCanBeSet() throws Exception {
List<String> beastObjectNames = AddOnManager.find(beast.core.BEASTObject.class,
AddOnManager.IMPLEMENTATION_DIR);
List<String> failingInputs = new ArrayList<String>();
for (String beastObjectName : beastObjectNames) {
try {
BEASTObject beastObject = (BEASTObject) Class.forName(beastObjectName).newInstance();
List<Input<?>> inputs = beastObject.listInputs();
for (Input<?> input : inputs) {
if (input.getType() == null) {
try {
input.determineClass(beastObject);
if (input.getType() == null) {
failingInputs.add(beastObject + ":" + input.getName());
}
} catch (Exception e2) {
failingInputs.add(beastObject + ":" + input.getName());
}
}
}
} catch (Exception e) {
// ignore
}
}
assertTrue(
"Type of input could not be set for these inputs (probably requires to be set by using the appropriate constructure of Input): "
+ failingInputs.toString(),
failingInputs.size() == 0);
}
示例14: pluginListAsString
import beast.core.BEASTObject; //导入依赖的package包/类
private String pluginListAsString(List<?> list) {
if (list.size() == 0) {
return "";
}
StringBuffer bf = new StringBuffer();
for (Object o : list) {
BEASTObject beastObject = (BEASTObject) o;
bf.append('"');
bf.append(beastObject.getID());
bf.append("\", ");
}
String str = bf.toString();
return "(" + str.substring(0, str.length()-2) + ");";
}
示例15: assertTraceLogEqual
import beast.core.BEASTObject; //导入依赖的package包/类
void assertTraceLogEqual(String... ids) {
System.err.println("assertTraceLogEqual");
Logger logger = (Logger) doc.pluginmap.get("tracelog");
List<BEASTObject> logs = logger.loggersInput.get();
asserListsEqual(logs, ids);
}