Advertisement
ProzacR

0523_13:37 sudeti_homopolymer.sh

May 23rd, 2018
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.54 KB | None | 0 0
  1. #!/usr/bin/bash
  2. #sudeti homopolimer eilutes gale pagal log failus:
  3.  
  4. #https://stackoverflow.com/questions/3685970/check-if-a-bash-array-contains-a-value
  5. function contains() {
  6.     local n=$#
  7.     local value=${!n}
  8.     for ((i=1;i < $#;i++)) {
  9.         if [ "${!i}" == "${value}" ]; then
  10.             echo "y"
  11.             return 0
  12.         fi
  13.     }
  14.     echo "n"
  15.     return 1
  16. }
  17. #example:
  18. #A=("one" "two" "three four")
  19. #if [ $(contains "${A[@]}" "one") == "y" ]; then
  20. #    echo "contains one"
  21. #fi
  22.  
  23.  
  24. for file in *_Filtered/Variants/*/; do
  25.         echo $file
  26.         cd $file
  27.         for log in homo*.log; do
  28.                 line=""
  29.                 while IFS='' read -r line || [[ -n "$line" ]]; do
  30.                         ARRAY=()    
  31.                         ARRAY+=($line)
  32.                         for i in ${ARRAY[@]}; do echo $i; done
  33.                 done < $log
  34.                 #atitinkamas vcf failas yra kiekvienam log
  35.                 #kurio kieviena eilute skenuot del skaiciaus is log failo
  36.                 line=""
  37.                 chr=${log%.log}
  38.                 chr=${chr#homo}
  39.                 echo "SmallVariants.filtered_${chr}.vcf.recode_out2.vcf"
  40.                 while IFS='' read -r line || [[ -n "$line" ]]; do
  41.                         #istraukti ID...
  42.                         if [ $(contains "${ARRAY[@]}" "dummy") == "y" ]; then
  43.                              #echo "contains dummy"
  44.                         fi
  45.                 done < SmallVariants.filtered_${chr}.vcf.recode_out2.vcf
  46.         done
  47.         cd ~/SNP_Luko_0523/
  48. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement