]> git.donarmstrong.com Git - biopieces.git/commitdiff
add bipartite_decode
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Tue, 23 Sep 2008 06:30:39 +0000 (06:30 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Tue, 23 Sep 2008 06:30:39 +0000 (06:30 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@264 74ccb610-7750-0410-82ae-013aeee3265d

code_c/Maasha/src/Makefile
code_c/Maasha/src/bipartite_scan.c

index 4312b1fd7bfc2b5709207781704768e928ac42c8..983bab713518e99a57a8f4babd6603336a6f22fe 100644 (file)
@@ -11,7 +11,7 @@ TEST_DIR = test/
 INC = -I $(INC_DIR)
 LIB = -lm $(LIB_DIR)*.o
 
-all: libs utest bed_sort bipartite_scan fasta_count repeat-O-matic
+all: libs utest bed_sort bipartite_scan bipartite_decode fasta_count repeat-O-matic
 
 libs:
        cd $(LIB_DIR) && ${MAKE} all
@@ -25,6 +25,9 @@ bed_sort: bed_sort.c
 bipartite_scan: bipartite_scan.c
        $(CC) $(Cflags) $(INC) $(LIB) bipartite_scan.c -o bipartite_scan
 
+bipartite_decode: bipartite_decode.c
+       $(CC) $(Cflags) $(INC) $(LIB) bipartite_decode.c -o bipartite_decode
+
 fasta_count: fasta_count.c
        $(CC) $(Cflags) $(INC) $(LIB) fasta_count.c -o fasta_count
 
@@ -36,5 +39,6 @@ clean:
        cd $(TEST_DIR) && ${MAKE} clean
        rm bed_sort
        rm bipartite_scan
+       rm bipartite_decode
        rm fasta_count
        rm repeat-O-matic
index 34fe55f22c4dd303278287cc81225351353b9e41..bb78a915e6c24c73bdc413a33795204d3fdf8cb2 100644 (file)
@@ -29,42 +29,6 @@ struct _bitblock
 
 typedef struct _bitblock bitblock;
 
-/* Byte array for fast convertion of binary blocks back to DNA. */
-char *bin2dna[256] = {
-    "AAAA", "AAAC", "AAAG", "AAAT", "AACA", "AACC", "AACG", "AACT",
-    "AAGA", "AAGC", "AAGG", "AAGT", "AATA", "AATC", "AATG", "AATT",
-    "ACAA", "ACAC", "ACAG", "ACAT", "ACCA", "ACCC", "ACCG", "ACCT",
-    "ACGA", "ACGC", "ACGG", "ACGT", "ACTA", "ACTC", "ACTG", "ACTT",
-    "AGAA", "AGAC", "AGAG", "AGAT", "AGCA", "AGCC", "AGCG", "AGCT",
-    "AGGA", "AGGC", "AGGG", "AGGT", "AGTA", "AGTC", "AGTG", "AGTT",
-    "ATAA", "ATAC", "ATAG", "ATAT", "ATCA", "ATCC", "ATCG", "ATCT",
-    "ATGA", "ATGC", "ATGG", "ATGT", "ATTA", "ATTC", "ATTG", "ATTT",
-    "CAAA", "CAAC", "CAAG", "CAAT", "CACA", "CACC", "CACG", "CACT",
-    "CAGA", "CAGC", "CAGG", "CAGT", "CATA", "CATC", "CATG", "CATT",
-    "CCAA", "CCAC", "CCAG", "CCAT", "CCCA", "CCCC", "CCCG", "CCCT",
-    "CCGA", "CCGC", "CCGG", "CCGT", "CCTA", "CCTC", "CCTG", "CCTT",
-    "CGAA", "CGAC", "CGAG", "CGAT", "CGCA", "CGCC", "CGCG", "CGCT",
-    "CGGA", "CGGC", "CGGG", "CGGT", "CGTA", "CGTC", "CGTG", "CGTT",
-    "CTAA", "CTAC", "CTAG", "CTAT", "CTCA", "CTCC", "CTCG", "CTCT",
-    "CTGA", "CTGC", "CTGG", "CTGT", "CTTA", "CTTC", "CTTG", "CTTT",
-    "GAAA", "GAAC", "GAAG", "GAAT", "GACA", "GACC", "GACG", "GACT",
-    "GAGA", "GAGC", "GAGG", "GAGT", "GATA", "GATC", "GATG", "GATT",
-    "GCAA", "GCAC", "GCAG", "GCAT", "GCCA", "GCCC", "GCCG", "GCCT",
-    "GCGA", "GCGC", "GCGG", "GCGT", "GCTA", "GCTC", "GCTG", "GCTT",
-    "GGAA", "GGAC", "GGAG", "GGAT", "GGCA", "GGCC", "GGCG", "GGCT",
-    "GGGA", "GGGC", "GGGG", "GGGT", "GGTA", "GGTC", "GGTG", "GGTT",
-    "GTAA", "GTAC", "GTAG", "GTAT", "GTCA", "GTCC", "GTCG", "GTCT",
-    "GTGA", "GTGC", "GTGG", "GTGT", "GTTA", "GTTC", "GTTG", "GTTT",
-    "TAAA", "TAAC", "TAAG", "TAAT", "TACA", "TACC", "TACG", "TACT",
-    "TAGA", "TAGC", "TAGG", "TAGT", "TATA", "TATC", "TATG", "TATT",
-    "TCAA", "TCAC", "TCAG", "TCAT", "TCCA", "TCCC", "TCCG", "TCCT",
-    "TCGA", "TCGC", "TCGG", "TCGT", "TCTA", "TCTC", "TCTG", "TCTT",
-    "TGAA", "TGAC", "TGAG", "TGAT", "TGCA", "TGCC", "TGCG", "TGCT",
-    "TGGA", "TGGC", "TGGG", "TGGT", "TGTA", "TGTC", "TGTG", "TGTT",
-    "TTAA", "TTAC", "TTAG", "TTAT", "TTCA", "TTCC", "TTCG", "TTCT",
-    "TTGA", "TTGC", "TTGG", "TTGT", "TTTA", "TTTC", "TTTG", "TTTT"
-};
-
 /* Function declarations. */
 void      run_scan( int argc, char *argv[] );
 void      print_usage();
@@ -75,7 +39,6 @@ void      scan_list( list_sl *list, uint *count_array );
 bitblock *bitblock_new();
 uint      blocks2motif( uchar bin1, uchar bin2, ushort dist );
 void      count_array_print( uint *count_array, size_t nmemb, size_t cutoff );
-void      motif_print( uint motif, uint count );
 void      bitblock_list_print( list_sl *list );
 void      bitblock_print( bitblock *out );
 
@@ -317,13 +280,10 @@ void scan_list( list_sl *list, uint *count_array )
         {
             block2 = ( bitblock * ) next_node->val;
         
-//             printf( "block1: %s  block2: %s   dist: %d\n", bin2dna[ block1->bin ], bin2dna[ block2->bin ], dist ); /* DEBUG */
-
             if ( ! block2->hasN )
             {
                 motif_bin = blocks2motif( block1->bin, block2->bin, dist );
 
-                // motif_print( motif_bin, 0 ); /* DEBUG */
                 // bitblock_list_print( list ); /* DEBUG */
 
                 count_array[ motif_bin ]++;
@@ -372,8 +332,6 @@ uint blocks2motif( uchar bin1, uchar bin2, ushort dist )
 
     motif |= dist;
 
-//    motif_print( motif, 0 ); /* DEBUG */
-
     return motif;
 }
 
@@ -395,67 +353,12 @@ void count_array_print( uint *count_array, size_t nmemb, size_t cutoff )
         count = count_array[ i ];
 
         if ( count >= cutoff ) {
-            motif_print( motif, count );
+            printf( "%u\t%u\n", motif, count );
         }
     }
 }
 
 
-void motif_print( uint motif, uint count )
-{
-    /* Martin A. Hansen, September 2008 */
-
-    /* Converts a binary encoded bipartite motif */
-    /* into DNA and output the motif, distance and */
-    /* count seperated by tabs: */
-    /* BLOCK1 \t BLOCK2 \t DIST \t COUNT */
-
-    uchar  bin1 = 0;
-    uchar  bin2 = 0;
-    ushort dist = 0;
-
-    // printf( "%d\t", motif ); /* DEBUG */
-
-    dist = ( ushort ) motif & BLOCK_MASK;
-
-    motif >>= sizeof( uchar ) * BITS_IN_BYTE;
-
-    bin2 = ( uchar ) motif;
-
-    motif >>= sizeof( uchar ) * BITS_IN_BYTE;
-
-    bin1 = ( uchar ) motif;
-
-    printf( "%s\t%s\t%d\t%d\n", bin2dna[ bin1 ], bin2dna[ bin2 ], dist, count );
-}
-
-
-void bitblock_list_print( list_sl *list )
-{
-    /* Martin A. Hansen, September 2008 */
-
-    /* Debug function to print all blocks in a list. */
-
-    node_sl *node = NULL;
-
-    printf( "\nbitblock_list_print:\n" );
-
-    for ( node = list->first; node != NULL; node = node->next ) {
-        bitblock_print( ( bitblock * ) node->val );
-    }
-}
-
-
-void bitblock_print( bitblock *out )
-{
-    /* Martin A. Hansen, September 2008 */
-
-    /* Debug function to print a given block. */
-
-    printf( "bin: %d  dna: %s   hasN: %d\n", out->bin, bin2dna[ ( int ) out->bin ], out->hasN );
-}
-
-
 /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> UNIT TESTS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */