Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 128 additions & 0 deletions Biopool/APPS/CIF2Seq.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/* This file is part of Victor.

Victor is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Victor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Victor. If not, see <http://www.gnu.org/licenses/>.
*/
/**
*/
#include <Protein.h>
#include <CIFLoader.h>
#include <SeqSaver.h>
#include <IoTools.h>
#include <GetArg.h>

using namespace Victor;using namespace Victor::Biopool;

void sShowHelp() {
cout << "CIF 2 Seq $Revision: 1.0 $ -- converts a CIF file into SEQ\n"
<< "(torsion angles) protein structure backbone torsion angles\n"
<< " Options: \n"
<< "\t-i <filename> \t Input CIF file\n"
<< "\t-o <filename> \t Output to file (default stdout)\n"
<< "\t-c <id> \t Chain identifier to read\n"
<< "\t--all \t All chains\n"
<< "\t-m <number> \t Model number to read (NMR only, default is first model)\n"
<< "\t--chi \t Write Chi angles (default false)\n"
<< "\t-v \t verbose output\n\n"
<< "\tIf both -c and --all are missing, only the first chain is processed.\n\n";

}

int main(int argc, char* argv[]) {

if (getArg("h", argc, argv)) {
sShowHelp();
return 1;
}

string inputFile, outputFile, chainID;
unsigned int modelNum;
bool chi, all;

getArg("i", inputFile, argc, argv, "!");
getArg("o", outputFile, argc, argv, "!");
getArg("c", chainID, argc, argv, "!");
getArg("m", modelNum, argc, argv, 999);
all = getArg("-all", argc, argv);
chi = getArg("-chi", argc, argv);

// Check input file
if (inputFile == "!") {
cout << "Missing input file specification. Aborting. (-h for help)" << endl;
return -1;
}
ifstream inFile(inputFile.c_str());
if (!inFile)
ERROR("Input file not found.", exception);


CIFLoader cifL(inFile);

// Set CIFLoader variables
cifL.setModel(modelNum);
cifL.setNoHAtoms();
cifL.setNoHetAtoms();
cifL.setNoSecondary();
if (!getArg("v", argc, argv)) {
cifL.setNoVerbose();
}


// Check chain args
if ((chainID != "!") && all) {
ERROR("You can use --all or -c, not both", error);
}
// User selected chain
if (chainID != "!") {
if (chainID.size() > 1)
ERROR("You can choose only 1 chain", error);
cifL.setChain(chainID[0]);
}// All chains
else if (all) {
cifL.setAllChains();
}// First chain
else {
cifL.setChain(cifL.getAllChains()[0]);
}

// Load the protein object
Protein prot;
prot.load(cifL);

// Open the proper output stream (file or stdout)
std::ostream* os = &cout;
std::ofstream fout;
if (outputFile != "!") {
fout.open(outputFile.c_str());
if (!fout) {
ERROR("Could not open file for writing.", exception);
} else {
os = &fout;
}
}


Spacer* sp;
for (unsigned int i = 0; i < prot.sizeProtein(); i++) {

sp = prot.getSpacer(i);

// Write the sequence
SeqSaver ss(*os);
if (!chi)
ss.setWriteChi(false);
sp->save(ss);
}

return 0;
}
108 changes: 108 additions & 0 deletions Biopool/APPS/CIF2secondary.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/* This file is part of Victor.

Victor is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Victor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Victor. If not, see <http://www.gnu.org/licenses/>.
*/
/**
@Description */

#include <string>
#include <GetArg.h>
#include <Spacer.h>
#include <CIFLoader.h>
#include <IoTools.h>

using namespace Victor;using namespace Victor::Biopool;

void sShowHelp() {
cout << "CIF 2 Secondary Structure converter\n"
<< "\t H = helix, \t E = extended (strand, sheet), \t . = other.\n"
<< " Options: \n"
<< "\t-i <filename> \t\t Input file for CIF structure\n"
<< "\n";
}

