#!/bin/bash
shopt -s expand_aliases
alias ~=”:«’~bash’”
:«’~~~bash’
Usage
$ sxExtractMarker.sh plasmid_file \
>marker1 \
3>marker2
---
title: sxExtractMarker.sh
---
flowchart TD
PF[(
plasmid_file
| adapter#0040;20bp#0041; + sgRNA#0040;20bp#0041; + scaffold#0040;83/93bp#0041; + query#0040;44bp#0041; + 3bp + RCbarcode#0040;18bp#0041; + RCprimer#0040;21bp#0041; |
|---|
| ... |
stdout
| primer#0040;21bp#0041; + barcode#0040;18bp#0041; |
|---|
| ... |
fd3
| adapter#0040;20bp#0041; + sgRNA#0040;20bp#0041; + scaffold#0040;83/93bp#0041; |
|---|
| ... |
- Extract
markersfrom the in-houseplasmid_file. marker1(primer(21bp) + barcode(18bp)) is output fromfd1(stdout).R2is aligned tomarker1. The 44bpqueryis 3bp downstream to the end ofbarcodeinR2.marker2adapter(20bp) + sgRNA(20bp) + scaffold(83/93bp) is output fromfd3.R1is aligned tomarker2.
Source
getSxPlasmidFilePrimer()
{
# Usage: getSxPlasmidFilePrimer <plasmid_file
rev | sed -r 's/^\s+//' | cut -c1-21 | dd conv=ucase 2>/dev/null | tr 'ACGT' 'TGCA'
}
getSxPlasmidFileBarcode()
{
# Usage: getSxPlasmidFileBarcode <plasmid_file
rev | sed -r 's/^\s+//' | cut -c22-39 | dd conv=ucase 2>/dev/null | tr 'ACGT' 'TGCA'
}
getSxPlasmidFileAdapter()
{
# Usage: getSxPlasmidFileAdapter <plasmid_file
cut -d, -f2 | cut -c1-20 | dd conv=ucase 2>/dev/null
}
getSxPlasmidFilesgRNA()
{
# Usage: getSxPlasmidFilesgRNA <plasmid_file
cut -d, -f2 | cut -c21-40 | dd conv=ucase 2>/dev/null
}
getSxPlasmidFileScaffold()
{
# Usage: getSxPlasmidFileScaffold <plasmid_file
cut -d, -f2 | sed -r 's/^[ACGTN]+//; s/[ACGTN]+\s+$//' | dd conv=ucase 2>/dev/null
}
getSxFaHead()
{
# Usage: getSxFaHead <plasmid_file
awk '{print ">" NR - 1}'
}
plasmid_file=$1
paste -d "" <(getSxPlasmidFilePrimer <"${plasmid_file}") <(getSxPlasmidFileBarcode <"${plasmid_file}") | paste -d "\n" <(getSxFaHead <"${plasmid_file}") - >&1
paste -d "" <(getSxPlasmidFileAdapter <"${plasmid_file}") <(getSxPlasmidFilesgRNA <"${plasmid_file}") <(getSxPlasmidFileScaffold <"${plasmid_file}") | paste -d "\n" <(getSxFaHead <"${plasmid_file}") - >&3
alias ~~~=":" # This suppresses a warning and is not part of source.