Search in sources :

Example 1 with ModuleDefinition

use of org.sbolstandard.core2.ModuleDefinition in project libSBOLj by SynBioDex.

the class ModuleDefinitionOutput method createInverter.

private static void createInverter(SBOLDocument document, ModuleDefinition moduleDef, ComponentDefinition promoter, ComponentDefinition TF) throws Exception {
    FunctionalComponent laciInverterModuleDef_promoter = moduleDef.createFunctionalComponent("promoter", AccessType.PUBLIC, promoter.getIdentity(), DirectionType.INOUT);
    FunctionalComponent laciInverterModuleDef_TF = moduleDef.createFunctionalComponent("TF", AccessType.PUBLIC, TF.getIdentity(), DirectionType.INOUT);
    Interaction interaction = moduleDef.createInteraction("LacI_pLacI", new HashSet<URI>(Arrays.asList(toURI(Terms.interactionTypes.transcriptionalRepression))));
    Participation participation = interaction.createParticipation(promoter.getDisplayId(), laciInverterModuleDef_promoter.getIdentity(), toURI(Terms.participantRoles.promoter));
    Participation participation2 = interaction.createParticipation(TF.getDisplayId(), laciInverterModuleDef_TF.getIdentity(), toURI(Terms.participantRoles.inhibitor));
}
Also used : Participation(org.sbolstandard.core2.Participation) Interaction(org.sbolstandard.core2.Interaction) FunctionalComponent(org.sbolstandard.core2.FunctionalComponent) URI(java.net.URI)

Example 2 with ModuleDefinition

use of org.sbolstandard.core2.ModuleDefinition in project libSBOLj by SynBioDex.

the class ModuleDefinitionOutput method main.

