From 25c1ac24f2f928abb4746d70ef67ab186ecbdb31 Mon Sep 17 00:00:00 2001 From: Max Zhao Date: Wed, 4 Oct 2023 16:26:51 +0200 Subject: [PATCH] Adding PMIDs for struc vars --- clinvar_this/io/tsv.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/clinvar_this/io/tsv.py b/clinvar_this/io/tsv.py index 53dbfd8..a2fdd70 100644 --- a/clinvar_this/io/tsv.py +++ b/clinvar_this/io/tsv.py @@ -692,7 +692,8 @@ def record_pubmed_citations( ) for pmid in record.pmids ] - return None + else: + return None def record_clinical_features( record: SeqVarTsvRecord, @@ -778,6 +779,20 @@ def record_condition(record: StrucVarTsvRecord) -> SubmissionCondition: else: return SubmissionCondition(db=ConditionDb.OMIM, id=record.omim[0]) + def record_pubmed_citations( + record: StrucVarTsvRecord, + ) -> typing.Optional[typing.List[SubmissionCitation]]: + if record.pmids: + return [ + SubmissionCitation( + db=CitationDb.PUBMED, + id=pmid, + ) + for pmid in record.pmids + ] + else: + return None + def record_clinical_features( record: StrucVarTsvRecord, ) -> typing.Optional[typing.List[SubmissionClinicalFeature]]: @@ -825,6 +840,7 @@ def record_clinical_features( clinical_significance=SubmissionClinicalSignificance( clinical_significance_description=record.clinical_significance_description, mode_of_inheritance=record.inheritance, + citation=record_pubmed_citations(record), ), record_status=RecordStatus.NOVEL, variant_set=SubmissionVariantSet( @@ -879,7 +895,8 @@ def _hpo_terms(submission: SubmissionClinvarSubmission) -> typing.Optional[typin def _pmids(submission: SubmissionClinvarSubmission) -> typing.Optional[typing.List[str]]: if citations := submission.clinical_significance.citation: return [c.id for c in citations if c.db == CitationDb.PUBMED and c.id] - return None + else: + return None def submission_to_seq_var_tsv_record( submission: SubmissionClinvarSubmission, @@ -979,7 +996,8 @@ def _inheritance(submission: SubmissionClinvarSubmission) -> typing.Optional[Mod def _pmids(submission: SubmissionClinvarSubmission) -> typing.Optional[typing.List[str]]: if citations := submission.clinical_significance.citation: return [c.id for c in citations if c.db == CitationDb.PUBMED and c.id] - return None + else: + return None def submission_to_struc_var_tsv_record( submission: SubmissionClinvarSubmission,