Commit f1ead48d authored by Julien Y. Dutheil's avatar Julien Y. Dutheil

New upstream version 2.4.0

parent 5a876b51
......@@ -35,7 +35,7 @@ ELSE(NO_DEP_CHECK)
# library implements.
# In other words, the library implements all the interface numbers in the
# range from number current - age to current.
SET(${PROJECT_NAME}_VERSION_CURRENT "2")
SET(${PROJECT_NAME}_VERSION_CURRENT "3")
SET(${PROJECT_NAME}_VERSION_REVISION "0")
SET(${PROJECT_NAME}_VERSION_AGE "0")
......@@ -53,7 +53,7 @@ if (CMAKE_INSTALL_PREFIX)
endif (CMAKE_INSTALL_PREFIX)
include (GNUInstallDirs)
find_package (bpp-seq 11.0.0 REQUIRED)
find_package (bpp-seq 12.0.0 REQUIRED)
# CMake package
set (cmake-package-location ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
......@@ -95,10 +95,10 @@ ENDIF(NO_DEP_CHECK)
# Packager
SET(CPACK_PACKAGE_NAME "libbpp-seq-omics")
SET(CPACK_PACKAGE_VENDOR "Bio++ Development Team")
SET(CPACK_PACKAGE_VERSION "2.3.1")
SET(CPACK_PACKAGE_VERSION "2.4.0")
SET(CPACK_PACKAGE_VERSION_MAJOR "2")
SET(CPACK_PACKAGE_VERSION_MINOR "3")
SET(CPACK_PACKAGE_VERSION_PATCH "1")
SET(CPACK_PACKAGE_VERSION_MINOR "4")
SET(CPACK_PACKAGE_VERSION_PATCH "0")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The Bio++ Sequence-Omics library")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING.txt")
SET(CPACK_RESOURCE_FILE_AUTHORS "${CMAKE_SOURCE_DIR}/AUTHORS.txt")
......@@ -107,6 +107,8 @@ SET(CPACK_SOURCE_GENERATOR "TGZ")
# /!\ This assumes that an external build is used
SET(CPACK_SOURCE_IGNORE_FILES
"/build/"
"/html/"
"/BppSeqOmics.tag"
"/\\\\.git/"
"/\\\\.gitignore"
${CPACK_SOURCE_IGNORE_FILES}
......
02/03/18 -*- Version 2.4.0 -*-
02/03/18 Julien Dutheil
* Removed all dynamic exception specifications
* Increased interface number to 3
21/01/18 Julien Dutheil
* Added OrderFilterMafIterator class.
03/01/18 Julien Dutheil
* Fixed bug in AlnFilter when relative proportions are set. Proportion was relative to block and not to window, which was incorrect.
22/12/17 Julien Dutheil
* Improved GTF parser, bug fixed when empty token in last column.
10/12/17 -*- Version 2.3.2 -*-
10/05/17 -*- Version 2.3.0 -*-
......
......@@ -38,7 +38,7 @@ PROJECT_NAME = bpp-seq-omics
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = 2.3.0
PROJECT_NUMBER = 2.4.0
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
......
%define _basename bpp-seq-omics
%define _version 2.3.1
%define _release 1
%define _prefix /usr
URL: http://biopp.univ-montp2.fr/
URL: https://github.com/BioPP/bpp-seq-omics
Name: %{_basename}
Version: %{_version}
Release: %{_release}
Name: bpp-seq-omics
Version: 2.4.0
Release: 1%{?dist}
License: CECILL-2.0
Vendor: The Bio++ Project
Source: http://biopp.univ-montp2.fr/repos/sources/%{_basename}-%{_version}.tar.gz
Source: %{name}-%{version}.tar.gz
Summary: Bio++ Sequence library: genomics components
Group: Development/Libraries/C and C++
Requires: bpp-core = %{_version}
Requires: bpp-seq = %{_version}
Requires: bpp-core = %{version}
Requires: bpp-seq = %{version}
BuildRoot: %{_builddir}/%{_basename}-root
BuildRoot: %{_builddir}/%{name}-root
BuildRequires: cmake >= 2.8.11
BuildRequires: gcc-c++ >= 4.7.0
BuildRequires: libbpp-core3 = %{_version}
BuildRequires: libbpp-core-devel = %{_version}
BuildRequires: libbpp-seq11 = %{_version}
BuildRequires: libbpp-seq-devel = %{_version}
BuildRequires: libbpp-core4 = %{version}
BuildRequires: libbpp-core-devel = %{version}
BuildRequires: libbpp-seq12 = %{version}
BuildRequires: libbpp-seq-devel = %{version}
AutoReq: yes
AutoProv: yes
......@@ -31,26 +28,26 @@ AutoProv: yes
This library contains the genomics components of the Bio++ sequence library.
It is part of the Bio++ project.
%package -n libbpp-seq-omics2
%package -n libbpp-seq-omics3
Summary: Bio++ Sequence library: genomics components
Group: Development/Libraries/C and C++
%description -n libbpp-seq-omics2
%description -n libbpp-seq-omics3
This library contains the genomics components of the Bio++ sequence library.
It is part of the Bio++ project.
%package -n libbpp-seq-omics-devel
Summary: Bio++ Sequence library: genomics components
Group: Development/Libraries/C and C++
Requires: libbpp-seq-omics2 = %{_version}
Requires: libbpp-seq11 = %{_version}
Requires: libbpp-seq-devel = %{_version}
Requires: libbpp-core3 = %{_version}
Requires: libbpp-core-devel = %{_version}
Requires: libbpp-seq-omics3 = %{version}
Requires: libbpp-seq12 = %{version}
Requires: libbpp-seq-devel = %{version}
Requires: libbpp-core4 = %{version}
Requires: libbpp-core-devel = %{version}
%description -n libbpp-seq-omics-devel
The libbpp-seq-omics-devel package contains the header files and static libraries for
building applications which use %{_basename}.
building applications which use %{name}.
%prep
%setup -q
......@@ -67,11 +64,11 @@ make DESTDIR=$RPM_BUILD_ROOT install
%clean
rm -rf $RPM_BUILD_ROOT
%post -n libbpp-seq-omics2 -p /sbin/ldconfig
%post -n libbpp-seq-omics3 -p /sbin/ldconfig
%postun -n libbpp-seq-omics2 -p /sbin/ldconfig
%postun -n libbpp-seq-omics3 -p /sbin/ldconfig
%files -n libbpp-seq-omics2
%files -n libbpp-seq-omics3
%defattr(-,root,root)
%doc AUTHORS.txt COPYING.txt INSTALL.txt ChangeLog
%{_prefix}/%{_lib}/lib*.so.*
......@@ -87,6 +84,9 @@ rm -rf $RPM_BUILD_ROOT
%{_prefix}/include/*
%changelog
* Fri Mar 03 2018 Julien Dutheil <julien.dutheil@univ-montp2.fr> 2.4.0-1
- Increased interface number
- Removed dynamic exceptions declarations.
* Tue Jun 06 2017 Julien Dutheil <julien.dutheil@univ-montp2.fr> 2.3.1-1
- Increased interface number
* Wed May 10 2017 Julien Dutheil <julien.dutheil@univ-montp2.fr> 2.3.0-1
......
......@@ -66,7 +66,7 @@ void BedGraphFeatureReader::getNextLine_() {
}
}
const BasicSequenceFeature BedGraphFeatureReader::nextFeature() throw (Exception)
const BasicSequenceFeature BedGraphFeatureReader::nextFeature()
{
if (!hasMoreFeature())
throw Exception("BedGraphFeatureReader::nextFeature(). No more feature in file.");
......
......@@ -92,7 +92,7 @@ class BedGraphFeatureReader:
public:
bool hasMoreFeature() const { return nextLine_ != ""; }
const BasicSequenceFeature nextFeature() throw (Exception);
const BasicSequenceFeature nextFeature();
void getAllFeatures(SequenceFeatureSet& features) {
while (hasMoreFeature()) {
......
......@@ -64,7 +64,7 @@ class FeatureReader
public:
virtual bool hasMoreFeature() const = 0;
virtual const BasicSequenceFeature nextFeature() throw (Exception) = 0;
virtual const BasicSequenceFeature nextFeature() = 0;
virtual void getAllFeatures(SequenceFeatureSet& features) = 0;
virtual void getFeaturesOfType(const std::string& type, SequenceFeatureSet& features) = 0;
virtual void getFeaturesOfSequence(const std::string& seqId, SequenceFeatureSet& features) = 0;
......
......@@ -76,7 +76,7 @@ void GffFeatureReader::getNextLine_() {
}
}
const BasicSequenceFeature GffFeatureReader::nextFeature() throw (Exception)
const BasicSequenceFeature GffFeatureReader::nextFeature()
{
if (!hasMoreFeature())
throw Exception("GffFeatureReader::nextFeature(). No more feature in file.");
......
......@@ -93,7 +93,7 @@ class GffFeatureReader:
public:
bool hasMoreFeature() const { return nextLine_ != ""; }
const BasicSequenceFeature nextFeature() throw (Exception);
const BasicSequenceFeature nextFeature();
void getAllFeatures(SequenceFeatureSet& features) {
while (hasMoreFeature()) {
......
......@@ -51,9 +51,9 @@ knowledge of the CeCILL license and that you accept its terms.
using namespace bpp;
using namespace std;
const std::string GtfFeatureReader::GTF_PHASE = "GTF_PHASE";
const std::string GtfFeatureReader::GTF_GENE_ID = "gene_id";
const std::string GtfFeatureReader::GTF_TRANSCRIPT_ID = "transcript_id";
const string GtfFeatureReader::GTF_PHASE = "GTF_PHASE";
const string GtfFeatureReader::GTF_GENE_ID = "gene_id";
const string GtfFeatureReader::GTF_TRANSCRIPT_ID = "transcript_id";
void GtfFeatureReader::getNextLine_() {
nextLine_ = "";
......@@ -70,7 +70,7 @@ void GtfFeatureReader::getNextLine_() {
}
}
const BasicSequenceFeature GtfFeatureReader::nextFeature() throw (Exception)
const BasicSequenceFeature GtfFeatureReader::nextFeature()
{
if (!hasMoreFeature())
throw Exception("GtfFeatureReader::nextFeature(). No more feature in file.");
......@@ -81,28 +81,30 @@ const BasicSequenceFeature GtfFeatureReader::nextFeature() throw (Exception)
throw Exception("GtfFeatureReader::nextFeature(). Wrong GTF file format: should have 9 tab delimited columns.");
//if ok, we can parse each column:
std::string seqId = st.nextToken();
std::string source = st.nextToken();
std::string type = st.nextToken();
unsigned int start = TextTools::to<unsigned int>(st.nextToken()) - 1;
unsigned int end = TextTools::to<unsigned int>(st.nextToken());
double score = TextTools::to<double>(st.nextToken());
std::string strand = st.nextToken();
std::string phase = st.nextToken();
std::string attrDesc = st.nextToken();
std::map<string, string> attributes;
bpp::StringTokenizer st1(attrDesc, ";");
string seqId = st.nextToken();
string source = st.nextToken();
string type = st.nextToken();
unsigned int start = TextTools::to<unsigned int>(st.nextToken()) - 1;
unsigned int end = TextTools::to<unsigned int>(st.nextToken());
double score = TextTools::to<double>(st.nextToken());
string strand = st.nextToken();
string phase = st.nextToken();
string attrDesc = st.nextToken();
map<string, string> attributes;
StringTokenizer st1(attrDesc, ";");
while (st1.hasMoreToken()) {
std::string item(bpp::TextTools::removeSurroundingWhiteSpaces(st1.nextToken()));
std::string::size_type idx = item.find_first_of(' ');
std::string key(item.substr(0, idx));
std::string value(item.substr(idx));
string item(st1.nextToken());
if (TextTools::isEmpty(item)) continue;
item = TextTools::removeSurroundingWhiteSpaces(item);
string::size_type idx = item.find_first_of(' ');
string key(item.substr(0, idx));
string value(item.substr(idx));
// remove first "
while (
value.size() > 0
&& (
value[0] == '"'
|| bpp::TextTools::isWhiteSpaceCharacter(value[0])
|| TextTools::isWhiteSpaceCharacter(value[0])
)
) {
value.erase(value.begin());
......@@ -112,7 +114,7 @@ const BasicSequenceFeature GtfFeatureReader::nextFeature() throw (Exception)
value.size() > 0
&& (
value[value.size() - 1] == '"'
|| bpp::TextTools::isWhiteSpaceCharacter(value[value.size() - 1])
|| TextTools::isWhiteSpaceCharacter(value[value.size() - 1])
)
) {
value.erase(value.end() - 1);
......@@ -122,15 +124,15 @@ const BasicSequenceFeature GtfFeatureReader::nextFeature() throw (Exception)
}
//KeyvalTools::multipleKeyvals(attrDesc, attributes, ";", false);
//std::string id = attributes["ID"];
std::string id = "";
string id = "";
BasicSequenceFeature feature(id, seqId, source, type, start, end, strand[0], score);
//Set phase attributes:
phase = bpp::TextTools::removeSurroundingWhiteSpaces(phase);
phase = TextTools::removeSurroundingWhiteSpaces(phase);
if (phase != ".") feature.setAttribute(GTF_PHASE, phase);
//now check additional attributes:
for (std::map<std::string, std::string>::iterator it = attributes.begin(); it != attributes.end(); ++it) {
for (map<std::string, std::string>::iterator it = attributes.begin(); it != attributes.end(); ++it) {
feature.setAttribute(it->first, it->second); //We accept all attributes, even if they are not standard.
//std::cout << "[" << it->first << "] = [" << it->second << "]" << std::endl;
//std::cout << "phase: " << phase << std::endl;
......
......@@ -84,7 +84,7 @@ class GtfFeatureReader:
public:
bool hasMoreFeature() const { return nextLine_ != ""; }
const BasicSequenceFeature nextFeature() throw (Exception);
const BasicSequenceFeature nextFeature();
void getAllFeatures(SequenceFeatureSet& features) {
while (hasMoreFeature()) {
......
......@@ -44,7 +44,7 @@ knowledge of the CeCILL license and that you accept its terms.
using namespace bpp;
bool Fastq::nextSequence(std::istream& input, Sequence& seq) const throw (Exception) {
bool Fastq::nextSequence(std::istream& input, Sequence& seq) const {
if (input && ! input.eof()) {
//SequenceWithQuality& sq;
std::string buffer;
......@@ -85,7 +85,7 @@ bool Fastq::nextSequence(std::istream& input, Sequence& seq) const throw (Except
/******************************************************************************/
void Fastq::writeSequence(std::ostream& output, const Sequence& seq) const throw (Exception)
void Fastq::writeSequence(std::ostream& output, const Sequence& seq) const
{
std::string qual(seq.size(), static_cast<char>(33));
try {
......
......@@ -118,7 +118,7 @@ namespace bpp
* in.close();
* @endcode
*/
bool nextSequence(std::istream& input, Sequence& seq) const throw (Exception);
bool nextSequence(std::istream& input, Sequence& seq) const;
/** @} */
/**
......@@ -130,7 +130,7 @@ namespace bpp
* @copydoc OSequenceStream::writeSequence()
* @author Sylvain Gaillard
*/
void writeSequence(std::ostream& output, const Sequence& seq) const throw (Exception);
void writeSequence(std::ostream& output, const Sequence& seq) const;
/** @} */
};
}
......
......@@ -47,7 +47,7 @@ using namespace bpp;
using namespace std;
MafBlock* AlignmentFilterMafIterator::analyseCurrentBlock_() throw (Exception)
MafBlock* AlignmentFilterMafIterator::analyseCurrentBlock_()
{
if (blockBuffer_.size() == 0) {
//Else there is no more block in the buffer, we need to parse more:
......@@ -125,7 +125,7 @@ MafBlock* AlignmentFilterMafIterator::analyseCurrentBlock_() throw (Exception)
}
bool test = (sumEnt / static_cast<double>(windowSize_)) > maxEnt_;
if (relative_) {
double propGap = static_cast<double>(sumGap) / static_cast<double>(nr * nc);
double propGap = static_cast<double>(sumGap) / static_cast<double>(nr * windowSize_);
test = test && (propGap > maxPropGap_);
} else {
test = test && (sumGap > maxGap_);
......@@ -170,7 +170,7 @@ MafBlock* AlignmentFilterMafIterator::analyseCurrentBlock_() throw (Exception)
}
bool test = (sumEnt / static_cast<double>(windowSize_)) > maxEnt_;
if (relative_) {
double propGap = static_cast<double>(sumGap) / static_cast<double>(nr);
double propGap = static_cast<double>(sumGap) / static_cast<double>(nr * windowSize_);
test = test && (propGap > maxPropGap_);
} else {
test = test && (sumGap > maxGap_);
......@@ -271,7 +271,7 @@ MafBlock* AlignmentFilterMafIterator::analyseCurrentBlock_() throw (Exception)
return block;
}
MafBlock* AlignmentFilter2MafIterator::analyseCurrentBlock_() throw (Exception)
MafBlock* AlignmentFilter2MafIterator::analyseCurrentBlock_()
{
if (blockBuffer_.size() == 0) {
//Else there is no more block in the buffer, we need to parse more:
......
......@@ -154,7 +154,7 @@ class AlignmentFilterMafIterator:
public:
MafBlock* nextRemovedBlock() throw (Exception) {
MafBlock* nextRemovedBlock() {
if (trashBuffer_.size() == 0) return 0;
MafBlock* block = trashBuffer_.front();
trashBuffer_.pop_front();
......@@ -162,7 +162,7 @@ class AlignmentFilterMafIterator:
}
private:
MafBlock* analyseCurrentBlock_() throw (Exception);
MafBlock* analyseCurrentBlock_();
};
/**
......@@ -251,7 +251,7 @@ class AlignmentFilter2MafIterator:
{}
public:
MafBlock* nextRemovedBlock() throw (Exception) {
MafBlock* nextRemovedBlock() {
if (trashBuffer_.size() == 0) return 0;
MafBlock* block = trashBuffer_.front();
trashBuffer_.pop_front();
......@@ -259,7 +259,7 @@ class AlignmentFilter2MafIterator:
}
private:
MafBlock* analyseCurrentBlock_() throw (Exception);
MafBlock* analyseCurrentBlock_();
};
......
......@@ -47,7 +47,7 @@ using namespace bpp;
using namespace std;
MafBlock* BlockMergerMafIterator::analyseCurrentBlock_() throw (Exception)
MafBlock* BlockMergerMafIterator::analyseCurrentBlock_()
{
if (!incomingBlock_) return 0;
currentBlock_ = incomingBlock_;
......@@ -124,7 +124,15 @@ MafBlock* BlockMergerMafIterator::analyseCurrentBlock_() throw (Exception)
seq->append(vector<int>(globalSpace, AlphabetTools::DNA_ALPHABET.getUnknownCharacterCode()));
}
if (seq->getChromosome() != tmp->getChromosome()) {
seq->setChromosome(seq->getChromosome() + "-" + tmp->getChromosome());
if (renameChimericChromosomes_) {
if (seq->getChromosome().substr(0, 7) != "chimtig") {
//Creates a new chimeric chromosome for this species:
chimericChromosomeCounts_[seq->getSpecies()]++;
seq->setChromosome("chimtig" + TextTools::toString(chimericChromosomeCounts_[seq->getSpecies()]));
}
} else {
seq->setChromosome(seq->getChromosome() + "-" + tmp->getChromosome());
}
seq->removeCoordinates();
}
if (seq->getStrand() != tmp->getStrand()) {
......
......@@ -66,16 +66,20 @@ class BlockMergerMafIterator:
private:
std::vector<std::string> species_;
MafBlock* incomingBlock_;
std::vector<std::string> ignoreChrs_; //These chromsomes will never be merged (ex: 'Un').
std::vector<std::string> ignoreChrs_; //These chromosomes will never be merged (ex: 'Un').
unsigned int maxDist_;
bool renameChimericChromosomes_;
std::map<std::string, unsigned int> chimericChromosomeCounts_;
public:
BlockMergerMafIterator(MafIterator* iterator, const std::vector<std::string>& species, unsigned int maxDist = 0) :
BlockMergerMafIterator(MafIterator* iterator, const std::vector<std::string>& species, unsigned int maxDist = 0, bool renameChimericChromosomes = false) :
AbstractFilterMafIterator(iterator),
species_(species),
incomingBlock_(0),
ignoreChrs_(),
maxDist_(maxDist)
maxDist_(maxDist),
renameChimericChromosomes_(renameChimericChromosomes),
chimericChromosomeCounts_()
{
incomingBlock_ = iterator->nextBlock();
}
......@@ -86,15 +90,19 @@ class BlockMergerMafIterator:
species_(iterator.species_),
incomingBlock_(iterator.incomingBlock_),
ignoreChrs_(iterator.ignoreChrs_),
maxDist_(iterator.maxDist_)
maxDist_(iterator.maxDist_),
renameChimericChromosomes_(iterator.renameChimericChromosomes_),
chimericChromosomeCounts_(iterator.chimericChromosomeCounts_)
{}
BlockMergerMafIterator& operator=(const BlockMergerMafIterator& iterator)
{
species_ = iterator.species_;
incomingBlock_ = iterator.incomingBlock_;
ignoreChrs_ = iterator.ignoreChrs_;
maxDist_ = iterator.maxDist_;
species_ = iterator.species_;
incomingBlock_ = iterator.incomingBlock_;
ignoreChrs_ = iterator.ignoreChrs_;
maxDist_ = iterator.maxDist_;
renameChimericChromosomes_ = iterator.renameChimericChromosomes_;
chimericChromosomeCounts_ = iterator.chimericChromosomeCounts_;
return *this;
}
......@@ -108,7 +116,7 @@ class BlockMergerMafIterator:
}
private:
MafBlock* analyseCurrentBlock_() throw (Exception);
MafBlock* analyseCurrentBlock_();
};
......
......@@ -47,7 +47,7 @@ using namespace bpp;
using namespace std;
MafBlock* ChromosomeMafIterator::analyseCurrentBlock_() throw (Exception)
MafBlock* ChromosomeMafIterator::analyseCurrentBlock_()
{
currentBlock_ = iterator_->nextBlock();
while (currentBlock_) {
......
......@@ -86,7 +86,7 @@ class ChromosomeMafIterator:
}
private:
MafBlock* analyseCurrentBlock_() throw (Exception);
MafBlock* analyseCurrentBlock_();
};
......
......@@ -50,7 +50,7 @@ using namespace bpp;
using namespace std;
MafBlock* ConcatenateMafIterator::analyseCurrentBlock_() throw (Exception)
MafBlock* ConcatenateMafIterator::analyseCurrentBlock_()
{
if (!incomingBlock_) return 0;
currentBlock_ = incomingBlock_;
......
......@@ -92,7 +92,7 @@ class ConcatenateMafIterator:
}
private:
MafBlock* analyseCurrentBlock_() throw (Exception);
MafBlock* analyseCurrentBlock_();
};
......
......@@ -51,7 +51,7 @@ using namespace bpp;
using namespace std;
MafBlock* CoordinateTranslatorMafIterator::analyseCurrentBlock_() throw (Exception)
MafBlock* CoordinateTranslatorMafIterator::analyseCurrentBlock_()
{
unique_ptr<MafBlock> block(iterator_->nextBlock());
if (!block.get()) return 0; //No more block.
......@@ -107,6 +107,7 @@ MafBlock* CoordinateTranslatorMafIterator::analyseCurrentBlock_() throw (Excepti
(*logstream_ << "COORDINATE CONVERTOR: lifting over " << ranges.getSet().size() << " features from block " << block->getDescription() << ".").endLine();
}
const Alphabet* alphabet = refSeq.getAlphabet();
size_t i = 0;
for (set<Range<size_t>*>::iterator it = ranges.getSet().begin();
it != ranges.getSet().end();
......@@ -117,14 +118,23 @@ MafBlock* CoordinateTranslatorMafIterator::analyseCurrentBlock_() throw (Excepti
}
size_t a = referenceWalker.getAlignmentPosition((**it).begin() - refSeq.start());
size_t b = referenceWalker.getAlignmentPosition((**it).end() - refSeq.start() - 1);
size_t a2 = targetWalker.getSequencePosition(a) + targetSeq.start();
size_t b2 = targetWalker.getSequencePosition(b) + targetSeq.start() + 1;
if (targetSeq.getStrand() == '-') {
a2 = targetSeq.getSrcSize() - a2;
b2 = targetSeq.getSrcSize() - b2;
string targetPos1 = "NA", targetPos2 = "NA";
if (!alphabet->isGap(targetSeq[a]) || outputClosestCoordinate_) {
size_t a2 = targetWalker.getSequencePosition(a) + targetSeq.start();
if (targetSeq.getStrand() == '-') {
a2 = targetSeq.getSrcSize() - a2;
}
targetPos1 = TextTools::toString(a2);
}
if (!alphabet->isGap(targetSeq[b]) || outputClosestCoordinate_) {
size_t b2 = targetWalker.getSequencePosition(b) + targetSeq.start() + 1;
if (targetSeq.getStrand() == '-') {
b2 = targetSeq.getSrcSize() - b2;
}
targetPos2 = TextTools::toString(b2);
}
output_ << refSeq.getChromosome() << "\t" << refSeq.getStrand() << "\t" << (**it).begin() << "\t" << (**it).end() << "\t";
output_ << targetSeq.getChromosome() << "\t" << targetSeq.getStrand() << "\t" << a2 << "\t" << b2 << endl;
output_ << targetSeq.getChromosome() << "\t" << targetSeq.getStrand() << "\t" << targetPos1 << "\t" << targetPos2 << endl;
}
if (verbose_)
......
......@@ -66,6 +66,7 @@ class CoordinateTranslatorMafIterator:
std::string targetSpecies_;
std::map<std::string, SequenceFeatureSet*> inputFeaturesPerChr_;
std::ostream& output_;
bool outputClosestCoordinate_;
public:
/**
......@@ -76,18 +77,22 @@ class CoordinateTranslatorMafIterator:
* @param targetSpecies The target species for which features coordinates should be translated
* @param features The set of features to lift over
* @param output Output stream for translated coordinates
* @param outputClosestCoordinate In case the target sequence has a gap at the corresponding position,
* tells if the previous non-gap position should be returned, or NA.
*/
CoordinateTranslatorMafIterator(
MafIterator* iterator,
const std::string& referenceSpecies,
const std::string& targetSpecies,
const SequenceFeatureSet& features,
std::ostream& output) :
std::ostream& output,
bool outputClosestCoordinate = true) :
AbstractFilterMafIterator(iterator),
referenceSpecies_(referenceSpecies),
targetSpecies_(targetSpecies),
inputFeaturesPerChr_(),
output_(output)
output_(output),
outputClosestCoordinate_(outputClosestCoordinate)
{
//Sort features per chromosome for a faster access:
std::set<std::string> seqIds = features.getSequences();
......@@ -111,7 +116,7 @@ class CoordinateTranslatorMafIterator:
}
private:
MafBlock* analyseCurrentBlock_() throw (Exception);
MafBlock* analyseCurrentBlock_();
};
......
......@@ -54,7 +54,7 @@ void CoordinatesOutputMafIterator::writeHeader_(ostream& out) const
out << endl;
}
MafBlock* CoordinatesOutputMafIterator::analyseCurrentBlock_() throw (Exception)
MafBlock* CoordinatesOutputMafIterator::analyseCurrentBlock_()
{
currentBlock_ = iterator_->nextBlock();
if (currentBlock_) {
......
......@@ -97,7 +97,7 @@ class CoordinatesOutputMafIterator:
private:
void writeHeader_(std::ostream& out) const;
MafBlock* analyseCurrentBlock_() throw (Exception);
MafBlock* analyseCurrentBlock_();
};
......
......@@ -47,7 +47,7 @@ using namespace bpp;
using namespace std;
MafBlock* DuplicateFilterMafIterator::analyseCurrentBlock_() throw (Exception)
MafBlock* DuplicateFilterMafIterator::analyseCurrentBlock_()
{
currentBlock_ = iterator_->nextBlock();
while (currentBlock_) {
......
......@@ -88,7 +88,7 @@ class DuplicateFilterMafIterator:
}
private:
MafBlock* analyseCurrentBlock_() throw (Exception);
MafBlock* analyseCurrentBlock_();
};
......
......@@ -47,7 +47,7 @@ using namespace bpp;
using namespace std;
MafBlock* EntropyFilterMafIterator::analyseCurrentBlock_() throw (Exception)
MafBlock* EntropyFilterMafIterator::analyseCurrentBlock_()
{
if (blockBuffer_.size() == 0) {
//Else there is no more block in the buffer, we need to parse more:
......