-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPairwiseAlignment.R
More file actions
82 lines (68 loc) · 2.23 KB
/
PairwiseAlignment.R
File metadata and controls
82 lines (68 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Author: Benben Miao
# Email: [email protected]
# Rversion: 4.2.0
# Date: 2023-02-25
# -> 0. Install and Library
# BiocManager::install("Biostrings")
library(Biostrings)
# <- 0. Install and Library
options(warn = 1)
# -> 1. File Read
file_path = "data/RevCom/RXAs-DNA.fasta"
seqType <- "DNA"
# ChoiceBox: "DNA", "RNA", "AminoAcid"
if (seqType == "DNA") {
seqs <- readDNAStringSet(file_path,
format = "fasta",
nrec = -1L,
skip = 0L,
seek.first.rec = FALSE,
use.names = TRUE,
with.qualities = FALSE)
} else if (seqType == "RNA") {
seqs <- readRNAStringSet(file_path,
format = "fasta",
nrec = -1L,
skip = 0L,
seek.first.rec = FALSE,
use.names = TRUE,
with.qualities = FALSE)
} else if (seqType == "AminoAcid") {
seqs <- readAAStringSet(file_path,
format = "fasta",
nrec = -1L,
skip = 0L,
seek.first.rec = FALSE,
use.names = TRUE,
with.qualities = FALSE)
}
# <- 1. File Read
# -> 2. Data Operation
alignType <- "global"
# ChoiceBox: "global", "local", "overlap", "global-local", "local-global"
scoreMatrix <- "BLOSUM62"
# ChoiceBox: "BLOSUM45", "BLOSUM50", "BLOSUM62", "BLOSUM80", "BLOSUM100", "PAM30", "PAM40", "PAM70", "PAM120", "PAM250"
gapOpening <- 10
# Slider: 10, 0, 100, 1
gapExtension <- 3
# Slider: 3, 0, 100, 1
res <- pairwiseAlignment(seqs[1],
seqs[2],
type = alignType, # "global", "local", "overlap", "global-local", "local-global"
# (Needleman-Wunsch) global alignment, (Smith-Waterman) local alignment, and (ends-free) overlap alignment
substitutionMatrix = scoreMatrix, # "BLOSUM45", "BLOSUM50", "BLOSUM62", "BLOSUM80", "BLOSUM100", "PAM30", "PAM40", "PAM70", "PAM120", "PAM250"
fuzzyMatrix = NULL,
gapOpening = gapOpening,
gapExtension = gapExtension,
scoreOnly = FALSE)
writePairwiseAlignments(res, file = "Results.txt",
Matrix = NA, block.width = 80)
# writeXStringSet(seqs2,
# filepath = "Results.fasta",
# append = FALSE,
# compress = FALSE,
# compression_level = NA,
# format = "fasta")
# write.table(as.data.frame(palindrome@ranges), file = "Results.txt",
# quote = F, sep = "\t", row.names = F)
# <- 2. Data Operation