public static void main(String[] args) throws Exception {
    SBOLDocument document = new SBOLDocument();
    setDefaultNameSpace(document, pr.getNamespaceURI());
    ComponentDefinition gfp = createComponenDefinition(document, pr.withLocalPart("BBa_E0040"), "gfp", Terms.biopaxTerms.DnaRegion, Terms.soTerms.CDS, "gfp coding sequence");
    ComponentDefinition tetR = createComponenDefinition(document, pr.withLocalPart("BBa_C0040"), "tetR", Terms.biopaxTerms.DnaRegion, Terms.soTerms.CDS, "tetR coding sequence");
    ComponentDefinition lacI = createComponenDefinition(document, pr.withLocalPart("BBa_C0012"), "lacI", Terms.biopaxTerms.DnaRegion, Terms.soTerms.CDS, "lacI coding sequence");
    ComponentDefinition placI = createComponenDefinition(document, pr.withLocalPart("BBa_R0010"), "pLacI", Terms.biopaxTerms.DnaRegion, Terms.soTerms.promoter, "pLacI promoter");
    ComponentDefinition ptetR = createComponenDefinition(document, pr.withLocalPart("BBa_R0040"), "pTetR", Terms.biopaxTerms.DnaRegion, Terms.soTerms.promoter, "pTet promoter");
    ComponentDefinition rbslacI = createComponenDefinition(document, pr.withLocalPart("BBa_J61101"), "BBa_J61101 RBS", Terms.biopaxTerms.DnaRegion, Terms.soTerms.RBS, "RBS1");
    ComponentDefinition rbstetR = createComponenDefinition(document, pr.withLocalPart("BBa_J61120"), "BBa_J61101 RBS", Terms.biopaxTerms.DnaRegion, Terms.soTerms.RBS, "RBS2");
    ComponentDefinition rbsgfp = createComponenDefinition(document, pr.withLocalPart("BBa_J61130"), "BBa_J61101 RBS", Terms.biopaxTerms.DnaRegion, Terms.soTerms.RBS, "RBS2");
    setDefaultNameSpace(document, uniprot.getNamespaceURI());
    ComponentDefinition GFP = createComponenDefinition(document, uniprot.withLocalPart("P42212"), "GFP", Terms.biopaxTerms.Protein, Terms.sboTerms.product, "GFP protein");
    ComponentDefinition TetR = createComponenDefinition(document, uniprot.withLocalPart("Q6QR72"), "TetR", Terms.biopaxTerms.Protein, Terms.sboTerms.inhibitor, "TetR protein");
    ComponentDefinition LacI = createComponenDefinition(document, uniprot.withLocalPart("P03023"), "LacI", Terms.biopaxTerms.Protein, Terms.sboTerms.inhibitor, "LacI protein");
    setDefaultNameSpace(document, pr.getNamespaceURI());
    ComponentDefinition lacITerminator = createComponenDefinition(document, pr.withLocalPart("ECK120029600"), "ECK120029600", Terms.biopaxTerms.DnaRegion, Terms.soTerms.terminator, "Terminator1");
    ComponentDefinition tetRTerminator = createComponenDefinition(document, pr.withLocalPart("ECK120033736"), "ECK120033736", Terms.biopaxTerms.DnaRegion, Terms.soTerms.terminator, "Terminator2");
    setDefaultNameSpace(document, vpr.getNamespaceURI());
    ComponentDefinition tetRInverter = createComponenDefinition(document, vpr.withLocalPart("pIKELeftCassette_1"), "TetR Inverter", Terms.biopaxTerms.DnaRegion, Terms.soTerms.engineeredGene, "TetR Inverter");
    ComponentDefinition lacIInverter = createComponenDefinition(document, vpr.withLocalPart("pIKERightCassette_1"), "LacI Inverter", Terms.biopaxTerms.DnaRegion, Terms.soTerms.engineeredGene, "LacI Inverter");
    ComponentDefinition toggleSwitch = createComponenDefinition(document, vpr.withLocalPart("pIKE_Toggle_1"), "LacI/TetR Toggle Switch", Terms.biopaxTerms.DnaRegion, Terms.soTerms.engineeredGene, "LacI/TetR Toggle Switch");
    // tetR inverter sequences
    addPRSequence(document, ptetR, "tccctatcagtgatagagattgacatccctatcagtgatagagatactgagcac");
    addPRSequence(document, rbslacI, "aaagacaggacc");
    addPRSequence(document, lacI, "atggtgaatgtgaaaccagtaacgttatacgatgtcgcagagtatgccggtgtctcttatcagaccgtttcccgcgtggtgaaccaggccagccacgtttctgcgaaaacgcgggaaaaagtggaagcggcgatggcggagctgaattacattcccaaccgcgtggcacaacaactggcgggcaaacagtcgttgctgattggcgttgccacctccagtctggccctgcacgcgccgtcgcaaattgtcgcggcgattaaatctcgcgccgatcaactgggtgccagcgtggtggtgtcgatggtagaacgaagcggcgtcgaagcctgtaaagcggcggtgcacaatcttctcgcgcaacgcgtcagtgggctgatcattaactatccgctggatgaccaggatgccattgctgtggaagctgcctgcactaatgttccggcgttatttcttgatgtctctgaccagacacccatcaacagtattattttctcccatgaagacggtacgcgactgggcgtggagcatctggtcgcattgggtcaccagcaaatcgcgctgttagcgggcccattaagttctgtctcggcgcgtctgcgtctggctggctggcataaatatctcactcgcaatcaaattcagccgatagcggaacgggaaggcgactggagtgccatgtccggttttcaacaaaccatgcaaatgctgaatgagggcatcgttcccactgcgatgctggttgccaacgatcagatggcgctgggcgcaatgcgcgccattaccgagtccgggctgcgcgttggtgcggatatctcggtagtgggatacgacgataccgaagacagctcatgttatatcccgccgttaaccaccatcaaacaggattttcgcctgctggggcaaaccagcgtggaccgcttgctgcaactctctcagggccaggcggtgaagggcaatcagctgttgcccgtctcactggtgaaaagaaaaaccaccctggcgcccaatacgcaaaccgcctctccccgcgcgttggccgattcattaatgcagctggcacgacaggtttcccgactggaaagcgggcaggctgcaaacgacgaaaactacgctttagtagcttaataa");
    addPRSequence(document, lacITerminator, "ttcagccaaaaaacttaagaccgccggtcttgtccactaccttgcagtaatgcggtggacaggatcggcggttttcttttctcttctcaa");
    // lacI inverter sequences
    addPRSequence(document, placI, "tccctatcagtgatagagattgacatccctatcagtgatagagatactgagcac");
    addPRSequence(document, rbstetR, "aaagacaggacc");
    addPRSequence(document, tetR, "atgtccagattagataaaagtaaagtgattaacagcgcattagagctgcttaatgaggtcggaatcgaaggtttaacaacccgtaaactcgcccagaagctaggtgtagagcagcctacattgtattggcatgtaaaaaataagcgggctttgctcgacgccttagccattgagatgttagataggcaccatactcacttttgccctttagaaggggaaagctggcaagattttttacgtaataacgctaaaagttttagatgtgctttactaagtcatcgcgatggagcaaaagtacatttaggtacacggcctacagaaaaacagtatgaaactctcgaaaatcaattagcctttttatgccaacaaggtttttcactagagaatgcattatatgcactcagcgctgtggggcattttactttaggttgcgtattggaagatcaagagcatcaagtcgctaaagaagaaagggaaacacctactactgatagtatgccgccattattacgacaagctatcgaattatttgatcaccaaggtgcagagccagccttcttattcggccttgaattgatcatatgcggattagaaaaacaacttaaatgtgaaagtgggtccgctgcaaacgacgaaaactacgctttagtagcttaataa");
    addPRSequence(document, rbsgfp, "aaagaaacgaca");
    addPRSequence(document, gfp, "atgcgtaaaggagaagaacttttcactggagttgtcccaattcttgttgaattagatggtgatgttaatgggcacaaattttctgtcagtggagagggtgaaggtgatgcaacatacggaaaacttacccttaaatttatttgcactactggaaaactacctgttccatggccaacacttgtcactactttcggttatggtgttcaatgctttgcgagatacccagatcatatgaaacagcatgactttttcaagagtgccatgcccgaaggttatgtacaggaaagaactatatttttcaaagatgacgggaactacaagacacgtgctgaagtcaagtttgaaggtgatacccttgttaatagaatcgagttaaaaggtattgattttaaagaagatggaaacattcttggacacaaattggaatacaactataactcacacaatgtatacatcatggcagacaaacaaaagaatggaatcaaagttaacttcaaaattagacacaacattgaagatggaagcgttcaactagcagaccattatcaacaaaatactccaattggcgatggccctgtccttttaccagacaaccattacctgtccacacaatctgccctttcgaaagatcccaacgaaaagagagaccacatggtccttcttgagtttgtaacagctgctgggattacacatggcatggatgaactatacaaataataa");
    addPRSequence(document, tetRTerminator, "ttcagccaaaaaacttaagaccgccggtcttgtccactaccttgcagtaatgcggtggacaggatcggcggttttcttttctcttctcaa");
    addSubComponents(document, tetRInverter, ptetR, rbslacI, lacI, lacITerminator);
    addSubComponents(document, lacIInverter, placI, rbstetR, tetR, rbsgfp, gfp, tetRTerminator);
    addSubComponents(document, toggleSwitch, tetRInverter, lacIInverter);
    setDefaultNameSpace(document, example.getNamespaceURI());
    ModuleDefinition laciInverterModuleDef = document.createModuleDefinition("laci_inverter");
    laciInverterModuleDef.addRole(Terms.moduleRoles.inverter);
    ModuleDefinition tetRInverterModuleDef = document.createModuleDefinition("tetr_inverter");
    tetRInverterModuleDef.addRole(Terms.moduleRoles.inverter);
    createInverter(document, laciInverterModuleDef, placI, LacI);
    createInverter(document, tetRInverterModuleDef, ptetR, TetR);
    ModuleDefinition toggleSwitchModuleDef = document.createModuleDefinition("toggle_switch");
    toggleSwitchModuleDef.addRole(toURI(example.withLocalPart("module_role/toggle_switch")));
    FunctionalComponent toggleSwitchModuleDef_TetR = toggleSwitchModuleDef.createFunctionalComponent("TetR", AccessType.PUBLIC, TetR.getIdentity(), DirectionType.INOUT);
    FunctionalComponent toggleSwitchModuleDef_LacI = toggleSwitchModuleDef.createFunctionalComponent("LacI", AccessType.PUBLIC, LacI.getIdentity(), DirectionType.INOUT);
    Module lacInverterSubModule = toggleSwitchModuleDef.createModule("laci_inverter", laciInverterModuleDef.getIdentity());
    lacInverterSubModule.createMapsTo("LacI_mapping", RefinementType.USEREMOTE, toggleSwitchModuleDef_LacI.getIdentity(), laciInverterModuleDef.getFunctionalComponent("TF").getIdentity());
    Module tetRInverterSubModule = toggleSwitchModuleDef.createModule("tetr_inverter", tetRInverterModuleDef.getIdentity());
    tetRInverterSubModule.createMapsTo("TetR_mapping", RefinementType.USEREMOTE, toggleSwitchModuleDef_TetR.getIdentity(), tetRInverterModuleDef.getFunctionalComponent("TF").getIdentity());
    Model model = document.createModel("toogleswitch", URI.create("http://virtualparts.org/part/pIKE_Toggle_1"), EDAMOntology.SBML, SystemsBiologyOntology.CONTINUOUS_FRAMEWORK);
    toggleSwitchModuleDef.addModel(model.getIdentity());
    SBOLWriter.write(document, (System.out));
}
Also used : ModuleDefinition(org.sbolstandard.core2.ModuleDefinition) SBOLDocument(org.sbolstandard.core2.SBOLDocument) Model(org.sbolstandard.core2.Model) FunctionalComponent(org.sbolstandard.core2.FunctionalComponent) Module(org.sbolstandard.core2.Module) ComponentDefinition(org.sbolstandard.core2.ComponentDefinition)

Example 3 with ModuleDefinition

use of org.sbolstandard.core2.ModuleDefinition in project libSBOLj by SynBioDex.

the class RepressionModel method main.

