BEAST2 and Intellij

The instructions here did not work for me. I kept getting Intellij projects where the BEAST2 would not compile due to libraries not found. I am using IDEA Community Edition 13.0.1 under Windows 7. The following is what I did on 2014-02-28.


I downloaded zip from and unpacked as beast2p1p1. There seem to be various places and ways to get the BEAST2 source. I don't know which is recommended. When I used SVN via Intellij, I kept getting bothered by SVN for my own code.

Make BEAST2 in Intellij

I suspect this is not necessary, but maybe best to make sure this works first.

Set up project for package DISSECT

To get BEAST2 to recognise new model

At this point, I could add code in Intellij that extends BEAST2 classes, and compile, but when BEASTMain is run from Intellij, the classes are not found. There has to be a link from the XML to where BEAST2 looks for them. By following source code in debugger, I found it was looking in \DISSECT\out\production\lib for a jar file. Also it checks for existing BEAST2 classes in the jar, and rejects jars containing them, so must put only DISSECT classes here.

Added an artifact (Menu - File - Project Structure...) to make a DISSECT.jar in \DISSECT\out\production\lib. This makes a jar containing package dissect containing BirthDeathCollapseModel.class. It seems important to make sure the artifact is always built before code is tested, so 'Build on make' ticked.

Edited copy of testStarBeast.xml (testStarBeast-b.xml) so that only one indiv per species. (*BEAST is currently bugged in Beauti, see user group.) Then replaced

<distribution id="SpeciesTreeDivergenceTimesPrior" spec="speciation.YuleModel" tree='@speciesTree'/>
  <birthDiffRate spec='parameter.RealParameter' id="birthRate" value='213.2021' lower='0' upper='10000'/>

with my own model BirthDeathCollapseModel which extends YuleModel. It is the spec="dissect.BirthDeathCollapseModel" that is key.

<distribution id="SpeciesTreeDivergenceTimesPrior" spec="dissect.BirthDeathCollapseModel" tree='@speciesTree' collapseHeight='0.00003'>
  <birthDiffRate spec='parameter.RealParameter' id="birthRate" value='100.0' lower='0' upper='10000' />
  <relativeDeathRate spec='parameter.RealParameter' id="relativeDeathRate" value='0.5' lower='0' upper='1.0' />
  <originHeight id="originHeight" spec="parameter.RealParameter" value="100.0" upper="10000000" lower="0"/>
  <collapseWeight spec='parameter.RealParameter' id="collapseWeight" value='0.5' lower='0' upper='1.0' />

I also copied DISSECT.jar into the user version of BEAST2, in \BEAST.v2.1.1\BEAST\lib and that ran too.