radiant.cpp 15.3 KB
Newer Older
Carsten Kemena's avatar
Carsten Kemena committed
1 2 3 4 5
// standard header
#include <bitset>
#include <map>
#include <string>
#include <fstream>
Dr. Carsten Kemena's avatar
changes  
Dr. Carsten Kemena committed
6
#include <set>
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
7
#include <algorithm>
Dr. Carsten Kemena's avatar
changes  
Dr. Carsten Kemena committed
8
#include <ctime>
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
9
#include <chrono>
Carsten Kemena's avatar
Carsten Kemena committed
10 11 12 13 14 15

// Boost header
#include <boost/program_options.hpp>
#include <boost/filesystem.hpp>

// BSDL header
16 17
#include "../libs/BioSeqDataLib/src/utility/Input.hpp"
#include "../libs/BioSeqDataLib/src/utility/Output.hpp"
18
#include "../libs/BioSeqDataLib/src/sequence/Sequence.hpp"
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
19
#include "../libs/BioSeqDataLib/src/sequence/SeqFunctions.hpp"
20
#include "../libs/BioSeqDataLib/src/sequence/SequenceSet.hpp"
21
#include "../libs/BioSeqDataLib/src/sequence/SeqSetIOManager.hpp"
22
#include "../libs/BioSeqDataLib/src/DomainModule.hpp"
23
#include "../libs/BioSeqDataLib/src/utility/utility.hpp"
24 25
#include "../libs/BioSeqDataLib/src/utility/stringHelpers.hpp"
#include "../libs/BioSeqDataLib/src/external_interfaces/DP_Manager.hpp"
26
#include "../libs/BioSeqDataLib/src/bio/GeneticCode.hpp"
Carsten Kemena's avatar
Carsten Kemena committed
27 28

#include "common.hpp"
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
29 30
#include "RadiantDB.hpp"
#include "version.hpp"
Carsten Kemena's avatar
Carsten Kemena committed
31 32

using namespace std;
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
33
using std::chrono::system_clock;
Carsten Kemena's avatar
Carsten Kemena committed
34 35
namespace po = boost::program_options;
namespace fs = boost::filesystem;
36
namespace BSDL = BioSeqDataLib;
Carsten Kemena's avatar
Carsten Kemena committed
37
namespace ct = boost::container;
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
38

39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
struct DomainInfo
{
	std::string name;
	std::string type;
	std::string clan;

	DomainInfo(const std::string &n, const std::string &t, const std::string &c) : name(n), type(t), clan(c)
	{}


};


void
readDomainInfo(const fs::path &pfamInfo, std::map<std::string, DomainInfo> &info)
{
	BSDL::Input in(pfamInfo);
	std::string line;
	while (getline(in, line))
	{
		auto tokens = BSDL::split(line, " ");
		if (tokens.size()==3)
			info.emplace(std::piecewise_construct, std::make_tuple(tokens[0]), std::make_tuple(tokens[1], tokens[2], "No_clan"));
		else
			info.emplace(std::piecewise_construct, std::make_tuple(tokens[0]), std::make_tuple(tokens[1], tokens[2], tokens[3]));
	}
}
Dr. Carsten Kemena's avatar
changes  
Dr. Carsten Kemena committed
66

67

Dr. Carsten Kemena's avatar
changes  
Dr. Carsten Kemena committed
68 69 70 71 72 73
/**
 * \brief Turns a word arrangement into a domain annotation
 * \param wordList The list of accession assignments.
 * \param m The number of matches needed.
 * \param w The window size.
 */
