def get_file_links(accession, database): if not accession: raise BadRequest("missing parameter accession", MISSING_PARAMETER, payload=None) if not database: raise BadRequest("missing parameter database", MISSING_PARAMETER, payload=None) res = requests.get(constants.FILE_LINKS_URL, params={ "accession": accession, "database": database }, headers=constants.HEADERS) if res.status_code != 200: raise BadRequest( "The request accession {} and database {} thrown connection error" .format(accession, database), res.status_code, payload=None) file_links = [] if res.json(): for file_link in res.json(): file_links.append(file_link) return file_links
def search(query, sortfield=None, order=None, start=0, size=20, face_count=20): params = {"start": start, "size": size, "faceCount": face_count} if not query: raise BadRequest("missing parameter query", MISSING_PARAMETER, payload=None) else: params.update(query=query) if sortfield: params.update(sortfield=sortfield) if order: params.update(order=order) res = requests.get(constants.SEARCH_URL, params=params, headers=constants.HEADERS) if res.status_code != 200: raise BadRequest( "The request query {} and sortfield {} and order {} thrown connection error" .format(query, sortfield, order), res.status_code, payload=None) return DataSetResult.get_object_from_json(res.json())
def batch(acc, database): if not acc: raise BadRequest("missing parameter acc", MISSING_PARAMETER, payload=None) if not database: raise BadRequest("missing parameter database", MISSING_PARAMETER, payload=None) res = requests.get(constants.BATCH_URL, params={ "accession": acc, "database": database }, headers=constants.HEADERS) if res.status_code != 200: raise BadRequest( "The request accession {} and database {} thrown connection error" .format(acc, database), res.status_code, payload=None) return BatchDataset.get_object_from_json(res.json())
def get_dataset_files(database, accession, position): if not database: raise BadRequest("missing parameter database", MISSING_PARAMETER, payload=None) if not accession: raise BadRequest("missing parameter accession", MISSING_PARAMETER, payload=None) if not position: raise BadRequest("missing parameter position", MISSING_PARAMETER, payload=None) res = requests.get(constants.DATASET_URL + "/" + database + "/" + accession + "/files", params={"position": position}, headers=constants.HEADERS) file_links = [] if res.json(): for file_link in res.json(): file_links.append(file_link) return file_links
def get_dataset_details(database, accession): if not database: raise BadRequest("missing parameter database", MISSING_PARAMETER, payload=None) if not accession: raise BadRequest("missing parameter accession", MISSING_PARAMETER, payload=None) res = requests.get(constants.DATASET_URL + "/" + database + "/" + accession, headers=constants.HEADERS) if res.status_code != 200: raise BadRequest( "The request dataset accession {} and database {} thrown connection error" .format(accession, database), res.status_code, payload=None) dataset = Dataset.get_object_from_json(res.json()) return dataset
def get_similar(acc, database): if not acc: raise BadRequest("missing parameter acc", MISSING_PARAMETER, payload=None) if not database: raise BadRequest("missing parameter database", MISSING_PARAMETER, payload=None) res = requests.get(constants.SIMILAR_URL, params={ "acc": acc, "database": database }, headers=constants.HEADERS) if res.status_code != 200: raise BadRequest( "The request accession {} and database {} thrown connection error" .format(acc, database), res.status_code, payload=None) return res
def get_term_by_pattern(q="hom", size=10): res = requests.get(constants.TERM_BY_PATTERN_URL, params={ "q": q, "size": size }, headers=constants.HEADERS) if res.status_code != 200: raise BadRequest("The request query {} and size {} thrown connection error".format(q, size), res.status_code, payload=None) if res.status_code == 200 and res.json()["total_count"] ==0: raise BadRequest("The request found nothing in server", DATA_NOT_FOUND, payload=None) return res
def get_seo_schema(acc, domain): if not acc: raise BadRequest("missing parameter acc", MISSING_PARAMETER, payload=None) if not domain: raise BadRequest("missing parameter domain", MISSING_PARAMETER, payload=None) res = requests.get(constants.SEO_SCHEMA_URL + "/" + domain + "/" + acc, headers=constants.HEADERS) return res
def get_seo_about(): res = requests.get(constants.SEO_ABOUT_URL, headers=constants.HEADERS) if res.status_code != 200: raise BadRequest("The request thrown connection error", res.status_code, payload=None) return res
def get_db_name(lucene_name): if not lucene_name: raise BadRequest("missing parameter lucene_name", MISSING_PARAMETER, payload=None) res = requests.get(constants.DB_NAME_URL, params={ "luceneName": lucene_name }, headers=constants.HEADERS) return res
def get_term_frequently_term_list(domain, field, size=20): if not domain: raise BadRequest("missing parameter domain", MISSING_PARAMETER, payload=None) if not field: raise BadRequest("missing parameter field", MISSING_PARAMETER, payload=None) res = requests.get(constants.FREQUENTLY_TERM_URL, params={ "size": size, "domain": domain, "field": field }, headers=constants.HEADERS) if res.status_code != 200: raise BadRequest("The request domain {} and field {} and size {} thrown connection error".format(domain, field, size), res.status_code, payload=None) return res
def get_database_all(): res = requests.get(constants.DATABASE_ALL_URL, headers=constants.HEADERS) if res.status_code != 200: raise BadRequest("The request thrown connection error", res.status_code, payload=None) return res
def get_lucene_name(db_name): if not db_name: raise BadRequest("missing parameter db_name", MISSING_PARAMETER, payload=None) res = requests.get(constants.LUCENE_NAME_URL, params={ "dbName": db_name }, headers=constants.HEADERS) return res
def get_similar_by_pubmed(pubmed): if not pubmed: raise BadRequest("missing parameter pubmed", MISSING_PARAMETER, payload=None) res = requests.get(constants.DATASET_URL + "/getSimilarByPubmed", params={"pubmed": pubmed}, headers=constants.HEADERS) if res.status_code != 200: raise BadRequest( "The request pubmed {} thrown connection error".format(pubmed), res.status_code, payload=None) return res
def get_synonyms_for_dataset(accession, database): if not accession: raise BadRequest("missing parameter accession", MISSING_PARAMETER, payload=None) if not database: raise BadRequest("missing parameter database", MISSING_PARAMETER, payload=None) res = requests.get(constants.SYNONYMS_URL, params={ "accession": accession, "database": database }, headers=constants.HEADERS) return res
def get(acc, database): if not acc: raise BadRequest("missing parameter acc", MISSING_PARAMETER, payload=None) if not database: raise BadRequest("missing parameter database", MISSING_PARAMETER, payload=None) res = requests.get(constants.GET_URL, params={ "acc": acc, "database": database }, headers=constants.HEADERS) return res.json()
def get_list(acc): if not acc: raise BadRequest("missing parameter acc", MISSING_PARAMETER, payload=None) res = requests.get(constants.LIST_URL, params={"acc": acc}, headers=constants.HEADERS) return res
def get_enrichment_info(accession, database): if not accession: raise BadRequest("missing parameter accession", MISSING_PARAMETER, payload=None) if not database: raise BadRequest("missing parameter database", MISSING_PARAMETER, payload=None) res = requests.get(constants.ENRICHMENT_INFO_URL, params={ "accession": accession, "database": database }, headers=constants.HEADERS) return res
def get_similar_datasets_by_biological_data(accession, database): if not accession: raise BadRequest("missing parameter accession", MISSING_PARAMETER, payload=None) if not database: raise BadRequest("missing parameter database", MISSING_PARAMETER, payload=None) res = requests.get(constants.SIMILAR_DATASETS_BIOLOGY_URL, params={ "accession": accession, "database": database }, headers=constants.HEADERS) return res
def get_database_pic(database_name): if not database_name: raise BadRequest("missing parameter database_name", MISSING_PARAMETER, payload=None) res = requests.get(constants.DATABASE_URL + "/" + database_name + "/picture", headers=constants.HEADERS) return res
def latest(size=20): res = requests.get(constants.LATEST_URL, params={"size": size}, headers=constants.HEADERS) if res.status_code != 200: raise BadRequest("The request thrown connection error", res.status_code, payload=None) return res
def get_statistics_organisms(size=20): res = requests.get(constants.STATISTICS_URL + "/organisms", params={"size": size}, headers=constants.HEADERS) if res.status_code != 200: raise BadRequest( "The request size {} thrown connection error".format(size), res.status_code, payload=None) return res
def most_accessed(size=20): res = requests.get(constants.MOST_ACCESSED_DATASETS, params={"size": size}, headers=constants.HEADERS) if res.status_code != 200: raise BadRequest("The request thrown connection error", res.status_code, payload=None) return res
def get_similar_by_pubmed(pubmed): if not pubmed: raise BadRequest("missing parameter pubmed", MISSING_PARAMETER, payload=None) res = requests.get(constants.DATASET_URL + "/getSimilarByPubmed", params={"pubmed": pubmed}, headers=constants.HEADERS) if res.status_code != 200: raise BadRequest( "The request pubmed {} thrown connection error".format(pubmed), res.status_code, payload=None) datasets = [] for i in res.json(): dataset = Dataset.get_object_from_json(i) datasets.append(dataset) return datasets
def get_dataset_by_url(url): if not url: raise BadRequest("missing parameter url", MISSING_PARAMETER, payload=None) res = requests.post(constants.DATASET_URL + "/getDatasetByUrl", params={"url": url}, headers=constants.HEADERS) return res
def get_dataset_files(domain, accession, position): if not domain: raise BadRequest("missing parameter domain", MISSING_PARAMETER, payload=None) if not accession: raise BadRequest("missing parameter accession", MISSING_PARAMETER, payload=None) if not position: raise BadRequest("missing parameter position", MISSING_PARAMETER, payload=None) res = requests.get(constants.DATASET_URL + "/" + domain + "/" + accession + "/files", params={"position": position}, headers=constants.HEADERS) return res
def get_seo_dataset(domain, acc): if not acc: raise BadRequest("missing parameter acc", MISSING_PARAMETER, payload=None) if not domain: raise BadRequest("missing parameter domain", MISSING_PARAMETER, payload=None) res = requests.get(constants.SEO_DATASET_URL + "/" + domain + "/" + acc, headers=constants.HEADERS) if res.status_code != 200: raise BadRequest( "The request accession {} and database {} thrown connection error", res.status_code, payload=None) return res
def get_similarity_info(accession, database, threshold): if not accession: raise BadRequest("missing parameter accession", MISSING_PARAMETER, payload=None) if not database: raise BadRequest("missing parameter database", MISSING_PARAMETER, payload=None) if not threshold: raise BadRequest("missing parameter threshold", MISSING_PARAMETER, payload=None) res = requests.get(constants.SIMILAR_INFO_URL, params={ "accession": accession, "database": database, "threshold": threshold }, headers=constants.HEADERS) return res
def get_dataset_details(domain, accession, debug=False): if not domain: raise BadRequest("missing parameter domain", MISSING_PARAMETER, payload=None) if not accession: raise BadRequest("missing parameter accession", MISSING_PARAMETER, payload=None) res = requests.get(constants.DATASET_URL + "/" + domain + "/" + accession, params={"debug": debug}, headers=constants.HEADERS) if res.status_code != 200: raise BadRequest( "The request dataset accession {} and database {} thrown connection error" .format(accession, domain), res.status_code, payload=None) return res.json()
def get_database_all(): res = requests.get(constants.DATABASE_ALL_URL, headers=constants.HEADERS) if res.status_code != 200: raise BadRequest("The request thrown connection error", res.status_code, payload=None) database_details = [] if res.json(): for database_detail_json in res.json(): database_detail = DatabaseDetail.get_object_from_json( database_detail_json) database_details.append(database_detail) return database_details