Exemplo n.º 1
0
/// Downloads the file for the biomolecule with the PDB ID of \p id.
/// If an error occurs \c 0 is returned.
///
/// The ownership of the returned file is passed to the caller.
///
/// For example, to download the ubiquitin pdb file (PDB ID: 1UBQ):
/// \code
/// PolymerFile *file = pdb.downloadFile("1UBQ");
/// \endcode
PolymerFile* ProteinDataBank::downloadFile(const QString &id) const
{
    QByteArray data = downloadFileData(id, "pdb");
    if(data.isEmpty()){
        return 0;
    }

    std::stringstream buffer(std::string(data.constData(), data.size()));

    PolymerFile *file = new PolymerFile;
    file->read(buffer, "pdb");

    return file;
}
Exemplo n.º 2
0
/// Downloads and returns the file containing the compounds with ID's
/// in the list \p ids. If an error occurs \c 0 is returned.
///
/// The ownership of the file is passed to the caller.
///
/// For example, to download the file containing %PubChem Compounds
/// 1, 2, 3, 42 and 57:
/// \code
/// QStringList ids;
/// ids << "1" << "2" << "3" << "42" << "57";
/// MoleculeFile *file = pubchem.downloadFile(ids);
/// \endcode
MoleculeFile* PubChem::downloadFile(const QStringList &ids) const
{
    QByteArray data = downloadFileData(ids, "sdf");
    if(data.isEmpty()){
        return 0;
    }

    std::stringstream buffer(std::string(data.constData(), data.size()));

    MoleculeFile *file = new MoleculeFile;
    file->read(buffer, "sdf");

    return file;
}
Exemplo n.º 3
0
/// Downloads and returns the file containing the compounds with ID's
/// in the list \p ids. If an error occurs \c 0 is returned.
///
/// The ownership of the file is passed to the caller.
///
/// For example, to download the file containing %PubChem Compounds
/// 1, 2, 3, 42 and 57:
/// \code
/// QStringList ids;
/// ids << "1" << "2" << "3" << "42" << "57";
/// MoleculeFile *file = pubchem.downloadFile(ids);
/// \endcode
MoleculeFile* PubChem::downloadFile(const QStringList &ids) const
{
    QByteArray data = downloadFileData(ids, "sdf");
    if(data.isEmpty()){
        return 0;
    }

    QBuffer buffer;
    buffer.setData(data);
    buffer.open(QBuffer::ReadOnly);

    MoleculeFile *file = new MoleculeFile;
    file->read(&buffer, "sdf");

    return file;
}