<div dir="ltr">Hi all, <div><br></div><div>Thanks for your valuable suggestions. however, I still have some minor issues.</div><div><br></div><div>I understand that in Stephen's code, in order to obtain results equivalent to the ones in the web, </div>


<div><br></div><div><a href="http://www.ensembl.org/Homo_sapiens/Gene/Compara_Alignments?align=548&db=core&g=ENSG00000171105&r=19%3A7112266-7294045" target="_blank">http://www.ensembl.org/Homo_sapiens/Gene/Compara_Alignments?align=548&db=core&g=ENSG00000171105&r=19%3A7112266-7294045</a></div>


<div><br></div><div>variables ($ref_start, $ref_end) should be asigned to  (7112266, 7294045), as my desired gene region is "<a href="http://www.ensembl.org/Homo_sapiens/Location/View?db=core;g=ENSG00000171105;r=19:7112266-7294045" target="_blank" style="font-size:13px;color:rgb(0,0,102);font-family:'Luxi Sans',Helvetica,Arial,Geneva,sans-serif;line-height:16px">Chromosome 19: 7,112,266-7,294,045</a><span style="font-size:13px;color:rgb(85,85,85);font-family:'Luxi Sans',Helvetica,Arial,Geneva,sans-serif;line-height:16px"> reverse strand". </span><span style="font-size:13px;font-family:arial,sans-serif">I have called  $</span><font face="arial, sans-serif">ref_slice_adaptor->fetch_by_region with strand 1 and -1.</font></div>

<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">However, the results I get are not the same than in your web example. Also, when executing PHYML on the results, it suceeds on the web example but fails on the one obtained with Stephen's code. I don't know wheter it is a minor format issue or a deeper problem. Have you got any experience on running phyml/phylip on the fetched results?</font></div>

<div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">Thank you very much for your help. Best regards,</font></div><div><font face="arial, sans-serif"><br>

</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">Manuel</font></div><div><br></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br>
<div class="gmail_quote">
2014/1/13 Stephen Fitzgerald <span dir="ltr"><<a href="mailto:stephenf@ebi.ac.uk" target="_blank">stephenf@ebi.ac.uk</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hi Manuel, you can also try our REST service, which will give you the option of accessing the data (output in JSON format) in a number of ways:<br>
<a href="http://beta.rest.ensembl.org/documentation/info/genomic_alignment_block_region" target="_blank">http://beta.rest.ensembl.org/<u></u>documentation/info/genomic_<u></u>alignment_block_region</a><br>
for example (using human coords 19:7184302-7184344):<br>
bash> curl '<a href="http://beta.rest.ensembl.org/alignment/block/region/homo_sapiens/19:7184302-7184344:1?species_set_group=primates" target="_blank">http://beta.rest.ensembl.org/<u></u>alignment/block/region/homo_<u></u>sapiens/19:7184302-7184344:1?<u></u>species_set_group=primates</a>' -H 'Content-type:application/<u></u>json'<br>


<br>
Also, if you wish to use the perl API, here is a script for retrieving the alignments in phylip format:<br>
bash> perl <a href="http://script.pl" target="_blank">script.pl</a> > out.phylip<br>
<br>
################ <a href="http://script.pl" target="_blank">script.pl</a><br>
<br>
use strict;<br>
use warnings;<br>
use Data::Dumper;<br>
use Bio::AlignIO;<br>
<br>
use Bio::EnsEMBL::Registry;<br>
<br>
#Auto-configure the registry<br>
Bio::EnsEMBL::Registry->load_<u></u>registry_from_db(<br>
        -host=>"<a href="http://ensembldb.ensembl.org" target="_blank">ensembldb.ensembl.org</a>"<u></u>, -user=>"anonymous",<br>
        -port=>'5306', db_version => 74);<br>
<br>
<br>
# Get the Compara Adaptor for MethodLinkSpeciesSets<br>
my $method_link_species_set_<u></u>adaptor =<br>
    Bio::EnsEMBL::Registry->get_<u></u>adaptor(<br>
      "Multi", "compara", "MethodLinkSpeciesSet");<br>
