Skip to main content
5 votes
Accepted

Keeping DNA sequence after changing FASTA header on command line

The grep, cut, sed pipeline could also be replaced with the following awk command: ...
Steve's user avatar
  • 3,109
5 votes
Accepted

Telling grep to treat N as [ATCG]

If you want to stick to grep, use a scripting language such as Perl to generate the regex programmatically. For example: ...
Timur Shtatland's user avatar
4 votes

Removing particular line along with Fasta header in fasta file

You can use awk here, by setting the input (RS) and output (ORS) record separator, this is ...
terdon's user avatar
  • 10.2k
4 votes

Grep peculiar pattern inside a file

One way using sed: sed -n '/^>/s/.*\[\([^]]*\)\]$/\1/p' input.fa Results: C.sp. balc. D.r. E.l. Explanation: Turn off ...
Steve's user avatar
  • 3,109
3 votes

Keeping DNA sequence after changing FASTA header on command line

The problem is in the grep command you're using, which only sends the fasta file headers to the output. Here's my guess at what the commands in your pipeline do: <...
gringer's user avatar
  • 14.3k
3 votes

How to remove empty files from a directory?

Always Google before asking on forums. I googled "delete empty files linux" and this was the second result: https://www.baeldung.com/linux/delete-empty-files-dirs ...
Ram RS's user avatar
  • 2,425
3 votes

Grep peculiar pattern inside a file

With GNU grep (the default on Linux): $ grep -oP '.*\[\K[^]]+' file C.sp. balc. D.r. E.l. The ...
terdon's user avatar
  • 10.2k
3 votes

How to copy only certain counts for genes in tsv file to new file in linux

Something like this should do job: ...
haci's user avatar
  • 4,162
3 votes

Removing particular line along with Fasta header in fasta file

Try this, if you have GNU grep (the default on Linux systems): ...
gringer's user avatar
  • 14.3k
3 votes

FASTQ file reads extraction paired ends

Your question can be rewritten as, "how do I get the union of reads in two files?" Since you have already subset the mates, the steps are: Process each file, storing the list of reads names ...
Devon Ryan's user avatar
  • 19.6k
2 votes

How to grep with a list of genes from a gff the GO terms

@Jim Hat I took a stab at this given the example files you included. If the 'list.txt' file looks like this: Solyc00g019980 Solyc01g005020 And the data.gff file ...
Helen Scott's user avatar
2 votes

Removing particular line along with Fasta header in fasta file

If there are no line breaks within the sequence data (the format I use) then the following will work. ...
M__'s user avatar
  • 12.6k
2 votes

Grep peculiar pattern inside a file

For OSX, I don't have a -P option (Perl pattern matching) so the best I can do is finish the one-liner by piping into perl ...
M__'s user avatar
  • 12.6k
2 votes

Removing particular line along with Fasta header in fasta file

One way using sed: sed -e '/^>/ { N; }; /Sequence unavailable/ { d; }' file.fa For each header line, append the next line of input into the pattern space. Then, ...
Steve's user avatar
  • 3,109
2 votes
Accepted

Extract sequences from partial Header

You could use Biopython. If its a fasta file, it will be complicated to write fasta output (especially multiline fasta) with grep or ...
geek_y's user avatar
  • 321
2 votes
Accepted

How to remove empty files from a directory?

This isn't the most efficient approach, using find will be easier and faster as long as your find supports the ...
terdon's user avatar
  • 10.2k
2 votes

How to remove empty files from a directory?

As already stated, one way is to use the GNU find (the default on Linux) command. This will find and print all empty files in the current directory: ...
Steve's user avatar
  • 3,109
1 vote

How to remove empty files from a directory?

@Ram RS has identified the solution here via find, if that does not work then the following will work, ...
M__'s user avatar
  • 12.6k
1 vote

Grep peculiar pattern inside a file

Some of the solutions suggested above utilize GNU grep. If you are a Mac user, you can easily install GNU version of the commands into your Mac. You can do this by ...
Supertech's user avatar
  • 606
1 vote
Accepted

Using grep to get lines from a file (.tsv) that contain specific samples listed in a sample file (.tsv)

This may help: cat ecDNA_samples.tsv | xargs -I % grep '^%\s' pcawg.tsv The command above executes ...
C. Aknesil's user avatar
1 vote

Finding smaller sequences from within larger sequences

Thank you all for your help. I managed to fix it in the end. The error was with how my pattern.txt file was formatted. I initially exported the .txt from R Studio by specifying the EOL as \r\n. ...
Jean Luc's user avatar
1 vote

Elegant Way to Extract Gene Symbols from FASTA Headers

We can't be sure without seeing your file, but if what you really want is the text between the last parentheses on lines that start with >, then you can do this ...
terdon's user avatar
  • 10.2k
1 vote

How to copy only certain counts for genes in tsv file to new file in linux

Alternatively, you can use grep like so to remove all lines starting with KLTH: ...
Timur Shtatland's user avatar
1 vote

How to copy only certain counts for genes in tsv file to new file in linux

One way using awk: awk 'NR==1 || /^YL/ { print $0 }' file.tsv The default action is to print the line/record, so all you need is the condition: ...
Steve's user avatar
  • 3,109
1 vote
Accepted

How to get matching pattern along with ID in a single command in grep?

Use this Perl one-liner: perl -lne '$id = $1 if /^>(.+)/; ($m) = /(CC[GT]AAA[GC][AC]TT[GC])/; print join "\t", $id, $m if $m;' input.fasta The Perl ...
Timur Shtatland's user avatar
1 vote

FASTQ file reads extraction paired ends

It's a little bit unclear what you're asking, but if you want to repair paired-end files that have become disordered (or the linking has been lost), then the repair function of bbtools should work. ...
gringer's user avatar
  • 14.3k
1 vote

How to replace sequence identifiers in a fasta with OTU IDs from another file?

You can put you fasta file in a single line per sequence: perl -pe 'if(/\>/){s/\n/\t/; s/>//; s/\n//}' file.fasta > file.tsv This line will create the ...
zorbax's user avatar
  • 769
1 vote

How to replace sequence identifiers in a fasta with OTU IDs from another file?

You can do it with bash quiet easy. First create a backup of your fasta file with cp otu.fasta otu_backup.fasta Then you can run: ...
Mr_Z's user avatar
  • 629
1 vote

Extract sequences from partial Header

Here is a solution with awk: This is the example fasta file which I used: ...
Mr_Z's user avatar
  • 629

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