Skip to content

Commit

Permalink
#2188 HELM 2 support: variant monomers (#2255)
Browse files Browse the repository at this point in the history
Co-authored-by: Aliakasndr Dziarkach <[email protected]>
  • Loading branch information
AliaksandrDziarkach and Aliakasndr Dziarkach authored Aug 27, 2024
1 parent a81491a commit 9ff19ad
Show file tree
Hide file tree
Showing 30 changed files with 4,742 additions and 1,513 deletions.
7 changes: 3 additions & 4 deletions api/c/indigo/src/indigo_molecule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,11 +719,10 @@ CEXPORT int indigoLoadHelm(int source, int library)
IndigoObject& lib_obj = self.getObject(library);
SequenceLoader loader(IndigoScanner::get(obj), IndigoMonomerLibrary::get(lib_obj));

std::unique_ptr<IndigoMolecule> molptr = std::make_unique<IndigoMolecule>();
std::unique_ptr<IndigoKetDocument> docptr = std::make_unique<IndigoKetDocument>();

Molecule& mol = molptr->mol;
loader.loadHELM(mol);
return self.addObject(molptr.release());
loader.loadHELM(docptr->get());
return self.addObject(docptr.release());
}
INDIGO_END(-1);
}
Expand Down
8 changes: 8 additions & 0 deletions api/c/indigo/src/indigo_savers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,14 @@ CEXPORT int indigoSaveHelm(int item, int output, int library)
out.flush();
return 1;
}
else if (IndigoKetDocument::is(obj))
{
IndigoObject& lib_obj = self.getObject(library);
SequenceSaver saver(out, IndigoMonomerLibrary::get(lib_obj));
saver.saveKetDocument(static_cast<IndigoKetDocument&>(obj).get(), SequenceSaver::SeqFormat::HELM);
out.flush();
return 1;
}
throw IndigoError("indigoSaveHelm(): expected molecule, got %s", obj.debugInfo());
}
INDIGO_END(-1);
Expand Down
5 changes: 4 additions & 1 deletion api/tests/integration/ref/formats/helm_to_ket.py.out
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
*** HELM to KET ***
aminoacids_variants.ket:SUCCEED
helm_annotations.ket:SUCCEED
helm_chem_peptide.ket:SUCCEED
helm_chem_rna.ket:SUCCEED
helm_mixed_base.ket:SUCCEED
helm_mixed_custom.ket:SUCCEED
helm_multi_char_rna.ket:SUCCEED
helm_peptide.ket:SUCCEED
helm_rna_without_base.ket:SUCCEED
helm_simple_rna.ket:SUCCEED
Test 'CHEM1{[A6OH]}|PEPTIDE1{A}$CHEM1,PEPTIDE1,1:R2-3:R1$$$V2.0': got expected error 'Polymer 'PEPTIDE1' does not contains monomer with number 3.'
Test 'CHEM1{[A6OH]}|PEPTIDE1{A}$CHEM10,PEPTIDE1,1:R2-1:R1$$$V2.0': got expected error 'Polymer 'CHEM10' not found.'
Test 'CHEM1{[MCC]}|RNA1{R(A)P.R(C)P.R(G)P.R(T)P.R(U)P}$RNA1,PEPTIDE1,15:R2-1:R1$$$V2.0': got expected error 'Polymer 'PEPTIDE1' not found.'
Test 'PEPTIDE1{A'2'}$$$$V2.0': got expected error 'Repeating do not supported now.'
Test 'PEPTIDE1{A'2'}$$$$V2.0': got expected error 'Repeating not supported now.'
5 changes: 5 additions & 0 deletions api/tests/integration/ref/formats/ket_to_helm.py.out
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
*** KET to HELM ***
aminoacids_variants.ket:SUCCEED
dna_variants.ket:SUCCEED
helm_annotations.ket:SUCCEED
helm_chem_peptide.ket:SUCCEED
helm_chem_rna.ket:SUCCEED
helm_connetion_separator.ket:SUCCEED
helm_cycled_polymer.ket:SUCCEED
helm_mixed_base.ket:SUCCEED
helm_mixed_custom.ket:SUCCEED
helm_multi_char_rna.ket:SUCCEED
helm_peptide.ket:SUCCEED
helm_rna_without_base.ket:SUCCEED
helm_simple_rna.ket:SUCCEED
rna_variants.ket:SUCCEED
5 changes: 4 additions & 1 deletion api/tests/integration/tests/formats/helm_to_ket.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ def find_diff(a, b):
"helm_annotations": 'BLOB1{BEAD}"Animated Polystyrene"|CHEM1{[hxy]"Annotation"}|RNA1{R(A"mutation")P.R(U)P.R(G)P}$$$$V2.0',
"helm_chem_rna": "CHEM1{[MCC]}|RNA1{R(U)P}$CHEM1,RNA1,1:R1-3:R2$$$V2.0",
"helm_rna_without_base": "RNA1{RP}$$$$V2.0",
"helm_mixed_base": "RNA1{[dR](A)P.[dR](A+G)P.[dR](A)P.[dR](G+C)}$$$$V2.0",
"helm_mixed_custom": "RNA1{[dR](A:10+C:20+G:30+T:50)P.[dR](A:10+C:20+G:30+T:50)P.[dR](A+C+G+T)}$$$$V2.0",
"aminoacids_variants": "PEPTIDE1{(D+N).(L+I).(E+Q).(A+C+D+E+F+G+H+I+K+L+M+N+O+P+Q+R+S+T+U+V+W+Y)}$$$$V2.0",
}