public static void main(String[] args) throws SBOLValidationException, SBOLConversionException, IOException {
    SBOLDocument doc = new SBOLDocument();
    doc.setDefaultURIprefix("http://sbols.org/CRISPR_Example/");
    doc.setComplete(true);
    doc.setCreateDefaults(true);
    String version = "1.0.0";
    // Create ComponentDefinition for cas9_generic protein
    doc.createComponentDefinition("cas9_generic", version, ComponentDefinition.PROTEIN);
    // Create ComponentDefinition for gRNA_generic RNA
    doc.createComponentDefinition("gRNA_generic", version, ComponentDefinition.RNA).addRole(SequenceOntology.SGRNA);
    // Create ComponentDefinition for cas9_gRNA_complex
    doc.createComponentDefinition("cas9_gRNA_complex", version, ComponentDefinition.COMPLEX);
    // Create ComponentDefinition for target gene
    doc.createComponentDefinition("target_gene", version, ComponentDefinition.DNA).addRole(SequenceOntology.PROMOTER);
    // Create ComponentDefinition for target protein
    doc.createComponentDefinition("target", version, ComponentDefinition.PROTEIN);
    // Create ModuleDefinition for CRISPR_Repression_Template
    ModuleDefinition CRISPR_Template = doc.createModuleDefinition("CRISPR_Template", version);
    // Complex Formation Interaction for Cas9m_BFP and gRNA
    Interaction Cas9Complex_Formation = CRISPR_Template.createInteraction("cas9_complex_formation", SystemsBiologyOntology.NON_COVALENT_BINDING);
    Cas9Complex_Formation.createParticipation("cas9_generic", "cas9_generic", SystemsBiologyOntology.REACTANT);
    Cas9Complex_Formation.createParticipation("gRNA_generic", "gRNA_generic", SystemsBiologyOntology.REACTANT);
    Cas9Complex_Formation.createParticipation("cas9_gRNA_complex", "cas9_gRNA_complex", SystemsBiologyOntology.PRODUCT);
    // Production of target from target gene
    Interaction EYFP_production = CRISPR_Template.createInteraction("target_production", SystemsBiologyOntology.GENETIC_PRODUCTION);
    EYFP_production.createParticipation("target_gene", "target_gene", SystemsBiologyOntology.PROMOTER);
    EYFP_production.createParticipation("target", "target", SystemsBiologyOntology.PRODUCT);
    // Inhibition of target by cas9m_BFP_gRNA
    Interaction target_generic_gene_inhibition = CRISPR_Template.createInteraction("target_gene_inhibition", SystemsBiologyOntology.INHIBITION);
    target_generic_gene_inhibition.createParticipation("cas9_gRNA_complex", "cas9_gRNA_complex", SystemsBiologyOntology.INHIBITOR);
    target_generic_gene_inhibition.createParticipation("target_gene", "target_gene", SystemsBiologyOntology.PROMOTER);
    // Create Sequence for CRa_U6 promoter
    String CRa_U6_seq_elements = "GGTTTACCGAGCTCTTATTGGTTTTCAAACTTCATTGACTGTGCC" + "AAGGTCGGGCAGGAAGAGGGCCTATTTCCCATGATTCCTTCATAT" + "TTGCATATACGATACAAGGCTGTTAGAGAGATAATTAGAATTAAT" + "TTGACTGTAAACACAAAGATATTAGTACAAAATACGTGACGTAGA" + "AAGTAATAATTTCTTGGGTAGTTTGCAGTTTTAAAATTATGTTTT" + "AAAATGGACTATCATATGCTTACCGTAACTTGAAATATAGAACCG" + "ATCCTCCCATTGGTATATATTATAGAACCGATCCTCCCATTGGCT" + "TGTGGAAAGGACGAAACACCGTACCTCATCAGGAACATGTGTTTA" + "AGAGCTATGCTGGAAACAGCAGAAATAGCAAGTTTAAATAAGGCT" + "AGTCCGTTATCAACTTGAAAAAGTGGCACCGAGTCGGTGCTTTTT" + "TTGGTGCGTTTTTATGCTTGTAGTATTGTATAATGTTTTT";
    doc.createSequence("CRa_U6_seq", version, CRa_U6_seq_elements, Sequence.IUPAC_DNA);
    // Create Sequence for gRNA_b coding sequence
    String gRNA_b_elements = "AAGGTCGGGCAGGAAGAGGGCCTATTTCCCATGATTCCTTCATAT" + "TTGCATATACGATACAAGGCTGTTAGAGAGATAATTAGAATTAAT" + "TTGACTGTAAACACAAAGATATTAGTACAAAATACGTGACGTAGA" + "AAGTAATAATTTCTTGGGTAGTTTGCAGTTTTAAAATTATGTTTT" + "AAAATGGACTATCATATGCTTACCGTAACTTGAAAGTATTTCGAT" + "TTCTTGGCTTTATATATCTTGTGGAAAGGACGAAACACCGTACCT" + "CATCAGGAACATGTGTTTAAGAGCTATGCTGGAAACAGCAGAAAT" + "AGCAAGTTTAAATAAGGCTAGTCCGTTATCAACTTGAAAAAGTGG" + "CACCGAGTCGGTGCTTTTTTT";
    doc.createSequence("gRNA_b_seq", version, gRNA_b_elements, Sequence.IUPAC_DNA);
    // Create Sequence for mKate
    String mKate_seq_elements = "TCTAAGGGCGAAGAGCTGATTAAGGAGAACATGCACATGAAGCTG" + "TACATGGAGGGCACCGTGAACAACCACCACTTCAAGTGCACATCC" + "GAGGGCGAAGGCAAGCCCTACGAGGGCACCCAGACCATGAGAATC" + "AAGGTGGTCGAGGGCGGCCCTCTCCCCTTCGCCTTCGACATCCTG" + "GCTACCAGCTTCATGTACGGCAGCAAAACCTTCATCAACCACACC" + "CAGGGCATCCCCGACTTCTTTAAGCAGTCCTTCCCTGAGGTAAGT" + "GGTCCTACCTCATCAGGAACATGTGTTTTAGAGCTAGAAATAGCA" + "AGTTAAAATAAGGCTAGTCCGTTATCAACTTGAAAAAGTGGCACC" + "GAGTCGGTGCTACTAACTCTCGAGTCTTCTTTTTTTTTTTCACAG" + "GGCTTCACATGGGAGAGAGTCACCACATACGAAGACGGGGGCGTG" + "CTGACCGCTACCCAGGACACCAGCCTCCAGGACGGCTGCCTCATC" + "TACAACGTCAAGATCAGAGGGGTGAACTTCCCATCCAACGGCCCT" + "GTGATGCAGAAGAAAACACTCGGCTGGGAGGCCTCCACCGAGATG" + "CTGTACCCCGCTGACGGCGGCCTGGAAGGCAGAAGCGACATGGCC" + "CTGAAGCTCGTGGGCGGGGGCCACCTGATCTGCAACTTGAAGACC" + "ACATACAGATCCAAGAAACCCGCTAAGAACCTCAAGATGCCCGGC" + "GTCTACTATGTGGACAGAAGACTGGAAAGAATCAAGGAGGCCGAC" + "AAAGAGACCTACGTCGAGCAGCACGAGGTGGCTGTGGCCAGATAC" + "TGCG";
    doc.createSequence("mKate_seq", version, mKate_seq_elements, Sequence.IUPAC_DNA);
    // Create Sequence for CRP_b promoter
    String CRP_b_seq_elements = "GCTCCGAATTTCTCGACAGATCTCATGTGATTACGCCAAGCTACG" + "GGCGGAGTACTGTCCTCCGAGCGGAGTACTGTCCTCCGAGCGGAG" + "TACTGTCCTCCGAGCGGAGTACTGTCCTCCGAGCGGAGTTCTGTC" + "CTCCGAGCGGAGACTCTAGATACCTCATCAGGAACATGTTGGAAT" + "TCTAGGCGTGTACGGTGGGAGGCCTATATAAGCAGAGCTCGTTTA" + "GTGAACCGTCAGATCGCCTCGAGTACCTCATCAGGAACATGTTGG" + "ATCCAATTCGACC";
    doc.createSequence("CRP_b_seq", version, CRP_b_seq_elements, Sequence.IUPAC_DNA);
    // Create ComponentDefinition for a Constitutive Promoter
    doc.createComponentDefinition("pConst", version, ComponentDefinition.DNA).addRole(SequenceOntology.PROMOTER);
    // Create ComponentDefinition for cas9m_BFP coding sequence
    doc.createComponentDefinition("cas9m_BFP_cds", version, ComponentDefinition.DNA).addRole(SequenceOntology.CDS);
    // Create ComponentDefinition for cas9m_BFP gene
    ComponentDefinition cas9m_BFP_gene = doc.createComponentDefinition("cas9m_BFP_gene", version, ComponentDefinition.DNA);
    cas9m_BFP_gene.addRole(SequenceOntology.PROMOTER);
    cas9m_BFP_gene.createSequenceConstraint("cas9m_BFP_gene_constraint", RestrictionType.PRECEDES, "pConst", "cas9m_BFP_cds");
    // Create ComponentDefintion for cas9m_BFP protein
    doc.createComponentDefinition("cas9m_BFP", version, ComponentDefinition.PROTEIN);
    // Create ComponentDefintion for CRa_U6 promoter
    ComponentDefinition CRa_U6 = doc.createComponentDefinition("CRa_U6", version, ComponentDefinition.DNA);
    CRa_U6.addRole(SequenceOntology.PROMOTER);
    CRa_U6.addSequence("CRa_U6_seq");
    // Create ComponentDefintion for gRNA_b coding sequence
    ComponentDefinition gRNA_b_nc = doc.createComponentDefinition("gRNA_b_nc", version, ComponentDefinition.DNA);
    gRNA_b_nc.addRole(SequenceOntology.CDS);
    gRNA_b_nc.addSequence("gRNA_b_seq");
    // Create ComponentDefinition for gRNA_b terminator
    doc.createComponentDefinition("gRNA_b_terminator", version, ComponentDefinition.DNA).addRole(SequenceOntology.TERMINATOR);
    // Create ComponentDefinition for gRNA_b gene
    ComponentDefinition gRNA_b_gene = doc.createComponentDefinition("gRNA_b_gene", version, ComponentDefinition.DNA);
    gRNA_b_gene.addRole(SequenceOntology.PROMOTER);
    gRNA_b_gene.createSequenceConstraint("gRNA_b_gene_constraint1", RestrictionType.PRECEDES, "CRa_U6", "gRNA_b_nc");
    gRNA_b_gene.createSequenceConstraint("gRNA_b_gene_constraint2", RestrictionType.PRECEDES, "gRNA_b_nc", "gRNA_b_terminator");
    // Create ComponentDefinition for gRNA_b RNA
    doc.createComponentDefinition("gRNA_b", version, ComponentDefinition.RNA).addRole(SequenceOntology.SGRNA);
    SequenceOntology so = new SequenceOntology();
    URI sgrna = so.getURIbyName("sgRNA");
    // Create ComponentDefinition for cas9m_BFP gRNA_b complex
    doc.createComponentDefinition("cas9m_BFP_gRNA_b", version, ComponentDefinition.COMPLEX);
    // Create ComponentDefinition for mKate coding sequence
    ComponentDefinition mKate_cds = doc.createComponentDefinition("mKate_cds", version, ComponentDefinition.DNA);
    mKate_cds.addRole(SequenceOntology.CDS);
    mKate_cds.addSequence("mKate_seq");
    // Create ComponentDefinition for mKate gene
    ComponentDefinition mKate_gene = doc.createComponentDefinition("mKate_gene", version, ComponentDefinition.DNA);
    mKate_gene.addRole(SequenceOntology.PROMOTER);
    mKate_gene.createSequenceConstraint("mKate_gene_constraint", RestrictionType.PRECEDES, "pConst", "mKate_cds");
    // Create ComponentDefinition for mKate protein
    doc.createComponentDefinition("mKate", version, ComponentDefinition.PROTEIN);
    // Create ComponentDefinition for Gal4VP16 coding sequence
    ComponentDefinition Gal4VP16_cds = doc.createComponentDefinition("Gal4VP16_cds", version, ComponentDefinition.DNA);
    Gal4VP16_cds.addRole(SequenceOntology.CDS);
    // Create ComponentDefintion for Gal4VP16 gene
    ComponentDefinition Gal4VP16_gene = doc.createComponentDefinition("Gal4VP16_gene", version, ComponentDefinition.DNA);
    Gal4VP16_gene.addRole(SequenceOntology.PROMOTER);
    Gal4VP16_gene.createSequenceConstraint("GAL4VP16_gene_constraint", RestrictionType.PRECEDES, "pConst", "Gal4VP16_cds");
    // Create ComponentDefintion for Gal4VP16 protein
    doc.createComponentDefinition("Gal4VP16", version, ComponentDefinition.PROTEIN);
    // Create ComponentDefinition for CRP_b promoter
    ComponentDefinition CRP_b = doc.createComponentDefinition("CRP_b", version, ComponentDefinition.DNA);
    CRP_b.addRole(SequenceOntology.PROMOTER);
    CRP_b.addSequence("CRP_b_seq");
    // Create ComponentDefintiion for EYFP coding sequence
    ComponentDefinition EYFP_cds = doc.createComponentDefinition("EYFP_cds", version, ComponentDefinition.DNA);
    EYFP_cds.addRole(SequenceOntology.CDS);
    // Create ComponentDefinition for EYFP gene
    ComponentDefinition EYFP_gene = doc.createComponentDefinition("EYFP_gene", version, ComponentDefinition.DNA);
    EYFP_gene.addRole(SequenceOntology.PROMOTER);
    EYFP_gene.createSequenceConstraint("EYFP_gene_constraint", RestrictionType.PRECEDES, "CRP_b", "EYFP_cds");
    // Create ComponentDefintiion for EYFP protein
    doc.createComponentDefinition("EYFP", version, ComponentDefinition.PROTEIN);
    // Create ModuleDefintion for CRISPR Repression
    ModuleDefinition CRPb_circuit = doc.createModuleDefinition("CRPb_characterization_circuit", version);
    // Create the FunctionalComponents for the ModuleDefinition CRISPR_Repression
    CRPb_circuit.createFunctionalComponent("cas9m_BFP", AccessType.PRIVATE, "cas9m_BFP", version, DirectionType.NONE);
    CRPb_circuit.createFunctionalComponent("cas9m_BFP_gene", AccessType.PRIVATE, "cas9m_BFP_gene", version, DirectionType.NONE);
    CRPb_circuit.createFunctionalComponent("gRNA_b", AccessType.PRIVATE, "gRNA_b", version, DirectionType.NONE);
    CRPb_circuit.createFunctionalComponent("gRNA_b_gene", AccessType.PRIVATE, "gRNA_b_gene", version, DirectionType.NONE);
    CRPb_circuit.createFunctionalComponent("mKate", AccessType.PRIVATE, "mKate", version, DirectionType.NONE);
    CRPb_circuit.createFunctionalComponent("mKate_gene", AccessType.PRIVATE, "mKate_gene", version, DirectionType.NONE);
    CRPb_circuit.createFunctionalComponent("Gal4VP16", AccessType.PRIVATE, "Gal4VP16", version, DirectionType.NONE);
    CRPb_circuit.createFunctionalComponent("Gal4VP16_gene", AccessType.PRIVATE, "Gal4VP16_gene", version, DirectionType.NONE);
    CRPb_circuit.createFunctionalComponent("EYFP", AccessType.PRIVATE, "EYFP", version, DirectionType.NONE);
    CRPb_circuit.createFunctionalComponent("EYFP_gene", AccessType.PRIVATE, "EYFP_gene", version, DirectionType.NONE);
    CRPb_circuit.createFunctionalComponent("cas9m_BFP_gRNA_b", AccessType.PRIVATE, "cas9m_BFP_gRNA_b", version, DirectionType.NONE);
    /* Production of mKate from the mKate gene */
    Interaction mKate_production = CRPb_circuit.createInteraction("mKate_production", SystemsBiologyOntology.GENETIC_PRODUCTION);
    mKate_production.createParticipation("mKate", "mKate", SystemsBiologyOntology.PRODUCT);
    mKate_production.createParticipation("mKate_gene", "mKate_gene", SystemsBiologyOntology.PROMOTER);
    // Production of GAL4VP16 from the GAL4VP16 gene
    Interaction GAL4VP16_production = CRPb_circuit.createInteraction("Gal4VP16_production", SystemsBiologyOntology.GENETIC_PRODUCTION);
    GAL4VP16_production.createParticipation("Gal4VP16_gene", "Gal4VP16_gene", SystemsBiologyOntology.PROMOTER);
    GAL4VP16_production.createParticipation("Gal4VP16", "Gal4VP16", SystemsBiologyOntology.PRODUCT);
    // Production of cas9m_BFP from the cas9m_BFP gene
    Interaction cas9m_BFP_production = CRPb_circuit.createInteraction("cas9m_BFP_production", SystemsBiologyOntology.GENETIC_PRODUCTION);
    cas9m_BFP_production.createParticipation("cas9m_BFP_gene", "cas9m_BFP_gene", SystemsBiologyOntology.PROMOTER);
    cas9m_BFP_production.createParticipation("cas9m_BFP", "cas9m_BFP", SystemsBiologyOntology.PRODUCT);
    // Production of gRNA_b from the gRNA_b gene
    Interaction gRNA_b_production = CRPb_circuit.createInteraction("gRNA_b_production", SystemsBiologyOntology.GENETIC_PRODUCTION);
    gRNA_b_production.createParticipation("gRNA_b_gene", "gRNA_b_gene", SystemsBiologyOntology.PROMOTER);
    gRNA_b_production.createParticipation("gRNA_b", "gRNA_b", SystemsBiologyOntology.PRODUCT);
    // Activation of EYFP production by GAL4VP16
    Interaction EYFP_Activation = CRPb_circuit.createInteraction("EYFP_Activation", SystemsBiologyOntology.STIMULATION);
    EYFP_Activation.createParticipation("Gal4VP16", "Gal4VP16", SystemsBiologyOntology.STIMULATOR);
    EYFP_Activation.createParticipation("EYFP_gene", "EYFP_gene", SystemsBiologyOntology.PROMOTER);
    // Degradation of mKate
    Interaction mKate_deg = CRPb_circuit.createInteraction("mKate_deg", SystemsBiologyOntology.DEGRADATION);
    mKate_deg.createParticipation("mKate", "mKate", SystemsBiologyOntology.REACTANT);
    // Degradation of GAL4VP16
    Interaction GAL4VP16_deg = CRPb_circuit.createInteraction("Gal4VP16_deg", SystemsBiologyOntology.DEGRADATION);
    GAL4VP16_deg.createParticipation("Gal4VP16", "Gal4VP16", SystemsBiologyOntology.REACTANT);
    // Degradation of cas9m_BFP
    Interaction cas9m_BFP_deg = CRPb_circuit.createInteraction("cas9m_BFP_deg", SystemsBiologyOntology.DEGRADATION);
    cas9m_BFP_deg.createParticipation("cas9m_BFP", "cas9m_BFP", SystemsBiologyOntology.REACTANT);
    // Degradation of gRNA_b
    Interaction gRNA_b_deg = CRPb_circuit.createInteraction("gRNA_b_deg", SystemsBiologyOntology.DEGRADATION);
    gRNA_b_deg.createParticipation("gRNA_b", "gRNA_b", SystemsBiologyOntology.REACTANT);
    // Degradation of EYFP
    Interaction EYFP_deg = CRPb_circuit.createInteraction("EYFP_deg", SystemsBiologyOntology.DEGRADATION);
    EYFP_deg.createParticipation("EYFP", "EYFP", SystemsBiologyOntology.REACTANT);
    // Degradation of cas9m_BFP_gRNA_b
    Interaction cas9m_BFP_gRNA_b_deg = CRPb_circuit.createInteraction("cas9m_BFP_gRNA_b_deg", SystemsBiologyOntology.DEGRADATION);
    cas9m_BFP_gRNA_b_deg.createParticipation("cas9m_BFP_gRNA_b", "cas9m_BFP_gRNA_b", SystemsBiologyOntology.REACTANT);
    // Create Template Module
    Module Template_Module = CRPb_circuit.createModule("CRISPR_Template", "CRISPR_Template", version);
    // Add MapsTos to Template Module
    Template_Module.createMapsTo("cas9m_BFP_map", RefinementType.USELOCAL, "cas9m_BFP", "cas9_generic");
    Template_Module.createMapsTo("gRNA_b_map", RefinementType.USELOCAL, "gRNA_b", "gRNA_generic");
    Template_Module.createMapsTo("cas9m_BFP_gRNA_map", RefinementType.USELOCAL, "cas9m_BFP_gRNA_b", "cas9_gRNA_complex");
    Template_Module.createMapsTo("EYFP_map", RefinementType.USELOCAL, "EYFP", "target");
    Template_Module.createMapsTo("EYFP_gene_map", RefinementType.USELOCAL, "EYFP_gene", "target_gene");
    // try {
    // SBOLWriter.write(doc, "/Users/myers/RepressionModel.rdf");
    // }
    // catch (XMLStreamException | FactoryConfigurationError | CoreIoException e) {
    // e.printStackTrace();
    // }
    // catch (IOException e) {
    // e.printStackTrace();
    // }
    // END of Repression Model construction. Code below uses trivial manipulations to show other major methods in the library.
    ComponentDefinition cas9_generic1 = doc.getComponentDefinition("cas9_generic", version);
    ComponentDefinition cas9_generic2 = doc.getComponentDefinition("cas9_generic", null);
    if (cas9_generic1.equals(cas9_generic2)) {
        System.out.println("Two Cas9 generic protein objects are equal.");
    }
    gRNA_b_gene.getSequenceConstraint("gRNA_b_gene_constraint1");
    CRISPR_Template.setName("C~R*I!S@P#R-based Repression Template");
    if (CRISPR_Template.isSetName()) {
        CRISPR_Template.unsetName();
        CRISPR_Template.setName("CRISPR-based Repression Template");
    }
    CRISPR_Template.setDescription("Authors: S. Kiani, J. Beal, M. Ebrahimkhani, J. Huh, R. Hall, Z. Xie, Y. Li, and R. Weiss" + "Titel: Crispr transcriptional repression devices and layered circuits in mammalian cells" + "Journal: Nature Methods, vol. 11, no. 7, pp. 723–726, 2014.");
    URI gRNA_b_gene_role2 = URI.create("http://identifiers.org/so/SO:0000613");
    gRNA_b_gene.addRole(gRNA_b_gene_role2);
    if (gRNA_b_gene.containsRole(gRNA_b_gene_role2)) {
        gRNA_b_gene.removeRole(gRNA_b_gene_role2);
    }
    gRNA_b_gene.clearRoles();
    if (!gRNA_b_gene.getRoles().isEmpty()) {
        System.out.println("gRNA_b_gene set is not empty.");
    }
    gRNA_b_gene.setRoles(new HashSet<URI>(Arrays.asList(SequenceOntology.PROMOTER)));
    CRP_b.clearSequences();
    CRP_b.addSequence("CRP_b_seq");
    // CRP_b.addSequence(
    // URI.create("http://partsregistry.org/seq/partseq_154")
    // );
    String prURI = "http://partsregistry.org/";
    String prPrefix = "pr";
    doc.addNamespace(URI.create(prURI), prPrefix);
    ComponentDefinition pConst = doc.getComponentDefinition("pConst", version);
    pConst.createAnnotation(new QName(prURI, "experience", prPrefix), URI.create("http://parts.igem.org/Part:BBa_J23119:Experience"));
    String myersLabURI = "http://www.async.ece.utah.edu/";
    String myersLabPrefix = "myersLab";
    doc.addNamespace(URI.create(myersLabURI), myersLabPrefix);
    GenericTopLevel datasheet = doc.createGenericTopLevel("datasheet", "1.1", new QName(myersLabURI, "datasheet", myersLabPrefix));
    datasheet.setName("Datasheet for Custom Parameters");
    datasheet.createAnnotation(new QName(myersLabURI, "characterizationData", myersLabPrefix), URI.create(myersLabURI + "/measurement/BBa_J23119"));
    datasheet.createAnnotation(new QName(myersLabURI, "transcriptionRate", myersLabPrefix), 0.75);
    pConst.createAnnotation(new QName(myersLabURI, "datasheet", myersLabPrefix), datasheet.getIdentity());
    ComponentDefinition pConst_alt = (ComponentDefinition) doc.createCopy(pConst, "pConst_alt");
    // pConst_alt.createAnnotation(
    // new QName(prURI, "", prPrefix),
    // URI.create("http://parts.igem.org/Part:BBa_J23100"));
    Sequence pConst_alt_seq = doc.createSequence("pConst_alt_seq", version, "ttgacggctagctcagtcctaggtacagtgctagc", Sequence.IUPAC_DNA);
    pConst_alt.addSequence(pConst_alt_seq);
    SBOLValidate.validateSBOL(doc, true, true, true);
    if (SBOLValidate.getNumErrors() > 0) {
        for (String error : SBOLValidate.getErrors()) {
            System.out.println(error);
        }
        return;
    }
    SBOLWriter.write(doc, (System.out));
    SBOLWriter.write(doc, "RepressionModel.rdf");
}
Also used : SequenceOntology(org.sbolstandard.core2.SequenceOntology) ModuleDefinition(org.sbolstandard.core2.ModuleDefinition) Interaction(org.sbolstandard.core2.Interaction) QName(javax.xml.namespace.QName) SBOLDocument(org.sbolstandard.core2.SBOLDocument) GenericTopLevel(org.sbolstandard.core2.GenericTopLevel) Sequence(org.sbolstandard.core2.Sequence) Module(org.sbolstandard.core2.Module) URI(java.net.URI) ComponentDefinition(org.sbolstandard.core2.ComponentDefinition)

