Пример #1
0
void SodController::postscript(f_parameter& par)
{
  QString dviewer;
  if(!par.param("viewer", dviewer)){
    warn("Specify viewer to be used viewer=(..)");
    return;
  }
  if(!distanceViewers.count(dviewer)){
    warn("Unknown viewer specified");
    return;
  }
  DistanceViewer* viewer = distanceViewers[dviewer];  

  QString error;
  QTextStream qts(&error);
  float w, h;
  QString fname;
  if(!par.param("fname", fname))
    qts << "Specify postscript output file name fname=...\n";
  if(!par.param("w", w))
    qts << "Specify width (in points) of plot w=..\n";
  if(!par.param("h", h))
    qts << "Specify height (in points) of plot h=..\n";
  if(error.length()){
    warn(error);
    return;
  }
  bool stress = par.defined("stress");
  
  if(!par.defined("svg")){
    viewer->postscript(fname, w, h, stress);
  }else{
    viewer->svg(fname, (int)w, (int)h);
  }
}
Пример #2
0
bool GetInfo_Devices (QListView *lbox)
{
	QFile *f = new QFile("/var/run/dmesg.boot");
	if (f->open(IO_ReadOnly)) {
		QTextStream qts(f);
		QDict<QListViewItem> lv_items;
		Device *dev;
		QString line, controller;
		lbox->setRootIsDecorated(true);
		lbox->addColumn("Device");
		lbox->addColumn("Description");
		while ( !(line=qts.readLine()).isNull() ) {
			controller = GetController(line);
			if (controller.isNull())
				continue;
			dev=GetDevice(line);
			if (!dev)
				continue;
			// Ewww assuing motherboard is the only toplevel controller is rather gross
			if (controller == "motherboard") {
				if (!lv_items[dev->name]) {
					lv_items.insert(dev->name, new QListViewItem(lbox, dev->name, dev->description) );
				}
			} else {
				QListViewItem *parent=lv_items[controller];
				if (parent && !lv_items[dev->name]) {
					lv_items.insert(dev->name, new QListViewItem(parent, dev->name, dev->description) );
				}
			}
		}
		return true;
	}
	return false;
}
Пример #3
0
void SodController::read_annotation(f_parameter& par)
{
  QString error;
  QTextStream qts(&error);
  QString filename;
  QString dist_name;
  if(!par.param("file", filename))
    qts << "read_annotation: no file specified, (file=..)\n";
  if(!par.param("dist", dist_name))
    qts << "read_annotation: no dist mapper specified (dist=..)\n";
  if(!distanceViewers.count(dist_name))
    qts << "read_annotation: unknown dist mapper: " << dist_name << "\n";
  if(error.length()){
    warn(error);
    return;
  }
  node_set ns = read_node_set(filename, true);
  if(!ns.n_size()){
    warn("read_annotation obtained empty node_set");
    return;
  }
  if(!distances.count(dist_name)){
    warn("read_annotation: unknown distance set");
    return;
  }
  if(distances[dist_name].n_size() != ns.n_size() ){
    warn("read_annotation: specified node set has a different size to the annotation node_set");
    return;
  }
  Annotation annot(ns);
  distanceViewers[dist_name]->setAnnotation(annot);
}
Пример #4
0
void SodController::make_gaussian_background(f_parameter& par)
{
  QString error;
  QTextStream qts(&error);
  QString dviewer;
  float var;
  std::vector<unsigned int> dims;
  std::vector<unsigned int> alpha;
  std::vector<unsigned int> red;
  std::vector<unsigned int> green;
  std::vector<unsigned int> blue;
  if(!par.param("viewer", dviewer))
    qts << "Specify viewer (viewer=..)\n";
  if(!dviewer.isEmpty() && !distanceViewers.count(dviewer))
    qts << "Unknown viewer " << dviewer << "\n";
  if(!par.param("dims", ',', dims))
    qts << "Specify dimensions to use (dims=a,b,c)\n";
  if(!par.param("a", ',', alpha) || !par.param("r", ',', red) || 
     !par.param("g", ',', green) || !par.param("b", ',', blue))
    qts << "Specify argb components (a=a,b,c r=a,b,c) one value (0-255) for each dim\n";
  if(!par.param("var", var))
    qts << "Specify the variance to use (radius will be 2xvar) (var=..)\n";
  if(error.length()){
    warn(error);
    return;
  }
  // there should be a viewer, but also there should be a positions of the same name
  if(!positions.count(dviewer)){
    qts << "No positions set for viewer " << dviewer << " aborting";
    warn(error);
    return;
  }
  // check that colours have been specified for all dimensions and that no value is
  // larger than 255
  if(dims.size() != alpha.size() || dims.size() != red.size() ||
     dims.size() != green.size() || dims.size() != blue.size()){
    warn("Colors not same size as specified by dim\n");
  }
  // check that none of the dimensions is too large..
  for(unsigned int i=0; i < dims.size(); ++i){
    if(dims[i] >= positions[dviewer].n_dim()){
      warn("dimension specified too large");
      return;
    }
    if(alpha[i] > 255 || red[i] > 255 || green[i] > 255 || blue[i] > 255){
      warn("Illegal color specified (value larger than 255)");
      return;
    }
  }
  // if that's ok..
  unsigned char* color_matrix = new unsigned char[4 * dims.size()];
  for(unsigned int i=0; i < dims.size(); ++i){
    color_matrix[i * 4 + 0] = alpha[i];
    color_matrix[i * 4 + 1] = red[i];
    color_matrix[i * 4 + 2] = green[i];
    color_matrix[i * 4 + 3] = blue[i];
  }
  // then make a function in the viewer..
  distanceViewers[dviewer]->set_simple_gaussian_background(dims, color_matrix, var);
}
Пример #5
0
  //-------------------------------------------------------------------------
   QString buildLine(QVector<aln::s_hap> vT, QString &f_genotype, int &i, int &j, QVector<s_res> &vRes)
   {
       //build line of data in tab 6
       //uses makeFreq & makeSZ
       QString str;
       QTextStream ts(&str);

       QString qstr;
       QTextStream qts(&qstr);

       int nrS = 0;
       int nrZ = 0;
       QString colum23;
       QString colum45;
       float dprob;

       qts << vT[i].a << vT[i].b << vT[j].a << vT[j].b;
       colum23 = aln::makeSZ(f_genotype, qstr, nrS, nrZ);
       ts << qstr << "  " << vT[i].a << " " << vT[i].b << " " << vT[j].a << " " << vT[j].b << "  " << colum23;

       dprob = (vT[i].dprob * vT[j].dprob);
       colum45 = aln::makeFreq(nrS, nrZ, dprob, vRes);
       ts << "  " << colum45;

      return(str);
   }
