write(file=file.path(tempdir(), "tmp.fasta"), c(
">1\nGAAC------ATGC",
">2\nGAAC------TTGC",
">3\nGAAC---CCTTTGC",
">4\nGAA---------GC"))
write(file=file.path(tempdir(), "tmp_expected.fasta"), c(
">1\nGAAC------ATGCCA-",
">2\nGAAC------TTGCCA-",
">3\nGAAC---CCTTTGCCCA",
">4\nGAA---------GCA--"))
tmp <- Read.fasta(file=file.path(tempdir(), "tmp.fasta"))
expected <- Read.fasta(file=file.path(tempdir(), "tmp_expected.fasta"))
seqs <- tmp$sequence
gc <- Gap.code(seqs)
tmp$sequence <- apply(cbind(seqs, gc), 1, paste, collapse="")
identical(tmp, expected) # TRUE, isn't it?
Run the code above in your browser using DataLab