modified: makefile
[GalaxyCodeBases.git] / BGI / SOAPdenovo2 / standardPregraph / output_pregraph.c
blobf553885b5f5940cfa26139aae65768877e59f198
1 /*
2 * 31mer/output_pregraph.c
4 * Copyright (c) 2008-2012 BGI-Shenzhen <soap at genomics dot org dot cn>.
6 * This file is part of SOAPdenovo.
8 * SOAPdenovo is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
13 * SOAPdenovo is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with SOAPdenovo. If not, see <http://www.gnu.org/licenses/>.
23 #include <stdinc.h>
24 #include "newhash.h"
25 #include "kmerhash.h"
26 #include <extfunc.h>
27 #include <extvab.h>
28 static int outvCounter = 0;
30 //after this LINKFLAGFILTER in the Kmer is destroyed
31 static void output1vt ( kmer_t * node1, FILE * fp )
33 if ( !node1 )
35 return;
38 if ( ! ( node1->linear ) && ! ( node1->deleted ) )
40 outvCounter++;
41 print_kmer ( fp, node1->seq, ' ' );
43 if ( outvCounter % 8 == 0 )
45 fprintf ( fp, "\n" );
50 void output_vertex ( char * outfile )
52 char temp[256];
53 FILE * fp;
54 int i;
55 kmer_t * node;
56 KmerSet * set;
57 sprintf ( temp, "%s.vertex", outfile );
58 fp = ckopen ( temp, "w" );
60 for ( i = 0; i < thrd_num; i++ )
62 set = KmerSets[i];
63 set->iter_ptr = 0;
65 while ( set->iter_ptr < set->size )
67 if ( !is_kmer_entity_null ( set->flags, set->iter_ptr ) )
69 node = set->array + set->iter_ptr;
70 output1vt ( node, fp );
73 set->iter_ptr++;
77 fprintf ( fp, "\n" );
78 fprintf ( stderr, "%d vertex(es) output.\n", outvCounter );
79 fclose ( fp );
80 sprintf ( temp, "%s.preGraphBasic", outfile );
81 fp = ckopen ( temp, "w" );
82 fprintf ( fp, "VERTEX %d K %d\n", outvCounter, overlaplen );
83 fprintf ( fp, "\nEDGEs %d\n", num_ed );
84 fprintf ( fp, "\nMaxReadLen %d MinReadLen %d MaxNameLen %d\n", maxReadLen4all, minReadLen, maxNameLen );
85 fclose ( fp );
88 void output_1edge ( preEDGE * edge, gzFile * fp )
90 int i;
91 gzprintf ( fp, ">length %d,", edge->length );
92 print_kmer_gz ( fp, edge->from_node, ',' );
93 print_kmer_gz ( fp, edge->to_node, ',' );
94 gzprintf ( fp, "cvg %d, %d\n", edge->cvg, edge->bal_edge );
96 for ( i = 0; i < edge->length; i++ )
98 gzprintf ( fp, "%c", int2base ( ( int ) edge->seq[i] ) );
100 if ( ( i + 1 ) % 100 == 0 )
102 gzprintf ( fp, "\n" );
106 if ( edge->length % 100 != 0 )
108 gzprintf ( fp, "\n" );