-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding an annotateSingleSeq function
- Loading branch information
Showing
3 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const { autoAnnotate } = require("./autoAnnotate"); | ||
|
||
function annotateSingleSeq({ fullSeq, searchSeq }) { | ||
const fullSeqId = fullSeq.id || "fullSeqId"; | ||
const searchSeqId = searchSeq.id || "searchSeqId"; | ||
const results = autoAnnotate({ | ||
seqsToAnnotateById: { | ||
[fullSeqId]: { | ||
...fullSeq, | ||
id: fullSeqId | ||
} | ||
}, | ||
annotationsToCheckById: { | ||
[searchSeqId]: { | ||
...searchSeq, | ||
id: searchSeqId | ||
} | ||
}, | ||
compareName: false | ||
}); | ||
if (results && results[fullSeqId]) { | ||
return { | ||
matches: results[fullSeqId] | ||
}; | ||
} else { | ||
return { matches: [] }; | ||
} | ||
} | ||
module.exports = { annotateSingleSeq }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
const { annotateSingleSeq } = require("./annotateSingleSeq"); | ||
const { expect } = require("chai"); | ||
|
||
describe("annotateSingleSeq", function() { | ||
it(`regexes work - correctly annotates a single seq with a regex annotation`, done => { | ||
const results = annotateSingleSeq({ | ||
fullSeq: { sequence: "AAAATTTTGGGGGCCCCCAAGT" }, | ||
searchSeq: { sequence: "TTTT.*CCC" } | ||
}); | ||
// eslint-disable-next-line no-unused-expressions | ||
expect(results).to.not.be.undefined; | ||
//this should return an object keyed by the sequence id with the list of annotations to create | ||
expect(results).to.deep.eq({ | ||
matches: [ | ||
{ | ||
start: 4, | ||
end: 17, | ||
strand: 1, | ||
id: "searchSeqId" | ||
} | ||
] | ||
}); | ||
done(); | ||
}); | ||
it(`correctly annotates a single seq with multiple matches`, done => { | ||
const results = annotateSingleSeq({ | ||
fullSeq: { sequence: "AAAATTTTGGGGGCCCCCAAGTAAAATTTTGGGGGCCCCCAAGT" }, | ||
searchSeq: { sequence: "AAAATTTTGGGGGCCCCCAAGT", id: 2 } | ||
}); | ||
// eslint-disable-next-line no-unused-expressions | ||
expect(results).to.not.be.undefined; | ||
//this should return an object keyed by the sequence id with the list of annotations to create | ||
expect(results).to.deep.eq({ | ||
matches: [ | ||
{ | ||
start: 0, | ||
end: 21, | ||
strand: 1, | ||
id: 2 | ||
}, | ||
{ | ||
start: 22, | ||
end: 43, | ||
strand: 1, | ||
id: 2 | ||
} | ||
] | ||
}); | ||
done(); | ||
}); | ||
it(`correctly finds no matches when there are none`, done => { | ||
const results = annotateSingleSeq({ | ||
fullSeq: { sequence: "AAAATTTTGGGGGCCCCCAAGTAAAATTTTGGGGGCCCCCAAGT" }, | ||
searchSeq: { sequence: "AAAATTTTGGGGGGGGGGCCCCCAAGT" } | ||
}); | ||
// eslint-disable-next-line no-unused-expressions | ||
expect(results).to.not.be.undefined; | ||
//this should return an object keyed by the sequence id with the list of annotations to create | ||
expect(results).to.deep.eq({ | ||
matches: [] | ||
}); | ||
done(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters