nested for loop for data extraction

I have a 50 files, each contains lines start with gene namesb (each file name referes to a specific tissue) and I have all file names a file (file_name):

cat file_name:
Esophagus_Gastroesophageal_Junction.v8.signif_variant_gene_pairs.txt
Esophagus_Mucosa.v8.signif_variant_gene_pairs.txt
Esophagus_Muscularis.v8.signif_variant_gene_pairs.txt
Heart_Atrial_Appendage.v8.signif_variant_gene_pairs.txt
Heart_Left_Ventricle.v8.signif_variant_gene_pairs.txt

each files contains some lines like:
ENSG00000227232.5 WASH7P chr1 14410 29553 - 1364 1.03463 306.354

ENSG00000233750.3 CICP27 chr1 131025 134836 + 1824 1.05908 353.821
ENSG00000268903.1 RP11-34P13.15 chr1 135141 135895 - 1863 1.01726 359.4

and I have one file (gene_name) contains a list of genes:
cat gene_name
ENSG00000210082.2
ENSG00000075624.13
ENSG00000156508.17
ENSG00000198886.2
ENSG00000170323.8
ENSG00000198763.3
ENSG00000198938.2
ENSG00000188257.10

I am going to write a nested for loop that extract each lines from files (in file_name) contains genes (gene_list) and print whole lines in seprate files for each genes (step 2).
I expect to have different files (according to file name) containg genes from gene_name like:
files:
your textENSG00000227232.5_Esophagus_Gastroesophageal_Junction
your textENSG00000075624.13_Esophagus_Mucosa
your texteach have one line contains gene_name

**What is the way to do this? **

For more clarificaiton, here is the nested for loop strucutre I use:

your textfor g in cat gene_name your textdo for n in cat file_name your textdoyour textecho "$n"your textecho "$g"your text***********your textdoneyour text`done

I used the follwoing commands (some in the bash script and some in command line) and didnt return the result:

your textawk '/${g}/ {print $0}' ${n} > ${g}/${g}_${n%.*} your textawk '/${g}/{a = a ";" $0} END {print $0}, substr(a, 1) }' ${n} > ${g}

your textawk 'END{for g in cat gene_name your textfor n in cat file_name your textprint "$0"}'

your textgrep -hnr "$g" $n > grep_${g}/${g}${n%.*} your textcat $n | grep -w '$g' > 2w${g}/${n%.v8*} your textgrep -x "$g" $n > ${g}/${g}${n.*}



Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation