/usr/include/gbtools/gbtoolsTrackhub.hpp is in libgbtools-dev 4.44.1+dfsg-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | /* File: gbtoolsTrackhub.hpp
* Author: Gemma Barson (gb10@sanger.ac.uk)
* Copyright (c) 2016: Genome Research Ltd.
*-------------------------------------------------------------------
* gbtools is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* or see the on-line version at http://www.gnu.org/copyleft/gpl.txt
*-------------------------------------------------------------------
* This file is part of the gbtools genome browser tools library,
* written by
* Ed Griffiths (Sanger Institute, UK) <edgrif@sanger.ac.uk>
* Gemma Barson (Sanger Institute, UK) <gb10@sanger.ac.uk>
* Steve Miller (Sanger Institute, UK) <sm23@sanger.ac.uk>
*
* Description: Ensembl Track Hub Registry functions
*----------------------------------------------------------------------------
*/
#ifndef GBTOOLS_TRACKHUB_H
#define GBTOOLS_TRACKHUB_H
#include <string>
#include <list>
#include <map>
#include <json/json.h>
#include <gbtools/gbtoolsCurl.hpp>
namespace gbtools
{
namespace trackhub
{
// Class to hold info about a track
class Track
{
public:
Track(std::string name,
std::string shortLabel,
std::string url,
std::string file_type,
std::string visibility)
: name_(name),
shortLabel_(shortLabel),
url_(url),
file_type_(file_type),
visibility_(visibility)
{};
std::string name() const { return name_; };
std::string description() const { return shortLabel_; };
std::string url() const { return url_; };
std::list<Track> children() const { return children_; };
std::string visibility() const { return visibility_; };
bool visible() const { return visibility_ != "hide"; };
std::string fileType() const { return file_type_; };
std::list<Track> children_;
private:
std::string name_;
std::string shortLabel_;
std::string url_;
std::string file_type_;
std::string visibility_;
};
// Class to hold info about a trackDb (i.e. a collection of tracks from a particular hub)
class TrackDb
{
public:
TrackDb()
: id_(""),
hub_shortLabel_(""),
hub_longLabel_(""),
hub_url_(""),
species_scientific_name_(""),
assembly_name_(""),
type_(""),
num_tracks_(0),
num_with_data_(0)
{} ;
TrackDb(const std::string &id,
const std::string &name,
const std::string &shortLabel,
const std::string &longLabel,
const std::string &url,
const std::string &scientific_name,
const std::string &assembly_name,
const std::string &type,
const int num_tracks,
const int num_with_data,
const std::list<std::string> &file_types,
const std::list<Track> &tracks
)
: id_(id),
hub_name_(name),
hub_shortLabel_(shortLabel),
hub_longLabel_(longLabel),
hub_url_(url),
species_scientific_name_(scientific_name),
assembly_name_(assembly_name),
type_(type),
num_tracks_(num_tracks),
num_with_data_(num_with_data),
file_types_(file_types),
tracks_(tracks)
{} ;
std::string id() const { return id_; } ;
std::string name() const { return hub_name_; } ;
std::string label() const { return hub_shortLabel_; } ;
std::string description() const { return hub_longLabel_; } ;
std::string url() const { return hub_url_; } ;
std::string species() const { return species_scientific_name_; } ;
std::string assembly() const { return assembly_name_; } ;
int num_tracks() const { return num_tracks_; } ;
int num_with_data() const { return num_with_data_; } ;
std::list<std::string> file_types() const { return file_types_; } ;
std::list<Track> tracks() const { return tracks_; } ;
private:
std::string id_ ;
std::string hub_name_ ;
std::string hub_shortLabel_ ;
std::string hub_longLabel_ ;
std::string hub_url_ ;
std::string species_scientific_name_ ;
std::string assembly_name_ ;
std::string type_ ;
int num_tracks_;
int num_with_data_;
std::list<std::string> file_types_;
std::list<Track> tracks_;
};
// Class to hold info about a track hub
class Trackhub
{
public:
Trackhub()
: name_(""),
shortLabel_(""),
longLabel_(""),
url_("")
{} ;
Trackhub(std::string name,
std::string shortLabel,
std::string longLabel,
std::string url)
: name_(""),
shortLabel_(""),
longLabel_(""),
url_("")
{} ;
std::string name() { return name_; } ;
std::string label() { return shortLabel_; } ;
std::string description() { return longLabel_; } ;
std::string url() { return url_; } ;
private:
std::string name_ ;
std::string shortLabel_ ;
std::string longLabel_ ;
std::string url_ ;
} ;
/* Class for accessing the Ensembl Track Hub Registry API */
class Registry
{
public:
//
// Construct/destruct
//
Registry();
~Registry();
void initCurl() ;
//
// API functions
//
bool ping(std::string &err_msg);
std::string version(std::string &err_msg);
std::list<std::string> species(std::string &err_msg);
std::map<std::string, std::list<std::string>> assemblies(std::string &err_msg);
std::list<Trackhub> trackhubs(std::string &err_msg);
bool getSearchPage(std::stringstream &payload_ss,
const int page_no, std::list<TrackDb> &result,
std::string &err_msg);
std::list<TrackDb> search(const std::string &query, const std::string &species,
const std::string &assembly, const std::string &hub,
std::string &err_msg);
TrackDb searchTrackDb(const std::string &trackdb, std::string &err_msg);
bool login(const std::string &user, const std::string &pwd, std::string &err_msg);
bool logout(std::string &err_msg);
Json::Value registerHub(const std::string &url,
const std::map<std::string, std::string> &assemblies,
const std::string &type,
const bool is_public,
std::string &err_msg);
std::list<TrackDb> retrieveHub(const std::string &trackhub, std::string &err_msg);
std::string deleteHub(const std::string &trackhub, std::string &err_msg);
Json::Value retrieveTrackDb(const std::string &trackdb, std::string &err_msg);
Json::Value deleteTrackDb(const std::string &trackdb, std::string &err_msg);
//
// Query
//
bool loggedIn();
//
// Set properties
//
void setDebug(const bool debug);
void setProxy(const std::string &proxy);
void setCainfo(const std::string &cainfo);
void setUserAgent(const std::string &useragent);
private:
curl_slist* getHeaders(const bool authorise);
curl_slist* postHeaders(const bool authorise);
std::string doGetRequest(const std::string &url, const bool authorise, long *response_code = NULL);
std::string doPostRequest(const std::string &url, const std::string &postfields, const bool authorise, long *response_code = NULL);
std::string doDeleteRequest(const std::string &url, const bool authorise, long *response_code = NULL);
Json::Value getRequest(const std::string &request, const bool authorise, std::string &err_msg);
Json::Value postRequest(const std::string &request, const std::string &postfields, const bool authorise, std::string &err_msg);
Json::Value deleteRequest(const std::string &request, const bool authorise, std::string &err_msg);
std::string host_;
std::string user_;
std::string auth_token_;
CURLObject curl_object_get_;
CURLObject curl_object_post_;
CURLObject curl_object_delete_;
Json::Reader json_reader_;
Json::FastWriter json_writer_;
bool debug_ ;
std::string proxy_ ;
std::string cainfo_ ;
std::string useragent_ ;
};
} // namespace trackhub
} /* namespace gbtools */
#endif /* GBTOOLS_TRACKHUB_H */
|