annotate retrieve_fasta_from_NCBI.py @ 0:0bdc5a73c8d1 draft

planemo upload for repository https://bitbucket.org/drosofff/gedtools/
author drosofff
date Sun, 21 Jun 2015 14:29:45 -0400
parents
children 79cb7620843d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
1 #!/usr/bin/env python
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
2 # -*- coding: utf-8 -*-
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
3 """
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
4 From a taxonomy ID retrieves all the nucleotide sequences
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
5 It returns a multiFASTA nuc/prot file
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
6
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
7 Entrez Database UID common name E-utility Database Name
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
8 Nucleotide GI number nuccore
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
9 Protein GI number protein
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
10
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
11 Retrieve strategy:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
12
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
13 esearch to get total number of UIDs (count)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
14 esearch to get UIDs in batches
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
15 loop untile end of UIDs list:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
16 epost to put a batch of UIDs in the history server
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
17 efetch to retrieve info from previous post
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
18
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
19 retmax of efetch is 1/10 of declared value from NCBI
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
20
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
21 queries are 1 sec delayed, to satisfy NCBI guidelines (more than what they request)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
22
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
23
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
24 python get_fasta_from_taxon.py -i 1638 -o test.out -d protein
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
25 python get_fasta_from_taxon.py -i 327045 -o test.out -d nuccore # 556468 UIDs
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
26 """
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
27 import sys
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
28 import logging
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
29 import optparse
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
30 import time
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
31 import urllib
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
32 import urllib2
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
33 import httplib
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
34 import re
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
35 class Eutils:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
36
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
37 def __init__(self, options, logger):
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
38 self.logger = logger
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
39 self.base = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/"
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
40 self.query_string = options.query_string
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
41 self.dbname = options.dbname
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
42 if options.outname:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
43 self.outname = options.outname
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
44 else:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
45 self.outname = 'NCBI_download' + '.' + self.dbname + '.fasta'
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
46 self.ids = []
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
47 self.retmax_esearch = 100000
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
48 self.retmax_efetch = 1000
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
49 self.count = 0
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
50 self.webenv = ""
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
51 self.query_key = ""
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
52
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
53 def retrieve(self):
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
54 """ """
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
55 self.get_count_value()
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
56 self.get_uids_list()
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
57 self.get_sequences()
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
58
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
59 def get_count_value(self):
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
60 """
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
61 just to retrieve Count (number of UIDs)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
62 Total number of UIDs from the retrieved set to be shown in the XML
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
63 output (default=20). By default, ESearch only includes the first 20
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
64 UIDs retrieved in the XML output. If usehistory is set to 'y',
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
65 the remainder of the retrieved set will be stored on the History server;
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
66
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
67 http://www.ncbi.nlm.nih.gov/books/NBK25499/#chapter4.EFetch
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
68 """
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
69 self.logger.info("retrieving data from %s" % self.base)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
70 self.logger.info("for Query: %s and database: %s" %
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
71 (self.query_string, self.dbname))
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
72 querylog = self.esearch(self.dbname, self.query_string, '', '', "count")
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
73 self.logger.debug("Query response:")
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
74 for line in querylog:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
75 self.logger.debug(line.rstrip())
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
76 if '</Count>' in line:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
77 self.count = int(line[line.find('<Count>')+len('<Count>') : line.find('</Count>')])
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
78 self.logger.info("Founded %d UIDs" % self.count)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
79
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
80 def get_uids_list(self):
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
81 """
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
82 Increasing retmax allows more of the retrieved UIDs to be included in the XML output,
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
83 up to a maximum of 100,000 records.
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
84 from http://www.ncbi.nlm.nih.gov/books/NBK25499/#chapter4.ESearch
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
85 """
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
86 retmax = self.retmax_esearch
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
87 if (self.count > retmax):
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
88 num_batches = (self.count / retmax) + 1
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
89 else:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
90 num_batches = 1
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
91 self.logger.info("Batch size for esearch action: %d UIDs" % retmax)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
92 self.logger.info("Number of batches for esearch action: %d " % num_batches)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
93 for n in range(num_batches):
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
94 querylog = self.esearch(self.dbname, self.query_string, n*retmax, retmax, '')
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
95 for line in querylog:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
96 if '<Id>' in line and '</Id>' in line:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
97 uid = (line[line.find('<Id>')+len('<Id>') : line.find('</Id>')])
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
98 self.ids.append(uid)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
99 self.logger.info("Retrieved %d UIDs" % len(self.ids))
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
100
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
101 def esearch(self, db, term, retstart, retmax, rettype):
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
102 url = self.base + "esearch.fcgi"
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
103 self.logger.debug("url: %s" % url)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
104 values = {'db': db,
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
105 'term': term,
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
106 'rettype': rettype,
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
107 'retstart': retstart,
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
108 'retmax': retmax}
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
109 data = urllib.urlencode(values)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
110 self.logger.debug("data: %s" % str(data))
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
111 req = urllib2.Request(url, data)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
112 response = urllib2.urlopen(req)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
113 querylog = response.readlines()
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
114 time.sleep(1)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
115 return querylog
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
116
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
117 def epost(self, db, ids):
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
118 url = self.base + "epost.fcgi"
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
119 self.logger.debug("url_epost: %s" % url)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
120 values = {'db': db,
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
121 'id': ids}
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
122 data = urllib.urlencode(values)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
123 req = urllib2.Request(url, data)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
124 #self.logger.debug("data: %s" % str(data))
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
125 req = urllib2.Request(url, data)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
126 serverResponse = False
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
127 while not serverResponse:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
128 try:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
129 response = urllib2.urlopen(req)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
130 serverResponse = True
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
131 except: # catch *all* exceptions
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
132 e = sys.exc_info()[0]
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
133 self.logger.info( "Catched Error: %s" % e )
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
134 self.logger.info( "Retrying in 10 sec")
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
135 time.sleep(10)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
136 querylog = response.readlines()
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
137 self.logger.debug("query response:")
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
138 for line in querylog:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
139 self.logger.debug(line.rstrip())
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
140 if '</QueryKey>' in line:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
141 self.query_key = str(line[line.find('<QueryKey>')+len('<QueryKey>'):line.find('</QueryKey>')])
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
142 if '</WebEnv>' in line:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
143 self.webenv = str(line[line.find('<WebEnv>')+len('<WebEnv>'):line.find('</WebEnv>')])
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
144 self.logger.debug("*** epost action ***")
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
145 self.logger.debug("query_key: %s" % self.query_key)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
146 self.logger.debug("webenv: %s" % self.webenv)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
147 time.sleep(1)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
148
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
149 def efetch(self, db, query_key, webenv):
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
150 url = self.base + "efetch.fcgi"
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
151 self.logger.debug("url_efetch: %s" % url)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
152 values = {'db': db,
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
153 'query_key': query_key,
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
154 'webenv': webenv,
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
155 'rettype': "fasta",
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
156 'retmode': "text"}
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
157 data = urllib.urlencode(values)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
158 req = urllib2.Request(url, data)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
159 self.logger.debug("data: %s" % str(data))
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
160 req = urllib2.Request(url, data)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
161 serverTransaction = False
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
162 counter = 0
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
163 while not serverTransaction:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
164 counter += 1
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
165 self.logger.info("Server Transaction Trial: %s" % ( counter ) )
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
166 try:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
167 response = urllib2.urlopen(req)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
168 fasta = response.read()
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
169 if "Resource temporarily unavailable" in fasta:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
170 serverTransaction = False
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
171 else:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
172 serverTransaction = True
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
173 except urllib2.HTTPError as e:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
174 serverTransaction = False
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
175 self.logger.info("urlopen error:%s, %s" % (e.code, e.read() ) )
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
176 except httplib.IncompleteRead as e:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
177 serverTransaction = False
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
178 self.logger.info("IncompleteRead error: %s" % ( e.partial ) )
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
179 if self.dbname != "pubmed":
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
180 assert fasta.startswith(">"), fasta
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
181 fasta = self.sanitiser(self.dbname, fasta) #
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
182 time.sleep(1)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
183 return fasta
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
184
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
185 def sanitiser(self, db, fastaseq):
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
186 if db not in "nuccore protein" : return fastaseq
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
187 regex = re.compile(r"[ACDEFGHIKLMNPQRSTVWYBZ]{49,}")
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
188 sane_seqlist = []
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
189 seqlist = fastaseq.split("\n\n")
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
190 for seq in seqlist[:-1]:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
191 fastalines = seq.split("\n")
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
192 if len(fastalines) < 2:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
193 self.logger.info("Empty sequence for %s" % ("|".join(fastalines[0].split("|")[:4]) ) )
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
194 self.logger.info("%s download is skipped" % ("|".join(fastalines[0].split("|")[:4]) ) )
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
195 continue
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
196 if db == "nuccore":
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
197 badnuc = 0
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
198 for nucleotide in fastalines[1]:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
199 if nucleotide not in "ATGC":
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
200 badnuc += 1
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
201 if float(badnuc)/len(fastalines[1]) > 0.4:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
202 self.logger.info("%s ambiguous nucleotides in %s or download interrupted at this offset | %s" % ( float(badnuc)/len(fastalines[1]), "|".join(fastalines[0].split("|")[:4]), fastalines[1]) )
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
203 self.logger.info("%s download is skipped" % (fastalines[0].split("|")[:4]) )
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
204 continue
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
205 fastalines[0] = fastalines[0].replace(" ","_")[:100] # remove spaces and trim the header to 100 chars
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
206 cleanseq = "\n".join(fastalines)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
207 sane_seqlist.append(cleanseq)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
208 elif db == "protein":
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
209 fastalines[0] = fastalines[0][0:100]
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
210 fastalines[0] = fastalines[0].replace(" ", "_")
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
211 fastalines[0] = fastalines[0].replace("[", "_")
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
212 fastalines[0] = fastalines[0].replace("]", "_")
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
213 fastalines[0] = fastalines[0].replace("=", "_")
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
214 fastalines[0] = fastalines[0].rstrip("_") # because blast makedb doesn't like it
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
215 fastalines[0] = re.sub(regex, "_", fastalines[0])
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
216 cleanseq = "\n".join(fastalines)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
217 sane_seqlist.append(cleanseq)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
218 self.logger.info("clean sequences appended: %d" % (len(sane_seqlist) ) )
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
219 return "\n".join(sane_seqlist)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
220
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
221 def get_sequences(self):
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
222 """
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
223 Total number of records from the input set to be retrieved, up to a maximum
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
224 of 10,000. Optionally, for a large set the value of retstart can be iterated
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
225 while holding retmax constant, thereby downloading the entire set in batches
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
226 of size retmax.
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
227
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
228 http://www.ncbi.nlm.nih.gov/books/NBK25499/#chapter4.EFetch
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
229
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
230 """
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
231 batch_size = self.retmax_efetch
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
232 count = self.count
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
233 uids_list = self.ids
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
234 self.logger.info("Batch size for efetch action: %d" % batch_size)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
235 self.logger.info("Number of batches for efetch action: %d" % ((count / batch_size) + 1))
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
236 with open(self.outname, 'w') as out:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
237 for start in range(0, count, batch_size):
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
238 end = min(count, start+batch_size)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
239 batch = uids_list[start:end]
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
240 self.epost(self.dbname, ",".join(batch))
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
241 mfasta = ''
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
242 while not mfasta:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
243 self.logger.info("retrieving batch %d" % ((start / batch_size) + 1))
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
244 mfasta = self.efetch(self.dbname, self.query_key, self.webenv)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
245 out.write(mfasta + '\n')
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
246
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
247
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
248 LOG_FORMAT = '%(asctime)s|%(levelname)-8s|%(message)s'
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
249 LOG_DATEFMT = '%Y-%m-%d %H:%M:%S'
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
250 LOG_LEVELS = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
251
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
252
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
253 def __main__():
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
254 """ main function """
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
255 parser = optparse.OptionParser(description='Retrieve data from NCBI')
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
256 parser.add_option('-i', dest='query_string', help='NCBI Query String')
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
257 parser.add_option('-o', dest='outname', help='output file name')
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
258 parser.add_option('-l', '--logfile', help='log file (default=stderr)')
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
259 parser.add_option('--loglevel', choices=LOG_LEVELS, default='INFO', help='logging level (default: INFO)')
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
260 parser.add_option('-d', dest='dbname', help='database type')
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
261 (options, args) = parser.parse_args()
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
262 if len(args) > 0:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
263 parser.error('Wrong number of arguments')
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
264
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
265 log_level = getattr(logging, options.loglevel)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
266 kwargs = {'format': LOG_FORMAT,
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
267 'datefmt': LOG_DATEFMT,
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
268 'level': log_level}
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
269 if options.logfile:
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
270 kwargs['filename'] = options.logfile
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
271 logging.basicConfig(**kwargs)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
272 logger = logging.getLogger('data_from_NCBI')
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
273
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
274 E = Eutils(options, logger)
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
275 E.retrieve()
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
276
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
277
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
278 if __name__ == "__main__":
0bdc5a73c8d1 planemo upload for repository https://bitbucket.org/drosofff/gedtools/
drosofff
parents:
diff changeset
279 __main__()