3737from api .pairwise_api import PairwiseResults , PairwiseResultVector , PairwiseFilterMessage
3838from api .api_helpers import sql_connection
3939
40- from projects .models import Study
40+ from projects .models import Project
4141
4242import sys
4343
4747 'BMI' : 'kg/m^2' ,
4848}
4949
50- ISB_CGC_STUDIES = {
50+ ISB_CGC_PROJECTS = {
5151 'list' : []
5252}
5353
5454# DUPLICATE METHOD
5555# Due to the way sql connections are done, it's easiest to duplicate this method and the static variable
5656# it creates. The original is in Cohorts/views, and all changes will happen there first.
5757#
58- # Generate the ISB_CGC_STUDIES ['list'] value set based on the get_isbcgc_study_set sproc
59- def fetch_isbcgc_study_set ():
58+ # Generate the ISB_CGC_PROJECTS ['list'] value set based on the get_isbcgc_project_set sproc
59+ def fetch_isbcgc_project_set ():
6060 try :
6161 cursor = None
6262 db = sql_connection ()
63- if not ISB_CGC_STUDIES ['list' ] or len (ISB_CGC_STUDIES ['list' ]) <= 0 :
63+ if not ISB_CGC_PROJECTS ['list' ] or len (ISB_CGC_PROJECTS ['list' ]) <= 0 :
6464 cursor = db .cursor ()
65- cursor .execute ("SELECT COUNT(SPECIFIC_NAME) FROM INFORMATION_SCHEMA.ROUTINES WHERE SPECIFIC_NAME = 'get_isbcgc_study_set ';" )
65+ cursor .execute ("SELECT COUNT(SPECIFIC_NAME) FROM INFORMATION_SCHEMA.ROUTINES WHERE SPECIFIC_NAME = 'get_isbcgc_project_set ';" )
6666 # Only try to fetch the study set if the sproc exists
6767 if cursor .fetchall ()[0 ][0 ] > 0 :
68- cursor .execute ("CALL get_isbcgc_study_set ();" )
69- ISB_CGC_STUDIES ['list' ] = []
68+ cursor .execute ("CALL get_isbcgc_project_set ();" )
69+ ISB_CGC_PROJECTS ['list' ] = []
7070 for row in cursor .fetchall ():
71- ISB_CGC_STUDIES ['list' ].append (row [0 ])
71+ ISB_CGC_PROJECTS ['list' ].append (row [0 ])
7272 else :
7373 # Otherwise just warn
74- logger .warn ("[WARNING] Stored procedure get_isbcgc_study_set was not found!" )
74+ logger .warn ("[WARNING] Stored procedure get_isbcgc_project_set was not found!" )
7575
76- return ISB_CGC_STUDIES ['list' ]
76+ return ISB_CGC_PROJECTS ['list' ]
7777 except Exception as e :
7878 logger .error (e )
7979 logger .error (traceback .format_exc ())
@@ -152,10 +152,11 @@ class PlotDataCohortInfo(Message):
152152
153153class PlotDataPoint (Message ):
154154 sample_id = StringField (1 )
155- x = StringField (2 )
156- y = StringField (3 )
157- c = StringField (4 )
158- cohort = IntegerField (5 , repeated = True )
155+ case_id = StringField (2 )
156+ x = StringField (3 )
157+ y = StringField (4 )
158+ c = StringField (5 )
159+ cohort = IntegerField (6 , repeated = True )
159160
160161
161162class PlotDataTypes (Message ):
@@ -392,7 +393,7 @@ def get_merged_feature_vectors(self, x_id, y_id, c_id, cohort_id_array, logTrans
392393 "[WARNING] No valid log base was supplied - log transformation will not be applied!"
393394 )
394395
395- vms = VectorMergeSupport ('NA' , 'sample_id' , ['x' , 'y' , 'c' ]) # changed so that it plots per sample not patient
396+ vms = VectorMergeSupport ('NA' , 'sample_id' , 'case_id' , ['x' , 'y' , 'c' ]) # changed so that it plots per sample not patient
396397 vms .add_dict_array (x_vec , 'x' , 'value' )
397398 vms .add_dict_array (y_vec , 'y' , 'value' )
398399 vms .add_dict_array (c_vec , 'c' , 'value' )
@@ -496,7 +497,7 @@ def data_access_for_plot(self, request):
496497 logging .error ("Invalid internal feature ID '{}'" .format (feature_id ))
497498 raise NotFoundException ()
498499
499- # Get the study IDs these cohorts' samples come from
500+ # Get the project IDs these cohorts' samples come from
500501 cohort_vals = ()
501502 cohort_params = ""
502503
@@ -509,9 +510,9 @@ def data_access_for_plot(self, request):
509510 db = sql_connection ()
510511 cursor = db .cursor ()
511512
512- tcga_studies = fetch_isbcgc_study_set ()
513+ tcga_studies = fetch_isbcgc_project_set ()
513514
514- cursor .execute ("SELECT DISTINCT study_id FROM cohorts_samples WHERE cohort_id IN (" + cohort_params + ");" ,cohort_vals )
515+ cursor .execute ("SELECT DISTINCT project_id FROM cohorts_samples WHERE cohort_id IN (" + cohort_params + ");" ,cohort_vals )
515516
516517 # Only samples whose source studies are TCGA studies, or extended from them, should be used
517518 confirmed_study_ids = []
@@ -525,11 +526,11 @@ def data_access_for_plot(self, request):
525526 unconfirmed_study_ids .append (row [0 ])
526527
527528 if len (unconfirmed_study_ids ) > 0 :
528- studies = Study .objects .filter (id__in = unconfirmed_study_ids )
529+ projects = Project .objects .filter (id__in = unconfirmed_study_ids )
529530
530- for study in studies :
531- if study .get_my_root_and_depth ()['root' ] in tcga_studies :
532- confirmed_study_ids .append (study .id )
531+ for project in projects :
532+ if project .get_my_root_and_depth ()['root' ] in tcga_studies :
533+ confirmed_study_ids .append (project .id )
533534
534535 return self .get_merged_feature_vectors (x_id , y_id , c_id , cohort_id_array , logTransform , confirmed_study_ids )
535536 except NotFoundException as nfe :
0 commit comments