Example 4 with ModuleDefinition

use of org.sbolstandard.core2.ModuleDefinition in project libSBOLj by SynBioDex.

the class SBOLReader method parseModuleDefinition.

/**
 * @param SBOLDoc
 * @param topLevel
 * @param nested
 * @return
 *
 * @throws SBOLValidationException if either of the following conditions is satisfied:
 * <ul>
 * <li>any of the following SBOL validation rules was violated:
 * 10202, 10203, 10204, 10206, 10208, 10212, 10213, 11602, 11607 or</li>
 * <li>an SBOL validation rule violation occurred in the following constructor or methods:
 * 	<ul>
 * 		<li>{@link #parseModule(NestedDocument, Map)},</li>
 * 		<li>{@link #parseInteraction(NestedDocument, Map)},</li>
 * 		<li>{@link #parseFunctionalComponent(NestedDocument, Map)},</li>
 * 		<li>{@link ModuleDefinition#ModuleDefinition(URI)}, </li>
 * 		<li>{@link ModuleDefinition#setDisplayId(String)}, </li>
 * 		<li>{@link ModuleDefinition#setVersion(String)}, </li>
 * 		<li>{@link ModuleDefinition#setFunctionalComponents(Set)}, </li>
 * 		<li>{@link ModuleDefinition#setInteractions(Set)}, </li>
 * 		<li>{@link ModuleDefinition#setModels(Set)}, </li>
 * 		<li>{@link ModuleDefinition#setModules(Set)}, </li>
 * 		<li>{@link ModuleDefinition#setWasDerivedFrom(URI)}, </li>
 * 		<li>{@link ModuleDefinition#setAnnotations(List)}, or</li>
 * 		<li>{@link SBOLDocument#addModuleDefinition(ModuleDefinition)}.</li>
 * 	</ul>
 * </li>
 * </ul>
 */