74
BSDL::DomainArrangement<BSDL::Domain>
75
words2arrangement(multiset<pair<size_t, std::pair<unsigned short, bool> > > &wordList, int m, size_t w)
76 77
{
	BSDL::DomainArrangement<BSDL::Domain> arrangement;
Dr. Carsten Kemena's avatar
changes  
Dr. Carsten Kemena committed
78 79
	if (wordList.size() < w)
		return arrangement;
80 81
	map<unsigned short, int> counter;
	unsigned short last = 0;
Dr. Carsten Kemena's avatar
changes  
Dr. Carsten Kemena committed
82 83 84
	auto it = wordList.begin();
	auto itEnd = wordList.end();
	for (size_t i = 0; i<w; ++i, ++it)
85
	{
86 87
		counter[it->second.first] += 1;
		if ((counter[it->second.first] >= m) && (arrangement.empty() || (last != it->second.first)))
88
		{
89 90
			last = it->second.first;
			string acc = to_string(it->second.first);
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
91 92
			while (acc.size() < 5)
				acc = "0" + acc;
Dr. Carsten Kemena's avatar
changes  
Dr. Carsten Kemena committed
93
			arrangement.emplace_back("PF" + acc, it->first, it->first, 0.0);
94 95 96
		}
	}

Dr. Carsten Kemena's avatar
changes  
Dr. Carsten Kemena committed
97 98
	auto it2 = wordList.begin();
	while (it != itEnd)
99
	{
100 101 102
		counter[it2->second.first] -= 1;
		counter[it->second.first] += 1;
		if ((counter[it->second.first] >= m) && (arrangement.empty() || (last != it->second.first)))
103
		{
104 105
			last = it->second.first;
			string acc = to_string(it->second.first);
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
106 107
			while (acc.size() < 5)
				acc = "0" + acc;
Dr. Carsten Kemena's avatar
changes  
Dr. Carsten Kemena committed
108
			arrangement.emplace_back("PF" + acc, it->first, it->first, 0.0);
109
		}
Dr. Carsten Kemena's avatar
changes  
Dr. Carsten Kemena committed
110 111
		++it;
		++it2;
112 113 114
	}
	return arrangement;
}
115

Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
BSDL::DomainArrangement<BSDL::Domain>
words2arrangement(multiset<pair<size_t, std::pair<unsigned short, bool> > > &wordList, const std::map<unsigned short, int> &m, size_t w)
{
	BSDL::DomainArrangement<BSDL::Domain> arrangement;
	if (wordList.size() < w)
		return arrangement;
	map<unsigned short, int> counter;
	unsigned short last = 0;
	auto it = wordList.begin();
	auto itEnd = wordList.end();
	short t = 7;
	for (size_t i = 0; i<w; ++i, ++it)
	{
		counter[it->second.first] += 1;

		auto it_m = m.find(it->second.first);
		if (it_m == m.end())
			t=7;
		else
			t = it_m->second;
		if ((counter[it->second.first] >= t) && (arrangement.empty() || (last != it->second.first)))
		{
			last = it->second.first;
			string acc = to_string(it->second.first);
			while (acc.size() < 5)
				acc = "0" + acc;
			arrangement.emplace_back("PF" + acc, it->first, it->first, 0.0);
		}
	}

	auto it2 = wordList.begin();
	while (it != itEnd)
	{
		counter[it2->second.first] -= 1;
		counter[it->second.first] += 1;
		auto it_m = m.find(it->second.first);
		if (it_m == m.end())
			t=7;
		else
			t = it_m->second;
		if ((counter[it->second.first] >= t) && (arrangement.empty() || (last != it->second.first)))
		{
			last = it->second.first;
			string acc = to_string(it->second.first);
			while (acc.size() < 5)
				acc = "0" + acc;
			arrangement.emplace_back("PF" + acc, it->first, it->first, 0.0);
		}
		++it;
		++it2;
	}
	return arrangement;
}
169

Dr. Carsten Kemena's avatar
changes  
Dr. Carsten Kemena committed
170 171 172 173 174 175 176 177 178 179
/**
 * \brief Reads RADIANT database.
 * @param inFile the database file.
 * @param[in|out] database The object that will store the database.
 */
void
readDatabase(const fs::path &inFile, std::unordered_map<PrefixType, vector<SuffixAcc> > &database)
{
	database.clear();
	ifstream fin(inFile.string(), ios::in | ios::binary);
180 181 182 183 184
	if (!fin.is_open())
	{
		std::cerr << "Error! Could not open database file: " << inFile.string() << "!" << std::endl;
		exit(1);
	}
Dr. Carsten Kemena's avatar
changes  
Dr. Carsten Kemena committed
185 186 187 188 189 190 191 192 193 194 195 196 197
	size_t dbLength = 0;
	fin.read((char*)&dbLength, sizeof(size_t));
	database.reserve(dbLength);
	for (size_t i=0; i<dbLength; ++i)
	{
		// read prefix
		PrefixType prefix;
		fin.read((char*)&prefix, sizeof(PrefixType));
		auto it = database.emplace(std::move(prefix), vector<SuffixAcc>()).first;

		// read suffixe and accession from file
		size_t numSuffixes;
		fin.read((char*)&numSuffixes, sizeof(size_t));
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
198
		//it->second.reserve(numSuffixes);
199 200
		it->second.resize(numSuffixes);
		fin.read((char*)&(it->second[0]), numSuffixes*(sizeof(SuffixAcc)));
Dr. Carsten Kemena's avatar
changes  
Dr. Carsten Kemena committed
201 202 203 204 205
	}
	fin.close();
}