<br>
my $methodLinkSpeciesSet = $method_link_species_set_<u></u>adaptor-><br>
        fetch_by_method_link_type_<u></u>species_set_name("EPO", "primates");<br>
<br>
# Define the start and end positions for the alignment<br>
my ($ref_start, $ref_end) = (7184302, 7184344);<br>
<br>
# Get the reference species *core* Adaptor for Slices<br>
my $ref_slice_adaptor =<br>
    Bio::EnsEMBL::Registry->get_<u></u>adaptor(<br>
      "homo_sapiens", "core", "Slice");<br>
<br>
# Get the slice corresponding to the region of interest<br>
my $ref_slice = $ref_slice_adaptor->fetch_by_<u></u>region(<br>
    "chromosome", 19, $ref_start, $ref_end);<br>
<br>
# Get the Compara Adaptor for GenomicAlignBlocks<br>
my $genomic_align_block_adaptor =<br>
    Bio::EnsEMBL::Registry->get_<u></u>adaptor(<br>
      "Multi", "compara", "GenomicAlignBlock");<br>
<br>
# The fetch_all_by_<u></u>MethodLinkSpeciesSet_Slice() returns a ref.<br>
# to an array of GenomicAlingBlock objects (human is the reference species)<br>
my $all_genomic_align_blocks = $genomic_align_block_adaptor-><br>
    fetch_all_by_<u></u>MethodLinkSpeciesSet_Slice(<br>
        $methodLinkSpeciesSet, $ref_slice);<br>
<br>
# set up an AlignIO to format SimpleAlign output<br>
my $alignIO = Bio::AlignIO->newFh(-<u></u>interleaved => 0,<br>
                                  -fh => \*STDOUT,<br>
                                  -format => 'phylip',<br>
                                  -idlength => 30);<br>
<br>
# print the restricted alignments<br>
foreach my $genomic_align_block( @{ $all_genomic_align_blocks }) {<br>
        my $restricted_gab = $genomic_align_block-><u></u>restrict_between_reference_<u></u>positions($ref_start, $ref_end);<br>
        print $alignIO $restricted_gab->get_<u></u>SimpleAlign;<br>
}<br>
<br>
################ out.phylip<br>
 6 44<br>
homo_sapiens/19               cccc-<u></u>agacccacatccagaactcacttgctggaa<u></u>ttcatcgtg<br>
pongo_abelii/19               cccc-<u></u>agacctacatccagaactcacttgctggaa<u></u>ttcatcgtg<br>
pan_troglodytes/19            cccc-<u></u>agacccacaaccagaactcacttgctggaa<u></u>ttcatcgtg<br>
gorilla_gorilla/19            cccc-<u></u>agacccacatctagaactcacttgctggaa<u></u>ttcatcgtg<br>
callithrix_jacchus/22         ccccaagacccacatgcaggactcacttgc<u></u>tggaattcatcgtg<br>
macaca_mulatta/19             cccc-<u></u>ggacccacatacagaactcacttgctggaa<u></u>ttcatcgtg<br>
<br>
<br>
Cheers,<br>
Stephen.<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
<br>
On Mon, 13 Jan 2014, Emily Pritchard wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Manuel<br>
<br>
Have you seen our API course on EBI Train Online:<br>
<a href="http://www.ebi.ac.uk/training/online/course/ensembl-filmed-api-workshop" target="_blank">http://www.ebi.ac.uk/training/<u></u>online/course/ensembl-filmed-<u></u>api-workshop</a><br>
<br>
The Core section will introduce you to the API itself, and the Compara module for alignments.<br>
<br>
Hope this helps<br>
<br>
Emily<br>
<br>
On 13/01/2014 13:32, Manuel Rodríguez Pascual wrote:<br>
      I am just starting working with Ensembl API. I am not really experienced neither with Ensembl or bioinformatics itself,so I am stuck<br>
      in a problem that seems to be easy to solve.<br>