@SuppressWarnings("unchecked")
private static ModuleDefinition parseModuleDefinition(SBOLDocument SBOLDoc, IdentifiableDocument<QName> topLevel, Map<URI, NestedDocument<QName>> nested) throws SBOLValidationException {
    // URIcompliance.extractDisplayId(topLevel.getIdentity());
    String displayId = null;
    String name = null;
    String description = null;
    // URI.create(URIcompliance.extractPersistentId(topLevel.getIdentity()));
    URI persistentIdentity = null;
    String version = null;
    Set<URI> wasDerivedFroms = new HashSet<>();
    Set<URI> wasGeneratedBys = new HashSet<>();
    Set<URI> attachments = new HashSet<>();
    Set<URI> roles = new HashSet<>();
    Set<URI> models = new HashSet<>();
    Set<FunctionalComponent> functionalComponents = new HashSet<>();
    Set<Interaction> interactions = new HashSet<>();
    Set<Module> subModules = new HashSet<>();
    List<Annotation> annotations = new ArrayList<>();
    for (NamedProperty<QName> namedProperty : topLevel.getProperties()) {
        if (namedProperty.getName().equals(Sbol2Terms.Identified.persistentIdentity)) {
            if (!(namedProperty.getValue() instanceof Literal) || persistentIdentity != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI))) {
                throw new SBOLValidationException("sbol-10203", topLevel.getIdentity());
            }
            persistentIdentity = URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString());
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.version)) {
            if (!(namedProperty.getValue() instanceof Literal) || version != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
                throw new SBOLValidationException("sbol-10206", topLevel.getIdentity());
            }
            version = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.displayId)) {
            if (!(namedProperty.getValue() instanceof Literal) || displayId != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
                throw new SBOLValidationException("sbol-10204", topLevel.getIdentity());
            }
            displayId = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
        } else if (namedProperty.getName().equals(Sbol2Terms.ModuleDefinition.roles)) {
            if (!(namedProperty.getValue() instanceof Literal) || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI))) {
                throw new SBOLValidationException("sbol-11602", topLevel.getIdentity());
            }
            roles.add(URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString()));
        } else if (namedProperty.getName().equals(Sbol2Terms.ModuleDefinition.hasModule) || namedProperty.getName().equals(Sbol2Terms.ModuleDefinition.hasSubModule)) {
            if (namedProperty.getValue() instanceof NestedDocument) {
                NestedDocument<QName> nestedDocument = ((NestedDocument<QName>) namedProperty.getValue());
                if (nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.Module.Module)) {
                    throw new SBOLValidationException("sbol-11604", topLevel.getIdentity());
                }
                subModules.add(parseModule(SBOLDoc, ((NestedDocument<QName>) namedProperty.getValue()), nested));
            } else {
                URI uri = (URI) ((Literal<QName>) namedProperty.getValue()).getValue();
                NestedDocument<QName> nestedDocument = nested.get(uri);
                if (nestedDocument == null || nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.Module.Module)) {
                    throw new SBOLValidationException("sbol-11604", topLevel.getIdentity());
                }
                subModules.add(parseModule(SBOLDoc, nested.get(uri), nested));
            }
        } else if (namedProperty.getName().equals(Sbol2Terms.ModuleDefinition.hasInteractions)) {
            if (namedProperty.getValue() instanceof NestedDocument) {
                NestedDocument<QName> nestedDocument = ((NestedDocument<QName>) namedProperty.getValue());
                if (nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.Interaction.Interaction)) {
                    throw new SBOLValidationException("sbol-11605", topLevel.getIdentity());
                }
                interactions.add(parseInteraction((NestedDocument<QName>) namedProperty.getValue(), nested));
            } else {
                URI uri = (URI) ((Literal<QName>) namedProperty.getValue()).getValue();
                NestedDocument<QName> nestedDocument = nested.get(uri);
                if (nestedDocument == null || nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.Interaction.Interaction)) {
                    throw new SBOLValidationException("sbol-11605", topLevel.getIdentity());
                }
                interactions.add(parseInteraction(nested.get(uri), nested));
            }
        } else if (namedProperty.getName().equals(Sbol2Terms.ModuleDefinition.hasfunctionalComponent) || namedProperty.getName().equals(Sbol2Terms.ComponentDefinition.hasComponent)) {
            if (namedProperty.getValue() instanceof NestedDocument) {
                NestedDocument<QName> nestedDocument = ((NestedDocument<QName>) namedProperty.getValue());
                if (nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.FunctionalComponent.FunctionalComponent)) {
                    throw new SBOLValidationException("sbol-11606", topLevel.getIdentity());
                }
                functionalComponents.add(parseFunctionalComponent(SBOLDoc, (NestedDocument<QName>) namedProperty.getValue(), nested));
            } else {
                URI uri = (URI) ((Literal<QName>) namedProperty.getValue()).getValue();
                NestedDocument<QName> nestedDocument = nested.get(uri);
                if (nestedDocument == null || nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.FunctionalComponent.FunctionalComponent)) {
                    throw new SBOLValidationException("sbol-11606", topLevel.getIdentity());
                }
                functionalComponents.add(parseFunctionalComponent(SBOLDoc, nested.get(uri), nested));
            }
        } else if (namedProperty.getName().equals(Sbol2Terms.ModuleDefinition.hasModels)) {
            if (namedProperty.getValue() instanceof Literal) {
                if (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI)) {
                    throw new SBOLValidationException("sbol-11607", topLevel.getIdentity());
                }
                models.add(URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString()));
            } else if (namedProperty.getValue() instanceof IdentifiableDocument) {
                if (((IdentifiableDocument<QName>) namedProperty).getType().equals(Sbol2Terms.Model.Model)) {
                    Model model = parseModel(SBOLDoc, (IdentifiableDocument<QName>) namedProperty.getValue());
                    models.add(model.getIdentity());
                } else {
                    throw new SBOLValidationException("sbol-11607", topLevel.getIdentity());
                }
            } else {
                throw new SBOLValidationException("sbol-11607", topLevel.getIdentity());
            }
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.title)) {
            if (!(namedProperty.getValue() instanceof Literal) || name != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
                throw new SBOLValidationException("sbol-10212", topLevel.getIdentity());
            }
            name = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.description)) {
            if (!(namedProperty.getValue() instanceof Literal) || description != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
                throw new SBOLValidationException("sbol-10213", topLevel.getIdentity());
            }
            description = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.wasDerivedFrom)) {
            if (!(namedProperty.getValue() instanceof Literal) || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI))) {
                throw new SBOLValidationException("sbol-10208", topLevel.getIdentity());
            }
            wasDerivedFroms.add(URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString()));
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.wasGeneratedBy)) {
            if (!(namedProperty.getValue() instanceof Literal) || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI))) {
                throw new SBOLValidationException("sbol-10221", topLevel.getIdentity());
            }
            wasGeneratedBys.add(URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString()));
        } else if (namedProperty.getName().equals(Sbol2Terms.TopLevel.hasAttachment)) {
            if (namedProperty.getValue() instanceof Literal) {
                if (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI)) {
                    throw new SBOLValidationException("sbol-XXXXX", topLevel.getIdentity());
                }
                attachments.add(URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString()));
            } else if (namedProperty.getValue() instanceof IdentifiableDocument) {
                if (((IdentifiableDocument<QName>) namedProperty).getType().equals(Sbol2Terms.Attachment.Attachment)) {
                    Attachment attachment = parseAttachment(SBOLDoc, (IdentifiableDocument<QName>) namedProperty.getValue());
                    attachments.add(attachment.getIdentity());
                } else {
                    throw new SBOLValidationException("sbol-XXXXX", topLevel.getIdentity());
                }
            } else {
                throw new SBOLValidationException("sbol-XXXXX", topLevel.getIdentity());
            }
        } else {
            annotations.add(new Annotation(namedProperty));
        }
    }
    // ModuleDefinition moduleDefinition = SBOLDoc.createModuleDefinition(topLevel.getIdentity());
    ModuleDefinition moduleDefinition = new ModuleDefinition(topLevel.getIdentity());
    if (!roles.isEmpty())
        moduleDefinition.setRoles(roles);
    if (persistentIdentity != null)
        moduleDefinition.setPersistentIdentity(persistentIdentity);
    if (version != null)
        moduleDefinition.setVersion(version);
    if (displayId != null)
        moduleDefinition.setDisplayId(displayId);
    if (!functionalComponents.isEmpty())
        moduleDefinition.setFunctionalComponents(functionalComponents);
    if (!interactions.isEmpty())
        moduleDefinition.setInteractions(interactions);
    if (!models.isEmpty())
        moduleDefinition.setModels(models);
    if (!subModules.isEmpty())
        moduleDefinition.setModules(subModules);
    if (name != null)
        moduleDefinition.setName(name);
    if (description != null)
        moduleDefinition.setDescription(description);
    moduleDefinition.setWasDerivedFroms(wasDerivedFroms);
    moduleDefinition.setWasGeneratedBys(wasGeneratedBys);
    moduleDefinition.setAttachments(attachments);
    if (!annotations.isEmpty())
        moduleDefinition.setAnnotations(annotations);
    ModuleDefinition oldM = SBOLDoc.getModuleDefinition(topLevel.getIdentity());
    if (oldM == null) {
        SBOLDoc.addModuleDefinition(moduleDefinition);
    } else {
        if (!moduleDefinition.equals(oldM)) {
            throw new SBOLValidationException("sbol-10202", moduleDefinition);
        }
    }
    return moduleDefinition;
}
Also used : StringifyQName(org.sbolstandard.core.io.json.StringifyQName) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI) URI(java.net.URI) NestedDocument(org.sbolstandard.core.datatree.NestedDocument) IdentifiableDocument(org.sbolstandard.core.datatree.IdentifiableDocument) Literal(org.sbolstandard.core.datatree.Literal) HashSet(java.util.HashSet)

