seq_alignment = function(sequences) { shell("del /f my_needle_file") for (i in 1:length(sequences[,1])) { cat(as.character(paste(">", as.vector(sequences[i,1]), sep="")), as.character(as.vector(sequences[i,6])), file = "file1", sep = "\n") for(j in 1:length(sequences[,1])) { cat(as.character(paste(">", as.vector(sequences[i,1]), sep="")), as.character(as.vector(sequences[i,6])), file = "file2", sep = "\n") shell("needle file1 file2 stdout -gapopen 10.0 -gapextend 0.5 >> my_needle_file") } }
时间: 2024-04-06 11:29:19 浏览: 20
这段代码看起来像是一个用于序列比对的脚本。它首先定义了一个名为 seq_alignment 的函数,该函数接受一个包含序列的矩阵作为参数。接着,函数使用 shell 命令删除名为 my_needle_file 的文件(如果存在的话)。
接下来的循环使用 cat 函数将每个序列写入名为 file1 的文件中。然后,内部循环迭代每个序列,并使用 cat 函数将当前序列写入名为 file2 的文件中。然后,shell 命令调用 needle 程序,使用 file1 和 file2 中的序列进行 Needleman-Wunsch 序列比对,并将结果追加到 my_needle_file 中。
需要注意的是,这段代码的实际效果可能需要根据实际应用场景进行修改。
相关问题
seq_alignment(sequences = hit_sequences) seq_alignment = function(sequences) { shell("del /f my_needle_file") for (i in 1:length(sequences[,1])) { cat(as.character(paste(">", as.vector(sequences[i,1]), sep="")), as.character(as.vector(sequences[i,6])), file = "file1", sep = "\n") for(j in 1:length(sequences[,1])) { cat(as.character(paste(">", as.vector(sequences[i,1]), sep="")), as.character(as.vector(sequences[i,6])), file = "file2", sep = "\n") shell("needle file1 file2 stdout -gapopen 10.0 -gapextend 0.5 >> my_needle_file") } } 输出乱码文件
这段代码的作用是对一组序列进行 Needleman-Wunsch 全局比对,并将比对结果输出到一个乱码文件中。其中,输入的序列信息存储在 sequences 变量中,每行包含了序列的 ID(第一列)和序列本身(第六列)。在函数中,首先删除之前可能存在的名为 "my_needle_file" 的文件,然后对每个序列两两进行比对,并将比对结果追加到 "my_needle_file" 文件中。但是,由于比对结果是直接输出到文件而不是变量中,所以函数输出的是乱码文件而不是比对结果。
my_sequences = seq_import(input_file = my_file) Error in seq_import(input_file = my_file) : unused argument (input_file = my_file)
这个错误提示是因为在调用 `seq_import()` 函数时,没有定义 `input_file` 参数。请检查你的代码,确认是否正确传递了 `my_file` 参数给 `seq_import()` 函数。你可以尝试修改代码如下:
```
my_sequences = seq_import(my_file)
```
这样应该就可以正常导入序列了。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)