Add Search Studies object

This object has natural language parsing for searches and returns a dictionary of {study_id: [samp1, samp2, ...]} of samples and studies matching the search query. An example query is also in the documentation, showing you can get pretty complex with them.
Possible to join on INTERSECT instead of magic numbers?
On Jul 9, 2014 5:44 PM, "adamrp" <notifications@github.com> wrote:

> In qiita_db/search.py:
>
> > +        # create the study finding SQL
> > +        # remove metadata headers that are in required_sample_info table
> > +        meta_headers = meta_headers.difference(required_cols)
> > +        # get all study ids that contain all metadata categories searched for
> > +        sql = []
> > +        for meta in meta_headers:
> > +            sql.append("SELECT study_id FROM qiita.study_sample_columns WHERE "
> > +                       "column_name = '%s' INTERSECT" %
> > +                       scrub_data(meta))
> > +        # combine the query, stripping off the last INTERSECT
> > +        study_sql = ' '.join(sql)[:-10]
> > +
> > +        # create  the sample finding SQL
> > +        sample_sql = ("SELECT r.sample_id FROM qiita.required_sample_info r "
> > +                      "JOIN qiita.sample_%s s ON s.sample_id = r.sample_id "
> > +                      "WHERE {0}".format(sql_where))
>
> If the above INTERSECTs do not find any tables, this will throw an SQL
> error, right?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/biocore/qiita/pull/190/files#r14743256>.
>