Intermine-Python: Tutorial 8: Accessing your saved Templates

This very short tutorial will talk about how you can access your saved templates and lists if you have your login information (username and password). If you don't have an account, you can create one at http://www.flymine.org/

Once, you have made an account, you can use the web service to create a query of your choice and save it as a template. This template can be used through the Python API or through the web service.

To login and access your templates through Python, you can provide your login information as shown below. Note that the code shown below is in comments because it needs to be specific to your account. Change the username and password to match yours, uncomment the code, and then run it.

In [1]:
from intermine.webservice import Service
from intermine import query
In [2]:
# service=Service("www.flymine.org/flymine/service",username="Enter username",password="Enter password")
In [3]:
#template=service.get_template("Name of a saved template")

You can then play around with this saved template like any of the existing templates on Flymine.

To view the names of all the available templates you can view the templates dictionary and iterate through it. This can be done as follows.

In [4]:
service = Service("https://www.flymine.org/flymine/service")
In [5]:
templates=service.templates
for name in templates.keys():
    print(name)
Gene_RegionLocation
AlleleClass_Allele
FlyFish_Genes
Organism_Sequence
GOterm_GenesInsertions
Gene_BDGP
Pathway_Genes
AllGene_Chromosome
Gene_IntronChromosome
RNA_seq_Genes
protein_interactions
Gene_GOAll
Gene_Interactions2
RNAiScreen_genes
Gene_CDSs
OrganismGO_GenePointMutation
Gene_Publications
Protein_GeneChromosomeLength
protein_domains2
GO_Gene
Gene_Pathway
All_Genes_In_Organism_To_Publications
Organism_NaturalTransposableElements
Organism_Protein
Tissue_Flyatlas
PhenotypeType_Alleles
TranscriptionFactor_Genes
ChromLocation_GeneTranscriptExon
Gene_PointMutationLocation
AnatomyTerm_Region
Gene_Protein
Gene_transposableElementsOverlappingExons
Gene_OverlapppingGenes
Transcriptionfactor_TFBindingSiteGene
Gene_RNAi
Gene_TimeCourseExpression
CRM _AnatomyTerm
protein_domain
ChromLocation_Gene
Chromosome_Gene
Gene_GO
Organism_transposableElementInsertionSites
ChromLocation_CRM
Gene_AdjacentGenes
Organism_3UTR
Gene_overlapping2
Gene_Orth_seq
Gene_disease
Protein_PublicationAll
Intron_regulatoryRegions
Disease_gene2
FlyRegBindingSite_TranscriptionFactor
organism_allmiRNA
Gene_FlyAtlas_TissueList
Gene_RegulatoryRegion
Gene_proteindomain
ChromLocation_RegulatoryRegion
Probe_Gene
BDGP_Gene
geneInteractiongene
modENCODE_RNA_seq_Tissues
Gene_AlleleStocks
Publication_Genes
Transcript_INDAC
Pathway_GenesOrthol_new2
Test_for_Julianne
Gene_TranscriptExonLocation
ChromLocation_TFBindingSiteLocationGeneFactor
Gene_upstreamRegulatoryRegions
GOterm_genesDrosDelDeletion
Gene_Insertion
Stage_FlyFishBDGP
Organism_5UTR
organismGenes_GOterms
Intergenic_RegRegion
Organism_GenesTranscriptsExonsIntrons
ChromLocation_CRMOverlappingTFBindingsite
Gene_enhancer
Gene_AdjacentGene_FlyAtlas_upstream
MeSH_Publication
Gene_Location
Gene_Probe
Gene_ExonLocation2
ChromLocation_GeneTranscriptINDAC
Gene_RNA_seq
Gene_INDAC
PointMutation_Gene_Chromosome
Clone_gene
TimeCourseData_Gene
Chromosome_IntergenicSequence
Gene_AdjacentGene_FlyAtlas_downstream
Gene_1CDSsequence
Gene_DrosophilaOrthologues
NaturalTransposableElement_InsertedElements
Organism_Intergenic
Gene_pathway_interactions
Organism_NaturalTransposableElementsandSites
GeneTissue_FlyAtlas
Gene_TranscriptOrthologue
Gene_FlyAtlas
Mutagen_Allele
AnatomyTerm_Alleles
ECnumber_gene_protein
miRNA_Targets
Organism_GOtermsOrthologues
Dataset_TF_BindingSites
Chromosome_CRMOverlappingInsertion
DrosDel_GeneLocation
Genes_Publications
miRNAtargetGene_miRNAgene
ProbeSet_FlyAtlas
ListPathway
INDAC_GeneLocation
Gene_transcriptionFactors
Gene_FlyFish
Gene_AdjacentGenesLocations
Protein_GOterms_1
Disease_gene_orthologue
Protein_Publication
InterPro_Domain_Family
Gene_Alleles
Gene_Orth
organism_allGenes
GO_GeneOrthologues
Chromosome_GeneInsertionLocation
Gene_BDGPFlyFish
Protein_DomainGO

This dictionary contains all the information about all the available templates, including the exact name and description. If you now want to view the details about a particular template name, this can be done as shown below.

In [6]:
templates["Gene_RNAi"]
Out[6]:
'<template comment="" name="Gene_RNAi" title="Gene --&gt; RNAi phenotypes"><query longDescription="Show RNAi phenotypes for a specified gene or genes." model="genomic" name="Gene_RNAi" sortOrder="Gene.primaryIdentifier asc" view="Gene.primaryIdentifier Gene.symbol Gene.rnaiResults.phenotype Gene.rnaiResults.score Gene.rnaiResults.rnaiScreen.scoreType Gene.rnaiResults.reagentId Gene.rnaiResults.conditions Gene.rnaiResults.rnaiScreen.publication.pubMedId Gene.rnaiResults.rnaiScreen.name Gene.rnaiResults.rnaiScreen.assay Gene.rnaiResults.rnaiScreen.bioSourceName Gene.rnaiResults.rnaiScreen.bioSourceType Gene.rnaiResults.rnaiScreen.method"><constraint description="Show RNAi phenotypes for the following gene:" editable="true" extraValue="D. melanogaster" op="LOOKUP" path="Gene" value="eve"/></query></template>'

If you don't feel comfortable with viewing this dictionary, you can also view the templates on: http://beta.flymine.org/beta/templates.do and https://www.flymine.org/flymine/templates.do You can scroll through the list of templates. If you find an interesting template, click on the template and click on the Python tab (in blue). This would show you how to call the template in Python using the exact name.