Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support RNA sequence in gb file #5

Merged
merged 7 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/bio-parsers/src/genbankToJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ function genbankToJson(string, options = {}) {

if (
j === 4 &&
(item.match(/ds-dna/i) || item.match(/ss-dna/i) || item.match(/dna/i))
(item.match(/ds-dna/i) || item.match(/ss-dna/i) || item.match(/dna/i) || item.match(/rna/i))
) {
if (options.isProtein === undefined) {
options.isProtein = false;
Expand All @@ -347,6 +347,9 @@ function genbankToJson(string, options = {}) {
if (item.match(/ss-dna/i)) {
options.isSingleStrandedDNA = true;
}
if (item.match(/rna/i) && !item.match(/ss-rna/i)) {
options.isDoubleStrandedRNA = true;
}
}

// Division
Expand All @@ -368,6 +371,7 @@ function genbankToJson(string, options = {}) {
result.parsedSequence.gbDivision = gbDivision;
result.parsedSequence.sequenceTypeFromLocus = options.sequenceTypeFromLocus;
result.parsedSequence.isSingleStrandedDNA = options.isSingleStrandedDNA;
result.parsedSequence.isDoubleStrandedRNA = options.isDoubleStrandedRNA;
result.parsedSequence.date = date;
result.parsedSequence.circular = circular;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/bio-parsers/src/jsonToGenbank.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ function createGenbankLocus(serSeq, options) {
if (serSeq.isProtein) {
dnaType = "";
} else if (serSeq.type === "RNA") {
dnaType = "RNA";
dnaType = serSeq?.doubleStranded ? 'RNA' : serSeq?.sequenceTypeFromLocus ?? "ss-RNA";
} else {
dnaType = serSeq?.sequenceTypeFromLocus ?? "DNA";
dnaType = serSeq?.doubleStranded ? 'DNA' : serSeq?.sequenceTypeFromLocus ?? "DNA";
}
const date = getCurrentDateString();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function getComplementSequenceAndAnnotations(
options
);
const newSeqObj = Object.assign({}, seqObj, {
sequence: getComplementSequenceString(seqObj.sequence)
sequence: getComplementSequenceString(seqObj.sequence, seqObj.isRna)
});
return tidyUpSequenceData(newSeqObj, options);
};
6 changes: 4 additions & 2 deletions packages/sequence-utils/src/getComplementSequenceString.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import DNAComplementMap from "./DNAComplementMap";
import { merge } from "lodash";


// ac.throw([ac.string,ac.bool],arguments);
export default function getComplementSequenceString(sequence) {
export default function getComplementSequenceString(sequence, isRna) {
// ac.throw([ac.string],arguments);
let complementSeqString = "";
const complementMap = merge(DNAComplementMap, isRna ? { a: 'u', A: 'U'} : {a: 't', A: 'T'});
for (let i = 0; i < sequence.length; i++) {
let complementChar = DNAComplementMap[sequence[i]];
let complementChar = complementMap[sequence[i]];
if (!complementChar) {
complementChar = sequence[i];
// throw new Error('trying to get the reverse compelement of an invalid base');
Expand Down