libStatGen Software  1
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 #include <assert.h>
00021 #include <iostream>
00022 #include <stdlib.h>
00023 #include <string>
00024 
00025 int main(int argc, const char **argv)
00026 {
00027     std::string test;
00028     std::string::iterator result;
00029 
00030     //
00031     // from the left:
00032     //
00033     test = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
00034     result = trimSequence(test, 'A', true);
00035     assert(result == test.begin());
00036 
00037     test = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
00038     result = trimSequence(test, '~', true);
00039     assert(result == test.end());
00040 
00041     test = "AAAAABCDEFGHIJKLMNOPQRSTUVWXYZ";
00042     result = trimSequence(test, 'B', true);
00043     assert(result == (test.begin() + 5));
00044 
00045     test = "AAAAAAAABCDEFGHIJKLMNOPQRSTUVWXYZ";
00046     result = trimSequence(test, 'B', true);
00047     assert(result == (test.begin() + 8));
00048 
00049     test = "AAAAAAAABCDEFGHIJKLMNOPQRSTUVWXYZ";
00050     result = trimSequence(test, 'F', true);
00051     assert(result == (test.begin() + 12));
00052 
00053     test = "AAAAAAAABCDEFGHIJKLMNOPQRSTUVWXYZ";
00054     result = trimSequence(test, '@', true);
00055     assert(result == (test.begin() + 0));
00056 
00057     test = "AAAAAAAABCDEFGHIJKLMNOPQRSTUVWXYZ";
00058     result = trimSequence(test, '@', true);
00059     assert(result == (test.begin() + 0));
00060 
00061     test = "AAAFAAAABCDEFGHIJKLMNOPQRSTUVWXYZ";
00062     result = trimSequence(test, 'F', true);
00063     assert(result == (test.begin() + 12));
00064 
00065     // trim left 12 bases, and untrimmed bases are 'FG' (turn bug into this test cass)
00066     test = "AAAFAAAABCDEFG";
00067     result = trimSequence(test, 'F', true);
00068     assert(result == (test.begin() + 12));
00069 
00070     //
00071     // from the right:
00072     //
00073     test = "ZYXWVUTSRQPONMLKJIHGFEDCBA";
00074     result = trimSequence(test, 'A', false);
00075     assert(result == test.end());
00076 
00077     test = "ZYXWVUTSRQPONMLKJIHGFEDCBA";
00078     result = trimSequence(test, '~', false);
00079     assert(result == test.begin());
00080 
00081     test = "ZYXWVUTSRQPONMLKJIHGFEDCBAAAAA";
00082     result = trimSequence(test, 'B', false);
00083     assert(result == (test.end() - 5));
00084 
00085     test = "ZYXWVUTSRQPONMLKJIHGFEDCBAAAAAAA";
00086     result = trimSequence(test, 'B', false);
00087     assert(result == (test.end() - 7));
00088 
00089     test = "ZYXWVUTSRQPONMLKJIHGFEDCBAAAAAAAA";
00090     result = trimSequence(test, 'F', false);
00091     assert(result == (test.end() - 12));
00092 
00093     test = "ZYXWVUTSRQPONMLKJIHGFEDCBAAAAAAAA";
00094     result = trimSequence(test, '@', false);
00095     assert(result == (test.end() + 0));
00096 
00097     test = "ZYXWVUTSRQPONMLKJIHGFEDCBAAAAFAAA";
00098     result = trimSequence(test, 'F', false);
00099     assert(result == (test.end() - 12));
00100 
00101     test = "#################################";
00102     result = trimSequence(test, 'F', false);
00103     assert(result == (test.begin()));
00104 
00105 #if 0
00106     // TODO: add explanation why this test case should trim 5 right most bases?
00107     test = ">BC@>28B==>=><?@=?>@8(>0309261/;6=@";
00108     result = trimSequence(test, '0', false);
00109     assert(result == (test.end())-5);
00110 #endif
00111 
00112     exit(0);
00113 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends