Skip to content

Commit

Permalink
Fix linting errors again, mostly indentation changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vang Le-Quy committed May 30, 2020
1 parent 1a71ae5 commit 2b40b72
Show file tree
Hide file tree
Showing 6 changed files with 244 additions and 245 deletions.
63 changes: 31 additions & 32 deletions cli/server/handleGenomeDbs.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
const fs = require('fs');
const path = require("path");
const through = require('through2');
const {PassThrough} = require('stream');
const Engine = require('nedb');
const fasta = require('bionode-fasta');
const bodyParser = require('body-parser');

const { promisify } = require('util');

Expand Down Expand Up @@ -35,7 +33,7 @@ const fetchRecords = (ids, dbPath) =>
if (err) {
console.log('EE');
reject(err);
} else if (docs.length == 0) {
} else if (docs.length === 0) {
console.log("No record found!");
resolve(docs);
} else {
Expand All @@ -54,11 +52,11 @@ const fetchRecords = (ids, dbPath) =>
const getGenomeDB = (datasetsPath) => {
return async (req, res) => { // eslint-disable-line consistent-return
try {
let prefix = req.body.prefix
.replace(/^\//, '')
.replace(/\/$/, '')
.split("/")
.join("_");
const prefix = req.body.prefix
.replace(/^\//, '')
.replace(/\/$/, '')
.split("/")
.join("_");
const dbPath = datasetsPath + '/genomeDbs/' + prefix + '.db';
if (!req.body.ids || req.body.ids.length === 0) {
res.setHeader('Content-Type', 'application/json');
Expand All @@ -70,8 +68,8 @@ const getGenomeDB = (datasetsPath) => {
return;
}
res.setHeader('Content-Type', 'text/plain');
var db = await fetchRecords(req.body.ids, dbPath);
db.forEach(v=> {
const db = await fetchRecords(req.body.ids, dbPath);
db.forEach((v) => {
const wrappedSeq = v.seq.match(/.{1,80}/g).join('\n') + '\n';
res.write('>' + v.id + '\n');
res.write(wrappedSeq);
Expand All @@ -83,27 +81,6 @@ const getGenomeDB = (datasetsPath) => {
};
};

/**
@param {string} path Path to datasetDir so we can create database if corresponding fasta
files exists for aupsice input JSON file
*/
const prepareDbs = async (path) => {
try {
const files = await readdir(path);
const v2Files = files.filter((file) => (
file.endsWith(".fasta")
));
v2Files.forEach((v) => {
makeDB(path, path + '/' + v);
});


} catch (err) {
// utils.warn(`Couldn't collect available dataset files (path searched: ${path})`);
// utils.verbose(err);
}
};

/**
@param {string} dbRoot Path to directory where genome database should be saved
@param {string} fastaPath Path to fasta file to use as input to create database
Expand All @@ -129,7 +106,7 @@ const makeDB = (dbRoot, fastaPath) => new Promise((resolve, reject) => {
let rc = 0;

processRecord.on('data', (rec) => {
obj = JSON.parse(rec);
const obj = JSON.parse(rec);
const outrec = {id: obj.id, seq: obj.seq, source: fastaPath};
db.insert(outrec);
rc++;
Expand All @@ -149,6 +126,28 @@ const makeDB = (dbRoot, fastaPath) => new Promise((resolve, reject) => {
.pipe(processRecord);

});

/**
@param {string} path Path to datasetDir so we can create database if corresponding fasta
files exists for aupsice input JSON file
*/
const prepareDbs = async (localpath) => {
try {
const files = await readdir(localpath);
const v2Files = files.filter((file) => (
file.endsWith(".fasta")
));
v2Files.forEach((v) => {
makeDB(path, path + '/' + v);
});


} catch (err) {
// utils.warn(`Couldn't collect available dataset files (path searched: ${path})`);
// utils.verbose(err);
}
};

module.exports = {
fetchRecords,
getDbPath,
Expand Down
2 changes: 1 addition & 1 deletion cli/server/parseNarrative.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const makeFrontMatterBlock = (frontMatter) => {
markdown.push(`#### License: ${license}`);
}
}

const block = new Proxy({}, blockProxyHandler);
block.url = frontMatter.dataset;
block.contents = markdown.join("\n");
Expand Down
2 changes: 1 addition & 1 deletion docs-src/website/siteConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const siteConfig = {

// Header links in the top nav bar
headerLinks: [
{doc: 'introduction/overview', label: 'Docs'},
{doc: 'introduction/overview', label: 'Docs'}
// {doc: 'tutorial/overview', label: 'Tutorial'}
],

Expand Down
8 changes: 4 additions & 4 deletions docs/js/scrollSpy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// throttle
return;
}
timer = setTimeout(function() {
timer = setTimeout(function () {
timer = null;
let activeNavFound = false;
const headings = findHeadings(); // toc nav anchors
Expand Down Expand Up @@ -48,7 +48,7 @@
} else {
console.error('Can not find header element', {
id: next,
heading,
heading
});
}
}
Expand All @@ -68,9 +68,9 @@

document.addEventListener('scroll', onScroll);
document.addEventListener('resize', onScroll);
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('DOMContentLoaded', function () {
// Cache the headings once the page has fully loaded.
headingsCache = findHeadings();
onScroll();
});
})();
}());
90 changes: 45 additions & 45 deletions src/components/download/downloadModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,17 @@ class DownloadModal extends React.Component {
}
formatPublications(pubs) {
return (
<span>
<span>
<ul>
{pubs.map((pub) => (
{pubs.map((pub) => (
<li key={pub.href}>
<a href={pub.href} target="_blank" rel="noreferrer noopener">
{pub.author}, {pub.title}, <i>{pub.journal}</i> ({pub.year})
</a>
<a href={pub.href} target="_blank" rel="noreferrer noopener">
{pub.author}, {pub.title}, <i>{pub.journal}</i> ({pub.year})
</a>
</li>
))}
</ul>
</span>
))}
</ul>
</span>
);
}
getFilePrefix() {
Expand Down Expand Up @@ -233,21 +233,21 @@ class DownloadModal extends React.Component {
const buttonTextStyle = Object.assign({}, materialButton, {backgroundColor: "rgba(0,0,0,0)", paddingLeft: "10px", color: "white", minWidth: "300px", textAlign: "left" });
const buttonLabelStyle = { fontStyle: "italic", fontSize: "14px", color: "lightgray" };
return (
<div style={{display: "block", justifyContent: "space-around", marginLeft: "25px", width: "100%" }}>
<div style={{display: "block", justifyContent: "space-around", marginLeft: "25px", width: "100%" }}>
<div style={{ width: "100%" }}>
{buttons.map((data) => (
{buttons.map((data) => (
<div key={data[0]} onClick={data[3]} style={{cursor: 'pointer' }}>
{data[2]}
<button style={buttonTextStyle} name={data[0]}>
{data[0]}
</button>
<div style={{ display: "inline-block", height: "30px", verticalAlign: "top", paddingTop: "6px" }}>
<label style={buttonLabelStyle} htmlFor={data[0]}>{data[1]}</label>
{data[2]}
<button style={buttonTextStyle} name={data[0]}>
{data[0]}
</button>
<div style={{ display: "inline-block", height: "30px", verticalAlign: "top", paddingTop: "6px" }}>
<label style={buttonLabelStyle} htmlFor={data[0]}>{data[1]}</label>
</div>
</div>
</div>
))}
</div>
))}
</div>
</div>
);
}
dismissModal() {
Expand Down Expand Up @@ -279,42 +279,42 @@ class DownloadModal extends React.Component {

const meta = this.props.metadata;
return (
<div style={infoPanelStyles.modalContainer} onClick={this.dismissModal}>
<div style={infoPanelStyles.modalContainer} onClick={this.dismissModal}>
<div style={panelStyle} onClick={(e) => stopProp(e)}>
<p style={infoPanelStyles.topRightMessage}>
<p style={infoPanelStyles.topRightMessage}>
({t("click outside this box to return to the app")})
</p>
</p>

<div style={infoPanelStyles.modalSubheading}>
{meta.title} ({t("last updated")} {meta.updated})
</div>
<div style={infoPanelStyles.modalSubheading}>
{meta.title} ({t("last updated")} {meta.updated})
</div>

<div>
{this.createSummaryWrapper()}
</div>
<div style={infoPanelStyles.break}/>
{" " + t("A full list of sequence authors is available via the TSV files below")}
<div style={infoPanelStyles.break}/>
{getAcknowledgments({}, {preamble: {fontWeight: 300}, acknowledgments: {fontWeight: 300}})}
<div>
{this.createSummaryWrapper()}
</div>
<div style={infoPanelStyles.break}/>
{" " + t("A full list of sequence authors is available via the TSV files below")}
<div style={infoPanelStyles.break}/>
{getAcknowledgments({}, {preamble: {fontWeight: 300}, acknowledgments: {fontWeight: 300}})}

<div style={infoPanelStyles.modalSubheading}>
{t("Data usage policy")}
</div>
{t("Data usage part 1") + " " + t("Data usage part 2")}
<div style={infoPanelStyles.modalSubheading}>
{t("Data usage policy")}
</div>
{t("Data usage part 1") + " " + t("Data usage part 2")}

<div style={infoPanelStyles.modalSubheading}>
{t("Please cite the authors who contributed genomic data (where relevant), as well as")+":"}
</div>
{this.formatPublications(this.getRelevantPublications())}
<div style={infoPanelStyles.modalSubheading}>
{t("Please cite the authors who contributed genomic data (where relevant), as well as")+":"}
</div>
{this.formatPublications(this.getRelevantPublications())}


<div style={infoPanelStyles.modalSubheading}>
{t("Download data")}:
</div>
{this.downloadButtons()}
<div style={infoPanelStyles.modalSubheading}>
{t("Download data")}:
</div>
{this.downloadButtons()}

</div>
</div>
</div>
);
}
}
Expand Down
Loading

0 comments on commit 2b40b72

Please sign in to comment.