Skip to content
Open
115 changes: 115 additions & 0 deletions Biopool/APPS/Cif2Secondary.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/* 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 <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 argc, char** argv) {

if (getArg("h", argc, argv)) {
sShowHelp();
return 1;
};
vector<char> allCh;
string chainID = "!";
string inputFile;
getArg("i", inputFile, argc, argv, "!");

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

ifstream inFile(inputFile.c_str());
if (!inFile) {
ERROR("File not found.", exception);
}

CifLoader il(inFile);
il.setNoHAtoms();
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);
Spacer *sp;
sp = prot.getSpacer(chainID[0]);

allCh = il.getAllChains();
cout << ">" << inputFile << "\n";

inFile.close();

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;
}

133 changes: 133 additions & 0 deletions Biopool/APPS/Cif2Seq.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/* 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: 0.1 $ -- 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 cl(inFile);

// Set PdbLoader variables
cl.setModel(modelNum);
cl.setNoHAtoms();
cl.setNoHetAtoms();
cl.setNoSecondary();
if (!getArg("v", argc, argv)) {
cl.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);
cl.setChain(chainID[0]);
}// All chains
else if (all) {
cl.setAllChains();
}// First chain
else {
cl.setChain(cl.getAllChains()[0]);
}

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

inFile.close();

// 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);
}

fout.close();

return 0;
}

71 changes: 71 additions & 0 deletions Biopool/APPS/CifCorrector.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/* 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 argc, char** argv) {

if (argc != 2) {
cout << "Cif Corrector $Revision: 0.1 $ -- adds missing oxygen atoms to "
<< "protein structure backbones" << endl;
cout << " Usage: \t\t CifCorrector <filename> \n";
return 1;
};

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

CifLoader il(inFile);
Protein prot;
prot.load(il);
unsigned int zero = 0;
Spacer sp = *(prot.getSpacer(zero));

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

inFile.close();

ofstream outFile(argv[1]);

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

CifSaver pss(outFile);
sp.save(pss);

outFile.close();

return 0;
}

Loading