saketkc / pysradb

Package for fetching metadata and downloading data from SRA/ENA/GEO
https://saketkc.github.io/pysradb
BSD 3-Clause "New" or "Revised" License
307 stars 50 forks source link

[BUG] gsm-to-gse fails to produce output #127

Closed DevangThakkar closed 3 years ago

DevangThakkar commented 3 years ago

Describe the bug The gsm-to-gse subcommand fails with an error.

To Reproduce Steps to reproduce the behavior: pysradb gsm-to-gse GSM3396533 fails but all of pysradb gsm-to-srr GSM3396533 pysradb gsm-to-srx GSM3396533 pysradb gsm-to-srs GSM3396533 pysradb gsm-to-srp GSM3396533 work perfectly fine.

This is because there is no gsm_to_gse() function in sraweb.py but the others have their functions in there.

This is the traceback:

Traceback (most recent call last):<br/>
  File "/usr/local/bin/pysradb", line 8, in <module>
    sys.exit(parse_args())
  File "/usr/local/lib/python3.7/dist-packages/pysradb/cli.py", line 1223, in parse_args
    gsm_to_gse(args.gsm_ids, args.saveto, args.detailed, args.desc, args.expand)
  File "/usr/local/lib/python3.7/dist-packages/pysradb/cli.py", line 254, in gsm_to_gse
    expand_sample_attributes=expand,
  File "/usr/local/lib/python3.7/dist-packages/pysradb/sradb.py", line 793, in gsm_to_gse
    df = self.query(sql)
  File "/usr/local/lib/python3.7/dist-packages/pysradb/basedb.py", line 108, in query
    results = self.cursor.execute(sql_query).fetchall()
AttributeError: 'SRAweb' object has no attribute 'cursor'

Desktop (please complete the following information):

I have added the following function in class SRAweb that makes it work:

    def gsm_to_gse(self, gsm, **kwargs):
        gsm_df = self.fetch_gds_results(gsm, **kwargs)
        gsm_df = gsm_df[gsm_df.entrytype == "GSE"]
        gsm_df = gsm_df.rename(
            columns={
                "accession": "study_alias",
                "SRA": "study_accession"
            }
        )
        return gsm_df[["study_alias", "study_accession"]]

I can create a pull request if you'd like.

saketkc commented 3 years ago

Thanks for the bug report @DevangThakkar! A PR would be fantastic!

saketkc commented 3 years ago

Closed via #128