summaryrefslogtreecommitdiffstats
path: root/src/assign/assign_blast_scores.c (plain)
blob: 3bdcccc339ec8061d4c63caa91cce621e5a1d79d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "assign_blast_scores.h"
#include <petscmat.h>
#include <stdio.h>

void
assign_blast_scores (hid_t file_id)
{
  /*
   * Create a sparse matrix for the pairwise protein BLAST scores.
   *
   * 138,769 proteins x 138,769 proteins = 19,256,835,361 pairs.  At 8
   * bytes (double) per pair this will require 154.1 GB of memory to
   * hold the full structure.  This is available on the compute nodes
   * of Cobalt however use of a sparse matrix should reduce this size
   * dramatically.
   */

  // http://www.netlib.org/blas/blast-forum/blas_sparse_proto.h
  //  blas_sparse_matrix M = BLAS_duscr_begin (138769, 138769);

  Mat M;
  MatCreateSeqAIJ (PETSC_COMM_SELF, 138769, 138769, 50, NULL, &M);

  MatSetValue (M, 12, 8, 12.8, INSERT_VALUES);

  MatAssemblyBegin (M, MAT_FINAL_ASSEMBLY);
  MatAssemblyEnd (M, MAT_FINAL_ASSEMBLY);

  /*
   * Write the contents of the matrix to a HDF5 file.
   */
  PetscViewer viewer;

  //  PetscErrorCode err =
  //  PetscViewerHDF5Open (PETSC_COMM_WORLD, "sparse.h5", FILE_MODE_WRITE, &viewer);

  PetscErrorCode err =
    PetscViewerBinaryOpen (PETSC_COMM_WORLD,
			   "sparse.petsc",
			   FILE_MODE_WRITE,
			   &viewer);

  MatView (M, viewer);
  PetscViewerDestroy (viewer);

  MatDestroy (M);

  return;
}

Valid XHTML 1.0 Strict

Copyright © 2009 Don Pellegrino All Rights Reserved.