diff -U 3 -H -d -r -N -- old/main.cpp new/main.cpp
--- old/main.cpp	2008-05-14 14:00:26.000000000 +0200
+++ new/main.cpp	2008-06-22 03:05:26.000000000 +0200
@@ -96,7 +96,7 @@
 static const string SCALE = "....,....1....,....2....,....3....,....4....,....5....,....6....,....7....,....8\n";
 
 void alignMultiple(deque<RNAProfileAlignment*> &alignList, Score &score,const RNAforesterOptions &options);
-void alignPairwise(deque<RNAForest*> &inputListPW,Score &score,const RNAforesterOptions &options);
+void alignPairwise(deque<RNAForest*> &inputListPW,Score &score,const RNAforesterOptions &options, bool deleteInput = true);
 void cutAfterChar(string &s,char c);
 
 void editPairwise(list<RNAForestSZ*> &inputListSZ,Score &score,RNAforesterOptions &options);
@@ -114,6 +114,7 @@
 	string baseStr,viennaStr,nameStr;
 	Ulong basePairCount,maxDepth;
 	deque<RNAForest*> inputListPW;
+	deque<RNAForest*> databaseListPW;
 	deque<RNAProfileAlignment*> alignList;
 	bool showScale=true,multipleAlign=false;
 	istream *inputStream=NULL;
@@ -215,6 +216,85 @@
 		    showScale=false;
 		  }
 
+		// load database
+	      if(options.has(RNAforesterOptions::Database))
+		{
+		  string filename;
+  
+		  options.get(RNAforesterOptions::Database,filename,string(""));		    		    
+		  ifstream *inputStream=new ifstream(filename.c_str());
+		  if(inputStream->fail())
+		  {
+			  cerr << "cannot open file: \"" << filename << "\"" << endl;
+			  exit(EXIT_FAILURE);
+		  }
+		  for(;;) {
+			  getline(*inputStream,buffer);
+
+			  if(inputStream->eof()) {			    
+			    break;
+			  }
+			  
+			  if(buffer.empty()) continue;
+
+			  // delete '\r' at line end from non unix files
+			  if(buffer[buffer.size()-1]=='\r')
+				  buffer.erase(buffer.size()-1);
+
+			  // check for name of structure
+			  if(buffer[0]=='>') {
+				  nameStr=&buffer[1];
+				  continue;
+			  }
+
+			  // cut after blank
+			  cutAfterChar(buffer,' ');
+
+			  if(RNAFuncs::isRNAString(buffer)) {
+			      baseStr=buffer;
+			      // convert to small letters
+			      transform(baseStr.begin(),baseStr.end(),baseStr.begin(),ToLower());
+			      // t -> u
+			      replace(baseStr.begin(),baseStr.end(),'t','u');
+			      // delete '.'  and '-' from alignment files
+			      remove(baseStr.begin(),baseStr.end(),'.');
+			      remove(baseStr.begin(),baseStr.end(),'-');
+			  } else {
+			      if(RNAFuncs::isViennaString(buffer,basePairCount,maxDepth)) {
+				viennaStr=buffer;	       
+			      } else { 
+				  cerr << "The input sequence is neither an RNA/DNA string nor in vienna format." << endl;
+				  cerr << "line: " << buffer << endl;
+				  exit(EXIT_FAILURE);
+			      }
+
+			      // add structure to input list
+				if(options.has(RNAforesterOptions::TreeEdit)) {
+				  cerr << "TreeEdit search against database is not supported!" << endl;
+				  exit(EXIT_FAILURE);
+				}
+				else
+				  {
+				    RNAForest *rnaForest=new RNAForest(baseStr,viennaStr,nameStr);			
+				    nameStr="";
+				    //makeDotFileInp(*rnaForest,options,structure_count);
+				    databaseListPW.push_back(rnaForest);
+				  }
+
+			      structure_count++;      
+			  }
+		  }
+/*
+		    deque<RNAForest*>::const_iterator it;
+		    for(it = databaseListPW.begin(); it!=databaseListPW.end(); it++) {
+		      cout << "it: " << *it << endl;
+		    }
+*/
+		    //inputListPW.clear();
+
+		    structure_count = 0;
+		}
+
 		for(;;)
 		{
 			getline(*inputStream,buffer);
@@ -389,6 +469,27 @@
 			  break;
 			}
 
+			// ***** database pairwise alignment
+			if(inputListPW.size()==1 && RNAforesterOptions::Database) {
+
+			  deque<RNAForest*> tempList;
+			  RNAForest* small = inputListPW[0];
+			  deque<RNAForest*>::const_iterator it;
+//			  cout << "database count: " << databaseListPW.size() << endl;
+			  int item_pos = 0;
+			  for(it = databaseListPW.begin(); it!=databaseListPW.end(); it++) {
+			    cout << "Database item: " << item_pos++ << " : " << (*it)->getName() << endl;
+			    tempList.clear();
+			    tempList.push_back(small);
+			    tempList.push_back(*it);
+			    if(options.has(RNAforesterOptions::GlobalAlignment))
+			      alignPairwiseSimple(tempList,score,options);
+			    else
+			      alignPairwise(tempList,score,options,false);
+			    delete *it;
+			  }
+			}
+
 		}
 
 		// free dynamic allocated memory
@@ -565,7 +666,7 @@
 }
 
 
-void alignPairwise(deque<RNAForest*> &inputListPW,Score &score,const RNAforesterOptions &options)
+void alignPairwise(deque<RNAForest*> &inputListPW,Score &score,const RNAforesterOptions &options,bool deleteInputList)
 {
 	IntScoreRNA_AlgebraType *alg;
 	Uint xbasepos,ybasepos,xlen,ylen;
@@ -847,10 +948,12 @@
 #endif	
 
 	// clear input list
+	if( deleteInputList ) {
 	deque<RNAForest*>::const_iterator it;
-	for(it = inputListPW.begin(); it!=inputListPW.end(); it++)
-		delete *it;
-	inputListPW.clear();
+	  for(it = inputListPW.begin(); it!=inputListPW.end(); it++)
+		  delete *it;
+	  inputListPW.clear();
+	}
 	delete alg;
 }
 
diff -U 3 -H -d -r -N -- old/rnaforester_options.cpp new/rnaforester_options.cpp
--- old/rnaforester_options.cpp	2005-08-05 14:35:01.000000000 +0200
+++ new/rnaforester_options.cpp	2008-05-14 12:59:18.000000000 +0200
@@ -31,6 +31,7 @@
 
 	setOption(Help,                      "--help","","                    ","shows this help info",false);
 	setOption(Version,                   "--version","","                 ","shows version information",false);
+	setOption(Database,                  "--database","=file","           ","searches structure against database",false);
 	setOption(OutputAlignmentDotFormat,  "-dot","=file","                 ","show alignment forest in dot format",true);
 	setOption(CalculateDistance,         "-d","","                        ","calculate distance instead of similarity",false);
 	setOption(RelativeScore,             "-r","","                        ","calculate relative score",false);
diff -U 3 -H -d -r -N -- old/rnaforester_options.h new/rnaforester_options.h
--- old/rnaforester_options.h	2006-05-08 13:48:51.000000000 +0200
+++ new/rnaforester_options.h	2008-05-14 12:58:17.000000000 +0200
@@ -30,6 +30,7 @@
   {
     Help=0,
     Version,
+    Database,
     OutputAlignmentDotFormat,
     CalculateDistance,
     RelativeScore,
