diff --git a/BIN-Storing_data.R b/BIN-Storing_data.R index 2ac9452..333197b 100644 --- a/BIN-Storing_data.R +++ b/BIN-Storing_data.R @@ -33,7 +33,7 @@ #TOC> ========================================================================== -#TOC> +#TOC> #TOC> Section Title Line #TOC> ----------------------------------------------------------------------- #TOC> 1 A Relational Datamodel in R: review 63 @@ -56,7 +56,7 @@ #TOC> 3.3 Create an R script to create your own database 572 #TOC> 3.3.1 Check and validate 600 #TOC> 3.4 Task: submit for credit (part 2/2) 645 -#TOC> +#TOC> #TOC> ========================================================================== @@ -206,7 +206,7 @@ str(philDB) # go back, re-read, play with it, and ask for help. These are the foundations. -# === 1.1.1 completing the database +# === 1.1.1 completing the database # Next I'll add one more person, and create the other two tables: @@ -293,6 +293,47 @@ for (ID in pID) { # BUT COPY THE EXACT, COMPLETE OUTPUT, PASTE IT INTO YOUR SUBMISSION, # AND FORMAT IT CORRECTLY. +# == Submission - Code to add another philosopher to the datamodel: + +pID <- autoincrement(philDB$person) +immanuelKant <- data.frame(id = pID, + name = "Immanuel Kant", + born = "1724", + died = "1804", + school = "Enlightenment Philosophy") +philDB$person <- rbind(philDB$person, immanuelKant) + +bID = autoincrement(philDB$books) +immanuelKantWork <- data.frame(id = bID, + title = "Critique of Pure Reason", + published = "1781") +philDB$books <- rbind(philDB$books, immanuelKantWork) +philDB$works <- rbind(philDB$works, data.frame(id = autoincrement(philDB$works), personID = pID, bookID = bID)) + +bID = autoincrement(philDB$books) +immanuelKantWork <- data.frame(id = bID, + title = "Critique of Judgement", + published = "1790") +philDB$books <- rbind(philDB$books, immanuelKantWork) +philDB$works <- rbind(philDB$works, data.frame(id = autoincrement(philDB$works), personID = pID, bookID = bID)) + +# == Submission: Code to list the philosophical schools in alphabetical order as well as their respective books in alphabetical order. + +schools <- unique(philDB$person$school) +schools <- sort(schools) + +for (s in schools) { + cat(sprintf("%s\n", s)) + authors = which(philDB$person$school == s) + for (author in authors) { + works = which(philDB$works$personID == author) + for (work in works) { + bookId = which(philDB$books$id == philDB$works$bookID[work]) + cat(sprintf("\t%s - (%s)\n", philDB$books$title[bookId], philDB$books$published[bookId])) + } + } +} + # = 2 Implementing the protein datamodel ================================== @@ -385,7 +426,7 @@ dbSanitizeSequence(x) # == 2.3 Create a protein table for our data model ========================= -# === 2.3.1 Initialize the database +# === 2.3.1 Initialize the database # The function dbInit contains all the code to return a list of empty @@ -397,7 +438,7 @@ myDB <- dbInit() str(myDB) -# === 2.3.2 Add data +# === 2.3.2 Add data # fromJSON() returns a dataframe that we can readily process to add data @@ -444,7 +485,7 @@ source("./scripts/ABC-createRefDB.R") str(myDB) -# === 2.4.1 Examples of navigating the database +# === 2.4.1 Examples of navigating the database # You can look at the contents of the tables in the usual way we access @@ -597,7 +638,7 @@ if (file.exists(sprintf("./myScripts/%staxonomy.json", biCode(MYSPE)))) { # "break" them with a code experiment. But always have a script with # which you can create what you need. -# === 3.3.1 Check and validate +# === 3.3.1 Check and validate # Is your protein named according to the pattern "MBP1_MYSPE"? It should be. diff --git a/.myProfile.R b/myScripts/.myProfile.R similarity index 81% rename from .myProfile.R rename to myScripts/.myProfile.R index d42d608..3e1cebb 100644 --- a/.myProfile.R +++ b/myScripts/.myProfile.R @@ -14,7 +14,8 @@ # ============================================================================== # options(stringsAsFactors = FALSE) -myEMail <- "" # e.g. "u.franklin@utoronto.ca" -myStudentNumber <- # e.g. 1003141592 +myEMail <- "yh.deng@mail.utoronto.ca" # e.g. "u.franklin@utoronto.ca" +myStudentNumber <- 1005845285 # e.g. 1003141592 +MYSPE <- "Cutaneotrichosporon oleaginosum" # [END] diff --git a/myScripts/CUTOLTaxonomy.json b/myScripts/CUTOLTaxonomy.json new file mode 100644 index 0000000..9025c71 --- /dev/null +++ b/myScripts/CUTOLTaxonomy.json @@ -0,0 +1,4 @@ +[{ + "ID": 879819, + "species": "Cutaneotrichosporon oleaginosum"} +] diff --git a/myScripts/MBP1_CUTOL.json b/myScripts/MBP1_CUTOL.json new file mode 100644 index 0000000..04d300b --- /dev/null +++ b/myScripts/MBP1_CUTOL.json @@ -0,0 +1,19 @@ +[ + { "name" : "MBP1_CUTOL", + "RefSeqID" : "XP_018278493.1", + "UniProtID" : "A0A0J0XLN0", + "taxonomyID" : 879819, + "sequence" : [ + "MGKKAAAAGDGGPNTIYKATYSGVPVFEFICRNVAVMRRRSDAYLNATQILKVAGFDKPQRTRVLEREVQ", + "KGEHEKVQGGYGKYQGTWVPIERGLALAKQYNVEDLLRPIIDFVPRESVSPPPAPKHAVAPPTKRNKEPK", + "PKEGLVPIKSAGVLSGTGRHQTPDSVGEDVESEVMDDMSESQTPSPLNGTSLLPAVDERSIDGMDIDGFS", + "MMNGGGHARKRSAAMMDDEDEYEQLKRARGNSAVHTPPPPGQSPRYGGMQHPLTQDEYNDIVLNYFVSEA", + "TQIPAVMTNPPYNWDPNGIIDDDHHTALHWAAAMGRTRVIKLLLSAGARIFDKNNLDQTPLMRSVMFTNN", + "YDLRKFPEVFELLHRSTLNIDKNNRTVFHHIANLALYKGKTHAARYYMEVILSRLADYPQELADVINFAD", + "EDGETALTLAARARSKRIVKALLDHGADPKLRNRDHKSAEDYILEDERFRSSPDVMLNRTQPSAAPRNPT", + "SLGAAVFSQGLPPQLYNSEAARLASGPHSSDILQQMQALARSFEAEKLNKERDVLEAKAMLTSIHTEVND", + "AGRTLHNLGEQMKPLEAKQGELDGLVERLQSKLQKDLARGARKWKAADEGRENRWKNGDDPSQAGEDYSD", + "LPELTAIPDNAEAEEERLRGEIEKMRARRGELVTRLVKAQTQTGTTDKMAQYRRLITAGCGGDINPGEID", + "DIVGQLLDMLENEAQSGRPAPPPQAAPSWVTS"] + } +] diff --git a/myScripts/makeProteinDB.R b/myScripts/makeProteinDB.R new file mode 100644 index 0000000..70a9864 --- /dev/null +++ b/myScripts/makeProteinDB.R @@ -0,0 +1,4 @@ +source("./scripts/ABC-createRefDB.R") + +myDB <- dbAddProtein(myDB, jsonlite::fromJSON("./myScripts/MBP1_CUTOL.json")) +myDB <- dbAddTaxonomy(myDB, jsonlite::fromJSON("./myScripts/CUTOLtaxonomy.json")) diff --git a/myScripts/myScript.R b/myScripts/myScript.R new file mode 100644 index 0000000..f42a47e --- /dev/null +++ b/myScripts/myScript.R @@ -0,0 +1,38 @@ +# myScript.R +# +# --- As you work with this file, you can delete the instructions below -------- +# Write your notes and code experiments into this document. Save it +# from time to time - however I recommend that you do not _commit_ +# your saved version. +# +# As long as you do not _commit_ this script to version control, +# you can _pull_ updated versions of the entire project from GitHub +# by using the RStudio version control interface. However, once +# you _commit_ any file in your local version, RStudio will require +# you to resolve conflicts before you can _pull_ updates. +# --- As you work with this file, you can delete the instructions above -------- +# +## Purpose: <...> +# +# Version: <...> +# +# Date: <...> +# Author: () +# +# Versions: +# +# +# +# TODO: +# <...> +# +# ==================================================================== + + + + + + + +# [END] +