Пример #6
0
std::ostream& operator<<(std::ostream& os, const RulesetObject& rulesetObject)
{
  QString str;
  QTextStream qts(&str);
  rulesetObject.toXml().save(qts, 2);
  os << str.toStdString();
  return os;
}
Пример #7
0
 std::ostream& operator<<(std::ostream& os, const BCLFileReference& file)
 {
   QDomDocument doc;
   QDomElement element = doc.createElement(QString("File"));
   doc.appendChild(element);
   file.writeValues(doc, element);
   
   QString str;
   QTextStream qts(&str);
   doc.save(qts, 2);
   os << str.toStdString();
   return os;
 }
Пример #8
0
// The file should contain rows and columns (more than 2).
// The first column identifies the node and the
// following columns contain it's coordinates. (These
// can indicate all against all distances as well as
// spatial coordinates)..
// All columns except the first should contain values that can be assigned as floats
node_set SodController::read_node_set(QString fileName, bool has_col_header)
{
  node_set ns;
  QString error;
  QTextStream qts(&error);
  QFile file(fileName);
  if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
    qts << "Unable to open file : " << fileName;
    warn(error);
    return(ns);
  }
  QTextStream in(&file);
  QString line;
  bool ok;
  /// A little bit messy, but what the hell..
  std::vector<QString> col_header;
  if(has_col_header){
    line = in.readLine();
    QStringList words = line.split(QRegExp("\\s+"), QString::SkipEmptyParts);
    for(int i=0; i < words.size(); ++i)
      col_header.push_back(words[i]);
  }
  while(!in.atEnd()){
    line = in.readLine();
    QStringList words = line.split(QRegExp("\\s+"), QString::SkipEmptyParts);
    if(words.size() < 2){
      warn("read_node_set skipping line");
      continue;
    }
    QString label = words[0];
    std::vector<float> coords;
    for(int i=1; i < words.size(); ++i){
      float f = words[i].toFloat(&ok);
      if(!ok) 
	continue;
      coords.push_back(f);
    }
    if(!ns.push_node(label, coords))
      warn("read_node_set failed to push node");
  }
  if(has_col_header){
    if(!ns.set_col_header(col_header))
      warn("read_node_set failed to set column header");
  }
  return(ns);
}
Пример #9
0
void SodController::read_positions(f_parameter& par)
{
  QString error;
  QTextStream qts(&error);
  QString filename;
  QString pos_name;
  unsigned int grid_points = 0;
  if(!par.param("file", filename))
    qts << "read_positions: no position file specified (file=..)\n";
  if(!par.param("pos", pos_name) || pos_name.isEmpty())
    qts << "specify a name for the position set (pos=..)\n";
  if(error.length()){
    warn(error);
    return;
  }
  par.param("grid", grid_points);
  node_set ns = read_node_set(filename);
  if(!ns.n_size()){
    warn("read_positions obtained empty node_set");
    return;
  }
  positions[pos_name] = ns;
  
  bool set_mapper = true;
  par.param("set_mapper", set_mapper);
  if(set_mapper && !distanceViewers.count(pos_name)){
    distances[pos_name] = positions[pos_name].distances();
    std::vector<int> memberInts = int_range(distances[pos_name].n_size());
    bool trackCoordinates = true;
    par.param("coords", trackCoordinates);
    if(!par.defined("gpu")){
      distanceViewers[ pos_name ] = new DistanceViewer(memberInts, distances[pos_name].Nodes(), pos_name, trackCoordinates);
      distanceViewers[ pos_name ]->show();
      distanceViewers[ pos_name ]->raise();
    }else{     // set up a gpu
      if(ocl_mappers.count(pos_name))
	delete(ocl_mappers[pos_name]);
      ocl_mappers[pos_name] = new OCL_DistanceMapperManager(&positions[pos_name], &distances[pos_name]);
      ocl_mappers[pos_name]->print_pointers();
    }
  }
  if(set_mapper && distanceViewers.count(pos_name)){
    distanceViewers[pos_name]->set_starting_dimensionality(ns.n_dim());
    distanceViewers[pos_name]->setPositions(ns.Nodes(), grid_points);
  }
}
Пример #10
0
void MainWindow::loadFile(const QString &fileName)
{
    //if is empty
    if(fileName.isEmpty())
    {
        //set the file name
        this->setFileName(QString ());
        ui->AppOutput->append("No file is open");
        return;
    }
    // create a QFile Object with the fileName variable
    QFile *qfo=new QFile(fileName);

    //if
    if(!(qfo->open(QIODevice::Text|QIODevice::ReadOnly)))
    {
        ui->AppOutput->append("The file "+fileName+" cannot be opened");
        QMessageBox::warning(this,"Error","The file cannot be opened",QMessageBox::Ok,QMessageBox::Ok);
        setFileName(QString());
        return;
    }
    else
    {
        ui->AppOutput->append("The file at "+fileName+" is opened");
        QTextStream qts(qfo);
        //codigo de parseo.

        int count_lines=0;
        while(!qts.atEnd())
        {
            //se lee la linea
            QString line=qts.readLine();
            //se muestra en la pantalla
            ui->textEdit->appendPlainText(line);
            //se envia a parsearla
            lineParser(line);
            //se cuenta la cantidad de lineas
            count_lines++;
        }
        ui->AppOutput->append("Lines: "+QString::number(count_lines));
        qfo->close();
        setFileName(fileName);
        setWindowModified(false);
    }

}
Пример #11
0
void SodController::read_distances(f_parameter& par)
{
  QString error;
  QTextStream qts(&error);
  QString fileName;
  QString disName;
  //  std::string filename;
  if(!par.param("file", fileName))
    qts << "read_distances: no distance file specified\n";
  if(!par.param("dist", disName))
    qts << "read_distances: specify name for distances (dist=..)";
  if(error.length()){
    warn(error);
    return;
  }
  node_set ns = read_node_set(fileName);
  if(!ns.n_size()){
    warn("read_distances obtained empty node_set");
    return;
  }
  if(ns.n_size() != ns.n_dim()){
    qts << "read_distances node_set is not square: " << ns.n_size() << "*" << ns.n_dim();
    warn(error);
    return;
  }
  distances[disName] = ns;
  std::vector<int> memberInts(ns.n_size());
  for(unsigned int i=0; i < memberInts.size(); ++i)
    memberInts[i] = i;

  bool trackCoordinates = true;
  par.param("coords", trackCoordinates);
  par.param("comps", trackCoordinates);

  DistanceViewer* viewer = new DistanceViewer(memberInts, ns.Nodes(), fileName, trackCoordinates);
  if(distanceViewers.count(disName))
    delete distanceViewers[disName];

  distanceViewers[disName] = viewer;
  viewer->show();
  viewer->raise();
}
Пример #12
0
void SodController::titrate(f_parameter& par)
{
  QString dviewer;
  if(!par.param("viewer", dviewer)){
    warn("Specify viewer to be used viewer=(..)");
    return;
  }
  if(!distanceViewers.count(dviewer)){
    warn("Unknown viewer specified");
    return;
  }
  DistanceViewer* viewer = distanceViewers[dviewer];
  unsigned int rep=10;
  std::vector<unsigned int> iter;
  std::vector<unsigned int> dim_no;
  QString error;
  QTextStream qts(&error);
  par.param("rep", rep);
  if(!par.param("iter", ',', iter))
    qts << "Please specify iteration numbers: iter=300,500, etc..\n";
  if(!par.param("dim_no", ',', dim_no))
    qts << "Please specify starting dimensionalities dim_no=6,4,2 or something\n";
  if(error.length()){
    warn(error);
    return;
  }
  std::vector<std::vector<float> > minStresses ;
  for(unsigned int i=0; i < dim_no.size(); ++i){
    for(unsigned int j=0; j < iter.size(); ++j)
      minStresses.push_back( viewer->runMultiple(rep, iter[j], dim_no[i]));
  }
  // and then let's try to print out a simple table..
  std::string out_file;
  std::ofstream out;
  if(par.param("ofile", out_file))
    out.open(out_file.c_str());

  for(unsigned int d=0; d < dim_no.size(); ++d){
    for(unsigned int it=0; it < iter.size(); ++it){
      std::cout << "\t" << dim_no[d] << "," << iter[it];
      if(out.is_open())
	out << "\t" << dim_no[d] << "," << iter[it];
    }
  }
  std::cout << std::endl;
  if(out.is_open())
    out << std::endl;
  for(unsigned int i=0; i < rep; ++i){
    std::cout << i;
    if(out.is_open())
      out << i;
    for(unsigned int d=0; d < dim_no.size(); ++d){
      for(unsigned int it=0; it < iter.size(); ++it){
	unsigned int j = d * iter.size() + it;
	std::cout << "\t" << minStresses[j][i];
	if(out.is_open())
	  out << "\t" << minStresses[j][i];
      }
    }
    std::cout << std::endl;
    if(out.is_open())
      out << std::endl;
  }
}