\RequirePackage{color}
%\documentclass[pstcol,pdf,baltica,slideColor,colorBG,gyom]{prosper}
\documentclass[pstcol,pdf,baltica,slideColor,colorBG,thomasd]{prosper}
%\documentclass[pstcol,pdf,baltica,slideColor,colorBG,azure]{prosper}
\usepackage{pstricks,pst-node,pst-text,pst-3d}
\usepackage{graphics}
\usepackage{amsmath, amssymb, amsfonts}
\usepackage{multirow}
\usepackage{slashbox}
\usepackage{fancyheadings}
\usepackage{multicol}
\usepackage{colortbl}

\usepackage{ascmac}
\usepackage{latexsym}
\usepackage{fancybox}
\usepackage[ps2pdf]{hyperref}


%% BibTeX �������
\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
    T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}

%% Bibtex ����ʸ�� to Reference. (�Ѹ�λ��ϲ��Υ����Ȥ򳰤�)
\renewcommand{\refname}{}

%%\renewcommand{\scriptsize}{\@setfontsize\scriptsize{\@vipt}{2\@Q}}
\renewcommand\scriptsize{\@setfontsize\scriptsize\@viiipt{1}}

\renewcommand{\kanjifamilydefault}{gt}
\DefaultTransition{Split}

\newcommand{\bibfont}{\scriptsize}

\title{
\includegraphics[width=2em]{Rlogo.eps}
�ˤ��DDBJ�Υ���������ˡ}
\subtitle{- 2007-06-18 -}
\author{Ei-ji Nakama}
\email{nakama at com-one.com}
\institution{COM-ONE Ltd.}

\usepackage{/usr/share/R/share/texmf/Sweave}
\begin{document}
\bf\mathversion{bold}\maketitle
%%\bibliographystyle{junsrt}
\bibliographystyle{plain}

%% ========================== Sweave setting
%% ��ʬ��
\DefineVerbatimEnvironment{Sinput}{Verbatim}{
  formatcom={\color{black}},
  frame=none
}
\DefineVerbatimEnvironment{Scode}{Verbatim}{
  formatcom={\color{glay}},
  frame=none
}
\DefineVerbatimEnvironment{Soutput}{Verbatim}{
  fontshape=sl,
  formatcom={\color{red}},
  frame=none
}
%% �Եͤ�
\fvset{listparameters={\setlength{\topsep}{0pt}}}


%% ========================= �����start ===================
%% ========================= �����end ===================

