Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
reader.onload = function(evt) {
const content = evt.target.result;
anyToJson(
content,
async result => {
// TODO maybe handle import errors/warnings better
const failed = !result[0].success;
const messages = result[0].messages;
if (messages && messages.length) {
messages.forEach(msg => {
const type = msg
.substr(0, 20)
.toLowerCase()
.includes("error")
? failed
? "error"
: "warning"
: "info";
window.toastr[type](msg);
const bioParsers = require('bio-parsers')
const fs = require('fs')
const string = fs.readFileSync('./exampleData/JBx_078420.gb',"utf8")
console.info('string:',string)
bioParsers.genbankToJson(string, (res) => {
console.info('res[0].parsedSequence:',JSON.stringify(res[0].parsedSequence,null,4))
})
reader.onload = function(evt: Object) {
const content: string = evt.target.result;
anyToJson(
content,
result => {
updateSequenceData(result[0].parsedSequence);
},
{ fileName: file.name, acceptParts: true }
);
};
reader.onerror = function() {
flatMap(files, async file => {
const results = await anyToJson(file.originalFileObj, {
fileName: file.name,
acceptParts: true
});
return results.forEach(result => {
if (result.success) {
array.push("addedSequences", result.parsedSequence);
} else {
return window.toastr.warning("Error parsing file: ", file.name);
}
});
});
onChange([]);
render() {
const { sequenceData = {} } = this.props;
let filestring;
switch (this.state.fileTypeToView) {
case "fasta":
filestring = jsonToFasta(sequenceData);
break;
case "teselagen":
filestring = JSON.stringify(
cleanUpTeselagenJsonForExport(sequenceData),
null,
4
);
break;
default:
filestring = jsonToGenbank(sequenceData);
}
return (
<div>
{
this.setState({ fileTypeToView: e.target.value });
}}
/>
</div>
function getGenbankFromSelection(selectedSeqData, sequenceData) {
const spansEntireSeq =
sequenceData.sequence.length === selectedSeqData.sequence.length;
const feats = map(selectedSeqData.features);
const just1Feat = feats.length === 1;
return {
sequence: jsonToGenbank({
...selectedSeqData,
name: spansEntireSeq
? selectedSeqData.name
: just1Feat
? feats[0].name
: selectedSeqData.name + "_partial",
circular: spansEntireSeq ? selectedSeqData.circular : false
})
};
}
render() {
const { sequenceData = {} } = this.props;
let filestring;
switch (this.state.fileTypeToView) {
case "fasta":
filestring = jsonToFasta(sequenceData);
break;
case "teselagen":
filestring = JSON.stringify(
cleanUpTeselagenJsonForExport(sequenceData),
null,
4
);
break;
default:
filestring = jsonToGenbank(sequenceData);
}
return (
<div>
</div>
render() {
const { sequenceData = {} } = this.props;
let filestring;
switch (this.state.fileTypeToView) {
case "fasta":
filestring = jsonToFasta(sequenceData);
break;
case "teselagen":
filestring = JSON.stringify(
cleanUpTeselagenJsonForExport(sequenceData),
null,
4
);
break;
default:
filestring = jsonToGenbank(sequenceData);
}
return (
<div>
</div>