A Python library for interacting with Tripal.
It allows to load data into a remote Tripal instance, and explore its content, directly from Python code, or using a CLI (Command Line Interface).
See below for examples of what you can do using the tripal
python module, and the tripaille
CLI.
(in case you wonder: Tripaille's name comes from a bad french word play)
The tripal_rest_api module needs to be installed on your Tripal instance (choose the master branch for Tripal 2, or the branch 7.x-3.x for Tripal 3).
$ pip install tripal
# On first use you'll need to create a config file to connect to the tripal server, just run:
$ tripaille init
Welcome to Tripal's Tripaille!
TRIPAL_URL: http://localhost/
TRIPAL_USER: admin
TRIPAL_PASS: changeme
This will create a tripaille config file in ~/.tripaille.yml
from tripal import TripalInstance
ti = TripalInstance(tripal_url='http://localhost:8500/', username='admin', password='changeme')
# Create human species
org = ti.organism.add_organism(genus="Homo", species="sapiens", common="Human", abbr="H.sapiens")
# Then display the list of organisms
orgs = ti.organism.get_organisms()
for org in orgs:
print('{} {}'.format(org['genus'], org['species']))
# Create an analysis
an = ti.analysis.add_analysis(name="My cool analysis",
program="Something",
programversion="1.0",
algorithm="Google",
sourcename="src",
sourceversion="2.1beta",
sourceuri="http://example.org/",
date_executed="2018-02-03")
# Then display the list of organisms
ans = ti.analysis.get_analyses()
# And load some data
ti.analysis.load_fasta(fasta="./test-data/Citrus_sinensis-scaffold00001.fasta", analysis_id=ans[0]['analysis_id'], organism_id=orgs[0]['organism_id'])
ti.analysis.load_gff3(gff="./test-data/Citrus_sinensis-orange1.1g015632m.g.gff3", analysis_id=ans[0]['analysis_id'], organism_id=orgs[0]['organism_id'])
Or with the Tripaille client:
$ tripaille organism add_organism --abbr H.sapiens --common Human Homo sapiens
$ tripaille organism get_organisms
[
{
"organism_id": "17",
"abbreviation": "H.sapiens",
"genus": "Homo",
"species": "sapiens",
"common_name": "Human",
"infraspecific_name": null,
"type_id": null,
"comment": ""
}
]
# Then load some data
$ tripaille analysis add_analysis \
"My cool analysis" \
"Something" \
"v1.0" \
"src"
$ tripaille analysis get_analyses
[
{
"analysis_id": "68",
"name": "My cool analysis",
"description": "",
"program": "Something",
"programversion": "1.0",
"timeexecuted": "2018-02-03 00:00:00"
},
]
$ tripaille analysis load_fasta \
--analysis_id 68 \
--sequence_type contig \
--organism_id 17 \
./test-data/Citrus_sinensis-scaffold00001.fasta
3.2.1
3.2
3.1.1
3.1
3.0
job add_import_job
for generic Tripal 3 importerorganism get_organism_nodes
to organism get_organisms_tripal
and analysis get_analysis_nodes
to analysis get_analyses_tripal
.
Both now return Drupal Nodes for Tripal 2 or Entities for Tripal 3.delete_orphans
methods for organisms and analyses2.0.4
2.0.3
2.0.2
2.0.1
2.0
1.9
Available under the MIT License