void PickResidueList::add( const PickResidueRange& resRange ) { assertInternal(); for( size_t i = 0; i < resRange.getNRes(); i++ ) { size_t resIndex = resRange.getStartResIndex()+i; ASSERT( resIndex < m_Mol->nResidues(), OutOfRangeException, "PickResidueList: The supplied residue index does not lie within the scope of the current molecule"); if( !VectorContains(m_ResList,resIndex) ) m_ResList.push_back(resIndex); } }
void PickResidueList::invertSelection() { ASSERT( m_Mol != NULL, NullInternalException, "PickResidueList: Internal Molecule is NULL" ); std::vector<size_t> temp_ResList(m_ResList); m_ResList.clear(); for( size_t ir = 0; ir < m_Mol->nResidues(); ir++ ) { if( !VectorContains(temp_ResList, ir ) ) { m_ResList.push_back( ir ); } } }
void BMARefinerOptionsDialog::OnCheck(wxCommandEvent& event) { if (event.GetId() == ID_ALL_UNST_SEQ_CHECKBOX) { if (!allUnstSeqCheck->GetValue()) { // if checkbox is turned off, then we need to select rows map < unsigned int, unsigned int > choice2row; wxArrayString choices; wxArrayInt selected; for (unsigned int i=0; i<rowTitles.size(); ++i) { if (rowTitles[i].size() > 0) { // only select on non-structured rows (assuming titles are set accordingly) choice2row[choices.GetCount()] = i; if (!VectorContains(rowsToExclude, i)) selected.Add(choices.GetCount()); choices.Add(wxString(rowTitles[i].c_str(),wxConvUTF8)); } } wxMultiChoiceDialog dialog(this, wxT("Choose unstructured rows to align:"), wxT("Row Selection"), choices, wxCAPTION | wxOK | wxCENTRE); dialog.SetSelections(selected); while (dialog.ShowModal() == wxID_OK) { rowsToExclude.clear(); selected = dialog.GetSelections(); // convert inclusion list -> exclusions vector < bool > exclude(rowTitles.size(), true); unsigned int i; for (i=0; i<selected.GetCount(); ++i) exclude[choice2row.find(selected.Item(i))->second] = false; for (i=0; i<rowTitles.size(); ++i) if (exclude[i] && rowTitles[i].size() > 0) rowsToExclude.push_back(i); if (selected.size() == 0 && !fixStructCheck->IsChecked()) ERRORMSG("Must select at least one unstructured row to refine when not refining structured rows"); else break; } } } else if (event.GetId() == ID_DO_LOO_CHECKBOX) { // toggle loo controls activity bool doLoo = doLooCheck->IsChecked(); unsigned int nStructs = GetNumEmptyRowTitles(false); bool enableFixStructCheck = (nStructs > 0 && nStructs < rowTitles.size() - 1); // enable if there's a non-master structure, but not if all are structures bool enableAllUnstSeqCheck = (nStructs < rowTitles.size() - 1); // enable if there's at least one non-structure looSelectionOrderCombo->Enable(doLoo); fullSeqCheck->Enable(doLoo); fixStructCheck->Enable(doLoo && enableFixStructCheck); allUnstSeqCheck->Enable(doLoo && enableAllUnstSeqCheck); nExtSpin->GetTextCtrl()->Enable(doLoo); nExtSpin->GetSpinButton()->Enable(doLoo); cExtSpin->GetTextCtrl()->Enable(doLoo); cExtSpin->GetSpinButton()->Enable(doLoo); lnoSpin->GetTextCtrl()->Enable(doLoo); lnoSpin->GetSpinButton()->Enable(doLoo); loopPercentSpin->GetTextCtrl()->Enable(doLoo); loopPercentSpin->GetSpinButton()->Enable(doLoo); loopExtensionSpin->GetTextCtrl()->Enable(doLoo); loopExtensionSpin->GetSpinButton()->Enable(doLoo); loopCutoffSpin->GetTextCtrl()->Enable(doLoo); loopCutoffSpin->GetSpinButton()->Enable(doLoo); rngSpin->GetTextCtrl()->Enable(doLoo); rngSpin->GetSpinButton()->Enable(doLoo); wxString comboValue = esCombo->GetValue(); bool editBlocks = (comboValue != blockEditAlgStrings[0]); phaseOrderCombo->Enable(editBlocks && doLoo); Refresh(); } else event.Skip(); }
int ExpressionParser::Parse(std::string message){ message = StringToLower( message ); std::string word = ""; std::vector<Word> words; char inquotes = 0; for( size_t i = 0; i < message.size(); ++i ){ if( message[i] == '"' || message[i] == '\'' ){ if( !inquotes && word == "" ){ inquotes = message[i]; continue; } else if( inquotes && message[i] == inquotes ){ inquotes = 0; words.push_back( word ); word = ""; continue; } } if( ( isspace(message[i]) || ispunct(message[i]) ) && !inquotes && message[i] != '\'' ){ if( word != "" ){ words.push_back( word ); word = ""; } if( ispunct(message[i]) ){ std::string temp = ""; temp += message[i]; words.push_back( temp ); } } else{ word += message[i]; } } if( word != "" ){ words.push_back( word ); word = ""; } Actions.clear(); ActionPosition = 0; Action a, aprev; std::string subject = ""; a.Subject = a.Verb = a.Delimiter = a.Preposition = a.Modifier = a.Who = ""; aprev = a; for( size_t i = 0; i < words.size(); ++i ){ if( VectorContains(Articles, words[i] ) ){ a.Who = ""; aprev.Who = ""; continue; } else if( VectorContains( Delimiters, words[i] ) ){ if( a.Verb == "" ){ a.Verb = aprev.Verb; } if( a.Who == "" ){ a.Who = aprev.Who; } if( a.ModifierWho == "" ){ a.ModifierWho = aprev.ModifierWho; } if( !(a.Subject == "" || a.Verb == "") ){ Actions.push_back(a); aprev = a; } a.Preposition = a.Modifier = ""; a.Subject = a.Verb = a.Who = a.ModifierWho = ""; a.Delimiter = words[i]; } else if( a.Verb == "" && ( VectorContains( Verbs, words[i] ) || VectorContains( BonusVerbs, words[i] ) ) ){ a.Verb = words[i]; aprev.Who = aprev.ModifierWho = ""; } else if( a.Subject == "" ){ if( a.Verb != "" || aprev.Verb != "" ){ if( a.Who == "" && VectorContains( Who, words[i] ) ){ Word w = Who[VectorContains( Who, words[i] )-1]; if( !w.IsFirstPersonPossessive() ){ if( subject != "" ){ a.Who = subject; } else if( aprev.Who != "" ){ a.Who = aprev.Who; } else{ a.Who = words[i]; } } else { a.Who = words[i]; } } else if( a.Who == "" && words[i].substr(words[i].size() - 2) == "'s" ){ subject = words[i].substr( 0, words[i].size() - 2 ); a.Who = subject; } else if( VectorContains( Pronouns, words[i] ) ){ if( subject != "" ){ a.Subject = subject; } else{ a.Subject = aprev.Subject; } } else if( !VectorContains( Prepositions, words[i] ) ){ a.Subject = words[i]; if( subject == "" ){ subject = a.Subject; } } } } else if( a.Preposition == "" && VectorContains( Prepositions, words[i] ) ){ a.Preposition = words[i]; } else if( a.Preposition != "" ){ if( a.Modifier != "" ){ a.Modifier += " "; } else if( VectorContains( Who, words[i] ) ){ Word w = Who[VectorContains( Who, words[i] )-1]; if( !w.IsFirstPersonPossessive() ){ if( subject != "" ){ a.ModifierWho = subject; } else if( aprev.ModifierWho != "" ){ a.ModifierWho = aprev.ModifierWho; } else{ a.ModifierWho = words[i]; } } else { a.ModifierWho = words[i]; } } else if( a.ModifierWho == "" && words[i].substr(words[i].size() - 2) == "'s" ){ subject = words[i].substr( 0, words[i].size() - 2 ); a.ModifierWho = subject; } else{ a.Modifier += words[i]; } } else if( a.Subject != "" && a.Verb != "" ){ a.Subject += " "; a.Subject += words[i]; } } if( a.Verb == "" ){ a.Verb = aprev.Verb; } if( a.Who == "" ){ a.Who = aprev.Who; } if( a.ModifierWho == "" ){ a.ModifierWho = aprev.Who; } if( a.Verb == "" ){ return Actions.size(); } Actions.push_back(a); return Actions.size(); }
void FF_BreakableBonded::validateBonds() { // Proxies WorkSpace& wspace = getWSpace(); if(OutputLevel) printf("Evaluating bond break list...\n"); for( size_t k = 0; k < m_BrokenBonds.size(); k++ ) { // Is the bond a real bond? bool valid = isBonded( m_BrokenBonds[k].i, m_BrokenBonds[k].j ); m_BrokenBonds[k].valid = valid; std::vector<int>& status = m_BrokenBonds[k].atomList; status.clear(); if( valid ) { // Atom proxy ParticleStore& atom = wspace.atom; // Get the shortest list of atoms from one side of the bond. int top, bottom; if( m_BrokenBonds[k].i < m_BrokenBonds[k].j) { bottom = m_BrokenBonds[k].i; top = m_BrokenBonds[k].j; } else { bottom = m_BrokenBonds[k].j; top = m_BrokenBonds[k].i; } bool secondRun = false; while(true) { int ignore; if( !secondRun ) { // begin by looking at atom indexes larger than that of the bonds largest atom index (top) ignore = bottom; status.push_back(top); for( size_t q = 0; q < atom[top].cov12atom.size(); q++ ) { int index = atom[top].cov12atom[q].i; if( ignore == index ) continue; // don't cross the bond itself! status.push_back(index); } } else { // If looking that way from the bond includes more than half // the total atoms, look the other way and try again! status.clear(); // reset the list for the next run! ignore = top; status.push_back(bottom); for( size_t q = 0; q < atom[bottom].cov12atom.size(); q++ ) { int index = atom[bottom].cov12atom[q].i; if( ignore == index ) continue; // don't cross the bond itself! status.push_back(index); } } int curindex = 0; while( curindex++ < status.size()-1 ) { int search = status[curindex]; for( size_t q = 0; q < atom[search].cov12atom.size(); q++ ) { int index = atom[search].cov12atom[q].i; if( index == ignore ) { // Our bond is in a ring structure!! if(OutputLevel) { printf("WARNING: Bond-break defined within a ring structure! Between: Atoms %d and %d\n", m_BrokenBonds[k].i, m_BrokenBonds[k].j); printf("Could be within chemical ring or a disulphide linked region.\n"); printf("Side effects are possible depending upon angle and improper definitions within the forcefield!\n"); } // Bugger ... // We now have to define some sensible atoms for the atoms on this "side" of the bond // - we now **have** to assume that any angles and torsions will be defined // accross the bond itself and with one of the first shell of covelent partners status.clear(); status.push_back(top); for( size_t q = 0; q < atom[top].cov12atom.size(); q++ ) { int index = atom[top].cov12atom[q].i; if( ignore == index ) continue; // don't cross the bond itself! status.push_back(index); } goto NEXTBOND; // Ewww :-D - but the only decent way to break out of several loops. } if( !VectorContains(status,index) ) status.push_back(index); } } if( secondRun ) { // We only have two runs, one for each side break; } else if(status.size() < (atom.size() / 2)) { // We have found the shortest side in the first pass :-D break; } else { // In some rare cases, a second run will be required secondRun = true; } } if(OutputLevel) printf("Breaking bond between: Atoms %d and %d:\n",m_BrokenBonds[k].i, m_BrokenBonds[k].j); } else { if(OutputLevel) printf("Invalid bond exclustion: Atoms %d and %d are not bonded.\n",m_BrokenBonds[k].i, m_BrokenBonds[k].j); } NEXTBOND: // Need this to allow a 'goto' breaker above // now sort our array, because we will be using std::binary_search below std::sort(status.begin(),status.end()); } }