Hot answers tagged

18 votes
Accepted

Using shells other than bash

Bioinformatics tools written in shell and other shell scripts generally specify the shell they want to use (via #!/bin/sh or e.g. ...
user avatar
11 votes

Using shells other than bash

TL;DR SH adheres to an official industry standard, but it is not suitable for scientific computing. Bash is considered an informal standard (e.g., by Google). Bash 3 is preferable in most of ...
user avatar
9 votes
Accepted

Splitting fasta file into smaller files based on header pattern

Here's a simple awk approach: awk '{if(/^>/){split($1,a,"[|.]")}print >> a[2]".fa"}' Protein_FASTA.txt Or, more concisely, just: ...
user avatar
  • 7,957
9 votes

How I can change the name of multiple files at once in R or terminal?

Use perl-rename. This is usually called rename on Debian-based systems like Ubuntu or Mint, and ...
user avatar
  • 7,957
8 votes
Accepted

How to merge .fastq.qz files into a single .fastq.gz with their same id without losing any content in parallel

All you need is cat. You won't find any better tool for a simple job like this. Just run: ...
user avatar
  • 7,957
7 votes

How do I efficiently subset a very large line-based file?

Turns out, simply keeping track of the next candidate line (after sorting the sample line numbers) fixes the performance issue, and most of the remaining slowness seems to be due to the overhead of ...
user avatar
7 votes

Using shells other than bash

The Open Group Base Specifications Issue 7 IEEE Std 1003.1™-2008, 2016 Edition, or "The POSIX Standard" for short, is the standard that defines the interfaces and utilities provided by a Unix system. ...
user avatar
6 votes

Remove/delete sequences by ID from multifasta

Just today I wrote a script to do exactly this using Biopython. I also add a warning If any the headers I wanted to filter was not present in the original fasta. So ...
user avatar
  • 5,287
6 votes

Remove/delete sequences by ID from multifasta

Suppose you keep sequence names in ids.txt and sequences in seq.fa: ...
user avatar
  • 5,645
6 votes

Remove/delete sequences by ID from multifasta

If you want to learn how to do things with command-line tools, you can linearize the FASTA with awk, pipe to grep to filter for ...
user avatar
6 votes
Accepted

Regular expression struggle

You have an extra done, instead you want: ...
user avatar
  • 19.3k
5 votes
Accepted

Bash script error at paste command

Your problem is that you have written a script in bash but are then running it using sh. Bash, the Bourne-again shell, is not ...
user avatar
  • 7,957
5 votes

Using shells other than bash

The generic command sh is quite literally an industry standard, a POSIX standard, to be precise (IEEE 1003.2 and 1003.2a, available for purchase for hundreds of ...
user avatar
  • 11.5k
5 votes

Using shells other than bash

I would not say bash as a "standard", but it is indeed likely to be the most widely used unix shell and available by default on most modern unix/linux distros. There are a few other more convenient ...
user avatar
  • 5,645
5 votes

How do I efficiently subset a very large line-based file?

Perl should be fairly fast with this when using a hash set to store the list of lines. A structure like this also works for subsetting based on a field value, where the comparison would be with the ...
user avatar
  • 11.5k
5 votes
Accepted

How I can change the name of multiple files at once in R or terminal?

just to complete your question, you can do it in R in one line. After setting the directory as your working directory, just type the following: ...
user avatar
  • 1,021
4 votes
Accepted

Replace lowercase characters with -

The following sed command will do the trick. sed -e '/^[^>]/ s/[a-z]/\-/g' in.fna > out.fna Lines starting with ...
user avatar
  • 584
4 votes

How do I efficiently subset a very large line-based file?

Some related questions appear in other sites, with potentially interesting solutions, which I report here: To sample approximately 1% of the non-empty lines: ...
user avatar
  • 2,930
4 votes
Accepted

Pattern mining from a genomic sequence

echo ">ATGCTTATTGCCCATTTCGTGCATGCATATGCGCATTCGCGATCGATTAGGGATAT" | grep -oP 'TTCG[CGT][ATGC]{1,15}TTCG[CGT]' [CGT] looks ...
user avatar
  • 3,472
4 votes

How I can run this code on my files?

$f in your command is not pointing anywhere since your for loop was defined as for file in *.vcf;. You should use ...
user avatar
  • 3,472
3 votes
Accepted

Batch alignment of inconsistently named Fastq files

A very simple approach, but one which will work with the names you show, is to remove any occurrence of 00N (where N is any ...
user avatar
  • 7,957
3 votes

How to merge .fastq.qz files into a single .fastq.gz with their same id without losing any content in parallel

We sequence DNA on daily basis. Like terdon said, you can use cat to group all the FastQ of all your sample whether they are ...
user avatar
3 votes
Accepted

Using a Bash Script to search TaxIDs against NCBI's Taxonomy yields "400 Bad Request" error?

If I understand correctly, your question boils down to: parsing a bunch of numbers in a row from a .csv file gives a different result from parsing a bunch of numbers as rows of a text file. I that ...
user avatar
  • 258
3 votes

Replace lowercase characters with -

You could try it with sed. Replace all lower-case chars with - in lines not starting with ...
user avatar
3 votes

Remove/delete sequences by ID from multifasta

Using the FastaToTbl and TblToFasta scripts I have posted before, you can do: ...
user avatar
  • 7,957
3 votes

How I can change the name of multiple files at once in R or terminal?

If your filenames do not contain blank spaces, you can do it with a for-loop in bash: Make a test run with echo so that the ...
user avatar
  • 1,181
3 votes

How I can change the name of multiple files at once in R or terminal?

EDIT: (Based on the comments by @terdon, with minor changes) Try this Perl one-liner. It is recommended for general use, even if your file names contain "unexpected" characters such as newlines. <...
user avatar
3 votes
Accepted

How to loop multiple function in shell script?

You don't need a loop. You can do the whole thing with a simple awk one-liner: awk -vRS='>' 'FNR>1{ printf ">%s",$0 > "gene"FNR-1".fasta"}' org*fasta ...
user avatar
  • 7,957

Only top scored, non community-wiki answers of a minimum length are eligible