[DAS] DAS Client

Saju Joseph saju_peruvachira@hotmail.com
Mon, 6 Jan 2003 15:49:22 +0530


This is a multi-part message in MIME format.

------=_NextPart_000_015B_01C2B59B.2E6DA090
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi Gurus,=20
I want to get the sequence for a chromosome region. Below is the piece =
of code I tried, and am struck in between. Can any of you help me. Other =
suggestions are welcome.

        //Connect to the url
        URL url =3D new =
URL("http://genome.cse.ucsc.edu/cgi-bin/das/hg8/dna?segment=3Dchr1:1,100;=
segment=3Dchr2:2,300");
        HttpURLConnection conn =3D (HttpURLConnection) =
url.openConnection();
       =20
        //Set Http request properties
        conn.setDoOutput(true);
        conn.setDoInput(true);
        conn.setRequestMethod("GET");
        conn.setRequestProperty("Content-Language", "en-US");
        conn.setRequestProperty("Content-Type", "application/xml");
        System.out.println("DAS Data Requested...");

        //Read data
        BufferedReader reader =3D new BufferedReader(new =
InputStreamReader(conn.getInputStream()));

       char[] buff =3D new char[20000];
       int bytes;
       String strFull =3D "";
       while (true){
           bytes =3D reader.read(buff,0,20000);
          if (bytes =3D=3D -1) break;
     =20
          String str =3D new String (buff, 0, bytes);
     =20
          strFull =3D strFull + str;
      }
  =20
          System.out.println(strFull);=20
    SequenceIterator stream =3D =
(SequenceIterator)SeqIOTools.readEmbl(reader);
     =20
   //Iterate over all sequences in the stream

   while (stream.hasNext()) {
       Sequence seq =3D stream.nextSequence();
       System.out.println(seq.getName());=20
}

Also I want to print the entire Sequence onto the console. How do I =
achieve this. Can any of you direct me to any samples.


Regards,
Saju Joseph





Hi,

The biojava library contains classes for connecting to the das server =
and for converting the results. They should provide everything you need.

Hope that helps
Thorsten Jansen
  -----Original Message-----
  From: das-admin@biodas.org [mailto:das-admin@biodas.org]On Behalf Of =
Saju Joseph
  Sent: Friday, December 20, 2002 8:07 AM
  To: das@biodas.org
  Subject: [DAS] DAS


  Gurus,
  We have implemented a genome browser. We would like to download =
external genome annotation data from the DAS servers with minimum =
effort. With an http Request made to the DAS server, XML data will be =
obtained. How is it possible to convert this XML data using the DAS =
standard. If any of you could provide me with a detailed input on this, =
it is highly appreciatable.
  Thanks in advance,
  Saju Joseph

------=_NextPart_000_015B_01C2B59B.2E6DA090
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>
<DIV><SPAN class=3D761372410-20122002><FONT face=3DArial color=3D#0000ff =
size=3D2>Hi=20
Gurus, </FONT></SPAN></DIV>
<DIV><SPAN class=3D761372410-20122002><FONT face=3DArial color=3D#0000ff =
size=3D2>I want=20
to get the sequence for a chromosome region. Below is the piece of code =
I tried,=20
and am struck in between. Can any of you help me. Other suggestions are=20
welcome.</FONT></SPAN></DIV>
<DIV><SPAN class=3D761372410-20122002></SPAN>&nbsp;</DIV>
<DIV><SPAN =
class=3D761372410-20122002>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
//Connect to the url</SPAN></DIV>
<DIV><SPAN class=3D761372410-20122002>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp; URL=20
url =3D new URL("<FONT color=3D#0000ff><U><A=20
href=3D"http://genome.cse.ucsc.edu/cgi-bin/das/hg8/dna?segment=3Dchr1:1,1=
00;segment=3Dchr2:2,300">http://genome.cse.ucsc.edu/cgi-bin/das/hg8/dna?s=
egment=3Dchr1:1,100;segment=3Dchr2:2,300</A></U></FONT>");<BR>&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;=20
&nbsp; HttpURLConnection conn =3D (HttpURLConnection)=20
url.openConnection();</SPAN></DIV>
<DIV><SPAN class=3D761372410-20122002></SPAN><SPAN=20
class=3D761372410-20122002>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
</SPAN></DIV>
<DIV><SPAN class=3D761372410-20122002>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp; //Set=20
Http request properties<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
conn.setDoOutput(true);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
conn.setDoInput(true);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
conn.setRequestMethod("GET");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;=20
conn.setRequestProperty("Content-Language",=20
"en-US");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
conn.setRequestProperty("Content-Type",=20
"application/xml");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
System.out.println("DAS Data Requested...");<BR></SPAN><SPAN=20
class=3D761372410-20122002></SPAN></DIV>
<DIV><SPAN class=3D761372410-20122002>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp; //Read=20
data<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BufferedReader =
reader =3D=20
new BufferedReader(new =
InputStreamReader(conn.getInputStream()));</SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN class=3D761372410-20122002>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; =
char[] buff=20
=3D new char[20000];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int=20
bytes;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String strFull =3D=20
"";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while=20
(true){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
bytes =3D=20
reader.read(buff,0,20000);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
if (bytes =3D=3D -1) break;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String str =3D new =
String=20
(buff, 0, bytes);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; strFull =3D =
strFull +=20
str;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;<BR>&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; System.out.println(strFull);&nbsp;</SPAN></DIV>
<DIV><SPAN class=3D761372410-20122002>&nbsp;&nbsp;&nbsp; =
SequenceIterator stream =3D=20
(SequenceIterator)SeqIOTools.readEmbl(reader);<BR>&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;//Iterate=20
over all sequences in the stream</SPAN></DIV>
<DIV>&nbsp;</DIV>
<DIV><SPAN class=3D761372410-20122002>&nbsp;&nbsp;&nbsp;while =
(stream.hasNext())=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;Sequence seq =3D=20
stream.nextSequence();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPA=
N><SPAN=20
class=3D761372410-20122002>System.out.println(seq.getName());&nbsp;</SPAN=
></DIV>
<DIV><SPAN class=3D761372410-20122002>}</SPAN></DIV><SPAN=20
class=3D761372410-20122002></SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D761372410-20122002></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D761372410-20122002><SPAN=20
class=3D761372410-20122002><FONT color=3D#0000ff>Also I want to print =
the entire=20
Sequence onto the console. How do I achieve this. Can any of you direct =
me to=20
any samples.</FONT></SPAN><BR></DIV></SPAN>
<DIV><SPAN class=3D761372410-20122002></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D761372410-20122002></SPAN><SPAN =
class=3D761372410-20122002><FONT=20
color=3D#0000ff>Regards,</FONT></SPAN></DIV>
<DIV><SPAN class=3D761372410-20122002><FONT color=3D#0000ff>Saju=20
Joseph</FONT></SPAN></DIV>
<DIV><SPAN class=3D761372410-20122002><FONT face=3DArial color=3D#0000ff =

size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D761372410-20122002><FONT=20
color=3D#0000ff></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D761372410-20122002><FONT=20
color=3D#0000ff></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D761372410-20122002><FONT=20
color=3D#0000ff></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D761372410-20122002><FONT=20
color=3D#0000ff></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D761372410-20122002><FONT face=3DArial color=3D#0000ff =

size=3D2>Hi,</FONT></SPAN></DIV>
<DIV><SPAN class=3D761372410-20122002><FONT face=3DArial color=3D#0000ff =

size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D761372410-20122002><FONT face=3DArial color=3D#0000ff =
size=3D2>The=20
biojava library contains classes for connecting to the das server and =
for=20
converting the results. They should provide everything you=20
need.</FONT></SPAN></DIV>
<DIV><SPAN class=3D761372410-20122002><FONT face=3DArial color=3D#0000ff =

size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D761372410-20122002><FONT face=3DArial color=3D#0000ff =
size=3D2>Hope=20
that helps</FONT></SPAN></DIV>
<DIV><SPAN class=3D761372410-20122002><FONT face=3DArial color=3D#0000ff =

size=3D2>Thorsten Jansen</FONT></SPAN></DIV>
<BLOCKQUOTE dir=3Dltr style=3D"MARGIN-RIGHT: 0px">
  <DIV class=3DOutlookMessageHeader dir=3Dltr align=3Dleft><FONT =
face=3DTahoma=20
  size=3D2>-----Original Message-----<BR><B>From:</B> =
das-admin@biodas.org=20
  [mailto:das-admin@biodas.org]<B>On Behalf Of </B>Saju =
Joseph<BR><B>Sent:</B>=20
  Friday, December 20, 2002 8:07 AM<BR><B>To:</B>=20
  das@biodas.org<BR><B>Subject:</B> [DAS] DAS<BR><BR></FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>Gurus,</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>We have implemented a genome browser. =
We would=20
  like to download external genome annotation data from the DAS servers =
with=20
  minimum effort. With an http Request made to the DAS server, XML data =
will be=20
  obtained. How is it possible to convert this XML data using the DAS =
standard.=20
  If any of you could provide me with a detailed input on this, it is =
highly=20
  appreciatable.</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>Thanks in advance,</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>Saju=20
Joseph</FONT></DIV></BLOCKQUOTE></FONT></BODY></HTML>

------=_NextPart_000_015B_01C2B59B.2E6DA090--