jeudi 12 avril 2018

Quicker way to go through nested if loop in awk rather than shell

I have following code

if [[ $intron_exon =~  E ]] ; then 
  upstream=$exon_id":I"$upstream_no
  downstream=$exon_id":I"$exon_number
  if grep -q -e "$upstream" Transcriptome.txt   ; then
  Up=$upstream
  fi
  if grep -q -e  "$downstream" Transcriptome.txt  ; then
  Down=$downstream
  fi
else 
  upstream=$exon_id":E"$upstream_no
  downstream=$exon_id":E"$exon_number
  if grep -q -e "$upstream" Transcriptome.txt  ; then
  Up=$upstream
  fi
  if  grep -q -e "$downstream" Transcriptome.txt  ; then
  Down=$downstream
  fi
fi

What I am trying to do is check if the variable is equal to E, if so then check if the upstream and downstream are present (Note that I initialize upstream and downstream differently in the main if and else); if not E then I initialize upstream and downstream differently and check if they are present in the file.

Aucun commentaire:

Enregistrer un commentaire