206
void
207
assignWords(const fs::path &inFile, BSDL::SequenceSet<BSDL::Sequence<> > &seqSet, vector<multiset<pair<size_t, pair<unsigned short, bool> > > > &assignments, bool reverse)
208
{
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
209 210
	RadiantDB database;
	database.read(inFile);
Dr. Carsten Kemena's avatar
changes  
Dr. Carsten Kemena committed
211 212 213
	size_t nSeqs = seqSet.size();
	assignments.resize(nSeqs);
	PrefixType prefix;
214
	CodedSuffix suffix;
Dr. Carsten Kemena's avatar
changes  
Dr. Carsten Kemena committed
215 216

	int multiplyer = reverse ? 1 : -1;
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
217

Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
218
//	#pragma omp parallel for schedule(static,100) private(prefix, suffix)
Dr. Carsten Kemena's avatar
changes  
Dr. Carsten Kemena committed
219
	for (size_t i=0; i<nSeqs; ++i)
220
	{
Dr. Carsten Kemena's avatar
changes  
Dr. Carsten Kemena committed
221
		auto &seq = seqSet[i];
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
222
		size_t l = 0;
Dr. Carsten Kemena's avatar
changes  
Dr. Carsten Kemena committed
223 224 225 226 227
		if (reverse)
		{
			std::reverse(seq.begin(), seq.end());
			l = seq.size() -1;
		}
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
228
		if (seq.size() > WORD_SIZE)
229
		{
Dr. Carsten Kemena's avatar
changes  
Dr. Carsten Kemena committed
230
			auto &assignment = assignments[i];
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
231
			size_t length = seq.size() - WORD_SIZE;
Dr. Carsten Kemena's avatar
changes  
Dr. Carsten Kemena committed
232
			bool last = false;
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
233
			bool position;
Dr. Carsten Kemena's avatar
changes  
Dr. Carsten Kemena committed
234
			for (size_t j=0; j<length; ++j)
235
			{
Dr. Carsten Kemena's avatar
changes  
Dr. Carsten Kemena committed
236 237 238 239 240
				if (last)
					last = getNextPrefixSuffix(seq, j, prefix, suffix);
				else
					last = getCompletePrefixSuffix(seq, j, prefix, suffix);
				if (last)
241
				{
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
242 243
					auto acc = database.getDomID(prefix, suffix, position);
					if (acc != 0)
244
					{
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
245
						assignment.emplace(l-(multiplyer*j), std::pair<unsigned short, bool>(acc, position));
246
					}
247
				}
248
			}
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
249
		}
250 251 252 253
	}
}


Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
254
void
255
printHeader(const std::string &radiantVersion, bool pfamLike, bool translate, const fs::path &inFile, const fs::path &databaseFile, BioSeqDataLib::Output &out)
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
{
	system_clock::time_point today = system_clock::now();
	std::time_t tt;
	tt = system_clock::to_time_t(today);

	if (pfamLike)
		out << "# pfam_scan.pl, actually running RADIANT \n";
	else
	{
		out << "# RADIANT " << radiantVersion << "\n";
		out << "# RADIANT output format: 1.0\n";
	}

	out << "# run at " << ctime (&tt);
	out << "#\n";
	out << "# Options used:\n";
	out << "#-----------------------------------------------------------------------------\n";
	out << "# query file: " << fs::absolute(inFile).string()<< "\n";
	out << "# database file: " << fs::absolute(databaseFile).string() << "\n";
	out << "# translate: " << std::boolalpha << translate << "\n";
	out << "#-----------------------------------------------------------------------------\n#\n";

	if (pfamLike)
		out << "# <seq id> <alignment start> <alignment end> <envelope start> <envelope end> <hmm acc> <hmm name> <type> <hmm start> <hmm end> <hmm length> <bit score> <E-value> <significance> <clan>\n\n";
	else
		out << "# <seq id> <match start> <match end> <hmm acc> <hmm name> <type> <clan>\n\n";
}

Dr. Carsten Kemena's avatar
changes  
Dr. Carsten Kemena committed
284

