我正在编写一个应用程序,用于搜索长序列中的特定碱基对。如果我有这样的碱基对序列:
A T G C A T G A C G T A A G C T
我需要搜索一组含糊不清的字符。
要找到的序列必须与
匹配n C G n A A
格式,其中" n"代表任何角色。因此,它会搜索文档以找到它所在的任何地方
[any character] [C] [G] [any character] [A] [A]
它会返回
A T G C A T G [A C G T A A] G C T
有没有办法代表" n"在Java?
答案 0 :(得分:2)
这个怎么样?正如Codebender所说,正则表达式非常适合这项工作:
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
mongoose.connect('mongodb://localhost:27017/mongoose_benn');
var UserSchema = new Schema({
firstName: {type: String, trim: true, default: ''},
lastName: {type: String, trim: true, default: ''},
displayName: {type: String, trim: true}
});
var SubjectSchema = new Schema({
name: {
type: String,
default: '',
required: 'Please fill the subject name.',
trim: true
},
description: {
type: String,
default: '',
required: 'Please fill subject description',
trim: true
}
});
var TrainingSubjectSchema = new Schema({
subject: {type: Schema.ObjectId, ref: 'Subject'},
attendanceRate: [{type: Number}]
});
var TrainingEventSchema = new Schema({
name: {
type: String,
default: '',
required: 'Please fill the training event name.',
trim: true
},
created: {type: Date, default: Date.now},
user: {type: Schema.ObjectId, ref: 'User'},
attendes: [{
type: Schema.ObjectId,
ref: 'User'
}],
subjects: [TrainingSubjectSchema]
});
module.exports = {
User: mongoose.model('User', UserSchema),
Subject: mongoose.model('Subject', SubjectSchema),
TrainingSubject: mongoose.model('TrainingSubject', TrainingSubjectSchema),
TrainingEvent: mongoose.model('TrainingEvent', TrainingEventSchema)
};