Example 5 with ModuleDefinition

use of org.sbolstandard.core2.ModuleDefinition in project libSBOLj by SynBioDex.

the class SBOLReader method parseImplementation.

/**
 * @param SBOLDoc
 * @param topLevel
 * @param nested
 * @return
 */
@SuppressWarnings("unchecked")
private static Implementation parseImplementation(SBOLDocument SBOLDoc, IdentifiableDocument<QName> topLevel, Map<URI, NestedDocument<QName>> nested) throws SBOLValidationException {
    // URIcompliance.extractDisplayId(topLevel.getIdentity());
    String displayId = null;
    String name = null;
    String description = null;
    // URI.create(URIcompliance.extractPersistentId(topLevel.getIdentity()));
    URI persistentIdentity = null;
    URI built = null;
    String version = null;
    Set<URI> wasDerivedFroms = new HashSet<>();
    Set<URI> wasGeneratedBys = new HashSet<>();
    Set<URI> attachments = new HashSet<>();
    List<Annotation> annotations = new ArrayList<>();
    for (NamedProperty<QName> namedProperty : topLevel.getProperties()) {
        if (namedProperty.getName().equals(Sbol2Terms.Identified.version)) {
            if (!(namedProperty.getValue() instanceof Literal) || version != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
                throw new SBOLValidationException("sbol-10206", topLevel.getIdentity());
            }
            version = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.persistentIdentity)) {
            if (!(namedProperty.getValue() instanceof Literal) || persistentIdentity != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI))) {
                throw new SBOLValidationException("sbol-10203", topLevel.getIdentity());
            }
            persistentIdentity = URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString());
        } else if (namedProperty.getName().equals(Sbol2Terms.Implementation.built)) {
            if (namedProperty.getValue() instanceof Literal) {
                if (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI)) {
                    throw new SBOLValidationException("sbol-13102", topLevel.getIdentity());
                }
                built = URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString());
            } else if (namedProperty.getValue() instanceof IdentifiableDocument) {
                if (((IdentifiableDocument<QName>) namedProperty).getType().equals(Sbol2Terms.ModuleDefinition.ModuleDefinition)) {
                    ModuleDefinition md = parseModuleDefinition(SBOLDoc, (IdentifiableDocument<QName>) namedProperty.getValue(), nested);
                    built = md.getIdentity();
                } else if (((IdentifiableDocument<QName>) namedProperty).getType().equals(Sbol2Terms.ComponentDefinition.ComponentDefinition)) {
                    ComponentDefinition md = parseComponentDefinition(SBOLDoc, (IdentifiableDocument<QName>) namedProperty.getValue(), nested);
                    built = md.getIdentity();
                } else {
                    throw new SBOLValidationException("sbol-13102", topLevel.getIdentity());
                }
            } else {
                throw new SBOLValidationException("sbol-13102", topLevel.getIdentity());
            }
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.displayId)) {
            if (!(namedProperty.getValue() instanceof Literal) || displayId != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
                throw new SBOLValidationException("sbol-10204", topLevel.getIdentity());
            }
            displayId = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.title)) {
            if (!(namedProperty.getValue() instanceof Literal) || name != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
                throw new SBOLValidationException("sbol-10212", topLevel.getIdentity());
            }
            name = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.description)) {
            if (!(namedProperty.getValue() instanceof Literal) || description != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
                throw new SBOLValidationException("sbol-10213", topLevel.getIdentity());
            }
            description = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.wasDerivedFrom)) {
            if (!(namedProperty.getValue() instanceof Literal) || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI))) {
                throw new SBOLValidationException("sbol-10208", topLevel.getIdentity());
            }
            wasDerivedFroms.add(URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString()));
        } else if (namedProperty.getName().equals(Sbol2Terms.TopLevel.hasAttachment)) {
            if (namedProperty.getValue() instanceof Literal) {
                if (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI)) {
                    throw new SBOLValidationException("sbol-XXXXX", topLevel.getIdentity());
                }
                attachments.add(URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString()));
            } else if (namedProperty.getValue() instanceof IdentifiableDocument) {
                if (((IdentifiableDocument<QName>) namedProperty).getType().equals(Sbol2Terms.Attachment.Attachment)) {
                    Attachment attachment = parseAttachment(SBOLDoc, (IdentifiableDocument<QName>) namedProperty.getValue());
                    attachments.add(attachment.getIdentity());
                } else {
                    throw new SBOLValidationException("sbol-XXXXX", topLevel.getIdentity());
                }
            } else {
                throw new SBOLValidationException("sbol-XXXXX", topLevel.getIdentity());
            }
        } else if (namedProperty.getName().equals(Sbol2Terms.Identified.wasGeneratedBy)) {
            if (!(namedProperty.getValue() instanceof Literal) || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI))) {
                throw new SBOLValidationException("sbol-10221", topLevel.getIdentity());
            }
            wasGeneratedBys.add(URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString()));
        } else {
            annotations.add(new Annotation(namedProperty));
        }
    }
    Implementation i = new Implementation(topLevel.getIdentity());
    if (displayId != null)
        i.setDisplayId(displayId);
    if (persistentIdentity != null)
        i.setPersistentIdentity(persistentIdentity);
    if (name != null)
        i.setName(name);
    if (description != null)
        i.setDescription(description);
    if (!annotations.isEmpty())
        i.setAnnotations(annotations);
    if (version != null)
        i.setVersion(version);
    if (built != null)
        i.setBuilt(built);
    i.setWasDerivedFroms(wasDerivedFroms);
    i.setWasGeneratedBys(wasGeneratedBys);
    i.setAttachments(attachments);
    Implementation oldI = SBOLDoc.getImplementation(topLevel.getIdentity());
    if (oldI == null) {
        SBOLDoc.addImplementation(i);
    } else {
        if (!i.equals(oldI)) {
            throw new SBOLValidationException("sbol-10202", i);
        }
    }
    return i;
}
Also used : StringifyQName(org.sbolstandard.core.io.json.StringifyQName) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI) URI(java.net.URI) IdentifiableDocument(org.sbolstandard.core.datatree.IdentifiableDocument) Literal(org.sbolstandard.core.datatree.Literal) HashSet(java.util.HashSet)