\begin{slide}[Wipe]{R��XML}
 \begin{itemize}
  \item R\cite{R}��XML�򰷤��ˤ�XML\cite{XML}�ѥå����������Ѥ��ޤ�.
  \item R��XML\cite{XML}�ѥå�������libxml(\url{http://xmlsoft.org/})��Ȥ��ޤ�.
  \item R��XML��������Ͼ��ʤ��Ǥ���, libxml�������㤬���ͤˤʤ�ޤ�.
  \item XML-1.9.0�ʹߤǤ�encoding�⥵�ݡ��Ȥ��ޤ���.
  \item Omegahat\footnote{\url{http://www.omegahat.org/}}�ˤ���ޤ�����,���ߤ�CRAN�ˤ���Ͽ����Ƥ��ޤ�.
 \end{itemize}
\end{slide}


\begin{slide}[Wipe]{R��XML ��-1}
\scriptsize{
\begin{Schunk}
\begin{Sinput}
> library(XML)
> f <- system.file("exampleData", "mathmlMatrix.xml",
+                  package = "XML")
> doc <- xmlTreeParse(f,useInternalNodes=T)
> # ����������XPATH���Ȥ��ޤ�
> unlist(xpathApply(doc,"//*",xmlName))
\end{Sinput}
\begin{Soutput}
[1] "mrow"  "reln"  "eq"    "apply" "times"
 [ reached getOption("max.print") -- omitted 15 entries ]]
\end{Soutput}
\begin{Sinput}
> sapply(getNodeSet(doc, "/mrow/reln/apply/vector"),
+        saveXML)
\end{Sinput}
\begin{Soutput}
[1] "<vector> <cn> 1 </cn> <cn> 2 </cn>\n          </vector>"
[2] "<vector> <cn> 2 </cn> <cn> 1 </cn>\n          </vector>"
\end{Soutput}
\begin{Sinput}
> free(doc)
\end{Sinput}
\begin{Soutput}
<pointer: (nil)>
attr(,"class")
[1] "XMLInternalDocument"
\end{Soutput}
\end{Schunk}
}
\end{slide}


\begin{slide}[Wipe]{R��XML ��-2}
\scriptsize{
\begin{Schunk}
\begin{Sinput}
> f <- system.file("exampleData", "mathmlMatrix.xml",
+                  package = "XML")
> doc <- xmlTreeParse(f,useInternalNodes=T)
> # XPATH�Ǥ��ͤμ�����
> path <- "/mrow/reln/apply/matrix/matrixrow/cn"
> unlist(xpathApply(doc, path, xmlValue))
\end{Sinput}
\begin{Soutput}
[1] " 0 " " 1 " " 1 " " 0 "
\end{Soutput}
\begin{Sinput}
> free(doc)
\end{Sinput}
\begin{Soutput}
<pointer: (nil)>
attr(,"class")
[1] "XMLInternalDocument"
\end{Soutput}
\end{Schunk}
}
\end{slide}


\begin{slide}[Wipe]{R��XML ��-3}
\scriptsize{
\begin{Schunk}
\begin{Sinput}
> doc<-xmlTreeParse(f,useInternalNodes=T)
> # ����������XML���ᤷ�ޤ�
> sapply(getNodeSet(doc, "/"), saveXML)
\end{Sinput}
\begin{Soutput}
[1] "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE mrow SYSTEM \"mathml.dtd\">\n<mrow>\n<reln> <eq/>\n        <apply><times/>\n          <vector> <cn> 1 </cn> <cn> 2 </cn>\n          </vector>\n\n          <matrix>\n          <matrixrow> <cn> 0 </cn> <cn> 1 </cn> </matrixrow>\n          <matrixrow> <cn> 1 </cn> <cn> 0 </cn> </matrixrow>\n          </matrix>\n        </apply>\n\n        <apply> <transpose/>\n          <vector> <cn> 2 </cn> <cn> 1 </cn>\n          </vector>\n        </apply>\n      </reln>\n</mrow>\n"
\end{Soutput}
\begin{Sinput}
> free(doc)
\end{Sinput}
\begin{Soutput}
<pointer: (nil)>
attr(,"class")
[1] "XMLInternalDocument"
\end{Soutput}
\end{Schunk}
}
\end{slide}


\begin{slide}[Wipe]{R��XML ��-4}
\scriptsize{
\begin{Schunk}
\begin{Sinput}
> doc <- xmlTreeParse(system.file("exampleData", "mtcars.xml",
+                                 package="XML"))
> # ���������Ǥ�̵�����
> names(xmlRoot(doc))
\end{Sinput}
\begin{Soutput}
[1] "variables" "record"    "record"    "record"   
[5] "record"   
 [ reached getOption("max.print") -- omitted 28 entries ]]
\end{Soutput}
\begin{Sinput}
> r <- xmlRoot(doc)
> r[names(r) == "variables"]
\end{Sinput}
\begin{Soutput}
$variables
<variables count="11">
 <variable unit="Miles/gallon">mpg</variable>
 <variable>cyl</variable>
 <variable>disp</variable>
 <variable>hp</variable>
 <variable>drat</variable>
 <variable>wt</variable>
 <variable>qsec</variable>
 <variable>vs</variable>
 <variable type="FactorVariable" levels="automatic,manual">am</variable>
 <variable>gear</variable>
 <variable>carb</variable>
</variables>
\end{Soutput}
\end{Schunk}
}
\end{slide}


\begin{slide}[Wipe]{R��HTTP}
 \begin{itemize}
  \item R��RCurl\cite{RCurl}�ѥå�������libcurl(\url{http://curl.haxx.se/})��Ȥ��ޤ�.
  \item RCurl\cite{RCurl}��ɸ���socket�⥸�塼�뤬�б����Ƥ��ʤ�SSL���ⰷ���ޤ�.
  \item XML\cite{XML}��SSOAP\cite{SSOAP}��Ϣ�Ȥ��ƹ��٤�HTTP�̿���Ԥ��ޤ�.
  \item RCurl\cite{RCurl}��Omegahat����,BioConductor\cite{Biobase}��Extra�˶��뤵��Ƥ��ޤ�.
 \end{itemize}
\end{slide}

\begin{slide}[Wipe]{R��HTTP PROXY����}
R��PROXY�����ꤹ����ϥ⥸�塼������б���ɬ�פǤ�.
\includegraphics{RdeDDBJ2-proxyoverview}
\\
�㤨�С�http\_proxy=http://prs.ism.ac.jp:3128/
\end{slide}


\begin{slide}[Wipe]{R��SOAP}
 \begin{itemize}
  \item R\cite{R}��SOAP�򰷤��ˤ�SSOAP\cite{SSOAP}�ѥå����������Ѥ��ޤ�.
  \item SSOAP\cite{SSOAP}��XML\cite{XML}��RCurl\cite{RCurl}��ɬ�פȤ��ޤ�.
  \item SSOAP\cite{SSOAP}��Omegahat����, BioConductor\cite{Biobase} 
	��Extra�˶��뤵��Ƥ��ޤ�.
 \end{itemize}
\end{slide}


\begin{slide}[Wipe]{R��DDBJ}
 R\cite{R}��DDBJ�˥�����������ˤ�,���ޤǤˤ�����,XML\cite{XML}
 , RCurl\cite{RCurl},SSOAP\cite{SSOAP}��ɬ�פǤ�. \\
DDBJ�Υ��塼�ȥꥢ��\footnote{\url{http://www.xml.nig.ac.jp/tutorial/index_jp.html}}
 \cite{tutorial}
 ����ä�, R�Ǥ�������ޤ���.
\end{slide}


\begin{slide}[Wipe]{R��DDBJ - ����ȥ꡼�μ���1}
\scriptsize{
\begin{Schunk}
\begin{Sinput}
> # 1. SSOAP �Υ�����
> library(SSOAP)
> # 2. WSDL�λ���
> url <- "http://xml.nig.ac.jp/wsdl/GetEntry.wsdl"
> GetEntry <- processWSDL (url)
> iface <- genSOAPClientInterface(def = GetEntry)
> # 3. WEB�����ӥ��θƤӽФ�
> result<-iface@functions$getXML_DDBJEntry("AB000003")
> # 4. ���Ū�ʳ�ǧ
> xmlRoot(xmlTreeParse(result))
\end{Sinput}
\begin{Soutput}
<DDBJXML>
 <LOCUS>AB000003</LOCUS>
 <LENGTH>641</LENGTH>
 <MOLECULAR_FORM>linear</MOLECULAR_FORM>
 <DIVISION>PLN</DIVISION>
 <LAST_UPDATE>12-SEP-2002</LAST_UPDATE>
 <DEFINITION>Rhizoctonia solani genes for 18S rRNA, 5.8S rRNA, 28S rRNA,partial and complete sequence, isolate:1556.</DEFINITION>
 <ACCESSION>AB000003</ACCESSION>
 <VERSION>AB000003.1</VERSION>
 <KEYWORDS>.</KEYWORDS>
 <SOURCE>Rhizoctonia solani</SOURCE>
 <ORGANISM>Thanatephorus cucumeris</ORGANISM>
 <TAXONOMY>Eukaryota; Fungi; Basidiomycota; Hymenomycetes;Heterobasidiomycetes; Heterobasidiomycetidae; Ceratobasidiales;Ceratobasidiaceae; Thanatephorus.</TAXONOMY>
 <REFERENCE ID="1">
  <authors>Kuninaga,S.</authors>
  <title>Direct Submission</title>
  <journal>Submitted (19-DEC-1996) to the DDBJ/EMBL/GenBank databases. ShiroKuninaga, Health Sciences University of Hokkaido, GeneralEducation; 1757 Kanazawa, Tohbetsu, Hokkaido 061-02, Japan(E-mail:kuninaga@hoku-iryo-u.ac.jp, Tel:81-1332-3-1211,Fax:81-1332-3-1276)</journal>
 </REFERENCE>
 <REFERENCE ID="2">
  <authors>Kuninaga,S., Natsuaki,T. and Takeuchi,T.</authors>
  <title>Sequence variation of the rDNA ITS regions within and betweenanastomosis groups in Rhizoctonia solani</title>
  <journal>Curr. Genet. 32, 237-243 (1997)</journal>
 </REFERENCE>
 <FEATURES>
  <source>
   <location>1..641</location>
   <qualifiers name="isolate">1556</qualifiers>
   <qualifiers name="mol_type">genomic DNA</qualifiers>
   <qualifiers name="organism">Rhizoctonia solani</qualifiers>
   <qualifiers name="strain">AG-7</qualifiers>
  </source>
  <rrna>
   <location>&lt;1..5</location>
   <qualifiers name="product">18S rRNA</qualifiers>
  </rrna>
  <rrna>
   <location>208..362</location>
   <qualifiers name="product">5.8S rRNA</qualifiers>
  </rrna>
  <rrna>
   <location>637..&gt;641</location>
   <qualifiers name="product">28S rRNA</qualifiers>
  </rrna>
 </FEATURES>
 <BASE_COUNT A="        169 " C="        136 " G="        128 " T="        208 "/>
 <SEQUENCE>aattaaatgtggagttggttgtagctggccttgattcattttctaggcatgtgcacaccttctctttcatccacacacacctgtgcacctgtgagacagttagggtgggaggactttattggactctctccctctctgtctactcaatttttacacaaactcaatttactttaaaatgaatgtcattgatgtaacgcatctaatactaagtttcaacaacggatctcttggctctcgcatcgatgaagaacgcagcgaaatgcgataagtaatgtgaattgcagaattcagtgaatcatcgaatctttgaacgcaccttgcgctccttggtattccttggagcatgcctgtttgagtatcatgaaatcttcaaagtgaaatcttttgttaattcaatcggttctactttggtatttggaggtcttttgcagcttcacacctgctcctctttgtgcattagctggatctcagtgttatgcttggttccactcagcgtgataagttatctatcgctgaggacactgtaaaaaggtggccaaggtaaatacagatgaaccgcttctaatagtccattgacttggacaaatccatttatgatctgatctcaaatcaggtaggactacccgctgaacttaagcata</SEQUENCE>
</DDBJXML>
\end{Soutput}
\end{Schunk}
}
\end{slide}


\begin{slide}[Wipe]{R��DDBJ - ����ȥ꡼�μ���2}
\scriptsize{
\begin{Schunk}
\begin{Sinput}
> # �������Ǥ�1-2�ϼ¹ԺѤ�
> # 3. �������å�����ֹ�AB000002-AB000005����٤μ¹ԤǼ���
> acsession <- c("AB000002","AB000003","AB000004","AB000005")
> # 4. WEB�����ӥ��θƤӽФ�
> result <- sapply(acsession,
+                  iface@functions$getFASTA_DDBJEntry)
> # 5. ���Ū�ʳ�ǧ
> print(result)
\end{Sinput}
\begin{Soutput}
                                                      AB000002 
">AB000002|Rhizoctonia solani genes for 18S rRNA, 5.8S rRNA, " 
                                                      AB000003 
">AB000003|Rhizoctonia solani genes for 18S rRNA, 5.8S rRNA, " 
                                                      AB000004 
">AB000004|Rhizoctonia solani genes for 18S rRNA, 5.8S rRNA, " 
                                                      AB000005 
">AB000005|Rhizoctonia solani genes for 18S rRNA, 5.8S rRNA, " 
\end{Soutput}
\end{Schunk}
}
\end{slide}


\begin{slide}[Wipe]{SRS��GetEntry��BlastϢ��1}
������ɤȤ��� `prion', Human Division, Molecule`mRNA'����ꤷ�ޤ�.
\scriptsize{
\begin{Schunk}
\begin{Sinput}
> # SSOAP �Υ�����
> library(SSOAP)
> # WSDL�λ���
> SRS <- processWSDL("http://xml.nig.ac.jp/wsdl/SRS.wsdl")
> SRSiface<-genSOAPClientInterface(def=SRS)
> # WEB�����ӥ��θƤӽФ� (��� & �� &amp; �ˤ��뤳��)
> result<-SRSiface@functions$searchSimple(
+         "[ddbj-AllText:prion*] &amp;
+          [ddbj-Division:hum]   &amp; [ddbj-Molecule:mrna]")
> print(result)
\end{Sinput}
\begin{Soutput}
[1] "DDBJ:AF187843\nDDBJ:AF187844\nDDBJ:AK090575\nDDBJ:AY008282\nDDBJ"
\end{Soutput}
\end{Schunk}
}
\end{slide}

\begin{slide}[Wipe]{SRS��GetEntry��BlastϢ��2}
���η�̤��饳���ǥ����ΰ�Υ��ߥλ������ȴ���Ф��ޤ�(GetEntry).
\scriptsize{
\begin{Schunk}
\begin{Sinput}
> # ������̤���Ԥ�ʬ�䤷, ����˳�Ǽ
> id <- unlist(strsplit(result,"\n"))
> url <- "http://xml.nig.ac.jp/wsdl/GetEntry.wsdl"
> getentry<-genSOAPClientInterface(def = processWSDL(url))
> # �������å����No(substring��DDBJ:�򥵥ץ쥹)
> # sapply�ǥ������å����No������ˤ���
> # DAD����ȥ꡼��FASTA�����Ǽ���
> result<-sapply(substring(id,6),
+                getentry@functions$getFASTA_DADEntry)
> print(result)
\end{Sinput}
\begin{Soutput}
[1] ">AF187843-1|AAG43448.1|148|Homo sapiens doppel protein\nMRKHL"
[2] ">AF187844-1|AAG43449.1|176|Homo sapiens prion-like protein\nM"
[3] "character(0)"                                                 
[4] ">AY008282-1|AAG21693.1|253|Homo sapiens prion protein\nMANLGC"
[5] ">AY569456-1|AAS80162.1|253|Homo sapiens prion protein\nMANLGC"
 [ reached getOption("max.print") -- omitted 14 entries ]]
\end{Soutput}
\end{Schunk}
}
\end{slide}

\begin{slide}[Wipe]{SRS��GetEntry��BlastϢ��3}
��Ʊ�������ΰ�ĤǤ��� Blastp �� ����о� Swiss-plot �Υǡ����١����˻��ꤷ�Ƽ¹�
\scriptsize{
\begin{Schunk}
\begin{Sinput}
> blastiface<-genSOAPClientInterface(def=processWSDL(
+                    "http://xml.nig.ac.jp/wsdl/Blast.wsdl"))
> # blast�����ӥ���ƤӽФ�
> result<-blastiface@functions$searchParam("blastp",
+                                          "SWISS",
+                                          unlist(result),
+                                          "-m 8")
> print(result)
\end{Sinput}
\begin{Soutput}
[1] "AF187843-1|AAG43448.1|148|Homo\tsp|Q9UKY0|PRND_HUMAN\t99.32\t14"
\end{Soutput}
\end{Schunk}
}
\end{slide}

\begin{slide}[Wipe]{SRS��GetEntry��BlastϢ��4}
���������ǡ�����ù�����
\scriptsize{
\begin{Schunk}
\begin{Sinput}
> # ��̤���ԥ����ɤ�ʬ�䤹��
> blastline<-unlist(strsplit(result,"\n"))
> print(blastline[1:3]) # ¿���Τǻ��Ĥ���ɽ��
\end{Sinput}
\begin{Soutput}
[1] "AF187843-1|AAG43448.1|148|Homo\tsp|Q9UKY0|PRND_HUMAN\t99.32\t14"
[2] "AF187843-1|AAG43448.1|148|Homo\tsp|Q9GJY2|PRND_SHEEP\t77.33\t15"
[3] "AF187843-1|AAG43448.1|148|Homo\tsp|Q9GK16|PRND_BOVIN\t76.67\t15"
\end{Soutput}
\begin{Sinput}
> # ID��ȴ���Ф�
> id <- as.vector(sapply(blastline,function(x){
+   unlist(strsplit(x,"\\|"))[5]
+ }))
> print(id)
\end{Sinput}
\begin{Soutput}
[1] "Q9UKY0" "Q9GJY2" "Q9GK16" "Q9QUG3" "O46501"
 [ reached getOption("max.print") -- omitted 71 entries ]]
\end{Soutput}
\end{Schunk}
}
\end{slide}

\begin{slide}[Wipe]{SRS��GetEntry��BlastϢ��5}
���Υơ�������GetEntry�Ǽ�����, �������å�����ֹ�, �ץ��ƥ���ID, 
Swiss-Prot ID, �ץ��ƥ��󥷥�ܥ�, �ץ��ƥ������� ��ɽ������.

\scriptsize{
\begin{Schunk}
\begin{Sinput}
> # ID����GetUNIPROTEntry����
> entry<-sapply(id, getentry@functions$getUNIPROTEntry)
> # ����򰵽�
> entry<-gsub("\\s{2,}"," ",entry)
> # ���Ԥ�ʬ��
> entry<-strsplit(entry,"\n")
> print(entry)
\end{Sinput}
\begin{Soutput}
[1] "c(\"ID PRND_HUMAN Reviewed; 176 AA.\", \"AC Q9UKY0; Q9H311; Q9H"  
[2] "c(\"ID PRND_SHEEP Reviewed; 178 AA.\", \"AC Q9GJY2; Q9MYU2;\", \""
[3] "c(\"ID PRND_BOVIN Reviewed; 178 AA.\", \"AC Q9GK16; A2VDR5; Q27"  
[4] "c(\"ID PRND_MOUSE Reviewed; 179 AA.\", \"AC Q9QUG3; Q9QZT5;\", \""
[5] "c(\"ID PRIO_CANFA Reviewed; 255 AA.\", \"AC O46501;\", \"DT 15-JU"
 [ reached getOption("max.print") -- omitted 71 entries ]]
\end{Soutput}
\end{Schunk}
}
\end{slide}

\begin{slide}[Wipe]{SRS��GetEntry��BlastϢ��6}
�����ǡ������Խ�
\scriptsize{
\begin{Schunk}
\begin{Sinput}
> # ID���Խ�
> ID<-sapply(entry, function(x)
+         paste(substring(x[grep("^ID",x)],4),collapse=" "))
> # DE���Խ�
> DE<-sapply(entry, function(x)
+          paste(substring(x[grep("^DE",x)],4),collapse=" "))
> ENTRY<-cbind(ID,DE)
> print(ENTRY)
\end{Sinput}
\begin{Soutput}
       ID                             
Q9UKY0 "PRND_HUMAN Reviewed; 176 AA." 
Q9GJY2 "PRND_SHEEP Reviewed; 178 AA." 
       DE                                                            
Q9UKY0 "Prion-like protein doppel precursor (PrPLP) (Prion protein 2"
Q9GJY2 "Prion-like protein doppel precursor (PrPLP)."                
 [getOption("max.print") ��ۤ��ޤ��� -- ���� 74 �Ԥ��ά���ޤ�]]
\end{Soutput}
\end{Schunk}
}
\end{slide}


\begin{slide}[Wipe]{����ʸ��}
\tiny{
 \bibliography{RdeDDBJ2,DDBJ}
}
\end{slide}

\end{document}
