The MenDeVAR (Meningococcal Deduced Vaccine Antigen Reactivity) Index tool can be accessed via the PubMLST RESTful API, allowing it to be incorporated in to an analysis pipeline.
Documentation for the API call can be found at http://bigsdb.readthedocs.io/en/latest/rest.html#db-schemes-scheme-id-sequence.
The following examples assume that you have a FASTA file containing a bacterial genome assembly called contigs.fasta in your current directory.
Command line (curl) | Perl | Python
curl
The curl command can be used to make API calls using the Linux command line. The FASTA file needs to be base64 encoded and embedded within a JSON payload. This can be done with the following commands.
(echo -n '{"base64":true,"details":true,"partial_matches":true,"sequence": "'; base64 contigs.fasta; echo '"}') | curl -s -H "Content-Type: application/json" -X POST "https://rest.pubmlst.org/db/pubmlst_neisseria_mendevar/schemes/77/sequence" -d @- |
Output is in JSON format, and looks like the following:
{ | |
"exact_matches": { | |
"fHbp_peptide": [ | |
{ | |
"contig": "31580", | |
"end": 1945401, | |
"orientation": "forward", | |
"start": 1944637, | |
"allele_id": "1", | |
"length": 255 | |
} | |
], | |
"NEIS2109": [ | |
{ | |
"length": 1467, | |
"allele_id": "5", | |
"start": 2207000, | |
"orientation": "reverse", | |
"end": 2208466, | |
"contig": "31580" | |
} | |
], | |
"NEIS0349": [ | |
{ | |
"end": 1945404, | |
"contig": "31580", | |
"length": 825, | |
"allele_id": "100", | |
"start": 1944580, | |
"orientation": "forward" | |
} | |
], | |
"PorA_VR2": [ | |
{ | |
"start": 862860, | |
"orientation": "forward", | |
"length": 14, | |
"allele_id": "16", | |
"contig": "31580", | |
"end": 862901 | |
} | |
], | |
"NHBA_peptide": [ | |
{ | |
"allele_id": "3", | |
"length": 488, | |
"orientation": "reverse", | |
"start": 2207003, | |
"end": 2208466, | |
"contig": "31580" | |
} | |
] | |
}, | |
"analysis": { | |
"trumenba": { | |
"notes": "fHbp_peptide: 1 is cross-reactive to vaccine variant - data derived from MEASURE assays (PMID:29535195), and SBA assays (PMID:22569484, PMID:22718089, PMID:22871351, PMID:23114369, PMID:23352429, PMID:26407272, PMID:26707218, PMID:26803328, PMID:26835974, PMID:26974889, PMID:27745812, PMID:27846061, PMID:28196734, PMID:28566335, PMID:29236639)", | |
"result": "cross-reactive" | |
}, | |
"bexsero": { | |
"notes": "fHbp_peptide: 1 is exact match to vaccine variant - peptide sequence match (PMID:27521232)", | |
"result": "exact match" | |
} | |
} | |
} |
Perl
#!/usr/bin/perl | |
#Upload contigs file to PubMLST MenDeVar via RESTful API | |
#Written by Keith Jolley | |
#Copyright (c) 2022, University of Oxford | |
#Licence: GPL3 | |
use strict; | |
use warnings; | |
use 5.010; | |
use JSON; | |
use MIME::Base64; | |
use LWP::UserAgent; | |
use constant URL => 'https://rest.pubmlst.org/db/pubmlst_neisseria_mendevar/schemes/77/sequence'; | |
my $filename = $ARGV[0] // 'contigs.fasta'; | |
open( my $fh, '<:raw', $filename ) || die "Cannot open $filename for reading.\n"; | |
my $fasta = do { local $/ = undef; <$fh> }; | |
close $fh; | |
my $agent = LWP::UserAgent->new; | |
my $payload = encode_json( | |
{ | |
base64 => JSON::true(), | |
details => JSON::true(), | |
sequence => encode_base64($fasta) | |
} | |
); | |
my $response = $agent->post( | |
URL, | |
Content_Type => 'application/json; charset=UTF-8', | |
Content => $payload | |
); | |
if ( $response->is_success ) { | |
my $data = decode_json( $response->content ); | |
say 'Bexsero:'; | |
if ( $data->{'analysis'}->{'bexsero'}) { | |
say "Result: $data->{'analysis'}->{'bexsero'}->{'result'}"; | |
say "Notes: $data->{'analysis'}->{'bexsero'}->{'notes'}"; | |
} else { | |
say 'No result'; | |
} | |
say ''; | |
say 'Trumenba:'; | |
if ( $data->{'analysis'}->{'trumenba'}) { | |
say "Result: $data->{'analysis'}->{'trumenba'}->{'result'}"; | |
say "Notes: $data->{'analysis'}->{'trumenba'}->{'notes'}"; | |
} else { | |
say 'No result'; | |
} | |
} else { | |
say $response->as_string; | |
} |
Output
Bexsero: Result: exact match Notes: fHbp_peptide: 1 is exact match to vaccine variant - peptide sequence match (PMID:27521232) Trumenba: Result: cross-reactive Notes: fHbp_peptide: 1 is cross-reactive to vaccine variant - data derived from MEASURE assays (PMID:29535195), and SBA assays (PMID:22569484, PMID:22718089, PMID:22871351, PMID:23114369, PMID:23352429, PMID:26407272, PMID:26707218, PMID:26803328, PMID:26835974, PMID:26974889, PMID:27745812, PMID:27846061, PMID:28196734, PMID:28566335, PMID:29236639)
Python
#!/usr/bin/env python3 | |
# Upload contigs file to PubMLST MenDeVar via RESTful API | |
# Written by Keith Jolley | |
# Copyright (c) 2022, University of Oxford | |
# Licence: GPL3 | |
import sys, requests, argparse, base64 | |
parser = argparse.ArgumentParser() | |
parser.add_argument('--file', '-f', type=str, default='contigs.fasta', help='assembly contig filename (FASTA format)') | |
args = parser.parse_args() | |
def main(): | |
uri = 'https://rest.pubmlst.org/db/pubmlst_neisseria_mendevar/schemes/77/sequence' | |
with open(args.file, 'r') as x: | |
fasta = x.read() | |
payload = '{"base64":true,"details":true,"sequence":"' + base64.b64encode(fasta.encode()).decode() + '"}' | |
response = requests.post(uri, data=payload) | |
if response.status_code == requests.codes.ok: | |
data = response.json() | |
try: | |
data['analysis'] | |
except KeyError: | |
print("No result") | |
sys.exit(0) | |
print("Bexsero:") | |
try: | |
data['analysis']['bexsero'] | |
except KeyError: | |
print("No result"); | |
print("Result: " + data['analysis']['bexsero']['result']) | |
print("Notes: " + data['analysis']['bexsero']['notes']) | |
print("\nTrumenba:"); | |
try: | |
data['analysis']['trumenba'] | |
except KeyError: | |
print("No result"); | |
print("Result: " + data['analysis']['trumenba']['result']) | |
print("Notes: " + data['analysis']['trumenba']['notes']) | |
else: | |
print(response.text) | |
if __name__ == "__main__": | |
main() |
Output
Bexsero: Result: exact match Notes: fHbp_peptide: 1 is exact match to vaccine variant - peptide sequence match (PMID:27521232) Trumenba: Result: cross-reactive Notes: fHbp_peptide: 1 is cross-reactive to vaccine variant - data derived from MEASURE assays (PMID:29535195), and SBA assays (PMID:22569484, PMID:22718089, PMID:22871351, PMID:23114369, PMID:23352429, PMID:26407272, PMID:26707218, PMID:26803328, PMID:26835974, PMID:26974889, PMID:27745812, PMID:27846061, PMID:28196734, PMID:28566335, PMID:29236639)