Synapse is a collaborative, open-source research platform that allows teams to share data, track analyses, and collaborate.
- More info: Synapse Homepage
Nextflow is a reactive workflow framework and a programming Domain-specific language that eases the writing of data-intensive computational pipelines.
- More info: Nextflow Homepage
The NIO.2 API introduced in the Java SE 7 release provides the ability to develop a custom file system provider that can be used to manage file system objects. A file system is essentially a container with organized, homogenous elements referred to as file system objects. A file system provides access to file system objects. A file system object can be a file store, file, or directory. A file store is a volume or partition in which files are stored. For example, in a native file system such as on the Windows platform, commonly known drives like c: or d: are file stores. On the Solaris operating system, / (root) and mounted directories are considered file stores.
- More info: Oracle Java Documentation
This project implements a Nextflow plugin named nf-synapse that creates the support for Synapse's Entity storage with customized Synapse File System Provider.
-
settings.gradleGradle project settings.
-
plugins/nf-synapseThe plugin implementation base directory.
-
plugins/nf-synapse/build.gradlePlugin Gradle build file. Project dependencies should be added here.
-
plugins/nf-synapse/src/resources/META-INF/MANIFEST.MFManifest file defining the plugin attributes e.g. name, version, etc. The attribute
Plugin-Classdeclares the plugin main class. This class should extend the base classnextflow.plugin.BasePlugine.g.nextflow.synapse.SynapsePlugin. -
plugins/nf-synapse/src/resources/META-INF/extensions.idxThis file declares one or more extension classes provided by the plugin. Each line should contain a Java class fully qualified name implementing the interface
org.pf4j.ExtensionPoint(or a sub-interface). -
plugins/nf-synapse/src/mainThe plugin implementation sources.
-
plugins/nf-synapse/src/testThe plugin unit tests.
ExtensionPoint is the basic interface who use nextflow-core to integrate plugins into it. It's only a basic interface and serves as starting point for more specialized extensions.
Among others, nextflow-core integrate following sub ExtensionPointS:
TraceObserverFactoryto provide a list of TraceObserverSChannelExtensionPointto enrich the channel with custom methods
In this plugin you can find examples for both of them
To run and test the plugin in the development environment, configure a local Nextflow build using the following steps:
- Create a root folder for the whole project & cd into the folder:
mkdir nfSynapseProject && cd nfSynapseProject - Clone this repo:
nf-synapsewhile insidenfSynapseProjectwith:git clone https://github.com/Sage-Bionetworks-Workflows/nf-synapse.git - Clone the Nextflow while inside
nfSynapseProjectwith:git clone https://github.com/nextflow-io/nextflow.git - Cd into folder
nextflow& build the local Nextflow source code with:cd nextflow && ./gradlew compile exportClasspath - Cd into folder
nf-synapse& compile the plugin source code:cd ../nf-synapse && ./gradlew compileGroovy - While inside
nf-synapse, include your Synapse_Auth_Token innextflow.configfile:plugins { id 'nf-synapse' } synapse { authToken='Put_Your_Synapse_Auth_Token_Here' } - While inside
nf-synapse, run Nextflow withnf-synapseplugin on the sample filesynapse_file.nf(created in this repo) using:./launch.sh run synapse_file.nf -plugins nf-synapse
SynapsePlugin.groovy: Wrapper for the whole plugin project. It also establishes and installs the customized Synapse FileSystem Provider.SynapsePathFactory.groovyandSynapsePathSerializer.groovy: Initiation points whenever a user initiates a file using URI.SynapsePath.groovy: Implements Synapse path object.SynapseConfig.groovy: Implement system env configs for Synapse FileSystem. It includes Synapse Auth Token as one of the requirements for Synapse FileSystem env.SynapseFileSystemProvider.groovy: Implements NIO File system provider for Synapse Entity Storage. It includes most the the logic on how to create a new instance of Synapse FileSystem, inititates Synapse Java API Client (that will be used to retrieve the remote Synapse file later), enforces Synapse authentication token and Synapse entity type check.- Some of very important methods: newFileSystem(), getFileSystem(), getPath(), newInputStream(), delete(), copy(), move()...
SynapseFileSystem.groovy: Implements NIO File system for Synapse Entity Storage.- Some of very important methods: SynapseFileSystem(), getPath(), newInputStream()...
Right now the user who wants to run the test cases will have to following the extra instructions inside SynapseTest. Particularly you will have to manually create the test mock .txt file in your Synapse repo and copy/paste the Synapse Id into SynapseTest. For future development, please use Synapse Java API Client to automate the process of create file -> upload file -> retrieve id -> delete file in Synapse repo remotely.
There are 2 ways to run the unit test cases:
- Using the command line terminal:
-
Add variable
SYNAPSE_AUTH_TOKENto your system source. For MacOS, you can add the variable by:vim ~/.zshrcor
vim ~/.bashrcthen modify/update the source file with:
export SYNAPSE_AUTH_TOKEN=YOUR_SYNAPSE_AUTH_TOKENthen reload the source file with:
source ~/.zshrcor
source ~/.bashrc -
Run the following command in the project root directory (ie. where the file
settings.gradleis located):./gradlew check
-
- Using IntelliJ:
Currently, in various methods, log.trace is being used. Whenever you run a .nf files with flag -trace, the .nextflow.log files will output results from log.trace
./gradlew compileGroovy && ./launch.sh -trace nextflow.synapse run synapse_file.nf -plugins nf-synapse
The project should hosted in a GitHub repository whose name should match the name of the plugin,
that is the name of the directory in the plugins folder e.g. nf-synapse in this project.
Following these step to package, upload and publish the plugin:
- Create a file named
gradle.propertiesin the project root containing the following attributes (this file should not be committed in the project repository):
github_organization: the GitHub organisation the plugin project is hostedgithub_usernameThe GitHub username granting access to the plugin project.github_access_token: The GitHub access token required to upload and commit changes in the plugin repository.github_commit_email: The email address associated with your GitHub account.
-
The following command, package and upload the plugin in the GitHub project releases page:
./gradlew :plugins:nf-synapse:upload -
Create a pull request against the nextflow-io/plugins project to make the plugin public accessible to Nextflow app.