lib = indigo.loadMonomerLibraryFromFile(
Expand All @@ -57,7 +60,7 @@ def find_diff(a, b):
print(diff)

helm_errors = {
"PEPTIDE1{A'2'}$$$$V2.0": "Repeating do not supported now.",
"PEPTIDE1{A'2'}$$$$V2.0": "Repeating not supported now.",
"CHEM1{[MCC]}|RNA1{R(A)P.R(C)P.R(G)P.R(T)P.R(U)P}$RNA1,PEPTIDE1,15:R2-1:R1$$$V2.0": "Polymer 'PEPTIDE1' not found.",
"CHEM1{[A6OH]}|PEPTIDE1{A}$CHEM10,PEPTIDE1,1:R2-1:R1$$$V2.0": "Polymer 'CHEM10' not found.",
"CHEM1{[A6OH]}|PEPTIDE1{A}$CHEM1,PEPTIDE1,1:R2-3:R1$$$V2.0": "Polymer 'PEPTIDE1' does not contains monomer with number 3.",
Expand Down
13 changes: 9 additions & 4 deletions api/tests/integration/tests/formats/ket_to_helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,26 @@ def find_diff(a, b):
"helm_peptide": "PEPTIDE1{A.[meA].C}$$$$V2.0",
"helm_chem_peptide": "CHEM1{[PEG2]}|PEPTIDE1{W.N.D.[Pen].G.[Orn].D.A.D.G.S.G.[Cap]}$CHEM1,PEPTIDE1,1:R1-1:R1$$$V2.0",
"helm_annotations": "CHEM1{[hxy]}|RNA1{R(A)P.R(U)P.R(G)P}$$$$V2.0",
"helm_connetion_separator": "PEPTIDE1{A}|CHEM1{[A6OH]}|PEPTIDE2{C}$PEPTIDE1,CHEM1,1:R2-1:R1|PEPTIDE2,CHEM1,1:R1-1:R2$$$V2.0",
"helm_connetion_separator": "PEPTIDE1{A}|PEPTIDE2{C}|CHEM1{[A6OH]}$PEPTIDE1,CHEM1,1:R2-1:R1|CHEM1,PEPTIDE2,1:R2-1:R1$$$V2.0",
"helm_chem_rna": "CHEM1{[MCC]}|RNA1{R(U)P}$CHEM1,RNA1,1:R1-3:R2$$$V2.0",
"helm_rna_without_base": "RNA1{RP}$$$$V2.0",
"helm_cycled_polymer": "PEPTIDE1{C.D.E.F.A}$PEPTIDE1,PEPTIDE1,5:R2-1:R1$$$V2.0",
"helm_cycled_polymer": "PEPTIDE1{A.C.D.E.F}$PEPTIDE1,PEPTIDE1,5:R2-1:R1$$$V2.0",
"helm_mixed_base": "RNA1{[dR](A)P.[dR](A+G)P.[dR](A)P.[dR](G+C)}$$$$V2.0",
"helm_mixed_custom": "RNA1{[dR](A:10+C:20+G:30+T:50)P.[dR](A:10+C:20+G:30+T:50)P.[dR](A+C+G+T)}$$$$V2.0",
"aminoacids_variants": "PEPTIDE1{(D+N).(L+I).(E+Q).(A+C+D+E+F+G+H+I+K+L+M+N+O+P+Q+R+S+T+U+V+W+Y)}$$$$V2.0",
"dna_variants": "RNA1{[dR](C+G+T)P.[dR](A+C+G+T)}$$$$V2.0",
"rna_variants": "RNA1{R(G+T)P.R(A+C+G+T)}$$$$V2.0",
}

for filename in sorted(helm_data.keys()):
mol = indigo.loadMoleculeFromFile(os.path.join(ref, filename + ".ket"))
mol = indigo.loadKetDocumentFromFile(os.path.join(ref, filename + ".ket"))
helm = mol.helm(lib)
helm_ref = helm_data[filename]
if helm_ref == helm:
print(filename + ".ket:SUCCEED")
else:
print(
"%s.helm FAILED : expected '%s', got '%s'"
"%s.ket FAILED : expected '%s', got '%s'"
% (filename, helm_ref, helm)
)

Expand Down
50 changes: 23 additions & 27 deletions api/tests/integration/tests/formats/ref/aminoacids_variants.ket
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,49 @@
"root": {
"nodes": [
{
"$ref": "monomer0"
"$ref": "variantMonomer-0"
},
{
"$ref": "monomer1"
"$ref": "variantMonomer-1"
},
{
"$ref": "monomer2"
"$ref": "variantMonomer-2"
},
{
"$ref": "monomer3"
"$ref": "variantMonomer-3"
}
],
"connections": [
{
"connectionType": "single",
"endpoint1": {
"monomerId": "monomer0",
"monomerId": "variantMonomer-0",
"attachmentPointId": "R2"
},
"endpoint2": {
"monomerId": "monomer1",
"monomerId": "variantMonomer-1",
"attachmentPointId": "R1"
}
},
{
"connectionType": "single",
"endpoint1": {
"monomerId": "monomer1",
"monomerId": "variantMonomer-1",
"attachmentPointId": "R2"
},
"endpoint2": {
"monomerId": "monomer2",
"monomerId": "variantMonomer-2",
"attachmentPointId": "R1"
}
},
{
"connectionType": "single",
"endpoint1": {
"monomerId": "monomer2",
"monomerId": "variantMonomer-2",
"attachmentPointId": "R2"
},
"endpoint2": {
"monomerId": "monomer3",
"monomerId": "variantMonomer-3",
"attachmentPointId": "R1"
}
}
Expand Down Expand Up @@ -130,48 +130,44 @@
}
]
},
"monomer0": {
"type": "monomer",
"variantMonomer-0": {
"type": "variantMonomer",
"id": "0",
"seqid": 1,
"position": {
"x": 0.000000,
"y": -0.000000
},
"alias": "B",
"seqid": 1,
"templateId": "B"
},
"monomer1": {
"type": "monomer",
"variantMonomer-1": {
"type": "variantMonomer",
"id": "1",
"seqid": 2,
"position": {
"x": 1.600000,
"y": -0.000000
},
"alias": "J",
"seqid": 2,
"templateId": "J"
},
"monomer2": {
"type": "monomer",
"variantMonomer-2": {
"type": "variantMonomer",
"id": "2",
"seqid": 3,
"position": {
"x": 3.200000,
"y": -0.000000
},
"alias": "Z",
"seqid": 3,
"templateId": "Z"
},
"monomer3": {
"type": "monomer",
"variantMonomer-3": {
"type": "variantMonomer",
"id": "3",
"seqid": 4,
"position": {
"x": 4.800000,
"y": -0.000000
},
"alias": "X",
"seqid": 4,
"templateId": "X"
},
"monomerTemplate-D___Aspartic acid": {
Expand Down Expand Up @@ -4756,7 +4752,7 @@
"templateId": "P___Proline"
},
{
"templateId": "G___Glycine"
"templateId": "Q___Glutamine"
},
{
"templateId": "R___Arginine"
Expand Down
Loading

0 comments on commit 9ff19ad

Please sign in to comment.