This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to remove special characters from text files?

Hi all

I have an miRNA text file (having ~2000 miRNA information) like the following

>hsa-miR-576-3p MIMAT0004796
AAGAUGUGGAAAAAUUGGAAUC
>hsa-miR-140-5p MIMAT0000431
CAGUGGUUUUACCCUAUGGUAG

i want it to become

>hsa-miR-576-3p
 AAGAUGUGGAAAAAUUGGAAUC
>hsa-miR-140-5p
CAGUGGUUUUACCCUAUGGUAG

without the MIMAT000XX

Could anyone help me to do this? My OS is Ubuntu 14.04

Thank You in advance.

textfiles mirnafiles ubuntu

Try sed ,

sed -e 's/MIMAT.*//' input.file > output.file

After this when i was running miRDeep2.pl, i got this error

mkdir mirdeep_runs/run_13_12_2018_t_16_20_32
#testing input files
#testing input files
started: 16:20:33
sanity_check_mature_ref.pl /home/shanthi/Desktop/Nivya/miRBase/mature_human_miRNA1.fa
Error: problem with /home/shanthi/Desktop/Nivya/miRBase/mature_human_miRNA1.fa
Error in line 5.309: The sequence
contains characters others than [acgtunACGTUN]
Please check your file for the following issues:
I.  Sequences are allowed only to comprise characters [ACGTNacgtn].
II. Identifiers are not allowed to have withespaces.

Do you have any idea how to rectify this?

Don't ask unrelated/new questions in existing threads. Consider opening a new thread, if you are not able to find a previous answer by searching.

1 answer

Assuming there is a whitespace before the part that you want to remove, you can do this:

$ cut -d " " -f1 input.fa > output.fa

cut selects the columns given with -f parameter. With -d " " we define a whitespace as a delimiter between two columns.

fin swimmer

If an answer was helpful, you should upvote it; if the answer resolved your question, you should mark it as accepted. You can accept more than one if they work.
Upvote|Bookmark|Accept

Please do the same for your previous posts as well.

Log in to answer this question.