3 de febrero de 2021

Consultas GraphQL al Protein Data Bank

Hola, 

durante el mantenimiento anual de footprintDB he descubierto que el Protein Data Bank ha cerrado su interfaz de web servicios (WS) https://www.rcsb.org/pages/webservices/rest-fetch .  Leyendo en https://data.rcsb.org/index.html#data-api veo que ahora se pueden hacer consultas REST o GraphQL, y opté por la segunda por aprender un poco.

Hay documentación en https://data.rcsb.org/migration-guide.html#legacy-fetch-api para migrar las consultas WS antiguas a GraphQL. Las nuevas consultas tienen este aspecto:

query={
 entry(entry_id:"9ANT"{
  polymer_entities{
   rcsb_polymer_entity{
    pdbx_description
   }
   rcsb_entity_source_organism{
    scientific_name
   }
   rcsb_polymer_entity_container_identifiers{
    entry_id
    auth_asym_ids
    reference_sequence_identifiers{
     database_accession,
     database_name
    }
   }
  }
  struct{
   title
  }
  rcsb_primary_citation{
   pdbx_database_id_PubMed
  }
 }
}

Y se pueden convertir a una URL como https://data.rcsb.org/graphql?query={entry(entry_id:%229ANT%22){polymer_entities{rcsb_polymer_entity{pdbx_description}rcsb_entity_source_organism{scientific_name},rcsb_polymer_entity_container_identifiers{entry_id,auth_asym_ids,reference_sequence_identifiers{database_accession,database_name}}}struct{title}rcsb_primary_citation{pdbx_database_id_PubMed}}}

 

Si haces click verás que en Chrome o Firefox no obtienes el resultado esperado, con un error:

Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986

Creo que se debe a un problema del servidor Tomcat del PDB. Sin embargo, sí funciona con wget y así obtienes la salida JSON que puedes procesar con tu lenguaje favorito:

wget 'https://data.rcsb.org/graphql?query={entry(entry_id:%229ANT%22){polymer_entities{rcsb_polymer_entity{pdbx_description}rcsb_entity_source_organism{scientific_name},rcsb_polymer_entity_container_identifiers{entry_id,auth_asym_ids,reference_sequence_identifiers{database_accession,database_name}}}struct{title}rcsb_primary_citation{pdbx_database_id_PubMed}}}' -O-

Hasta pronto,

Bruno

 

 

 

1 comentario:

  1. Esto me dicen de info@rcsb.org:

    The 400 Bad Request problem is because the query parameter isn’t URL encoded, it should be http://data.rcsb.org/graphql?query={entry(entry_id:"4HHB"){exptl{method }}}

    ResponderEliminar