Aggregations

URI (java.net.URI)15 URIcompliance.createCompliantURI (org.sbolstandard.core2.URIcompliance.createCompliantURI)10 ModuleDefinition (org.sbolstandard.core2.ModuleDefinition)8 SBOLDocument (org.sbolstandard.core2.SBOLDocument)7 ArrayList (java.util.ArrayList)4 QName (javax.xml.namespace.QName)4 ComponentDefinition (org.sbolstandard.core2.ComponentDefinition)4 FunctionalComponent (org.sbolstandard.core2.FunctionalComponent)4 Interaction (org.sbolstandard.core2.Interaction)4 HashSet (java.util.HashSet)3 IdentifiableDocument (org.sbolstandard.core.datatree.IdentifiableDocument)3 Literal (org.sbolstandard.core.datatree.Literal)3 StringifyQName (org.sbolstandard.core.io.json.StringifyQName)3 Module (org.sbolstandard.core2.Module)3 Before (org.junit.Before)2 NestedDocument (org.sbolstandard.core.datatree.NestedDocument)2 SequenceOntology (org.sbolstandard.core2.SequenceOntology)2 Test (org.junit.Test)1 CombinatorialDerivation (org.sbolstandard.core2.CombinatorialDerivation)1 GenericTopLevel (org.sbolstandard.core2.GenericTopLevel)1