localpdb/PDBDownloader.py
def download(self, file_type=''):
        """
        Downloads the selected file type from the selected PDB mirror based on the generated URL.
        @param file_type: file type to download.
        @return: True if downloaded was completed and validated.
        """
        if file_type in ['entries', 'bundles', 'entries_type', 'resolution', 'seqres']:
            dest = f'{self.db_path}/data/{self.version}/pdb_{file_type}.txt'
            if file_type == 'seqres':
                dest = '{}.gz'.format(dest)
            url = self.__gen__url(file_type=file_type)
            if download_url(url, dest):
                return self.__verify_timestamp(dest)
            else:
                return False

        elif file_type in ['added', 'modified', 'obsolete']:
            url = self.__gen__url(file_type=file_type, version=self.version)
            dest = f'{self.db_path}/data/{self.version}/{file_type}.txt'
            results = [self.__verify_timestamp(dest) if download_url(url, dest) else False]
            if file_type == 'modified':
                modified_dict, status = self.fetch_major_revisions()
                results.append(status)
            if self.versions is not None:
                dest_merged = f'{self.db_path}/data/{self.version}/{file_type}_merged.txt'
                with open(dest_merged, 'w') as f:
                    for version in self.versions:
                        tmp_dest = f'{self.db_path}/data/{self.version}/tmp_{version}_{file_type}.txt'
                        url = self.__gen__url(file_type=file_type, version=version)
                        if download_url(url, tmp_dest):
                            results.append(self.__verify_timestamp(tmp_dest, version=version))
                            with open(tmp_dest) as f_tmp:
                                f.write(f_tmp.read())
                            os.remove(tmp_dest)
                        else:
                            results.append(False)
                last_modified = get_last_modified(url)
                set_last_modified(dest_merged, last_modified)
                if file_type == 'modified':
                    modified_dict, status = self.fetch_major_revisions(merged=True)
                    results.append(status)
            if all(results) and file_type == 'modified':
                results.append(self.update_versioning_log(modified_dict))
            return all(results)

        Downloads the selected file type from the selected PDB mirror based on the generated URL.
        @param file_type: file type to download.
        @return: True if downloaded was completed and validated.
        
Downloads the selected file type from the selected PDB mirror based on the generated URL.
Downloads the selected file type from the selected PDB mirror based on the generated URL .
def download(self, file_type=''):
        if file_type in ['entries', 'bundles', 'entries_type', 'resolution', 'seqres']:
            dest = f'{self.db_path}/data/{self.version}/pdb_{file_type}.txt'
            if file_type == 'seqres':
                dest = '{}.gz'.format(dest)
            url = self.__gen__url(file_type=file_type)
            if download_url(url, dest):
                return self.__verify_timestamp(dest)
            else:
                return False
        elif file_type in ['added', 'modified', 'obsolete']:
            url = self.__gen__url(file_type=file_type, version=self.version)
            dest = f'{self.db_path}/data/{self.version}/{file_type}.txt'
            results = [self.__verify_timestamp(dest) if download_url(url, dest) else False]
            if file_type == 'modified':
                modified_dict, status = self.fetch_major_revisions()
                results.append(status)
            if self.versions is not None:
                dest_merged = f'{self.db_path}/data/{self.version}/{file_type}_merged.txt'
                with open(dest_merged, 'w') as f:
                    for version in self.versions:
                        tmp_dest = f'{self.db_path}/data/{self.version}/tmp_{version}_{file_type}.txt'
                        url = self.__gen__url(file_type=file_type, version=version)
                        if download_url(url, tmp_dest):
                            results.append(self.__verify_timestamp(tmp_dest, version=version))
                            with open(tmp_dest) as f_tmp:
                                f.write(f_tmp.read())
                            os.remove(tmp_dest)
                        else:
                            results.append(False)
                last_modified = get_last_modified(url)
                set_last_modified(dest_merged, last_modified)
                if file_type == 'modified':
                    modified_dict, status = self.fetch_major_revisions(merged=True)
                    results.append(status)
            if all(results) and file_type == 'modified':
                results.append(self.update_versioning_log(modified_dict))
            return all(results)
def download ( self , file_type = '' ) : if file_type in [ 'entries' , 'bundles' , 'entries_type' , 'resolution' , 'seqres' ] : dest = f'{self.db_path}/data/{self.version}/pdb_{file_type}.txt' if file_type == 'seqres' : dest = '{}.gz' . format ( dest ) url = self . __gen__url ( file_type = file_type ) if download_url ( url , dest ) : return self . __verify_timestamp ( dest ) else : return False elif file_type in [ 'added' , 'modified' , 'obsolete' ] : url = self . __gen__url ( file_type = file_type , version = self . version ) dest = f'{self.db_path}/data/{self.version}/{file_type}.txt' results = [ self . __verify_timestamp ( dest ) if download_url ( url , dest ) else False ] if file_type == 'modified' : modified_dict , status = self . fetch_major_revisions ( ) results . append ( status ) if self . versions is not None : dest_merged = f'{self.db_path}/data/{self.version}/{file_type}_merged.txt' with open ( dest_merged , 'w' ) as f : for version in self . versions : tmp_dest = f'{self.db_path}/data/{self.version}/tmp_{version}_{file_type}.txt' url = self . __gen__url ( file_type = file_type , version = version ) if download_url ( url , tmp_dest ) : results . append ( self . __verify_timestamp ( tmp_dest , version = version ) ) with open ( tmp_dest ) as f_tmp : f . write ( f_tmp . read ( ) ) os . remove ( tmp_dest ) else : results . append ( False ) last_modified = get_last_modified ( url ) set_last_modified ( dest_merged , last_modified ) if file_type == 'modified' : modified_dict , status = self . fetch_major_revisions ( merged = True ) results . append ( status ) if all ( results ) and file_type == 'modified' : results . append ( self . update_versioning_log ( modified_dict ) ) return all ( results )
Downloads the selected file type from the selected PDB mirror based on the generated URL.
Downloads the selected file type from the selected PDB mirror based on the generated URL .
"""
        Downloads the selected file type from the selected PDB mirror based on the generated URL.
        @param file_type: file type to download.
        @return: True if downloaded was completed and validated.
        """
True if downloaded was completed and validated.
True if downloaded was completed and validated .
self
file_type
file type to download.
file type to download .