285 286
int
main(int argc, char const *argv[])
Carsten Kemena's avatar
Carsten Kemena committed
287
{
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
288
	std::string radiantVersion(std::string(STR(MAJOR_VERSION)) + "." + std::string(STR(MINOR_VERSION)) + "." + std::string(STR(PATCH_VERSION)) );
Carsten Kemena's avatar
Carsten Kemena committed
289 290
	try
	{
291
		std::string in_string, out_string;
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
292 293 294 295 296 297
		fs::path inFile, databaseFile;
		//int nThreads;
		po::options_description allOpts("radiant " + radiantVersion + " (C) 2017  Carsten Kemena\nThis program comes with ABSOLUTELY NO WARRANTY;\n\nAllowed options are displayed below.");
		po::options_description general("General options");
		general.add_options()
			("help,h", "Produces this help message")
298
			("in,i", po::value<std::string>(&in_string)->required()->value_name("FILE"), "The input file")
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
299
			("database,d", po::value<fs::path>(&databaseFile)->required()->value_name("DIRECTORY"), "The path to the database")
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
300 301 302 303 304 305 306
			//("nThreads,t", po::value<int>(&nThreads)->default_value(1), "Number of threads to use")
		;

		fs::path outFile;
		bool pfamLike, noHeader;
		po::options_description outputO("Output options");
		outputO.add_options()
307
			("out,o", po::value<std::string>(&out_string)->value_name("FILE"), "The output file")
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332
			("pfam-like,p", po::value<bool>(&pfamLike)->default_value(false)->zero_tokens(), "Produces a fake Pfam format")
			("no-header,n", po::value<bool>(&noHeader)->default_value(false)->zero_tokens(), "Do not print the header")
		;

		bool translate;
		po::options_description translateO("Translate options");
		translateO.add_options()
			("translate", po::value<bool>(&translate)->default_value(false)->zero_tokens(), "Translate sequences into protein")
		;

		fs::path detailedFile;
		po::options_description hiddenO("Hidden options");
		//int w, m;
		//fs::path m, m2;
		hiddenO.add_options()
			("detailed", po::value<fs::path>(&detailedFile), "The output file for the detailed results")
		//	("window_size", po::value<int>(&w), "The window size")
		//	("match", po::value<int>(&m), "The number of matches required")
		//	("match2", po::value<fs::path>(&m2), "The number of matches required")
		;

		allOpts.add(general).add(outputO).add(translateO).add(hiddenO);
		po::options_description visible("radiant " + radiantVersion + " (C) 2017,2018  Carsten Kemena\nThis program comes with ABSOLUTELY NO WARRANTY;\n\nAllowed options are displayed below.");
		visible.add(general).add(outputO).add(translateO);

333

Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
334 335 336 337 338 339 340 341 342 343
		try
		{
			po::variables_map vm;
			po::store(po::command_line_parser(argc, argv).options(allOpts).run(), vm);
			if (vm.count("help"))
			{
				cout << visible << "\n";
				return EXIT_SUCCESS;
			}
			po::notify(vm);
344
			
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
345 346
		}
		catch (boost::program_options::error &e)
347
		{
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
348 349 350 351
			cerr << "An error occurred parsing the commandline: \n";
			cerr << e.what() << "\n";
			cerr << "Please use -h/--help for more information.\n";
			return EXIT_FAILURE;
Carsten Kemena's avatar
Carsten Kemena committed
352
		}
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
353

354 355 356
		inFile = in_string;
		outFile = out_string;

Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
357 358
		//omp_set_num_threads(nThreads);
		BSDL::SequenceSet<BSDL::Sequence<> > seqSet;
359 360 361 362 363
		BioSeqDataLib::SeqSetIOManager<BioSeqDataLib::Sequence<> > ioManager;
		ioManager.loadDefaultInputStrategies();
		seqSet = ioManager.read(inFile);

		//seqSet.read(inFile);
364

Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
365
		size_t nameLength = 0;
366
		for (auto &seq : seqSet)
367
		{
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
368 369 370 371 372 373
			if (seq.name().size() > nameLength)
				nameLength = seq.name().size();
		}

		if (translate)
		{
374
			BSDL::GeneticCode translator;
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
375 376
			BSDL::SequenceSet<BSDL::Sequence<> > newSeqSet;
			for (auto &seq : seqSet)
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
377
			{
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
378 379 380 381 382 383
				auto pair = BSDL::longestOrf(seq, {"ATG"}, {"TAA", "TAG", "TGA"}, 1);
				if (pair.first != pair.second)
				{
					if (pair.second < 0)
						BSDL::reverseComplement(seq);
					auto part = BSDL::subseq(seq, abs(pair.first), abs(pair.second));
384
					translator.translate(part);
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
385 386
					newSeqSet.push_back(std::move(part));
				}
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
387
			}
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
388
			seqSet = std::move(newSeqSet);
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
389
		}
390

Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
391
		vector<multiset<pair<size_t, pair<unsigned short, bool> > > >assignments;
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
392

Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
393 394
		assignWords(databaseFile.string() + "/forward.db", seqSet, assignments, false);
		assignWords(databaseFile.string() + "/reverse.db", seqSet, assignments, true);
395

396

Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
397
		if (!detailedFile.empty())
398
		{
399
			BioSeqDataLib::Output detailedOut(detailedFile);
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
400 401 402 403 404 405 406
			for (size_t i = 0; i< seqSet.size(); ++i)
			{
				detailedOut << ">" << seqSet[i].name() << "\n";
				for (auto pair : assignments[i])
					detailedOut << pair.first << " " << pair.second.first << " " << pair.second.second << "\n";
			}
			detailedOut.close();
407 408
		}

409

410
		std::map<std::string, DomainInfo> infoSet;
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
411 412 413 414 415 416 417 418 419 420
		try
		{
			readDomainInfo(databaseFile.string()+"/info.txt", infoSet);
		}
		catch (const std::ios_base::failure &e)
		{
			cerr << e.what() << "\n";
			exit(1);
		}

Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
421 422


Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
423 424 425 426 427 428 429 430 431 432
		/*for (size_t max_dist = 3; max_dist < 30; ++max_dist)
			for (float min_count = 0; min_count <= 0.5; min_count+=0.05 )
		{*/
			//fs::path tmp = outFile;
		//	tmp += to_string(max_dist) + "_" + to_string(min_count) + ".txt";
		//
	/*	map<unsigned short, int> domain2match;//, domain2match2;
		std::ifstream file(m.string());
		unsigned short p_id;
		int threshold;
433

Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
434
		while(!file.eof())
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
435
		{
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
436 437
		    file >> p_id >> threshold; // extracts 2 floating point values seperated by whitespace
			domain2match[p_id] = threshold;
438
		}
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
439 440 441 442 443 444 445 446 447 448
		file.close();*/
/*
		file.open(m2.string());
		while(!file.eof())
		{
			file >> p_id >> threshold; // extracts 2 floating point values seperated by whitespace
			domain2match2[p_id] = threshold;
		}
		file.close();
*/
449
		BioSeqDataLib::Output out(outFile);
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
450 451 452
		if (!noHeader)
			printHeader(radiantVersion, pfamLike, translate, inFile, databaseFile, out);
		for (size_t i = 0; i< seqSet.size(); ++i)
453
		{
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
454 455 456 457 458 459 460 461 462 463 464 465
			auto &assignment = assignments[i];
			auto da = words2arrangement(assignment, 10, 12);
			//auto da = words2arrangement(assignment, m, w);
			if (da.size() == 0)
				da = words2arrangement(assignment, 5, 7);

			//auto &assignment = assignments[i];
			//auto da = words2arrangement(assignment, domain2match, 10);
			//if (da.size() == 0)
			//	da = words2arrangement(assignment, domain2match2, 5);

			if (pfamLike)
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
466
			{
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482
				for (auto domain : da)
				{
					auto domInfo = infoSet.find(domain.accession());
					out << std::left << setw(nameLength) << seqSet[i].name() << " " << std::right << setw(6)  << domain.start()+1 << " " << setw(6) << domain.end()+1  \
					 << " " << std::right << setw(6) << domain.start() << " " << setw(6) << domain.end() << " " \
					 <<  domain.accession() << std::left << " " << setw(15) << domInfo->second.name << " " << setw(11) << domInfo->second.type << " 0 0 0 0 0 0 " << domInfo->second.clan << "\n";
				}
			}
			else
			{
				for (auto domain : da)
				{
					auto domInfo = infoSet.find(domain.accession());
					out << std::left << setw(nameLength) << seqSet[i].name() << " " << std::right << setw(6) << domain.start()+1 << " " << setw(6) << domain.end()+1 << " " <<
						domain.accession() << std::left << " " << setw(15) << domInfo->second.name << " " << setw(11) << domInfo->second.type << " " << domInfo->second.clan << "\n";
				}
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
483
			}
484
		}
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
485 486 487 488 489 490
	//}*/
	}
	catch (std::bad_alloc& ba)
	{
    	std::cerr << "Error! A memory allocation was caught: Please check if you have enough RAM on this machine\n";
		return 1;
491
	}
Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
492 493
	catch (const std::exception &e)
	{
494

Dr. Carsten Kemena's avatar
Dr. Carsten Kemena committed
495 496 497 498 499 500 501 502 503 504
		cerr << "Error! Please be so kind and report the error including the message below to the developers (c.kemena@wwu.de) and include, if possible, the data set you used." << endl;
		cerr << "Error: " << e.what() << endl;
		cerr << "RADIANT version: " << radiantVersion << "\n";
		cerr << "commandline: ";
		cerr << argv[0];
		for (int i = 1; i<argc; ++i)
			cerr << " " << argv[i];
		cerr << "\n";
		return 1;
	}
Carsten Kemena's avatar
Carsten Kemena committed
505
	return 0;
506
}