Skip to content

Commit 56430ab

Browse files
committed
publications endpoint
1 parent fb7afb8 commit 56430ab

2 files changed

Lines changed: 66 additions & 3 deletions

File tree

‎gemmapy/_processors.py‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,31 @@ def process_samples(d:list):
477477
for x in sub.field_in_list(d,"sample","factor_value_objects")]
478478

479479
}).sort_values(by= ['sample_ID'],ignore_index=True)
480-
480+
481+
return df
482+
483+
def process_publications(d:list):
484+
485+
df = pd.DataFrame({
486+
"publication_ID": sub.field_in_list(d,"id"),
487+
"title": sub.field_in_list(d,"title"),
488+
"authors": sub.field_in_list(d,"author_list"),
489+
"publication": sub.field_in_list(d,"publication"),
490+
"publication_date": sub.field_in_list(d,"publication_date"),
491+
"publisher": sub.field_in_list(d,"publisher"),
492+
"volume": sub.field_in_list(d,"volume"),
493+
"issue": sub.field_in_list(d,"issue"),
494+
"pages": sub.field_in_list(d,"pages"),
495+
"abstract": sub.field_in_list(d,"abstract_text"),
496+
"pubmed_ID": sub.field_in_list(d,"citation","pubmed_accession"),
497+
"pubmed_URL": sub.field_in_list(d,"citation","pubmed_url"),
498+
"citation": sub.field_in_list(d,"citation","citation"),
499+
"pub_accession": sub.field_in_list(d,"pub_accession"),
500+
"mesh_terms": sub.field_in_list(d,"mesh_terms"),
501+
"chemicals_terms": sub.field_in_list(d,"chemicals_terms"),
502+
"retracted": sub.field_in_list(d,"retracted"),
503+
})
504+
481505
return df
482506

483507
def process_datasets(d:list):

‎gemmapy/gemmapy_api.py‎

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,47 @@ def get_dataset_samples(self,
568568
response = self.raw.get_dataset_samples(dataset, use_processed_quantitation_type = use_processed_quantitation_type, **kwargs)
569569
df = ps.process_samples(response.data)
570570
return df
571-
572-
# datasets/{dataset}/svd ---
571+
572+
# /datasets/{dataset}/publications, get_dataset_all_publications ------
573+
def get_dataset_all_publications(self, dataset:str|int, **kwargs)->DataFrame:
574+
"""
575+
Retrieve all publications associated with a dataset
576+
577+
578+
:param dataset: A numerical dataset identifier or a dataset short name
579+
:type dataset: str|int
580+
:param **kwargs: Additional arguments to pass to raw.get_dataset_all_publications
581+
:return: A DataFrame with one row per publication associated with the
582+
dataset (the primary publication and any related references).
583+
584+
The fields of the DataFrame are:
585+
- publication_ID: Internal Gemma ID for the bibliographic reference
586+
- title: Title of the publication
587+
- authors: Author list as a single string
588+
- publication: Journal or venue name
589+
- publication_date: Date of publication
590+
- publisher: Publisher name
591+
- volume: Journal volume
592+
- issue: Journal issue
593+
- pages: Page range
594+
- abstract: Abstract text
595+
- pubmed_ID: PubMed accession ID
596+
- pubmed_URL: PubMed URL
597+
- citation: Formatted citation string
598+
- pub_accession: Accession in the source publication database
599+
- mesh_terms: List of MeSH terms
600+
- chemicals_terms: List of chemicals terms
601+
- retracted: Whether the publication has been retracted
602+
:rtype: DataFrame
603+
604+
"""
605+
response = self.raw.get_dataset_all_publications(dataset, **kwargs)
606+
df = ps.process_publications(response.data)
607+
ps.attach_attributes(df, response.to_dict())
608+
609+
return df
610+
611+
# datasets/{dataset}/svd ---
573612
# not implemented
574613

575614
# datasets, get_datasets ------

0 commit comments

Comments
 (0)