@@ -9,7 +9,7 @@ class IOClient(Client):
99
1010 def write_downloadable (self , organism , export_type = 'FASTA' ,
1111 seq_type = 'peptide' , export_format = 'text' ,
12- export_gff3_fasta = False , sequences = []):
12+ export_gff3_fasta = False , sequences = [], region = None ):
1313 """
1414 Prepare a download for an organism
1515
@@ -20,7 +20,7 @@ def write_downloadable(self, organism, export_type='FASTA',
2020 :param sequences: Names of references sequences to add (default is all)
2121
2222 :type export_type: str
23- :param export_type: Export type. Choices: FASTA, GFF3
23+ :param export_type: Export type. Choices: FASTA, GFF3, VCF
2424
2525 :type seq_type: str
2626 :param seq_type: Export selection. Choices: peptide, cds, cdna, genomic
@@ -31,10 +31,19 @@ def write_downloadable(self, organism, export_type='FASTA',
3131 :type export_gff3_fasta: bool
3232 :param export_gff3_fasta: Export reference sequence when exporting GFF3 annotations.
3333
34+ :type region: str
35+ :param region: Region to export in form sequence:min..max e.g., chr3:1001..1034
36+
3437 :rtype: dict
3538 :return: a dictionary containing download information
3639 """
3740
41+ if export_format .lower () not in ('gzip' , 'text' ):
42+ raise Exception ("export_format must be one of file, text" )
43+
44+ if export_type .lower () not in ('fasta' , 'gff3' , 'vcf' ):
45+ raise Exception ("export_type must be one of FASTA, GFF3, VCF" )
46+
3847 data = {
3948 'type' : export_type ,
4049 'seq_type' : seq_type ,
@@ -46,13 +55,16 @@ def write_downloadable(self, organism, export_type='FASTA',
4655 'exportGff3Fasta' : export_gff3_fasta ,
4756 }
4857
58+ if region :
59+ data ['region' ] = region
60+
4961 return self .post ('write' , data )
5062
5163 def write_text (self , organism , export_type = 'FASTA' , seq_type = 'peptide' ,
5264 export_format = 'text' , export_gff3_fasta = False ,
53- sequences = []):
65+ sequences = [], region = None ):
5466 """
55- Download or prepare a download for an organism
67+ [DEPRECATED, use write_downloadable] Download or prepare a download for an organism
5668
5769 :type organism: str
5870 :param organism: organism common name
@@ -61,7 +73,7 @@ def write_text(self, organism, export_type='FASTA', seq_type='peptide',
6173 :param sequences: Names of references sequences to add (default is all)
6274
6375 :type export_type: str
64- :param export_type: Export type. Choices: FASTA, GFF3
76+ :param export_type: Export type. Choices: FASTA, GFF3, VCF
6577
6678 :type seq_type: str
6779 :param seq_type: Export selection. Choices: peptide, cds, cdna, genomic
@@ -72,44 +84,36 @@ def write_text(self, organism, export_type='FASTA', seq_type='peptide',
7284 :type export_gff3_fasta: bool
7385 :param export_gff3_fasta: Export reference sequence when exporting GFF3 annotations.
7486
87+ :type region: str
88+ :param region: Region to export in form sequence:min..max e.g., chr3:1001..1034
89+
7590 :rtype: str
7691 :return: the exported data
7792 """
78- if sequences is None :
79- sequences = []
8093
81- data = {
82- 'type' : export_type ,
83- 'seqType' : seq_type ,
84- 'format' : export_format ,
85- 'sequences' : sequences ,
86- 'organism' : organism ,
87- 'output' : 'text' ,
88- 'exportAllSequences' : True if not sequences else len (sequences ) == 0 ,
89- 'exportGff3Fasta' : export_gff3_fasta ,
90- }
91-
92- return self .post ('write' , data , is_json = False )
94+ return self .write_downloadable (organism , export_type , seq_type ,
95+ export_format , export_gff3_fasta ,
96+ sequences , region )
9397
9498 def download (self , uuid , output_format = 'gzip' ):
9599 """
96- [CURRENTLY BROKEN] Download pre-prepared data by UUID
100+ Download pre-prepared data by UUID
97101
98102 :type uuid: str
99103 :param uuid: Data UUID
100104
101105 :type output_format: str
102106 :param output_format: Output format of the data, either "gzip" or "text"
103107
104- :rtype: dict
105- :return: a dictionary
108+ :rtype: str
109+ :return: The downloaded content
106110 """
107111
108112 if output_format .lower () not in ('gzip' , 'text' ):
109- raise Exception ("outputFormat must be one of file, text" )
113+ raise Exception ("output_format must be one of file, text" )
110114
111115 data = {
112116 'format' : output_format ,
113117 'uuid' : uuid ,
114118 }
115- return self .post ( 'write ' , data )
119+ return self .get ( 'download ' , get_params = data , is_json = False )
0 commit comments