Skip to content

Commit

Permalink
updating husky
Browse files Browse the repository at this point in the history
  • Loading branch information
tnrich committed Feb 27, 2023
1 parent def4e99 commit 4114a81
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 35 deletions.
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn lint-staged && yarn test
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"chai-subset": "^1.1.0",
"eslint": "8.35.0",
"eslint-config-teselagen": "6.0.16",
"husky": "^0.11.6",
"husky": "^8.0.3",
"jest": "^29.4.3",
"jsonfile": "^2.3.1",
"lint-staged": "^9.2.1",
Expand Down
42 changes: 21 additions & 21 deletions src/addGapsToSeqReads.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ module.exports = function addGapsToSeqReads(refSeq, seqReads) {

const refSeqWithGaps = insertGapsIntoRefSeq(refSeq.sequence, seqReads);
// first object is reference sequence with gaps, to be followed by seq reads with gaps
let seqReadsWithGaps = [
const seqReadsWithGaps = [
{ name: refSeq.name, sequence: refSeqWithGaps.toUpperCase() }
];
seqReads.forEach(seqRead => {
// get all insertions in seq reads
let allInsertionsInSeqReads = [];
const allInsertionsInSeqReads = [];
seqReads.forEach(seqRead => {
// split cigar string at S, M, D, or I (soft-clipped, match, deletion, or insertion), e.g. ["5S", "2M", "3I", "39M", "3D"..."9S"]
const splitSeqRead = seqRead.cigar.match(/([0-9]*[SMDI])/g);
Expand All @@ -51,7 +51,7 @@ module.exports = function addGapsToSeqReads(refSeq, seqReads) {
bpPosOfInsertion += previousComponentNumber;
}
}
let insertionInfo = {
const insertionInfo = {
// keeping bpPos 1-based
bpPos: bpPosOfInsertion,
number: numberOfInsertions
Expand All @@ -77,7 +77,7 @@ module.exports = function addGapsToSeqReads(refSeq, seqReads) {

// 2) add own deletions to own sequence
// get own deletions
let ownDeletions = [];
const ownDeletions = [];
for (
let componentI = 0;
componentI < splitSeqReadChunk.length;
Expand All @@ -94,7 +94,7 @@ module.exports = function addGapsToSeqReads(refSeq, seqReads) {
);
bpPosOfDeletion += previousComponentNumber;
}
let deletionInfo = {
const deletionInfo = {
// keeping bpPos 1-based
bpPos: bpPosOfDeletion,
number: numberOfDeletions
Expand All @@ -103,7 +103,7 @@ module.exports = function addGapsToSeqReads(refSeq, seqReads) {
}
}
// sort deletions by ascending bp pos
let sortedOwnDeletions = ownDeletions.sort(function(a, b) {
const sortedOwnDeletions = ownDeletions.sort(function(a, b) {
return a.bpPos - b.bpPos;
});
// add own deletions to own sequence
Expand All @@ -122,8 +122,8 @@ module.exports = function addGapsToSeqReads(refSeq, seqReads) {

// 3) remove own insertions from own sequence
// get own insertions
let ownInsertions = [];
let ownInsertionsBp = [];
const ownInsertions = [];
const ownInsertionsBp = [];
for (
let componentI = 0;
componentI < splitSeqReadChunk.length;
Expand All @@ -134,7 +134,7 @@ module.exports = function addGapsToSeqReads(refSeq, seqReads) {
const numberOfInsertions = Number(
splitSeqReadChunk[componentI].slice(0, -1)
);
let nucleotides = [];
const nucleotides = [];
for (let i = 0; i < componentI; i++) {
const previousComponentNumber = Number(
splitSeqReadChunk[i].slice(0, -1)
Expand All @@ -144,12 +144,12 @@ module.exports = function addGapsToSeqReads(refSeq, seqReads) {
for (let nucI = 0; nucI < numberOfInsertions; nucI++) {
nucleotides.push(eachSeqReadWithGaps[bpPosOfInsertion - 1 + nucI]);
}
let insertionInfo = {
const insertionInfo = {
// keeping bpPos 1-based
bpPos: bpPosOfInsertion,
number: numberOfInsertions
};
let insertionInfoBp = {
const insertionInfoBp = {
// keeping bpPos 1-based
bpPos: bpPosOfInsertion,
number: numberOfInsertions,
Expand All @@ -159,12 +159,12 @@ module.exports = function addGapsToSeqReads(refSeq, seqReads) {
ownInsertionsBp.push(insertionInfoBp);
}
}
let ownInsertionsCompare = JSON.parse(JSON.stringify(ownInsertions));
const ownInsertionsCompare = JSON.parse(JSON.stringify(ownInsertions));
// sort own insertions by ascending bp pos
let sortedOwnInsertions = ownInsertions.sort(function(a, b) {
const sortedOwnInsertions = ownInsertions.sort(function(a, b) {
return a.bpPos - b.bpPos;
});
let sortedOwnInsertionsBp = ownInsertionsBp.sort(function(a, b) {
const sortedOwnInsertionsBp = ownInsertionsBp.sort(function(a, b) {
return a.bpPos - b.bpPos;
});
// remove own insertions from own sequence
Expand Down Expand Up @@ -210,7 +210,7 @@ module.exports = function addGapsToSeqReads(refSeq, seqReads) {
}
// then remove own insertions from all insertions
for (let otherI = 0; otherI < ownInsertionsCompare.length; otherI++) {
let insertionInfoIndex = otherInsertions.findIndex(
const insertionInfoIndex = otherInsertions.findIndex(
e => e.bpPos === ownInsertionsCompare[otherI].bpPos
);
if (insertionInfoIndex !== -1) {
Expand All @@ -232,7 +232,7 @@ module.exports = function addGapsToSeqReads(refSeq, seqReads) {
}
// then combine overlap between other insertions & own insertions
for (let overlapI = 0; overlapI < sortedOwnInsertions.length; overlapI++) {
let insertionInfoIndex = otherInsertions.findIndex(
const insertionInfoIndex = otherInsertions.findIndex(
e => e.bpPos === sortedOwnInsertions[overlapI].bpPos
);
if (insertionInfoIndex !== -1) {
Expand All @@ -253,7 +253,7 @@ module.exports = function addGapsToSeqReads(refSeq, seqReads) {
}
}
// adjust own insertions according to other seq reads' insertions to be added (i.e. for all other reads' insertions with smaller bp pos, +1 to that own insertion's bp pos)
let adjustedOwnInsertionsBp = JSON.parse(
const adjustedOwnInsertionsBp = JSON.parse(
JSON.stringify(sortedOwnInsertionsBp)
);
for (let ownI = 0; ownI < adjustedOwnInsertionsBp.length; ownI++) {
Expand Down Expand Up @@ -322,7 +322,7 @@ module.exports = function addGapsToSeqReads(refSeq, seqReads) {
// 7) add gaps before starting bp pos
// add gaps based on any seq reads that extend beyond beginning of the ref seq due to soft-clipped reads
// a) get the lengths of bps that extend beyond the beginning of the ref seq among all seq reads
let seqReadLengthsBeforeRefSeqStart = [];
const seqReadLengthsBeforeRefSeqStart = [];
seqReads.forEach(seq => {
const splitSeqReadChunk = seq.cigar.match(/([0-9]*[SMDI])/g);
let adjustedSeqReadPos = cloneDeep(seq.pos);
Expand All @@ -344,7 +344,7 @@ module.exports = function addGapsToSeqReads(refSeq, seqReads) {
let longestSeqReadLength = 0;
for (let i = 1; i < seqReadsWithGaps.length; i++) {
// turn seq read into an array ["A", "T", "C", "G"...]
let eachSeqReadWithGaps = seqReadsWithGaps[i].sequence.split("");
const eachSeqReadWithGaps = seqReadsWithGaps[i].sequence.split("");
const splitSeqReadChunk = seqReads[i - 1].cigar.match(/([0-9]*[SMDI])/g);
let adjustedSeqReadPos = cloneDeep(seqReads[i - 1].pos);
// longest length of bps that extend beyond the beginning of the ref seq among all seq reads
Expand Down Expand Up @@ -378,13 +378,13 @@ module.exports = function addGapsToSeqReads(refSeq, seqReads) {

// add gaps before ref seq based on the longest length of soft-clipped reads that extend beyond beginning of ref seq
if (longestSeqReadLength > 0) {
let splitRefSeqWithGaps = seqReadsWithGaps[0].sequence.split("");
const splitRefSeqWithGaps = seqReadsWithGaps[0].sequence.split("");
splitRefSeqWithGaps.unshift("-".repeat(longestSeqReadLength + 1));
seqReadsWithGaps[0].sequence = splitRefSeqWithGaps.join("");
}

// 8) check if any seq read is longer than the ref seq, make ref seq & seq reads all the same length
let lengthsOfLongerSeqReads = [];
const lengthsOfLongerSeqReads = [];
for (let i = 1; i < seqReadsWithGaps.length; i++) {
const refSeq = seqReadsWithGaps[0];
if (seqReadsWithGaps[i].sequence.length > refSeq.sequence.length) {
Expand Down
18 changes: 5 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6945,13 +6945,10 @@ human-signals@^2.1.0:
resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0"
integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==

husky@^0.11.6:
version "0.11.9"
resolved "https://registry.yarnpkg.com/husky/-/husky-0.11.9.tgz#28cd1dc16bffdca1d4d93592814e5f3c327b38ee"
integrity sha1-KM0dwWv/3KHU2TWSgU5fPDJ7OO4=
dependencies:
is-ci "^1.0.9"
normalize-path "^1.0.0"
husky@^8.0.3:
version "8.0.3"
resolved "https://registry.yarnpkg.com/husky/-/husky-8.0.3.tgz#4936d7212e46d1dea28fef29bb3a108872cd9184"
integrity sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==

[email protected]:
version "0.4.15"
Expand Down Expand Up @@ -7291,7 +7288,7 @@ is-callable@^1.2.7:
resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.7.tgz#3bc2a85ea742d9e36205dcacdd72ca1fdc51b055"
integrity sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==

is-ci@^1.0.10, is-ci@^1.0.8, is-ci@^1.0.9:
is-ci@^1.0.10, is-ci@^1.0.8:
version "1.2.1"
resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-1.2.1.tgz#e3779c8ee17fccf428488f6e281187f2e632841c"
integrity sha512-s6tfsaQaQi3JNciBH6shVqEDvhGut0SUXr31ag8Pd8BBbVVlcGfWhpPmEOoM6RJ5TFhbypvf5yyRw/VXW1IiWg==
Expand Down Expand Up @@ -9593,11 +9590,6 @@ normalize-package-data@^2.3.2, normalize-package-data@^2.3.4:
semver "2 || 3 || 4 || 5"
validate-npm-package-license "^3.0.1"

normalize-path@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-1.0.0.tgz#32d0e472f91ff345701c15a8311018d3b0a90379"
integrity sha1-MtDkcvkf80VwHBWoMRAY07CpA3k=

normalize-path@^2.0.0, normalize-path@^2.0.1, normalize-path@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9"
Expand Down

0 comments on commit 4114a81

Please sign in to comment.