33import json
44from datetime import date
55
6+
67def today ():
78 """
89 Get today's snapshot of Brain Image Library.
@@ -23,87 +24,100 @@ def today():
2324 else :
2425 print ("Error: Failed to fetch JSON data" )
2526 return pd .DataFrame ()
26-
27+
28+
2729def __get_number_of_datasets (df ):
28- return len (df )
30+ return len (df )
31+
2932
3033def __get_completeness_score (df ):
31- return df ['score' ].sum ()/ len (df )
34+ return df ["score" ].sum () / len (df )
35+
3236
3337def __is_reachable (url ):
34- response = requests .get (url )
38+ response = requests .get (url )
39+
40+ if response .status_code == 200 :
41+ return True
42+ else :
43+ return False
3544
36- if response .status_code == 200 :
37- return True
38- else :
39- return False
4045
4146def __get_metadata_version (df ):
42- return df ['metadata_version' ] .value_counts ().to_dict ()
47+ return df ["metadata_version" ].value_counts ().to_dict ()
48+
4349
4450def __get_contributor (df ):
45- return df ['contributor' ].value_counts ().to_dict ()
51+ return df ["contributor" ].value_counts ().to_dict ()
52+
4653
4754def __get_affilation (df ):
48- return df ['affiliation' ].value_counts ().to_dict ()
55+ return df ["affiliation" ].value_counts ().to_dict ()
56+
4957
5058def __get_award_number (df ):
51- return df ['award_number' ].value_counts ().to_dict ()
59+ return df ["award_number" ].value_counts ().to_dict ()
60+
5261
5362def __get_species (df ):
54- return df ['species' ].value_counts ().to_dict ()
63+ return df ["species" ].value_counts ().to_dict ()
64+
5565
5666def __get_cnbtaxonomy (df ):
57- return df ['cnbtaxonomy' ].value_counts ().to_dict ()
67+ return df ["cnbtaxonomy" ].value_counts ().to_dict ()
68+
5869
5970def __get_samplelocalid (df ):
60- return df ['samplelocalid' ].value_counts ().to_dict ()
71+ return df ["samplelocalid" ].value_counts ().to_dict ()
72+
6173
6274def __get_genotype (df ):
63- return df ['genotype' ].value_counts ().to_dict ()
75+ return df ["genotype" ].value_counts ().to_dict ()
76+
6477
6578def __get_generalmodality (df ):
66- return df ['generalmodality' ].value_counts ().to_dict ()
79+ return df ["generalmodality" ].value_counts ().to_dict ()
80+
6781
6882def __get_technique (df ):
69- return df ['technique' ].value_counts ().to_dict ()
83+ return df ["technique" ].value_counts ().to_dict ()
84+
7085
7186def __get_locations (df ):
72- return df ['locations' ].value_counts ().to_dict ()
73-
74- def __get_contributors (df ):
87+ return df ["locations" ].value_counts ().to_dict ()
88+
89+
90+ def __get_contributors (df ):
7591 """
76- This returns an array of contributor names from the contributorname column.
77- """
78- return df [' contributorname' ].unique ()
79-
92+ This returns an array of contributor names from the contributorname column.
93+ """
94+ return df [" contributorname" ].unique ()
95+
8096
8197def report ():
8298 # Get today's date
83- tdate = date .today ()
84-
85- # Convert date to string
86- tdate = tdate .strftime ("%Y-%m-%d" )
87-
88- df = today ()
89-
90- report = {}
91- report ['date' ] = tdate
92- report ['number_of_datasets' ] = __get_number_of_datasets (df )
93- report ['completeness_score' ] = __get_completeness_score (df )
94- report ['metadata_version' ] = __get_metadata_version (df )
95- report ['contributor' ] = __get_contributor (df )
96- report ['affiliation' ] = __get_affilation (df )
97- report ['award_number' ] = __get_award_number (df )
98- report ['species' ] = __get_species (df )
99- report ['cnbtaxonomy' ] = __get_cnbtaxonomy (df )
100- report ['samplelocalid' ] = __get_samplelocalid (df )
101- report ['genotype' ] = __get_genotype (df )
102- report ['generalmodality' ] = __get_generalmodality (df )
103- report ['technique' ] = __get_technique (df )
104- report ['locations' ] = __get_locations (df )
105-
106- report ['is_reachable' ] = df ['URL' ].apply (__is_reachable )
107-
108- return report
109-
99+ tdate = date .today ()
100+
101+ # Convert date to string
102+ tdate = tdate .strftime ("%Y-%m-%d" )
103+
104+ df = today ()
105+
106+ report = {}
107+ report ["date" ] = tdate
108+ report ["number_of_datasets" ] = __get_number_of_datasets (df )
109+ report ["completeness_score" ] = __get_completeness_score (df )
110+ report ["metadata_version" ] = __get_metadata_version (df )
111+ report ["contributor" ] = __get_contributor (df )
112+ report ["affiliation" ] = __get_affilation (df )
113+ report ["award_number" ] = __get_award_number (df )
114+ report ["species" ] = __get_species (df )
115+ report ["cnbtaxonomy" ] = __get_cnbtaxonomy (df )
116+ report ["samplelocalid" ] = __get_samplelocalid (df )
117+ report ["genotype" ] = __get_genotype (df )
118+ report ["generalmodality" ] = __get_generalmodality (df )
119+ report ["technique" ] = __get_technique (df )
120+ report ["locations" ] = __get_locations (df )
121+ report ["is_reachable" ] = df ["URL" ].apply (__is_reachable )
122+
123+ return report
0 commit comments