Answers.Body: <p>Looking at the <a href="https://github.com/samtools/htslib/blob/5c7ff9c6812f1e6ef1fd83ba73b8e42cfbabba93/hts.c#L2627-L2645" rel="nofollow noreferrer">htslib source code</a>, it seems like the answer is no, a single region specifier cannot span multliple chromosomes. </p>
  
  <p>Seems like the closest you can get is to enumerate all the chromosomes as separate regions on the <a href="http://www.htslib.org/doc/tabix.html" rel="nofollow noreferrer">command line</a>. So to get everything between <code>chrA:X</code> and <code>chrN:Y</code>, you would have to write:</p>
  
  <pre><code>tabix inputfile.gz chrA:X chrB chrC ... chrN:1-Y
  </code></pre>
  
  <p>(If you omit the end coordinate like <code>chrA:X</code>, the region encompasses <code>chrA</code> from the specified coordinate to the end. If only specify the chromosome name without the coordinates, like <code>chrB</code>, the region encompasses the whole named chromosome, and for the last chromosome, you can specify up to the desired point by starting from the beginning: <code>chrN:1-Y</code>.) </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-05-20T21:50:40.843Z
Answers.Text: Okay, thanks, that worked great. I was able to order chromosomes as desired to write standard output in BEDOPS `sort-bed` order.
Answers.UserDisplayName: Alex Reynolds
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-05-18T07:44:37.170Z
Answers.LastActivityDate: 2019-05-18T07:44:37.170Z
Answers.UserDisplayName: Jukka Matilainen
Body: <p>I can do something like this:</p>
  
  <pre><code><span class="math-container">$ tabix $</span>{url} ${range}
  </code></pre>
  
  <p>where <code>${range}</code> spans a region on a single chromosome, <em>e.g.</em>, <code>chrA:X-Y</code>.</p>
  
  <p>Can a <code>tabix</code> query span multiple chromosomes, <em>e.g.</em>, where <code>${range}</code> looks like <code>chrA:X-chrN:Y</code> (or similar), which returns data between <code>chrA:X</code> and <code>chrN:Y</code> (using either a lexicographical or natural sort order between <code>chrA</code> and <code>chrN</code>)?</p>
  
  <p><em>Note: I do not want to pass in a BED file of intervals. If it can't be done without passing in a separate file, that's fine. I only want to provide a one-liner to give to someone who can run <code>tabix</code> on their end, to do this type of query directly and remotely.</em> </p>
  
Tags: <tabix>
Title: Tabix queries spanning chromosomes
ThreadText: # Tabix queries spanning chromosomes
  
  (Asked by: username_0 on 2019-05-17)
  
  I can do something like this:
  
  ```
  $ tabix ${url} ${range}
  
  ```
  
  where `${range}` spans a region on a single chromosome, *e.g.*, `chrA:X-Y`.
  
  Can a `tabix` query span multiple chromosomes, *e.g.*, where `${range}` looks like `chrA:X-chrN:Y` (or similar), which returns data between `chrA:X` and `chrN:Y` (using either a lexicographical or natural sort order between `chrA` and `chrN`)?
  
  *Note: I do not want to pass in a BED file of intervals. If it can't be done without passing in a separate file, that's fine. I only want to provide a one-liner to give to someone who can run `tabix` on their end, to do this type of query directly and remotely.*
  
  **Tags:** tabix
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-05-18. Score: 3 | Accepted answer
  
  Looking at the [htslib source code](https://github.com/samtools/htslib/blob/5c7ff9c6812f1e6ef1fd83ba73b8e42cfbabba93/hts.c#L2627-L2645), it seems like the answer is no, a single region specifier cannot span multliple chromosomes.
  
  Seems like the closest you can get is to enumerate all the chromosomes as separate regions on the [command line](http://www.htslib.org/doc/tabix.html). So to get everything between `chrA:X` and `chrN:Y`, you would have to write:
  
  ```
  tabix inputfile.gz chrA:X chrB chrC ... chrN:1-Y
  
  ```
  
  (If you omit the end coordinate like `chrA:X`, the region encompasses `chrA` from the specified coordinate to the end. If only specify the chromosome name without the coordinates, like `chrB`, the region encompasses the whole named chromosome, and for the last chromosome, you can specify up to the desired point by starting from the beginning: `chrN:1-Y`.)
  
  > **Comments:**
  > **username_0**: Okay, thanks, that worked great. I was able to order chromosomes as desired to write standard output in BEDOPS `sort-bed` order.  
  
  ---
  
  