Skip to content

'sample_id' is hard coded in as a field in virtual_db.py #78

@cmatKhan

Description

@cmatKhan

at line 593

raw = list(dict.fromkeys(["sample_id"] + meta_cols + prop_raw_cols))

and 595

raw = list(dict.fromkeys(["sample_id"] + prop_raw_cols))

the hard coded value "sample_id" is being added to the list of fields in the construction of the sql cmd that creates a view from the config in virtual_db.py.

This should be set to the field identified by the sample_id in the config, not hard coded.

This config

repositories:
  BrentLab/callingcards:
    regulator_locus_tag:
      field: regulator_locus_tag
    regulator_symbol:
      field: regulator_symbol
    carbon_source:
      path: experimental_conditions.media.carbon_source.compound
    temperature_celsius:
      path: experimental_conditions.temperature_celsius
    dataset:
      # binding
      annotated_features:
        db_name: cc_replicate_db
        sample_id: 
          field: id
      annotated_features_combined:
        db_name: cc_combined_db
        sample_id:
          field: genome_map_id_set
      annotated_features_orig_reprocess:
        db_name: cc_replicate_repro
        sample_id:
          field: id
        carbon_source:
          field: condition
          path: media.carbon_source.compound
...

produces this error

---------------------------------------------------------------------------
BinderException                           Traceback (most recent call last)
Cell In[4], [line 3](vscode-notebook-cell:?execution_count=4&line=3)
      1 # List all registered views
      2 print("Registered views:")
----> [3](vscode-notebook-cell:?execution_count=4&line=3) for name in vdb.tables():
      4     print(f"  {name}")

File ~/code/tfbp/tfbpapi/tfbpapi/virtual_db.py:315, in VirtualDB.tables(self)
    308 def tables(self) -> list[str]:
    309     """
    310     Return sorted list of registered view names.
    311 
    312     :return: Sorted list of view names
    313 
    314     """
--> [315](https://file+.vscode-resource.vscode-cdn.net/home/chase/code/tfbp/tfbpapi/tmp/~/code/tfbp/tfbpapi/tfbpapi/virtual_db.py:315)     self._ensure_sql_views()
    316     return sorted(self._list_views())

File ~/code/tfbp/tfbpapi/tfbpapi/virtual_db.py:402, in VirtualDB._ensure_sql_views(self)
    400     return
    401 self._conn = duckdb.connect(":memory:")
--> [402](https://file+.vscode-resource.vscode-cdn.net/home/chase/code/tfbp/tfbpapi/tmp/~/code/tfbp/tfbpapi/tfbpapi/virtual_db.py:402) self._register_all_views()
    403 self._views_registered = True
...
BinderException: Binder Error: Referenced column "sample_id" not found in FROM clause!
Candidate bindings: "callingcards_enrichment", "target_symbol"

LINE 1: ...ource, 'room' AS temperature_celsius FROM (SELECT DISTINCT sample_id, regulator_locus_tag, regulator_symbol FROM __cc_...
                                                                      ^
Output is truncated. View as a [scrollable element](command:cellOutput.enableScrolling?d9e4bee4-09e2-4062-b482-db0939036d84) or open in a [text editor](command:workbench.action.openLargeOutput?d9e4bee4-09e2-4062-b482-db0939036d84). Adjust cell output [settings](command:workbench.action.openSettings?%5B%22%40tag%3AnotebookOutputLayout%22%5D)...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions