TrimSequence.cpp

00001 /*
00002  *  Copyright (C) 2010  Regents of the University of Michigan
00003  *
00004  *   This program is free software: you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation, either version 3 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   This program is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 #include "TrimSequence.h"
00019 
00020 #if defined(TEST)
00021 
00022 #include <assert.h>
00023 #include <iostream>
00024 #include <stdlib.h>
00025 #include <string>
00026 
00027 int main(int argc, const char **argv)
00028 {
00029     std::string test;
00030     std::string::iterator result;
00031 
00032     //
00033     // from the left:
00034     //
00035     test = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
00036     result = trimSequence(test, 'A', true);
00037     assert(result == test.begin());
00038 
00039     test = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
00040     result = trimSequence(test, '~', true);
00041     assert(result == test.end());
00042 
00043     test = "AAAAABCDEFGHIJKLMNOPQRSTUVWXYZ";
00044     result = trimSequence(test, 'B', true);
00045     assert(result == (test.begin() + 5));
00046 
00047     test = "AAAAAAAABCDEFGHIJKLMNOPQRSTUVWXYZ";
00048     result = trimSequence(test, 'B', true);
00049     assert(result == (test.begin() + 8));
00050 
00051     test = "AAAAAAAABCDEFGHIJKLMNOPQRSTUVWXYZ";
00052     result = trimSequence(test, 'F', true);
00053     assert(result == (test.begin() + 12));
00054 
00055     test = "AAAAAAAABCDEFGHIJKLMNOPQRSTUVWXYZ";
00056     result = trimSequence(test, '@', true);
00057     assert(result == (test.begin() + 0));
00058 
00059     test = "AAAAAAAABCDEFGHIJKLMNOPQRSTUVWXYZ";
00060     result = trimSequence(test, '@', true);
00061     assert(result == (test.begin() + 0));
00062 
00063     test = "AAAFAAAABCDEFGHIJKLMNOPQRSTUVWXYZ";
00064     result = trimSequence(test, 'F', true);
00065     assert(result == (test.begin() + 12));
00066 
00067     // trim left 12 bases, and untrimmed bases are 'FG' (turn bug into this test cass)
00068     test = "AAAFAAAABCDEFG";
00069     result = trimSequence(test, 'F', true);
00070     assert(result == (test.begin() + 12));
00071 
00072     //
00073     // from the right:
00074     //
00075     test = "ZYXWVUTSRQPONMLKJIHGFEDCBA";
00076     result = trimSequence(test, 'A', false);
00077     assert(result == test.end());
00078 
00079     test = "ZYXWVUTSRQPONMLKJIHGFEDCBA";
00080     result = trimSequence(test, '~', false);
00081     assert(result == test.begin());
00082 
00083     test = "ZYXWVUTSRQPONMLKJIHGFEDCBAAAAA";
00084     result = trimSequence(test, 'B', false);
00085     assert(result == (test.end() - 5));
00086 
00087     test = "ZYXWVUTSRQPONMLKJIHGFEDCBAAAAAAA";
00088     result = trimSequence(test, 'B', false);
00089     assert(result == (test.end() - 7));
00090 
00091     test = "ZYXWVUTSRQPONMLKJIHGFEDCBAAAAAAAA";
00092     result = trimSequence(test, 'F', false);
00093     assert(result == (test.end() - 12));
00094 
00095     test = "ZYXWVUTSRQPONMLKJIHGFEDCBAAAAAAAA";
00096     result = trimSequence(test, '@', false);
00097     assert(result == (test.end() + 0));
00098 
00099     test = "ZYXWVUTSRQPONMLKJIHGFEDCBAAAAFAAA";
00100     result = trimSequence(test, 'F', false);
00101     assert(result == (test.end() - 12));
00102 
00103     test = "#################################";
00104     result = trimSequence(test, 'F', false);
00105     assert(result == (test.begin()));
00106 
00107 #if 0
00108     // TODO: add explanation why this test case should trim 5 right most bases?
00109     test = ">BC@>28B==>=><?@=?>@8(>0309261/;6=@";
00110     result = trimSequence(test, '0', false);
00111     assert(result == (test.end())-5);
00112 #endif
00113 
00114     exit(0);
00115 }
00116 
00117 #endif
Generated on Wed Nov 17 15:38:29 2010 for StatGen Software by  doxygen 1.6.3