ROOT logo
// Reads a motif file defined using gassiplex channel and converts
// it (using GCToBerg.dat file) into a motif file using berg pin numbering
// (as used by mapping software).

#include <fstream>
#include <vector>
#include <string>

void readGCToBerg(std::vector<int>& gc2berg)
{
  gc2berg.clear();

  std::ifstream in("GCToBerg.dat");
  
  int gc, berg;

  while ( in >> gc >> berg )
    {
      gc2berg.push_back(berg);
    }

  in.close();
}

void convertMotif(const char* inputfile, const char* outputfile)
{
  std::vector<int> gc2berg;

  readGCToBerg(gc2berg);

  std::ifstream in(inputfile);
  std::ofstream out(outputfile);

  char line[80];
  int n = 1;
  while ( in.getline(line,80) )
    {
      
      if ( line[0] == '#' )
	{
	  // Comment line. No change.
	  out << line << std::endl;
	}
      else
	{
	  std::string sline(line);
      
	  int gc = atoi(sline.c_str());
	  // assume the first 2 characters only are the gc number,
	  // so replace them with berg number.
	  int berg = gc2berg[gc];
	  out << berg << "\t1\t" << n << "\t-" << std::endl;
	  ++n;
	}
    }
  
  in.close();
  out.close();
}
 convertMotif_GCToBerg.C:1
 convertMotif_GCToBerg.C:2
 convertMotif_GCToBerg.C:3
 convertMotif_GCToBerg.C:4
 convertMotif_GCToBerg.C:5
 convertMotif_GCToBerg.C:6
 convertMotif_GCToBerg.C:7
 convertMotif_GCToBerg.C:8
 convertMotif_GCToBerg.C:9
 convertMotif_GCToBerg.C:10
 convertMotif_GCToBerg.C:11
 convertMotif_GCToBerg.C:12
 convertMotif_GCToBerg.C:13
 convertMotif_GCToBerg.C:14
 convertMotif_GCToBerg.C:15
 convertMotif_GCToBerg.C:16
 convertMotif_GCToBerg.C:17
 convertMotif_GCToBerg.C:18
 convertMotif_GCToBerg.C:19
 convertMotif_GCToBerg.C:20
 convertMotif_GCToBerg.C:21
 convertMotif_GCToBerg.C:22
 convertMotif_GCToBerg.C:23
 convertMotif_GCToBerg.C:24
 convertMotif_GCToBerg.C:25
 convertMotif_GCToBerg.C:26
 convertMotif_GCToBerg.C:27
 convertMotif_GCToBerg.C:28
 convertMotif_GCToBerg.C:29
 convertMotif_GCToBerg.C:30
 convertMotif_GCToBerg.C:31
 convertMotif_GCToBerg.C:32
 convertMotif_GCToBerg.C:33
 convertMotif_GCToBerg.C:34
 convertMotif_GCToBerg.C:35
 convertMotif_GCToBerg.C:36
 convertMotif_GCToBerg.C:37
 convertMotif_GCToBerg.C:38
 convertMotif_GCToBerg.C:39
 convertMotif_GCToBerg.C:40
 convertMotif_GCToBerg.C:41
 convertMotif_GCToBerg.C:42
 convertMotif_GCToBerg.C:43
 convertMotif_GCToBerg.C:44
 convertMotif_GCToBerg.C:45
 convertMotif_GCToBerg.C:46
 convertMotif_GCToBerg.C:47
 convertMotif_GCToBerg.C:48
 convertMotif_GCToBerg.C:49
 convertMotif_GCToBerg.C:50
 convertMotif_GCToBerg.C:51
 convertMotif_GCToBerg.C:52
 convertMotif_GCToBerg.C:53
 convertMotif_GCToBerg.C:54
 convertMotif_GCToBerg.C:55
 convertMotif_GCToBerg.C:56
 convertMotif_GCToBerg.C:57
 convertMotif_GCToBerg.C:58
 convertMotif_GCToBerg.C:59
 convertMotif_GCToBerg.C:60