The BioModelAnalyzer is a tool that allows biologists to easily and quickly build complex models of biological behaviour, and to analyse them using techniques derived from the field of formal verification. Its backend is written in F#, and its graphical frontend is an HTML5 application. It uses the SMT solver Z3.
This consists of
- An HTML5 user interface designed for rapid model construction and analysis, and
corresponding REST API application performing analysis and simulation (solution
bmaclient). - A command line tool for access to a wide range of analysis algorithms (solution
BioCheckConsole) - A command line hybrid physical/executable simulator (solution
Athene), as used in “Emergent stem cell homeostasis in the C. elegans germline is revealed by hybrid modeling”. - A chat bot intended for user education in linear temporal logic (folder
ChatBot) - A set of related tools for formally verifying biological models
The goal of the project is to provide access to biologists to powerful, newly developed algorithms without requiring expertise in the underlying computer science. This is achieved by bespoke user interfaces and novel methods of interaction. The aims of the project are to increase the range of modelling and analysis approaches made available through the tool, and to extend the interface to increase the ease of user adoption.
The user interface is considered as production quality, whilst all other tools are regarded as prototypes in different stages of readiness.
The three goals on the project roadmap are to add more advanced library and comparison functions to the user interface, to expand the range of concurrency types available in the tool, and to add support for alternative model formats. This are intended to be addressed over the next 2-3 years.
Contributions are welcome! Bugs or feature requests should be reported to the team,
whilst code contributions should follow the instructions in CONTRIBUTING.md.
Powershell scripts in the root of repository (PowerShell 5.0 or above is required):
PrepareRepository.ps1prepares freshly cloned repository for the first use. See Build and test.build.ps1buildsbmaclientsolution mentioned below.run.ps1starts BioModelAnalyzer (both API and client web applications) on local machine using OWIN. See Self-hosting application using OWIN.BuildAndRun.ps1consecutively runsPrepareRepository.ps1,build.ps1, andrun.ps1in order to start the BMA app on local machine right after cloning the repository.DeployAzure.ps1deploys BMA in Azure. See Deployment in Azure App Services.
/sln - Visual Studio solutions:
-
bmaclientcontains 2 web applications:bma.clientis a web site designed for rapid biological model construction and analysis. It usesApiServerto perform simulation and analysis of models.ApiServeris a REST API App which performs simulation and analysis of biological models. It is documented using Swagger, see/docs/ApiServer.yaml.
-
BioCheckConsoleis a command line tool for access to a wide range of analysis algorithms. -
Atheneis a command line hybrid physical/executable simulator, as used in “Emergent stem cell homeostasis in the C. elegans germline is revealed by hybrid modeling”. -
ClientStatis a command line tool that reads user activity statistics from Azure Storage Account, writes to CSV files and displays as charts. -
bmaclient-lracontains Azure Cloud ServiceApiService. This is a worker role that performs long-running LTL polarity checks. Note that this feature is yet unsupported by the BioModelAnalyzer web client application. This solution requires Microsoft Azure SDK for .NET 2.9 to be installed. -
fs-schedulercontains implementation of task scheduler based on Azure Storage Account. The scheduler enables fair sharing of computation resources between multiple applications. An Azure Worker is used to perform tasks. This scheduler is used inbmaclient-lrato perform long-running operations.
/ChatBot - A chat bot intended for user education in linear temporal logic.
/src - Visual Studio projects. A project can be shared between multiple solutions.
/docs - Project documentation.
-
ApiServer.yamldescribingApiServerREST API. It follows Swagger 2.0 specs. -
BMA Deployment Overview.pptxdescribes architecture of BioModelAnalyzer backend and frontent.
/ext/FParsec contains third party source code of FParsec, a parser combinator library for F#.
BioModelAnalyzer depends on this library.
/ext/CUDD contains third party source code of CUDD, a binary decision diagram library for C++.
Some functionality of BioModelAnalyzer depends on this library.
/Models contains biological models that can be imported from the BioModelAnalyzer application.
- Run the powershell script
PrepareRepository.ps1once after cloning the repository. PowerShell 5.0 or above is required.
The rest of building, testing, and deployment processes heavily rely on this first step having been performed.
The script downloads paket and runs it in order to fetch the external dependencies.
Also the script creates local files /src/ApiServer/unity.azure-appservice.config and
/src/ApiService/ServiceConfiguration.Cloud.cscfg with default Azure deployment configurations.
These files are configured to be ignored by git and will not be committed to the repository, thus
they may contain Azure Storage Account connection strings.
-
Visual Studio 2015/2017. If you don't have Visual Studio 2015/2017, you can install the free Visual Studio 2015/2017 Community. Currently the build process relies on tools that come with Visual Studio 2015/2017 such as Microsoft .NET Framework 4.5, Microsoft Build Tools, Web Applications Build Targets, Visual F# Tools, TypeScript compiler and Visual C++.
-
Visual F# Tools 4.0. The Visual F# Tools are installed automatically when you first create or open an F# project in Visual Studio. If you run the build script without using Visual Studio IDE you can install it directly as a separate download.
-
TypeScript 1.8. Certain versions of Visual Studio can install different versions of TypeScript by default, so you need to install TypeScript 1.8 from Microsoft web site.
After the repository is prepared using the script PrepareRepository.ps1,
you can build the solutions using Visual Studio or msbuild.
Also there are helpful build-related scripts located in the root of repository:
build.ps1buildsbmaclientsolution which contains BioModelAnalyzer Web API and Web client applications.run.ps1starts both BioModelAnalyzer Web API and Web client applications on local machine using OWIN.BuildAndRun.ps1consecutively runsPrepareRepository.ps1,build.ps1, andrun.ps1in order to start the BMA applications on local machine.
Solution /sln/bmaclient contains following test projects:
-
BackEndTestschecks that simulation and analysis of corner cases work correctly. It performs same checks twice: by calling appropriate methods directly and by sending HTTP requests to self-hosted ApiServer controllers. -
BmaJobsTestsperforms simulations and analysis for requests represented as files in/src/BmaTests.Common/Simulation,/src/BmaTests.Common/Analysis,/src/BmaTests.Common/CounterExamplesand/src/BmaTests.Common/LTLQueries. Results are checked against response files in the same folders. -
bma.packagecontains Jasmine-based unit tests forbma.clientcode. All Web App scripts tests are in the foldertestof projectbma.package.
Solution /sln/bmaclient contains test project WebApiTests that sends requests
represented as files in
/src/BmaTests.Common/Simulation, /src/BmaTests.Common/Analysis,
/src/BmaTests.Common/CounterExamples and /src/BmaTests.Common/LTLQueries
to the deployed ApiServer and checks the responses.
Server url is configured in the WebApiTests.fs.
This allows to check if the deployed server correctly performs operations.
End-to-end tests for bma.client web application are located in /src/CodedUITests.
They are based on Protractor framework.
- Install following extensions to Visual Studio (menu
Tools/Extensions and Updates):- NUnit Test Adapter 2.0.0 (NOT NUnit 3 Test Adapter)
- Chutzpah Test Adapter for Test Explorer
- Open and build solution
/sln/bmaclient. - Open Test Explorer from menu
Test/Windowsand run the tests. Note thatWebApiTestsrequire url of runningApiServerto be configured in the WebApiTests.fs; otherwise the tests fail.
Note that running tests for x64 requires setting default processor architecture for tests to x64.
In Visual Studio 2015/2017, use menu Test/Test Settings/Default Processor Architecture.
Here we describe how to run and deploy BioModelAnalyzer which consists of two web applications: ApiServer and bma.client.
- Local run using IIS Express.
- Self-hosting standalone application using OWIN.
- Deployment in Azure App Services.
Please see /docs/BMA Deployment Overview.pptx for details about BioModelAnalyzer architecture.
In the followings guidelines we will use Visual Studio 2015/2017.
The solution that produces the web applications is located in /sln/bmaclient.
Please make sure that you have run the powershell script ./PrepareRepository.ps1 as described
in the Build and test section to prepare the repository.
This deployment is useful when developing the applications. It allows easily debugging the applications using Visual Studio.
Use Visual Studio interface to select the solution platform, either x86 or x64.
In Visual Studio menu, click Tools/Options/Projects and Solutions/Web Projects and check or uncheck the option
Use the 64 bit version of IIS Express for web sites and projects.
Open ApiServer/Web.config and uncomment the unity configuration source unity.web.config
to write the activity and failure logs to local CSV files
or unity.trace-loggers.config to write logs to System.Diagnostics.TraceSource:
<unity configSource="unity.web.config"/>OR
<unity configSource="unity.trace-loggers.config"/>Make sure that only one <unity /> configuration is uncommented. See more details in
the Activity and failure logs section of this document.
Open Properties for the project ApiServer and go to section Web.
In the group Servers, choose IIS Express and check the Project Url text which contains
url of the ApiServer application. By default, it is http://localhost:8223.
In the context menu for the ApiServer, click on the Set as StartUp Project command. The project name should
become bold in the Solution Explorer.
In menu Debug click either Start Debugging or Start Without Debugging.
After the project is built and run, a browser window should open with the project url.
Most browsers normally show HTTP Error 403.14 - Forbidden because the root of the site is forbidden
and no default document is configured.
Now the ApiServer is available at http://localhost:8223. Next we will run bma.client web site which
allows using the BioModelAnalyzer HTML application to build and analyze models.
We should specify url of the ApiServer for the bma.client to send user requests, such as model analysis
and simulation. Edit the bma.client/Web.config so the <appSettings> contains key BackEndUrl:
<appSettings>
<add key="BackEndUrl" value="http://localhost:8223" />
</appSettings> Note that other two app settings, LiveAppId and RedirectUrl, are for integration with OneDrive which is unavailable
for local host and thus can be ignored here.
Open Properties for the project bma.client and go to section Web.
In the group Servers, choose IIS Express.
In the context menu for the bma.client, click on the Set as StartUp Project command. The project name should
become bold in the Solution Explorer.
After the project is built and run, a browser window should open with the project url.
Normally you see the start-up screen with logo and Launch Tool button.
Also you can click Help link at the top and load one of the examples.
You can run WebApiTests for the deployed ApiServer to check whether it works correctly;
see section Deployment tests in this document.
BMA can be hosted using OWIN. This is convenient for development and debugging, and it allows to use BMA standalone.
For those purposes the repository contains bma.selfhost application.
It hosts BMA using OWIN making both API and UI available at http://localhost:8224/ and it stores logs in
local files (see Activity and failure logs for details).
You can start it either by running run.ps1 powershell script located in the root of repository
(in which case your system's architecture will be used)
or you can find it within /sln/bmaclient solution. The script will also open a browser window with BMA UI
for you as soon as it is available. If you choose not to use the script and to
run the application directly instead, then, in order to access BMA UI you'll have to
open http://localhost:8224/ in your browser.
You can run WebApiTests with server url set to http://localhost:8224/ to check if it works correctly;
see Deployment tests for details.
This deployment allows to publish BMA web application for public use. Azure allows scaling the applications and distributes demand between multiple copies of an application.
Included powershell script DeployAzure.ps1 quickly deploys BMA using a free tier App Service plan to host API and UI and a locally-redundant storage account for logging.
Simply run in powershell console
.\DeployAzure.ps1 <name>
and log into Azure when prompted to deploy UI to https://<name>.azurewebsites.net and API to https://<name>api.azurewebsites.net.
It's possible to customize the names of deployed resources using script arguments. Run
Get-Help .\DeployAzure.ps1 -detailed
for details.
- Open
ApiServer/Web.configand uncomment the unity configuration sourceunity.azure-appservice.configto write the activity and failure logs to Azure Storage Account:
<unity configSource="unity.azure-appservice.config"/>Make sure that only one <unity /> configuration is uncommented.
- Edit
ApiServer/unity.azure-appservice.configand add connection strings for Azure Storage Account where the acitivities and failure logs will be accumulated. Read the Activity and failure logs section of this document for details.
The first time you publish the application you need to create an Azure App Service,
choose a resource group and a service plan. All these settings will be saved as a publish profile file
in the folder /src/ApiServer/Properties/PublishProfiles, so next deployments will be very simple.
- In Visual Studio, in the context menu for the
ApiServerproject, clickPublish... - Select
Microsoft Azure App Serviceas a publish target. - In the
App Servicewindow, you should either create new app service (if you do this first time), or choose previously created app service. For the first time, clickNew. - Click
Change Typeand chooseAPI App. - Enter
API App Name, for example,BioModelAnalyzerAPI. - Choose your Azure Subscription.
- Choose existing or create new Resource Group. In Azure, related resources such as app services, storage accounts and service plans are logically grouped to be managed as a single entity. So it makes sense to create a Resource Group for BMA.
- Choose existing or create new App Service Plan. The plan determines power and cost of the services. If you choose free plan, you cannot use x64 platform.
- Click
Createand wait until all deployment steps completed. - In the
Publishwindow, make sure thatPublish methodisWeb Deploy. Check site name and clickNext. - Select configuration, e.g.
Release - x86. If you need x64, please read section Choosing the platform architecture (32-bit or 64-bit) of this document, because there are certain requirements for service plan. - Click
Next, thenPublish. Visual Studio will start building the solution for the selected configuration. If build succeeds, the application will be deployed in Azure and Visual Studio will open a browser for the application's url, e.g.http://biomodelanalyzerapi.azurewebsites.net/.
Since the publish profile exists, deployment update is very simple:
- In Visual Studio, in the context menu for the
ApiServerproject, clickPublish.... - In the
Publishwindow, clickPublish. - If the password wasn't cached on your machine, Visual Studio will ask your for the password.
To find the password,
- Open https://portal.azure.com.
- Click
App Services. - Click the published Api App, for example,
BioModelAnalyzerAPI. - Click
...Morebutton and thenGet publish profile. - In the downloaded file, find
userPWDand use it as the password.
In the Publish window it is possible to click Profile button and create another publish profile.
You can then choose between existing publish profiles.
So far the API App is published. Next we should publish web application bma.client.
If you want to enable OneDrive functionality (allow users to use their OneDrive as model storage),
you have to register your deployment at OneDrive and modify bma.client's Web.config file accordingly.
To do so,
- Go to dev.onedrive.com
- Go to App Registration
- Register your app for OneDrive (not OneDrive for Business) by following the corresponding instructions on the page
- Add Web platform with redirect URI of the form "https://<domain>/html/callback.html", where <domain> is the domain you're deploying the client app on (e.g. bmainterface.azurewebsites.net)
- Add Application Id and RedirectUrl to the
Web.configof the projectbma.client. Note that it is required thatRedirectUrluseshttpsand BMA web site is also opened usinghttps.
<configuration>
<appSettings>
<add key="LiveAppId" value="..." /> <!--Live app ID goes here. Get it from the onedrive reg site-->
<add key="RedirectUrl" value="https://<domain>/html/callback.html" />
...
</appSettings>
...
</configuration>There is no need to register new application if you just want to move to a new domain.
You only need to update the redirect URI (both in the settings of your OneDrive App and the Web.config file).
Edit Web.config to provide url of the published ApiServer. BackEndUrl should be URI
of the ApiServer, e.g. http://biomodelanalyzerapi.azurewebsites.net/.
<configuration>
<appSettings>
<add key="BackEndUrl" value="--- url of the ApiServer ---" />
...
</appSettings>
...
</configuration>If you publish new version of BioModelAnalyzer application, you need to increase its version number.
To do that, edit bma.client/version.txt.
The first time you publish the application you need to create an Azure App Service,
choose a resource group and a service plan. All these settings will be saved as a publish profile file
in the folder /src/bma.client/Properties/PublishProfiles, so next deployments will be very simple.
- In Visual Studio, in the context menu for the
bma.clientproject, clickPublish... - Select
Microsoft Azure App Serviceas a publish target. - In the
App Servicewindow, you should either create new app service (if you do this first time), or choose previously created app service. For the first time, clickNew. - Click
Change Typeand chooseWeb App. - Enter
Web App Name, for example,BioModelAnalyzerClient. - Choose same Azure Subscription as for
ApiServer. - Choose the Resource Group you previously selected for the
ApiServer. - Choose the App Service Plan you previously selected for the
ApiServer. - Click
Createand wait until all deployment steps completed. - In the
Publishwindow, make sure thatPublish methodisWeb Deploy. Check site name and clickNext. - Select configuration. It is not significant for this application, so you can choose
Release - x86. - Click
Next, thenPublish. Visual Studio will start building the solution for the selected configuration. If build succeeds, the application will be deployed in Azure and Visual Studio will open a browser for the application's url. If you enabled OneDrive, you must usehttps, e.g.http://biomodelanalyzerclient.azurewebsites.net/, otherwise OneDrive will fails.
Since the publish profile exists, deployment update is very simple:
- In Visual Studio, in the context menu for the
bma.clientproject, clickPublish... - In the
Publishwindow, clickPublish. - If the password wasn't cached on your machine, Visual Studio will ask your for the password.
To find the password,
- Open https://portal.azure.com.
- Click
App Services. - Click the published Web App, for example,
BioModelAnalyzerClient. - Click
...Morebutton and thenGet publish profile. - In the downloaded file, find
userPWDand use it as the password.
In the Publish window it is possible to click Profile button and create another publish profile.
You can then choose between existing publish profiles.
After the project is deployed, a browser window should open with the project url.
Normally you see the start-up screen with logo and Launch Tool button.
Also you can click Help link at the top and load one of the examples.
You can run WebApiTests for the deployed ApiServer to check whether it works correctly;
see section Deployment tests in this document.
In Azure, a scale up operation allows to choose bigger or smaller server depending on your needs. A scale out operation creates multiple copies of a web application and adds a load balancer to distribute demand between them. The article Scale up an app in Azure shows how to scale an application in Azure App Service.
In Visual Studio, change current platform for the solution to either x86 or x64.
Note that applications built for x86 work on x64 platform, but not vice versa.
If you deploy it then, this selection must correspond to settings of web hosting or Azure application settings,
otherwise you will get Internal Server Error when trying to access the services.
This error is caused by BadImageFormatException thrown by the web application.
In Azure App Service, the 64-bit platform can be enabled in Basic plans and higher.
Open Azure Portal, find and click the deployed web application and then open its Application Settings and check Platform.
To run the applications using IIS Express in Visual Studio,
open Tools/Options/Projects and Solutions/Web Projects and check or uncheck the option
Use the 64 bit version of IIS Express for web sites and projects.
ApiServer exposes /api/activitylog endpoint to gather user activity statistics from BMA client. Browser sends
a message to this endpoint when a user closes the BMA page.
Also, ApiServer stores information about failures during simulations and analysis performed for BMA client. It saves the failed request and error message so it is possible to reproduce the error case.
Location and format of logs is determined by the Unity config files used by ApiServer and depend on deployment type. See Unity configuration file samples in following sections.
-
Azure deployment (both App Service or Cloud Service) should use Storage Account to store logs. To do that register
BMAWebApi.ActivityAzureLoggerandBMAWebApi.FailureAzureLoggertypes in the ApiServer Unity configuration file. You will get:- Activity logs are stored in the
ClientActivitytable of the given Storage Account. - Failure logs are stored in the
ServiceFailurestable of the given Storage Account. Table rows reference blobs of thefailurescontainer which keep both failed request and response.
The
/sln/ClientStatsolution builds a command line tool that allows to retrieve statistics from a Storage Account and display it as charts.It is highly advised not to commit the configuration files containing Azure connection strings to a public repository.
- Activity logs are stored in the
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
<container>
<register type="BMAWebApi.IFailureLogger, BMAWebApi"
mapTo="BMAWebApi.FailureAzureLogger, BMAWebApi">
<constructor>
<param name="connectionString"
value="-- Storage Account connection string --" />
</constructor>
</register>
<register type="BMAWebApi.IActivityLogger, BMAWebApi"
mapTo="BMAWebApi.ActivityAzureLogger, BMAWebApi">
<constructor>
<param name="connectionString"
value="-- Storage Account connection string --" />
</constructor>
</register>
</container>
</unity>-
Web hosting deployment (including local IIS Express) should use local files to store logs. To do that register
BMAWebApi.ActivityFileLoggerandBMAWebApi.FailureFileLoggertypes in the ApiServer Unity configuration file. You will get:- Activity logs are stored as a CSV file
activity_*date-time*.csvin a folder defined in the unity configuration file. - Failure logs are stored as a CSV file
failures_*date-time*.csvin a folder defined in the unity configuration file. Along with the file, there is a folderrequestswith files keeping the failed requests. The CSV table rows reference these files by names.
The folders are created in the Web application root directory.
- Activity logs are stored as a CSV file
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
<container>
<register type="BMAWebApi.IFailureLogger, BMAWebApi"
mapTo="BMAWebApi.FailureFileLogger, BMAWebApi">
<constructor>
<param name="dir"
value="Failures" />
<param name="tryServerPath"
value="True" />
</constructor>
</register>
<register type="BMAWebApi.IActivityLogger, BMAWebApi"
mapTo="BMAWebApi.ActivityFileLogger, BMAWebApi">
<constructor>
<param name="dir"
value="ActivityLog" />
<param name="tryServerPath"
value="True" />
</constructor>
</register>
</container>
</unity>- Alternatively, it is possible to write activity and failure logs to
System.Diagnostics.TraceSource. To do that registerBMAWebApi.ActivityTraceLoggerandBMAWebApi.FailureTraceLoggertypes in the ApiServer Unity configuration file. The loggers will useTraceSource.TraceData()method with the giveneventIdand event typeInformation.
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
<container>
<register type="BMAWebApi.IFailureLogger, BMAWebApi"
mapTo="BMAWebApi.FailureTraceLogger, BMAWebApi">
<constructor>
<param name="traceSourceName"
value="BioModelAnalyzer" />
<param name="eventId"
value="1" />
</constructor>
</register>
<register type="BMAWebApi.IActivityLogger, BMAWebApi"
mapTo="BMAWebApi.ActivityTraceLogger, BMAWebApi">
<constructor>
<param name="traceSourceName"
value="BioModelAnalyzer" />
<param name="eventId"
value="2" />
</constructor>
</register>
</container>
</unity>Here we describe how to release new version of the BioModelAnalyzer application which is
represented by the solution /sln/bmaclient.
- Update
/src/bma.client/version.txtso it contains new version number for the BioModelAnalyzer release. - Add new section to
/RELEASE_NOTES.mdwhich describes the releasing version and contains summary, new features and bug fixes lists. - Build the bmaclient solution in the Release configuration both for x86 and x64 platforms. See How to Build.
- Run regression tests for both platforms. All tests must pass. See How to Test and Validate.
- Run BioModelAnalyzer locally or make test deployment then run deployment and end-to-end tests. See Run and deploy.
- Create a GitHub release. See Creating Releases.
- Deploy new version of BioModelAnalyzer to a production server.
- Test the production deployment using deployment tests.