Coming to this late, but as a past contributor to biopython
and maintainer of rentrez
I feel I need to explain what is going on here.
Biopython is accessing "version 1.0" esummary records by default, and the R packages are fetching "version 2.0" records. There is a brief discussion about the differences between these records in the rentrez help page:
The NCBI offer two distinct formats for summary documents. Version
1.0 is a relatively limited summary of a database record based on
a shared Document Type Definition. Version 1.0 summaries are only
available as XML and are not available for some newer databases
Version 2.0 summaries generally contain more information about a
given record, but each database has its own distinct format. 2.0
summaries are available for records in all databases and as JSON
and XML files. As of version 0.4, rentrez fetches version 2.0
summaries by default and uses JSON as the exchange format (as JSON
object can be more easily converted into native R types). Existing
scripts which relied on the structure and naming of the "Version
1.0" summary files can be updated by setting the new ‘version’
argument to "1.0".
And just to demonstrate changing this argument reproduces the results from Biopython.
> eg_gene <- entrez_search(db="nuccore", term='183844[GPRJ]', retmax=1)
> entrez_summary(db="nuccore", id=eg_gene$ids, version="1.0")
esummary result with 13 items:
[1] Caption Title Extra Gi
[5] CreateDate UpdateDate Flags TaxId
[9] Length Status ReplacedBy Comment
[13] AccessionVersion
> entrez_summary(db="nuccore", id=eg_gene$ids)
esummary result with 31 items:
[1] uid caption title extra gi
[6] createdate updatedate flags taxid slen
[11] biomol moltype topology sourcedb segsetsize
[16] projectid genome subtype subname assemblygi
[21] assemblyacc tech completeness geneticcode strand
[26] organism strain biosample statistics properties
[31] oslt
Edit -- getting version 2.0 records with Biopython
handle = Entrez.esearch(db="nuccore", term="183844[GPRJ]", retmax=1)
record = Entrez.read(handle)
handle_two = Entrez.esummary(db="nuccore", id=record["IdList"][0], version="2.0")
Entrez.read(handle_two, validate=False)
.
{'DocumentSummarySet': ListElement([ListElement(['NPMJ00000000', 'Salmonella enterica subsp. enterica serovar Johannesburg strain CFSAN059880, whole genome shotgun sequencing project', 'gi|1235597280|gb|NPMJ00000000.1|NPMJ01000000', '1235597280', '2017/08/22', '2017/08/22', '0', '913076', '48', 'genomic', 'dna', 'linear', 'insd', '0', '186035', '', 'strain|serovar|host|sub_species|country|isolation_source|collection_date|collected_by', 'CFSAN059880|Johannesburg|Bos taurus|enterica|Nigeria|cattle stool|2012|University of Ibadan', '0', '', 'wgs', '', '11', '', 'Salmonella enterica subsp. enterica serovar Johannesburg', 'CFSAN059880', [StringElement('', attributes={'count': '1', 'type': 'all'}), StringElement('', attributes={'count': '3500', 'type': 'blob_size'}), StringElement('', attributes={'count': '1', 'type': 'org'}), StringElement('', attributes={'count': '2', 'type': 'pub'}), StringElement('', attributes={'count': '1', 'subtype': 'unpublished', 'type': 'pub'}), StringElement('', attributes={'count': '1', 'source': 'all', 'type': 'all'}), StringElement('', attributes={'count': '3500', 'source': 'all', 'type': 'blob_size'}), StringElement('', attributes={'count': '1', 'source': 'all', 'type': 'org'}), StringElement('', attributes={'count': '2', 'source': 'all', 'type': 'pub'})], StringElement('1', attributes={'master': '1', 'na': '1'}), StringElement('NPMJ00000000.1', attributes={'indexed': 'yes'}), 'NPMJ00000000.1'], attributes={'uid': '1235597280'})], attributes={'status': 'OK'})}
reutil
returns all item names even if they have no value, but the Python code is dropping items without a value. They both access the same underlying API data, so the difference must be in processing the result.id
, some of them are empty strings. I used therentrez
package with your query and it had the same behaviour: everyid
had those 31 fields but the values are empty string for some cases. My suspicion is that the Python code just drops those ones.