Partek Flow Documentation

Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

With the Partek Flow REST API, you can create custom solutions to query or drive your server. Below are some common use cases for the REST API:

Table of Contents
maxLevel2
minLevel2
excludeAdditional Assistance

A complete list of all the commands available reference for the API can be found on the REST API Command List. The public key and Python libraries  or by visiting [server]/api/v1/servlets

The referenced Python library can be downloaded here.

Generate an authentication token

An access token can be generated from the System information section of the settings page. 

Image RemovedImage Added


Alternatively, GetToken.py will generate a token:

Code Block
languagebash
python GetToken.py --server localhost:8080 --user admin

Example output:

Code Block
TOKEN: cUOWY0VvkSFagrDUANVtM7A8SPal8Gx0cf0ee24bfa9fe68e2b5564dab2b6a27e1fb525e5...

you will be prompted to enter your password.

 

This token can be specified as the --password parameter for the Python API. If the token is not supplied, then the Python API will prompt for the password and encrypt it.When accessing the API directly, the encrypt parameter must be specified with the RSA value to use the token: token parameter. 

 

Code Block
languagebash
curl --form username=admin --form encrypt=RSA --form password=token=cUOWY0VvkSFagr... http://localhost:8080/flow/api/v1/users/list

...

Code Block
languagebash
curl -X POST --form username=admin --form encrypt=RSA --form password=token=$FLOW_TOKEN --form project="My Project" http://localhost:8080/flow/api/v1/projects

...

Code Block
languagebash
 python UploadSamples.py --verbose --user admin --password token $FLOW_TOKEN --server http://localhost:8080 --project "My Project" \
	--files ~/MoreData/REST/sample1.fastq.gz ~/MoreData/REST/sample2.fastq.gz ~/MoreData/REST/sample3.fastq.gz ~/MoreData/REST/sample4.fastq.gz

...

Code Block
languagebash
python AddAttribute.py -v --server http://localhost:8080 --user admin --password token $FLOW_TOKEN --project_name "My Project" --sample_name sample1 --attribute Type --value Case 
python AddAttribute.py -v --server http://localhost:8080 --user admin --password token $FLOW_TOKEN --project_name "My Project" --sample_name sample2 --attribute Type --value Case 
python AddAttribute.py -v --server http://localhost:8080 --user admin --password token $FLOW_TOKEN --project_name "My Project" --sample_name sample3 --attribute Type --value Control

python AddAttribute.py -v --server http://localhost:8080 --user admin --password token $FLOW_TOKEN --project_name "My Project" --sample_name sample4 --attribute Type --value Control

...

Code Block
languagebash
python RunPipeline.py  -v --server http://localhost:8080 --user admin --password token $FLOW_TOKEN --project_id 0 --pipeline AlignAndQuantify --inputs 102,103

...

Code Block
languagebash
python UploadSamples.py -v --server http://localhost:8080 --user admin --password token $FLOW_TOKEN --files ~/sampleA.fastq.gz ~/sampleB.fastq.gz --project NewProject --pipeline AlignAndQuantify --inputs 102,103

...

Code Block
languagebash
curl -X PUT "http://localhost:8080/flow/api/v1/projects?project=ProjectName&collaborator=user1&role=Collaborator&username=admin&encrypt=RSA&password=[url encoded token]token=$FLOW_TOKEN"

 

Monitor a folder and upload files as they are created

Code Block
languagebash
#!/bin/bash
inotifywait -m $PATH_TO_MONITOR -e create -e moved_to |
  while read path action file; do
      if [[ $file == *.fastq.gz ]]; then
              echo "Uploading $file"
              python UploadSamples.py -v --server $SERVER --usertoken $USER$FLOW_TOKEN --password $TOKEN --files $path/$file --project "$PROJECT" 
      fi
  done

...

Code Block
languagebash
#!/bin/bash
while true; do
      result=`python QueueStatistics.py --server $SERVER --user $USER --password token $TOKEN --max_waiting $MAX_WAITING`
      if [ $? -eq 1 ]; then
              /usr/bin/notify-send $result
              exit 1
      fi
      sleep $INTERVAL
done

...