Answers.Body: <p>Invest some time in learning unix tools such as <code>grep</code>, <code>sed</code> and <code>awk</code>.</p>
  
  <pre><code>sed -r '/^&gt;/s/:[0-9]+-[0-9]+//' input.fasta &gt; output.fasta
  </code></pre>
  
  <p>This line of code matches the pattern <code>:&lt;numbers&gt;-&lt;numbers&gt;</code> on lines that start with <code>&gt;</code> (FASTA sequence headers) and replaces that pattern with <code>''</code>, essentially removing text that matches the pattern.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-03T22:26:57.487Z
Answers.Text: Thanks Ram, could you please suggest any book related to unix command line that can explain all these small problems related to bioinformatics.
Answers.UserDisplayName: bioinfonext
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-03T23:01:43.720Z
Answers.Text: I'd recommend looking at [Rosalind](http://rosalind.info/problems/locations/), but I think that's mostly python. Unix utilities are learnt as you stumble upon problems, as there's seldom some sort of comprehensive exercise to learn these utilities. Try googling "learn sed" or "learn grep" or "learn awk" and following tutorials that pop up. For awk, you can start with an Excel sheet of data, export the data to a tab-separated text file and use `awk` to do things you'd normally use Excel filters to do.
Answers.UserDisplayName: Ram RS
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-03T22:13:37.497Z
Answers.LastActivityDate: 2019-07-04T08:57:55.713Z
Answers.LastEditDate: 2019-07-04T08:57:55.713Z
Answers.UserDisplayName: Ram RS
Answers.Body: <p>Alternatively, Perl provides a slightly simpler regular expression syntax (<code>\d</code> instead of <code>[0-9]</code>) that I prefer over <code>sed</code>.</p>
  
  <pre><code>perl -pe 's/:\d+-\d+//' input.fasta &gt; output.fasta
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-09T23:20:52.930Z
Answers.Text: Using `-pe` is even simpler: `perl -pe 's/^(>\S+):\d+-\d+/$1/' input.fasta > output.fasta`
Answers.UserDisplayName: user172818
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-07-09T20:47:21.120Z
Answers.LastActivityDate: 2019-07-10T13:03:00.690Z
Answers.LastEditDate: 2019-07-10T13:03:00.690Z
Answers.UserDisplayName: Daniel Standage
Body: <p>Could you please suggest me how I can remove range from fasta header:like these number from below sequences which has some colons indicating the range of the genome</p>
  
  <p>:147010-147657 </p>
  
  <p>:149201-149845</p>
  
  <pre><code>&gt; FVJT01000004.1:147010-147657 Mycobacterium abscessus subsp. massiliense strain 974 
  GTGACCAGCAGCGCAGACCGATCCCCCGTCGAGGCGATGGTGAGCCACGCCGAGGGCGCCATCTCCGAGG
  ATGACATCGTCGCCGCCGCCCGGGAACGTGCCGTTGACCTGGGCGCGGGCCCGGTGACACCCGCGGTAGG
  
  &gt;FSAX01000002.1:149201-149845 Mycobacterium abscessus subsp. bolletii strain 286 genome 
  ATGACGACGCCCGTCAGCTTCGATAACAGATTCTTCTCCGCAACGTGGTCTGCTATCGCGCGGCGCGAAC
  CTCAGGAGATCAAGGAGCTGCGTGCGGAGAATCTACGCGGCCTGACCGGCCACGTTCTGGAGGTGGGAGC
  </code></pre>
  
Tags: <bash>
Title: how to remove range from fasta header
ThreadText: # how to remove range from fasta header
  
  (Asked by: username_0 on 2019-07-03)
  
  Could you please suggest me how I can remove range from fasta header:like these number from below sequences which has some colons indicating the range of the genome
  
  :147010-147657
  
  :149201-149845
  
  ```
  > FVJT01000004.1:147010-147657 Mycobacterium abscessus subsp. massiliense strain 974 
  GTGACCAGCAGCGCAGACCGATCCCCCGTCGAGGCGATGGTGAGCCACGCCGAGGGCGCCATCTCCGAGG
  ATGACATCGTCGCCGCCGCCCGGGAACGTGCCGTTGACCTGGGCGCGGGCCCGGTGACACCCGCGGTAGG
  
  >FSAX01000002.1:149201-149845 Mycobacterium abscessus subsp. bolletii strain 286 genome 
  ATGACGACGCCCGTCAGCTTCGATAACAGATTCTTCTCCGCAACGTGGTCTGCTATCGCGCGGCGCGAAC
  CTCAGGAGATCAAGGAGCTGCGTGCGGAGAATCTACGCGGCCTGACCGGCCACGTTCTGGAGGTGGGAGC
  
  ```
  
  **Tags:** bash
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2019-07-03. Score: 6 | Accepted answer
  
  Invest some time in learning unix tools such as `grep`, `sed` and `awk`.
  
  ```
  sed -r '/^>/s/:[0-9]+-[0-9]+//' input.fasta > output.fasta
  
  ```
  
  This line of code matches the pattern `:<numbers>-<numbers>` on lines that start with `>` (FASTA sequence headers) and replaces that pattern with `''`, essentially removing text that matches the pattern.
  
  > **Comments:**
  > **username_0**: Thanks Ram, could you please suggest any book related to unix command line that can explain all these small problems related to bioinformatics.  
  > **username_1**: I'd recommend looking at [Rosalind](http://rosalind.info/problems/locations/), but I think that's mostly python. Unix utilities are learnt as you stumble upon problems, as there's seldom some sort of comprehensive exercise to learn these utilities. Try googling "learn sed" or "learn grep" or "learn awk" and following tutorials that pop up. For awk, you can start with an Excel sheet of data, export the data to a tab-separated text file and use `awk` to do things you'd normally use Excel filters to do.  
  
  ---
  
  ### Answer by username_2 on 2019-07-09. Score: 1
  
  Alternatively, Perl provides a slightly simpler regular expression syntax (`\d` instead of `[0-9]`) that I prefer over `sed`.
  
  ```
  perl -pe 's/:\d+-\d+//' input.fasta > output.fasta
  
  ```
  
  > **Comments:**
  > **username_3**: Using `-pe` is even simpler: `perl -pe 's/^(>\S+):\d+-\d+/$1/' input.fasta > output.fasta`  
  
  ---
  
  