Sha256: 89e017f86e994a646673b6b3bb330ae19b726643f97d67f44a3f56a9ce150761

Contents?: true

Size: 310 Bytes

Versions: 96

Compression:

Stored size: 310 Bytes

Contents

#!/usr/bin/env bash

declare -A trans
trans[G]='C'
trans[C]='G'
trans[A]='U'
trans[T]='A'

for i in $(seq 1 ${#1}); do
  nt="${1:$i-1:1}"
  comp_nt="${trans[$nt]}"

  if [ -z "$comp_nt" ]; then
    echo 'Invalid nucleotide detected.'
    exit 1
  fi

  complement="$complement$comp_nt"
done

echo $complement

Version data entries

96 entries across 96 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/bash/exercises/rna-transcription/example.sh
trackler-2.2.1.179 tracks/bash/exercises/rna-transcription/example.sh
trackler-2.2.1.178 tracks/bash/exercises/rna-transcription/example.sh
trackler-2.2.1.177 tracks/bash/exercises/rna-transcription/example.sh
trackler-2.2.1.176 tracks/bash/exercises/rna-transcription/example.sh
trackler-2.2.1.175 tracks/bash/exercises/rna-transcription/example.sh
trackler-2.2.1.174 tracks/bash/exercises/rna-transcription/example.sh
trackler-2.2.1.173 tracks/bash/exercises/rna-transcription/example.sh
trackler-2.2.1.172 tracks/bash/exercises/rna-transcription/example.sh
trackler-2.2.1.171 tracks/bash/exercises/rna-transcription/example.sh
trackler-2.2.1.170 tracks/bash/exercises/rna-transcription/example.sh
trackler-2.2.1.169 tracks/bash/exercises/rna-transcription/example.sh
trackler-2.2.1.167 tracks/bash/exercises/rna-transcription/example.sh
trackler-2.2.1.166 tracks/bash/exercises/rna-transcription/example.sh
trackler-2.2.1.165 tracks/bash/exercises/rna-transcription/example.sh
trackler-2.2.1.164 tracks/bash/exercises/rna-transcription/example.sh
trackler-2.2.1.163 tracks/bash/exercises/rna-transcription/example.sh
trackler-2.2.1.162 tracks/bash/exercises/rna-transcription/example.sh
trackler-2.2.1.161 tracks/bash/exercises/rna-transcription/example.sh
trackler-2.2.1.160 tracks/bash/exercises/rna-transcription/example.sh