Closed rykahsay closed 1 year ago
@rykahsay You need this API endpoint: https://biocomputeobject.org/api/docs/#/BCO%20Management/api_objects_drafts_publish_create
I modified what you provided above.
draft_id
: is the BCO draft you want to publish, or the source.
object_id
[OPTIONAL]: This is the ID you would like to have it published as. The code will check the version and make sure it is available. If it is then that will be accepted. If not, it will get the next sequential object ID.
bco_file = "GLY_000001.json"
bco_body = json.loads(open(bco_file, "r").read())
header = {"accept": "application/json", "Content-Type": "application/json", "Authorization": "Token " + auth_token}
data = {
"POST_api_objects_drafts_publish": [
{
"prefix": "GLY",
"draft_id": "https://biocomputeobject.org/GLY_000001/DRAFT",
"object_id": "https://biocomputeobject.org/GLY_000001/2.0.3",
"delete_draft": False
}
]
}
api_url = "https://biocomputeobject.org/api/objects/drafts/publish/"
res = requests.post(api_url, headers=header, json=data)
Can the "publish" endpoint take "content" parameter which takes the BCO body instead of "draft_id" just like the "create" endpoint?
What I want to publish is not the draft on the biocomputeobject server. I want to publish the BCO I have as a file in the GlyGen server, and it was created by downloading the draft but then modified programmatically.
I know one way is to overwrite the draft bco with the modified bco on the glygen server and then publish but that is not the workflow we have agreed with my team.
"The code will check the version and make sure it is available. If it is then that will be accepted. If not, it will get the next sequential object ID"
--> How do I make sure the version is available? I do not want GLY_000001 to be published with a different object ID.
check the version and make sure it is available
RE: The VERSION is available. If the version is not then it will use the next sequential version or it will fail. But the OBJECT ID will not be changed.
I tried the following and it is not giving me any relevant error message. Can you please give me a working example in this form?
curl -H "Content-Type: application/json" -H "Authorization: Token xyz" https://biocomputeobject.org/api/objects/publish/ -d '{"POST_api_objects_publish": [{ "prefix": "GLY","owner_group": "gly_drafter","object_id":"https://biocomputeobject.org/GLY_000001/2.0.3", "schema": "IEEE","contents":{}}]}'
@rykahsay The server was throwing a 500 because of the empty contents. I. fixed the error handling for that and it will now return a proper response if the contents is empty. This is the curl I was using locally. It should work for you now.
This function WILL NOT create a draft for the object you publish. So if one does not exist and you want it you will need to create that independently in another API call.
curl -X POST "http://localhost:8000/api/objects/publish/" -H "accept: application/json" -H "Authorization: Token 2f2a599026581c158a07f968c56292c77f4be875" -H "Content-Type: application/json" -H "X-CSRFToken: wargvgMYWkoQdPrC2QymCKxELEjGZY9hbqEBcSX951PLwE7PwuqwCQwHQyp8Hnxz" -d "{ \"POST_api_objects_publish\": [ { \"prefix\": \"gly\", \"owner_group\": \"gly_drafter\", \"object_id\": \"http://127.0.0.1:8000/GLY_000001/2.0.3\", \"schema\": \"IEEE\", \"contents\": {\"object_id\":\"https://biocomputeobject.org/GLY_000001/2.0.2\",\"spec_version\":\"https://w3id.org/ieee/ieee-2791-schema/2791object.json\",\"extension_domain\":[{\"extension_schema\":\"http://www.w3id.org/biocompute/extension_domain/1.2.0/dataset/dataset_extension.json\",\"dataset_extension\":{\"additional_license\":{\"data_license\":\"https://creativecommons.org/licenses/by/4.0/\",\"script_license\":\"https://www.gnu.org/licenses/gpl-3.0.en.html\"},\"dataset_categories\":[{\"category_value\":\"Homo sapiens\",\"category_name\":\"species\"},{\"category_value\":\"Protein\",\"category_name\":\"molecule\"},{\"category_value\":\"Protein Canonical Accessions\",\"category_name\":\"tags\"},{\"category_value\":\"csv\",\"category_name\":\"file_type\"},{\"category_value\":\"Reviewed\",\"category_name\":\"status\"},{\"category_value\":\"internal\",\"category_name\":\"scope\"}]}}],\"provenance_domain\":{\"license\":\"https://creativecommons.org/licenses/by/4.0/\",\"name\":\"Human Proteome Masterlist (UniProtKB)\",\"contributors\":[{\"affiliation\":\"The George Washington University\",\"contribution\":[\"createdBy\"],\"name\":\"Jeet Vora\",\"email\":\"jeetvora@gwu.edu\"},{\"affiliation\":\"The George Washington University\",\"contribution\":[\"createdBy\"],\"name\":\"Rahi Navelkar\",\"email\":\"rsn13@gwu.edu\"},{\"affiliation\":\"The George Washington University\",\"contribution\":[\"createdBy\"],\"name\":\"Robel Kahsay\",\"email\":\"rykahsay@gwu.edu\"},{\"affiliation\":\"EMBL-EBI-UniProt\",\"contribution\":[\"contributedBy\"],\"name\":\"Maria Martin\",\"email\":\"martin@ebi.ac.uk\"},{\"affiliation\":\"EMBL-EBI-UniProt\",\"contribution\":[\"contributedBy\"],\"name\":\"Preethi Vasudev\",\"email\":\"pvasudev@ebi.ac.uk\"},{\"affiliation\":\"The George Washington University\",\"contribution\":[\"createdBy\"],\"name\":\"Karina Martinez\",\"email\":\"karinamartinez@gwu.edu\"},{\"affiliation\":\"The George Washington University\",\"contribution\":[\"createdBy\"],\"name\":\"Amanda Bell\",\"email\":\"amandab2140@gwu.edu\"},{\"affiliation\":\"The George Washington University\",\"contribution\":[\"createdBy\"],\"name\":\"Jonathon Keeney\",\"email\":\"keeneyjg@gwu.edu\"},{\"affiliation\":\"The George Washington University\",\"contribution\":[\"createdBy\"],\"name\":\"Millicent Quartey\",\"email\":\"mquartey@email.gwu.edu\"}],\"created\":\"2019-01-23T17:21:05.867420\",\"modified\":\"2022-09-26T08:44:32.945603\",\"version\":\"2.0.3\"},\"description_domain\":{\"keywords\":[\"canonical accessions\",\"gene name\",\"protein isoforms\",\"complete proteome\",\"UniProtKB\"],\"pipeline_steps\":[{\"name\":\"make-protein-dataset.py\",\"step_number\":1,\"version\":\"\",\"input_list\":[{\"uri\":\"https://data.glygen.org/ln2data/releases/data/v-2.0.2/source/uniprot-proteome-homo-sapiens.nt\",\"filename\":\"uniprot-proteome-homo-sapiens.nt\"}],\"output_list\":[{\"uri\":\"https://data.glygen.org/ln2data/releases/data/v-2.0.2/reviewed/human_protein_masterlist.csv\",\"filename\":\"human_protein_masterlist.csv\"}],\"prerequisite\":[],\"description\":\"The script loads the UniProtKB proteome data from the triplestore containing triples from nt file to map UniProtKB canonical accessions to reviewed and unreviewed isoforms via gene grouping\"}]},\"execution_domain\":{\"external_data_endpoints\":[],\"environment_variables\":{},\"script_driver\":\"manual\",\"software_prerequisites\":[{\"version\":\"2.7.5\",\"name\":\"Python\",\"uri\":{\"uri\":\"https://www.python.org/download/releases/2.7.5/\"}}],\"script\":[{\"uri\":{\"uri\":\"https://github.com/glygener/glygen-backend-integration/blob/master/dataset-maker/make-protein-dataset.py\",\"filename\":\"make-protein-dataset.py\"}}]},\"error_domain\":{\"empirical_error\":{},\"algorithmic_error\":{}},\"parametric_domain\":[{\"step\":\"\",\"param\":\"\",\"value\":\"\"}],\"usability_domain\":[\"The Human Proteome Materlist dataset contains human [taxid:9606] UniProtKB canonical accessions mapped to the reviewed (SwissProt) and unreviewed (TrEMBL) UniProtKB isoforms via gene grouping. The dataset is derived from 2019_09 UniProtKB release. If you use this dataset please provide proper attribution to EMBL-EBI-UniProtKB and GlyGen\"],\"etag\":\"1bbf8878ac72b2c9aebb2bb675f1738a5315c73d86079d8815d842e4a904e735\",\"io_domain\":{\"input_subdomain\":[{\"uri\":{\"filename\":\"uniprot-proteome-homo-sapiens.nt\",\"uri\":\"https:/data.glygen.org/ln2downloads/ebi/2022_03/uniprot-proteome-homo-sapiens.nt\"}}],\"output_subdomain\":[{\"mediatype\":\"csv\",\"uri\":{\"uri\":\"https:/data.glygen.org/ln2releases/data/v-2.0.2/reviewed/human_protein_masterlist.csv\",\"filename\":\"human_protein_masterlist.csv\"}},{\"mediatype\":\"csv\",\"uri\":{\"uri\":\"https:/data.glygen.org/ln2releases/data/v-2.0.2/reviewed/human_protein_masterlist.stat.csv\",\"filename\":\"human_protein_masterlist.stat.csv\"}}]}} } ]}"
How can I remove something I published incase I want to re-do the publishing. Currently, I get the following error:
[{"request_status":"FAILURE","status_code":"409","message":"The provided object GLY_000001/v-2.1.1 h as already been created on this server."}]
No un-publishing allowed.
Given below is a code that can upload a "draft" BCO. What needs to change if I want to upload a versioned BCO that should be accessed at https://biocomputeobject.org/GLY_000001/2.0.3? It would be great if you could edit this code and send me back.