首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >大蛋白序列中的比对序列

大蛋白序列中的比对序列
EN

Stack Overflow用户
提问于 2012-11-24 23:22:50
回答 1查看 847关注 0票数 1

我有一个很大的蛋白质序列,大约有5000个,所以我把它放在一个文本文件(p_sqn.txt)中,我有以下序列

例如;SDJGSKLDJGSNMMUWEURYI

我必须找到百分比同一性评分函数,因此我必须在蛋白质序列中找到最相似的序列。(protein_sequence.txt)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-11-25 03:16:27

我将从检查序列中每个点的Levenshtein distance开始。

由于长度只有5000,所以传递过程不会花费很长时间(毫秒)。

幸运的是,Apache commons-lang library提供了StringUtils.getLevenshteinDistance()实用程序方法。这样,代码就只有几行了:

代码语言:javascript
复制
import org.apache.commons.lang.StringUtils;

String protein; // the full sequence
String part; // your search string
int bestScore = Integer.MAX_VALUE;
int bestLocation = 0;
String bestSeqence = "";
for (int i = 0; i < protein.length() - part.length(); i++) {
    String sequence = protein.substring(i, part.length());
    int score = StringUtils.getLevenshteinDistance(sequence, part);
    if (score < bestScore) {
        bestScore = score;
        bestLocation = i;
        bestSeqence = sequence;
    }
}

// at this point in the code, the "best" variables will have data about the best match.

仅供参考,分数为零表示找到了完全匹配的项。

为了便于读取文件,您可以使用Apache common-io library实用程序方法FileUtils.readFileToString(),如下所示:

代码语言:javascript
复制
import org.apache.commons.io.FileUtils;

String protein = FileUtils.readFileToString(new File("/some/path/to/myproteinfile.txt"));
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13542577

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档