Skip to content

Instantly share code, notes, and snippets.

@aseetharam
Last active April 25, 2016 14:08
Show Gist options
  • Save aseetharam/06080d13fe3baba97604ae8a88a1137f to your computer and use it in GitHub Desktop.
Save aseetharam/06080d13fe3baba97604ae8a88a1137f to your computer and use it in GitHub Desktop.
thid version
# here is an example to write seperate files based on number of occurences of spacers:
perl -ne 'while ($_ =~ m/GTGTTCCCCGCGCCAGCGGGGATAAACC([ATCG]{32})/g) {push(@matches, $1)}if(@matches){ print "@matches\t";undef @matches; print "\n"}' example.list | awk 'NF==2'
GGTAACTTGCCGGAGGGCAGCGACCAGTTTAA GATGCACAGCCTGTTGCCATTCCGCCTCCTGT
GCAACTCGGTCGCCGCATACACTATTCTCAGA GGAAAGCCTCTTTCCTTTGTTTACGATATTGC
GGTTTTGCGCCATTCGATGGTGTCCGGGATCT GCGGCCCACGCTGGTTTGCCCCAGCAGGCGAA
GCGCTGATTTCTTAATGTGATCGGTAGCACGT AAAAAATTATATTGACGCGGCGAGTTATAATA
GTGCTCCAGTGGCTTCTGTTTCTATCAGCTGT GGGTGAACACTATCCCATATCACCAGCTCACC
GGAATATTCAGCGATTTGCCCGAGCTTGCGAG GCGTGCCGCCCCCAGCAACAATACGCTACTGA
# see the last part (awk 'NF==2'), here you are specifying that the number of fields should be exactly 2, you can change this to 1 to-
# get exactly one spacers lines only (or any other number)
# you can run them separately, too
perl -ne 'while ($_ =~ m/GTGTTCCCCGCGCCAGCGGGGATAAACC([ATCG]{32})/g) {push(@matches, $1)}if(@matches){ print "@matches\t";undef @matches; print "\n"}' example.list > example_spacers.tab
awk 'NF==1' example_spacers.tab
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment