try: org = wa.organisms.show_organism(org_cn) except Exception: org = None if org and 'error' not in org: old_directory = org['directory'] all_orgs = wa.organisms.get_organisms() if 'error' in all_orgs: all_orgs = [] all_orgs = [x['commonName'] for x in all_orgs] if org_cn not in all_orgs: raise Exception("Could not find organism %s" % org_cn) orgs = accessible_organisms(gx_user, [org_cn], 'WRITE') if not orgs: raise Exception("Naming Conflict. You do not have write permission on this organism. Either request permission from the owner, or choose a different name for your organism.") log.info("\tUpdating Organism") if IsRemote(): with tempfile.NamedTemporaryFile(suffix='.tar.gz') as archive: with tarfile.open(archive.name, mode="w:gz") as tar: dataset_data_dir = args.jbrowse_src for file in glob.glob(dataset_data_dir): tar.add(file, arcname=file.replace(dataset_data_dir, './')) if IsBlatEnabled(): tar.add(path_2bit, arcname="./searchDatabaseData/genome.2bit") data = wa.remote.update_organism( org['id'], archive,
org_cns, seqs = GuessCn(args, wa) if not isinstance(org_cns, list): org_cns = [org_cns] all_orgs = wa.organisms.get_organisms() if 'error' in all_orgs: all_orgs = [] all_orgs = [org['commonName'] for org in all_orgs] org_data = [] for org_cn in org_cns: if org_cn not in all_orgs: raise Exception("Could not find organism %s" % org_cn) orgs = accessible_organisms(gx_user, [org_cn], 'READ') if not orgs: raise Exception("You do not have read permission on organism %s" % org_cn) org = wa.organisms.show_organism(org_cn) uuid_gff = wa.io.write_downloadable(org['commonName'], 'GFF3', export_gff3_fasta=True, sequences=seqs) if 'error' in uuid_gff or 'uuid' not in uuid_gff: raise Exception("Apollo failed to prepare the file for download: %s" % uuid_gff) args.gff.write(wa.io.download(uuid_gff['uuid'], output_format="text")) time.sleep(1) uuid_vcf = wa.io.write_downloadable(org['commonName'], 'VCF', sequences=seqs) if 'error' in uuid_vcf or 'uuid' not in uuid_vcf: raise Exception("Apollo failed to prepare the file for download: %s" % uuid_vcf)
#!/usr/bin/env python from __future__ import print_function import argparse import json from apollo import accessible_organisms from arrow.apollo import get_apollo_instance from webapollo import UserObj, handle_credentials if __name__ == '__main__': parser = argparse.ArgumentParser(description='List all organisms available in an Apollo instance') parser.add_argument('email', help='User Email') args = parser.parse_args() wa = get_apollo_instance() gx_user = UserObj(**wa.users._assert_or_create_user(args.email)) handle_credentials(gx_user) all_orgs = wa.organisms.get_organisms() orgs = accessible_organisms(gx_user, all_orgs) print(json.dumps(orgs, indent=2))