3

I have 60 text files of different lengths and same column names.

For example:

cat Sample_145_Chimeric.out.junction.new.back_spliced_junction.bed.Circexplorer2.txt | gawk '{print $14}' | sort | uniq -c
  19258 circRNA
    612 ciRNA

cat Sample_146_Chimeric.out.junction.new.back_spliced_junction.bed.Circexplorer2.txt | gawk '{print $14}' | sort | uniq -c
  17791 circRNA
    729 ciRNA

cat Sample_147_Chimeric.out.junction.new.back_spliced_junction.bed.Circexplorer2.txt | gawk '{print $14}' | sort | uniq -c
  22838 circRNA
    686 ciRNA

cat Sample_148_Chimeric.out.junction.new.back_spliced_junction.bed.Circexplorer2.txt | gawk '{print $14}' | sort | uniq -c
  19404 circRNA
    475 ciRNA

I want to produce a 'master' table of all identified circRNAs, with readnumber as column for each sample and flankintronas rownames:

screen shot of the file

1 Answer 1

3

If all of the columns in all of the files are in the same order, then just concat them together with >>:

for x in {1..60}; do 
    # These flags for tail just cut of the top line, which is your headers
    tail -n 2 Sample_$x_blah.txt >> Sample_master.txt
    # and the double carat makes the output append^ 
done 

If not, then you can write the translations in awk sort of like you had above, i.e.

$ cat Sample_1.txt 
col1,col2,col3,col4 #etc 
$ cat Sample_2.txt 
col4,col3,col2,col1 
$ cat Sample_1.txt > Sample_Master.txt # no translation needed
$ awk '{print $4","$3","$2","$1 }' Sample_2.txt >> Sample_Master.txt 

But with 60 files, that would be more work than- something like writing a python script using python's csv lib...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .