meta file table
1
0
Entering edit mode
18 months ago
figueroacg • 0

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 • 349 views
ADD COMMENT
2
Entering edit mode
18 months ago
ATpoint 52k

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 COMMENT

Login before adding your answer.

Traffic: 2047 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6