Question: meta file table
0
gravatar for figueroacg
8 months ago by
figueroacg0
figueroacg0 wrote:

Hi,

How can I generate a meta file table from a list of text files?

I have a text file with multiple file names, like so:

ID1_GENDER_TREATMENT.fastq
ID2_GENDER_TREATMENT.fastq
.
.
.
IDn_GENDER_TREATMENT.fastq

I would like to generate a table that looks like this:

ID                  GENDER                  TREATMENT

ID1                  gender                        treatment

ID2                    gender                      treatment
.

. .

I am new in bioinformatics and I am not sure how to do this.

Thanks!

rna-seq • 175 views
ADD COMMENTlink modified 8 months ago by ATpoint38k • written 8 months ago by figueroacg0
2
gravatar for ATpoint
8 months ago by
ATpoint38k
Germany
ATpoint38k wrote:

Assume you had files like this:

$ ls *.fastq
ID1_GENDER1_TREATMENT1.fastq ID2_GENDER2_TREATMENT2.fastq ID3_GENDER3_TREATMENT3.fastq

Then do:

$ ls *.fastq | awk -F "_" 'OFS="\t" {if(NR==1)print "ID", "GENDER", "TREATMENT"} {gsub(".fastq","");print $1, $2, $3}'
ID  GENDER  TREATMENT
ID1 GENDER1 TREATMENT1
ID2 GENDER2 TREATMENT2
ID3 GENDER3 TREATMENT3

OFS="\t" will make it a tab-delimited list. Change that if you want alternative delimiters.

ADD COMMENTlink modified 8 months ago • written 8 months ago by ATpoint38k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 699 users visited in the last hour