Exemple #1
0
 def getTaxIdMetaData(ncbi_id):
     etal_bool = False
     if len(ncbi_id) > 1:
         ncbi_id = ncbi_id[0]
         etal_bool = True
     record = etools.eFetch(ncbi_id, logger=logger, db="taxonomy")[0]
     metadata = [record['Rank'], record['ScientificName']]
     if etal_bool:
         metadata = [e + ' et al.' for e in metadata]
     return metadata[0], metadata[1]
Exemple #2
0
 def _download(self, seqids):
     """Download records from GenBank given sequence ids"""
     records = []
     i = 1
     while i <= self.nseqs and len(seqids) > 0:
         if len(seqids) > 100:
             n = 100  # Download in chunks of 100
         else:
             n = len(seqids)
         seqs = []
         for _ in range(n):
             randi = random.randint(0, len(seqids)-1)
             seqs.append(seqids.pop(randi))
         for record in etools.eFetch(seqs, logger=self.logger):
             record = self._parse(record)
             if record:
                 records.append(record)
                 i += 1
     return records
Exemple #3
0
 def findParent(parentid):
     return etools.eFetch(parentid, logger=logger,
                          db="taxonomy")[0]['ParentTaxId']