def test_part_parameter_values(): ice = icebreaker.IceClient(os.path.join(conf_folder, 'john_doe_auth.yml')) part_id = 1 ice.set_part_custom_field(part_id, "TEST_PARAM", "TEST_VALUE") assert ice.get_part_custom_field(part_id, "TEST_PARAM") == "TEST_VALUE" parts = ice.find_parts_by_custom_field_value("TEST_PARAM", "TEST_VALUE") assert len(parts) == 1 fields = ice.get_part_custom_fields_list(part_id) assert len(fields) == 1 for field in fields: response = ice.delete_custom_field(field['id']) assert response.ok
def test_file_attachments(): ice = icebreaker.IceClient(os.path.join(conf_folder, 'john_doe_auth.yml')) record = load_record(os.path.join('tests', 'data', 'example_record.gb')) part_id = 1 try: ice.delete_part_record(part_id) except: pass ice.attach_record_to_part(ice_part_id=part_id, record=record) new_record = ice.get_record(part_id) assert len(new_record) == 150 ice.delete_part_record(part_id)
def test_folder_methods(): ice = icebreaker.IceClient(os.path.join(conf_folder, 'john_doe_token.yml')) folders = ice.get_collection_folders('PERSONAL') assert (len(folders) == 1) and (folders[0]['folderName'] == 'test_folder')
def test_search_methods(): ice = icebreaker.IceClient(os.path.join(conf_folder, 'john_doe_auth.yml')) test1_part, errors = ice.find_entry_by_name("Test1") assert (errors is None) assert test1_part["id"] == 1
def test_auth(): ice = icebreaker.IceClient(os.path.join(conf_folder, 'john_doe_token.yml')) assert (len(ice.get_collection_folders('PERSONAL')) > 0) ice = icebreaker.IceClient(os.path.join(conf_folder, 'john_doe_auth.yml')) assert ice.session_infos['description'] == 'I am John'
import os import time import icebreaker from icebreaker.tools import load_record conf_folder = os.path.join('tests', 'configs') ice_admin = icebreaker.IceClient(os.path.join(conf_folder, 'admin_auth.yml')) result = ice_admin.rebuild_search_indexes() assert result.ok time.sleep(5) def test_auth(): ice = icebreaker.IceClient(os.path.join(conf_folder, 'john_doe_token.yml')) assert (len(ice.get_collection_folders('PERSONAL')) > 0) ice = icebreaker.IceClient(os.path.join(conf_folder, 'john_doe_auth.yml')) assert ice.session_infos['description'] == 'I am John' def test_search_methods(): ice = icebreaker.IceClient(os.path.join(conf_folder, 'john_doe_auth.yml')) test1_part, errors = ice.find_entry_by_name("Test1") assert (errors is None) assert test1_part["id"] == 1 def test_folder_methods(): ice = icebreaker.IceClient(os.path.join(conf_folder, 'john_doe_token.yml')) folders = ice.get_collection_folders('PERSONAL') assert (len(folders) == 1) and (folders[0]['folderName'] == 'test_folder')
from Bio import SeqIO import os import pandas import json import icebreaker new_ice = icebreaker.IceClient("../api_tokens/local_update.yaml") new_ice_folders = new_ice.get_collection_folders("PERSONAL") root_data_folder = "local_data" collection_folders = os.listdir(root_data_folder) for folder in collection_folders: print("Processing folder", folder) if folder not in new_ice_folders: folder_infos = new_ice.create_folder(folder) new_ice_folders.append(folder) folder_id = folder_infos["id"] else: folder_id = new_ice.get_folder_id(folder) data_folder = os.path.join(root_data_folder, folder, "data") genbank_folder = os.path.join(root_data_folder, folder, "records") parts_ids = [] for data_file in os.listdir(data_folder): part_id = ".".join(data_file.split(".")[:-1]) print("... entry", part_id) data_file_path = os.path.join(root_data_folder, folder, "data", data_file) with open(data_file_path, "r") as f: part_infos = json.load(f) genbank_file_path = os.path.join(root_data_folder, folder, "records",
from Bio import SeqIO import os import pandas import json import icebreaker # LOAD ALL "SHARED" FOLDERS DATA ON YOUR COMPUTER ice = icebreaker.IceClient("../api_tokens/admin.yaml") folders = ice.get_collection_folders("SHARED") # folders = folders[:4] # test with a small part local_data_folder = "local_data" os.mkdir(local_data_folder) for folder in folders: print("Processing folder", folder["folderName"]) local_folder_path = os.path.join(local_data_folder, folder["folderName"]) if not os.path.exists(local_folder_path): os.mkdir(local_folder_path) parts_in_folder = ice.get_folder_entries(folder_id=folder["id"]) genbanks_path = os.path.join(local_folder_path, "records") if not os.path.exists(genbanks_path): os.mkdir(genbanks_path) parts_data_path = os.path.join(local_folder_path, "data") if not os.path.exists(parts_data_path): os.mkdir(parts_data_path) parts_infos_list = [] for part in parts_in_folder: print("... entry", part["name"]) part_infos = ice.get_part_infos(part["id"]) parts_infos_list.append(part_infos)