text: user8601: I would like to extract all information about each SAMPLE after running the following query (run the query and add a | grep SAMPLE for clarification on what I mean by SAMPLE):
  esearch -db sra -query PRJNA514750 | efetch -format xml
  I tried the following:
  esearch -db sra -query PRJNA514750 | efetch -format xml | xtract -pattern EXPERIMENT -element SAMPLE
  but this returns nothing (PS: SAMPLEs are within an EXPERIMENT tag). I read in the e-utilities guide that -pattern will divide the data into rows, and -element into columns, so I'm presuming that this didn't work because SAMPLE has multiple tags within it. So I then tried:
  esearch -db sra -query PRJNA514750 | efetch -format xml | xtract -pattern SAMPLE -element random_SAMPLE_tag
  
  where random_SAMPLE_tag is any tag within SAMPLE.
  Here's a concrete example:
  esearch -db sra -query PRJNA514750 | efetch -format xml | xtract -pattern SAMPLE -element TITLE
  
  This works, but I want to get all the information about each SAMPLE, and I do not know beforehand what the tags within it are (I manually got TITLE in this case), and since I want to get this info for a quite a few studies, I can't manually check this.
  
  user161: You can give pysradb a shot.
  study_accession experiment_accession experiment_title                                                   experiment_desc              
                                        organism_taxid  organism_name           library_strategy library_source  library_selection library_layout sample_accession sample_title instrument           total_spots total_size  run_accession run_total_spots run_total_bases
  SRP178555       SRX5243234             GSM3560726: 97-gem-Day3-OEA115; Caenorhabditis elegans; RNA-Seq    GSM3560726: 97-gem-Day3-OEA115; Caenorhabditis elegans; RNA-Seq  6239            Caenorhabditis elegans  RNA-Seq          TRANSCRIPTOMIC  cDNA              SINGLE         SRS4245909                    Illumina HiSeq 2500  19052916     446793895  SRR8435699    19052916         971698716    
  SRP178555       SRX5243233             GSM3560725: 97-gem-Day3-OEA087; Caenorhabditis elegans; RNA-Seq    GSM3560725: 97-gem-Day3-OEA087; Caenorhabditis elegans; RNA-Seq  6239            Caenorhabditis elegans  RNA-Seq          TRANSCRIPTOMIC  cDNA              SINGLE         SRS4245908                    Illumina HiSeq 2500  18156224     428457264  SRR8435698    18156224         925967424 
  .. [truncated]
  
  
original_text: 8601: <p>I would like to extract all information about each <code>SAMPLE</code> after running the following query (run the query and add a <code>| grep SAMPLE</code> for clarification on what I mean by <code>SAMPLE</code>):</p>
  <p><code>esearch -db sra -query PRJNA514750 | efetch -format xml</code></p>
  <p>I tried the following:</p>
  <p><code>esearch -db sra -query PRJNA514750 | efetch -format xml | xtract -pattern EXPERIMENT -element SAMPLE</code></p>
  <p>but this returns nothing (PS: <code>SAMPLE</code>s are within an <code>EXPERIMENT</code> tag). I read in the <a href="https://www.ncbi.nlm.nih.gov/books/NBK25497/" rel="nofollow noreferrer">e-utilities guide</a> that <code>-pattern</code> will divide the data into rows, and <code>-element</code> into columns, so I'm presuming that this didn't work because <code>SAMPLE</code> has multiple tags within it. So I then tried:</p>
  <pre><code>esearch -db sra -query PRJNA514750 | efetch -format xml | xtract -pattern SAMPLE -element random_SAMPLE_tag
  </code></pre>
  <p>where <code>random_SAMPLE_tag</code> is any tag within <code>SAMPLE</code>.</p>
  <p>Here's a concrete example:</p>
  <pre><code>esearch -db sra -query PRJNA514750 | efetch -format xml | xtract -pattern SAMPLE -element TITLE
  </code></pre>
  <p>This works, but I want to get all the information about each <code>SAMPLE</code>, and I do not know beforehand what the tags within it are (I manually got <code>TITLE</code> in this case), and since I want to get this info for a quite a few studies, I can't manually check this.</p>
   161: <p>You can give <a href="https://github.com/saketkc/pysradb" rel="nofollow noreferrer">pysradb</a> a shot.</p>
  <pre class="lang-bash prettyprint-override"><code>study_accession experiment_accession experiment_title                                                   experiment_desc              
                                        organism_taxid  organism_name           library_strategy library_source  library_selection library_layout sample_accession sample_title instrument           total_spots total_size  run_accession run_total_spots run_total_bases
  SRP178555       SRX5243234             GSM3560726: 97-gem-Day3-OEA115; Caenorhabditis elegans; RNA-Seq    GSM3560726: 97-gem-Day3-OEA115; Caenorhabditis elegans; RNA-Seq  6239            Caenorhabditis elegans  RNA-Seq          TRANSCRIPTOMIC  cDNA              SINGLE         SRS4245909                    Illumina HiSeq 2500  19052916     446793895  SRR8435699    19052916         971698716    
  SRP178555       SRX5243233             GSM3560725: 97-gem-Day3-OEA087; Caenorhabditis elegans; RNA-Seq    GSM3560725: 97-gem-Day3-OEA087; Caenorhabditis elegans; RNA-Seq  6239            Caenorhabditis elegans  RNA-Seq          TRANSCRIPTOMIC  cDNA              SINGLE         SRS4245908                    Illumina HiSeq 2500  18156224     428457264  SRR8435698    18156224         925967424 
  .. [truncated]
  </code></pre>
  