<br>
<br>
As a test and proof of concept, I am interested to retrieve information of a comparison in phylip format. In particular, the provided<br>
example<br>
<a href="http://www.ensembl.org/Homo_sapiens/Gene/Compara_Alignments?align=548&db=core&g=ENSG00000171105&r=19%3A7112266-7294045" target="_blank">http://www.ensembl.org/Homo_<u></u>sapiens/Gene/Compara_<u></u>Alignments?align=548&db=core&<u></u>g=ENSG00000171105&r=19%<u></u>3A7112266-7294045</a><br>


<br>
when exported into a phylip format, <br>
<br>
<a href="http://www.ensembl.org/Homo_sapiens/Export/Output/Location/Alignment?align=548;db=core;g=ENSG00000171105;output=alignment;r=19:7112266-7294045" target="_blank">http://www.ensembl.org/Homo_<u></u>sapiens/Export/Output/<u></u>Location/Alignment?align=548;<u></u>db=core;g=ENSG00000171105;<u></u>output=alignment;r=19:7112266-<u></u>7294045</a>;<br>


format=phylip;_format=Text<br>
<br>
I have however seen that the employment of wget is discouraged and the Ensembl API should be used instead.<br>
<br>
Reading the available documentation, I fell that I should use the Compara API Tutorial, <br>
<a href="http://www.ensembl.org/info/docs/api/compara/compara_tutorial.html" target="_blank">http://www.ensembl.org/info/<u></u>docs/api/compara/compara_<u></u>tutorial.html</a><br>
<br>
but I don't really understand it or how to apply it to my objective.<br>
<br>
The question is, can anyone orient me on how to proceed? <br>
<br>
<br>
<br>
Thanks for your attention,<br>
<br>
<br>
<br>
Manuel <br>
<br>
<br>
-- <br>
Dr. Manuel Rodríguez-Pascual<br>
skype: manuel.rodriguez.pascual<br>
phone: (+34) 913466173 // (+34) 679925108<br>
 <br>
CIEMAT-Moncloa<br>
Edificio 22, desp. 1.25<br>
Avenida Complutense, 40 <br>
28040- MADRID<br>
SPAIN<br>
<br>
<br>
______________________________<u></u>_________________<br>
Dev mailing list    <a href="mailto:Dev@ensembl.org" target="_blank">Dev@ensembl.org</a><br>
Posting guidelines and subscribe/unsubscribe info: <a href="http://lists.ensembl.org/mailman/listinfo/dev" target="_blank">http://lists.ensembl.org/<u></u>mailman/listinfo/dev</a><br>
Ensembl Blog: <a href="http://www.ensembl.info/" target="_blank">http://www.ensembl.info/</a><br>
<br>
<br>
-- <br>
Dr Emily Pritchard<br>
Ensembl Outreach Officer<br>
<br>
European Bioinformatics Institute (EMBL-EBI)<br>
European Molecular Biology Laboratory<br>
Wellcome Trust Genome Campus<br>
Hinxton<br>
Cambridge<br>
CB10 1SD<br>
UK <br>
</blockquote>
</div></div><br>_______________________________________________<br>
Dev mailing list    <a href="mailto:Dev@ensembl.org">Dev@ensembl.org</a><br>
Posting guidelines and subscribe/unsubscribe info: <a href="http://lists.ensembl.org/mailman/listinfo/dev" target="_blank">http://lists.ensembl.org/mailman/listinfo/dev</a><br>
Ensembl Blog: <a href="http://www.ensembl.info/" target="_blank">http://www.ensembl.info/</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Dr. Manuel Rodríguez-Pascual<br>skype: manuel.rodriguez.pascual<br>phone: (+34) 913466173 // (+34) 679925108<br> <br>CIEMAT-Moncloa<br>Edificio 22, desp. 1.25<br>

Avenida Complutense, 40 <br>28040- MADRID<br>SPAIN
</div>