Skip to content

Commit

Permalink
reformat date like a date object in ontobio
Browse files Browse the repository at this point in the history
  • Loading branch information
sierra-moxon committed Mar 6, 2024
1 parent 3543344 commit 4d88920
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
16 changes: 15 additions & 1 deletion src/gopreprocess/goa_annotation_creation_controller.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Protein 2 GO AnnotationConverter class."""

import collections
import copy
import datetime
from typing import Any, Union
Expand Down Expand Up @@ -57,7 +58,20 @@ def generate_annotation(
new_annotation.subject.id = new_gene
new_annotation.subject.synonyms = []
new_annotation.object.taxon = Curie.from_str("NCBITaxon:10090")
new_annotation.date = datetime.datetime.now().strftime("%Y-%m-%d")

Date = collections.namedtuple("Date", ["year", "month", "day", "time"])

# Format the date as YYYYMMDD, which is suitable for GAF date requirements
gaf_date = datetime.now().strftime("%Y%m%d")

# Extract year, month, and day components from the YYYYMMDD string
year = gaf_date[:4]
month = gaf_date[4:6]
day = gaf_date[6:8]

# Create a Date object, time is set to an empty string.
date_object = Date(year=year, month=month, day=day, time="")
new_annotation.date = date_object

# gp_isoforms: self.subject_extensions[0].term

Expand Down
15 changes: 14 additions & 1 deletion src/gopreprocess/ortho_annotation_creation_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
to map genes between species).
"""

import collections
import copy
import datetime
from typing import List
Expand Down Expand Up @@ -333,7 +334,19 @@ def generate_annotation(
new_annotation.subject_extensions = []
new_annotation.provided_by = "GO_Central"

new_annotation.date = datetime.datetime.now().strftime("%Y-%m-%d")
Date = collections.namedtuple("Date", ["year", "month", "day", "time"])

# Format the date as YYYYMMDD, which is suitable for GAF date requirements
gaf_date = datetime.now().strftime("%Y%m%d")

# Extract year, month, and day components from the YYYYMMDD string
year = gaf_date[:4]
month = gaf_date[4:6]
day = gaf_date[6:8]

# Create a Date object, time is set to an empty string.
date_object = Date(year=year, month=month, day=day, time="")
new_annotation.date = date_object

new_annotation.subject.fullname = target_genes[taxon_to_provider[self.target_taxon] + ":" + gene][
"fullname"
Expand Down

0 comments on commit 4d88920

Please sign in to comment.