int main(int nArgs, char* argv[]) {
if (getArg("h", nArgs, argv)) {
sShowHelp();
return 1;
};
vector<char> allCh;
string chainID = "!";
string inputFile;
getArg("i", inputFile, nArgs, argv, "!");

if (inputFile == "!") {
cout << "Missing file specification. Aborting. (-h for help)" << endl;
return -1;
}

Spacer *sp;
ifstream inFile(inputFile.c_str());
if (!inFile)
ERROR("File not found.", exception);

CIFLoader il(inFile);
il.setNoHAtoms();
// sp.load(il);
allCh = il.getAllChains();
for (unsigned int i = 0; i < allCh.size(); i++)
cout << "\t," << allCh[i] << ",";
cout << "\n";

/*check on validity of chain:
if user select a chain then check validity
else select first valid one by default*/
if (chainID != "!") {
bool validChain = false;
for (unsigned int i = 0; i < allCh.size(); i++) {
if (allCh[i] == chainID[0]) {
il.setChain(chainID[0]);
cout << "Loading chain " << chainID << "\n";
validChain = true;
break;
}
}
if (!validChain) {
cout << "Chain " << chainID << " is not available\n";
return -1;
}

} else {
chainID[0] = allCh[0];
cout << "Using chain " << chainID << "\n";
}
Protein prot;
prot.load(il);
sp = prot.getSpacer(chainID[0]);

allCh = il.getAllChains();
cout << ">" << inputFile << "\n";
for (unsigned int i = 0; i < sp->sizeAmino(); i++) {
switch (sp->getAmino(i).getState()) {
case HELIX:
cout << "H";
break;
case STRAND:
cout << "E";
break;
default:
cout << ".";
};
if ((i + 1) % 60 == 0)
cout << "\n";
}
cout << "\n";

return 0;
}
59 changes: 59 additions & 0 deletions Biopool/APPS/CIFCorrector.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* This file is part of Victor.

Victor is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Victor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Victor. If not, see <http://www.gnu.org/licenses/>.
*/

#include <Spacer.h>
#include <Group.h>
#include <SideChain.h>
#include <vector3.h>
#include <CIFLoader.h>
#include <CIFSaver.h>
#include <XyzSaver.h>
#include <SeqSaver.h>
#include <IoTools.h>
#include <IntCoordConverter.h>
#include <IntSaver.h>

using namespace Victor;using namespace Victor::Biopool;

int main(int nArgs, char* argv[]) {
if (nArgs != 2) {
cout << "CIF Corrector $Revision: 1.0 $ -- adds missing oxygen atoms to "
<< "protein structure backbones" << endl;
cout << " Usage: \t\t CIFCorrector <filename> \n";
return 1;
};

Spacer sp;
ifstream inFile(argv[1]);
if (!inFile)
ERROR("File not found.", exception);

CIFLoader CIFL(inFile);
sp.load(CIFL);

for (unsigned int i = 0; i < sp.sizeAmino(); i++)
sp.getAmino(i).addMissingO();

ofstream outFile2(argv[1]);

if (!outFile2)
ERROR("Couldn't write file.", exception);

CIFSaver pss2(outFile2);
sp.save(pss2);

return 0;
}
86 changes: 86 additions & 0 deletions Biopool/APPS/CIFEditor.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/* This file is part of Victor.

Victor is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Victor is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Victor. If not, see <http://www.gnu.org/licenses/>.
*/
/**

*/
#include <Spacer.h>
#include <CIFLoader.h>
#include <CIFSaver.h>
#include <IoTools.h>

using namespace Victor;using namespace Victor::Biopool;

int main(int nArgs, char* argv[]) {
if (nArgs != 3) {
cout << "CIF Editor $Revision: 1.0 $ -- allows sequential manipulation of "
<< "protein structure backbone torsion angles" << endl;
cout << " Usage: \t\t CIFEditor <input_filename> <output_filename> \n";
return 1;
};

Spacer sp;
ifstream inFile(argv[1]);
if (!inFile)
ERROR("File not found.", exception);

CIFLoader il(inFile);
sp.load(il);

cout << "Editing " << argv[1] << " output goes to " << argv[2] << "\n";

int aaid = -1;
do {
cout << "Aminoacid# or -1: ";
cin >> aaid;
if (aaid <= -1) {
cout << "Bye.\n";
return 0;
};

if (aaid >= (int) sp.sizeAmino()) {
cout << "\t Invalid aa#!\n";
} else {
double newVal = 999;
cout << "\t " << aaid << " " << sp.getAmino(aaid).getType() << "\n";
cout << "Phi= " << sp.getAmino(aaid).getPhi()
<< "\t new phi or 999: ";
cin >> newVal;
if (newVal != 999)
sp.getAmino(aaid).setPhi(newVal);
cout << "Psi= " << sp.getAmino(aaid).getPsi()
<< "\t new psi or 999: ";
cin >> newVal;
if (newVal != 999)
sp.getAmino(aaid).setPsi(newVal);
cout << "Omega= " << sp.getAmino(aaid).getOmega()
<< "\t new omega or 999: ";
cin >> newVal;
if (newVal != 999)
sp.getAmino(aaid).setOmega(newVal);

ofstream outFile2(argv[2]);

if (!outFile2)
ERROR("Couldn't write file.", exception);

CIFSaver pss2(outFile2);

sp.save(pss2);
};
} while (aaid != -1);

return 0;
}
Loading