Esempio n. 1
0
//
// Parse suffix to add max connection for each atom.
//
void Linker::parseAppendix(std::string& suffix)
{
    // std::cerr << "Linker::parseAppendix: " << suffix << "|" << std::endl;

    // Use a string stream instead of manipulatiing the string
    std::stringstream suffStream(suffix);

    //
    // Read until we get "> <"
    //
    std::string line = "";
    while(line.find("> <") == std::string::npos)
    {
        getline(suffStream, line);
    }

    //
    // Now, read the MAX Connections for each atom.
    //
    int maxConnections = -1;
    std::string atomType;

    for(int x = 0; x < this->getNumberOfAtoms(); x++)
    {
        suffStream >> maxConnections;
        suffStream >> atomType;

        // A linker can link to any atom.
        this->atoms[x].setCanConnectToAnyAtom();
        this->atoms[x].setMaxConnect(maxConnections);
        this->atoms[x].setAtomType(* new AtomT(atomType));
        this->atoms[x].setOwnerMolecule(this);
        this->atoms[x].setOwnerMoleculeType(LINKER);
    }
}
//
// Parse suffix to add max connection for each atom.
//
void Linker::parseAppendix(std::string& suffix, int numAtoms)
{
    // std::cerr << "Linker::parseAppendix: " << suffix << "|" << std::endl;

    // Use a string stream instead of manipulatiing the string
    std::stringstream suffStream(suffix);

    //
    // Read until we get "> <"
    //
    std::string line = ""; 
    while(line.find("> <") == std::string::npos)
    {
        getline(suffStream, line);
    }

    //
    // Now, read the MAX Connections for each atom.
    //
    int maxConnections = -1;
    std::string atomType;

    for(int x = 0; x < numAtoms; x++)
    {
        suffStream >> maxConnections;
        suffStream >> atomType;

        // A linker can link to any atom.
        this->atoms.push_back(new LinkerConnectableAtom(maxConnections, atomType, this));
    }
}
Esempio n. 3
0
void Rigid::parseAppendix(std::string& suffix)
{
    // Use a string stream instead of manipulatiing the string
    std::stringstream suffStream(suffix);

    //
    // Read until we get "> <"
    //
    std::string line = "";
    while(line.find("> <") == std::string::npos)
    {
        getline(suffStream, line);
    }

    //
    // Read the Atom Types
    //
    std::string atomType;
    for(int x = 0; x < this->getNumberOfAtoms(); x++)
    {
        suffStream >> atomType;

//std::cerr << "Type: " << atomType << std::endl;
//std::cerr << "Parsed Type: " << * new AtomT(atomType) << std::endl;

        this->atoms[x].setAtomType(* new AtomT(atomType));
        this->atoms[x].setOwnerMoleculeType(RIGID);
    }

    // Get the next line.
    getline(suffStream, line);

    //
    // Read until we get "> <"
    //
    while(line.find("> <") == std::string::npos)
    {
        getline(suffStream, line);
    }

    //
    // Read Branches
    //
    int atomId = -1;

    while (!isspace(suffStream.peek()))    
    {
        suffStream >> atomId;
        suffStream >> atomType;

//std::cerr << "Type: " << atomType << std::endl;
//std::cerr << "Parsed Type: " << * new AtomT(atomType) << std::endl;

        this->atoms[atomId - 1].setMaxConnect(1);
        this->atoms[atomId - 1].addConnectionType(* new AtomT(atomType));

        // Get the newline
        suffStream.get();
    }

    //
    // Read through the $$$$
    //
    while(line.find("$$$$") == std::string::npos)
    {
        getline(suffStream, line);
    }
}