示例#1
0
BondGraph::VertexIntPropertyMap BondGraph::get_vertex_index_map() const {
  if (index_key_== IntKey()) {
    std::ostringstream oss;
    oss << this << " bond graph index";
    index_key_= IntKey(oss.str().c_str());
    int last=0;
    for (Particles::const_iterator it= sc_.begin(); it != sc_.end(); ++it) {
      (*it)->add_attribute(index_key_, last);
      ++last;
    }
  }
  return VertexIntPropertyMap(index_key_);
}
示例#2
0
文件: BcTest.c 项目: taysom/tau
void
BcTest8(void)
{
	/*
	 * Extensive test of all functions. Want to cover most code paths.
	 * 1. Dynamically adjust number of records by a factor of 100.
	 * 2. Randomly pick operations.
	 * 3. Test iteration intermixed with other operations.
	 */
	enum { MAX_RECS = 100 * ONE_THOUSAND };

	Bc t;
	u64 key;
	u64 keys[MAX_RECS];
	u64 numKeys = 0;
	u64 numPuts = 0;
	u64 numDeletes = 0;
	VAR_LUMP(v, MAX_DATA);

	init_twister(37);
	BcInit(&t, KEY_LEN);
	RandLump(v);
	for (u64 i = 0; i < 10; i++) {
		u64 maxKeys = twister_urand(MAX_RECS);
		PRu(maxKeys);
		while (numKeys != maxKeys) {
			aver(numKeys <= MAX_RECS);
			if (numKeys < maxKeys && Prob(75)) {
				key = twister_random();
				keys[numKeys++] = key;
				BcPut(&t, IntKey(key).s, v);
				++numPuts;
			} else {
				if (numKeys) {
					u64 j = twister_urand(numKeys);
					key = keys[j];
					keys[j] = keys[--numKeys];
					BcDelete(&t, IntKey(key).s);
					++numDeletes;
				}
			}
		}
	}
	aver(numPuts - numDeletes == numKeys);
	PRu(numPuts);
	PRu(numDeletes);
	PRu(numKeys);
	BcReport(__FUNCTION__, BcDoAudit(&t));
}
示例#3
0
BondGraph::~BondGraph() {
  if (index_key_ != IntKey()) {
    for (unsigned int i = 0; i < sc_.size(); ++i) {
      sc_[i]->remove_attribute(index_key_);
    }
  }
}
示例#4
0
//------------------------------------------------------------------------------------------------------------------------------------------------------
int Settings::GetInt(char *name)
{
    int retValue = mapIntChild[IntKey(name)];
    if(!GetIntFromChild(name, &retValue))
    {
        SetInt(name, retValue);
    }
    return retValue;
}
示例#5
0
文件: BcTest.c 项目: taysom/tau
void
BcTest6(void)
{
	enum { NUM_RECS = 2000, NUM_TRIALS = ONE_MILLION };
	Bc t;
	VAR_LUMP(v, MAX_DATA);
	Key a[NUM_RECS];
	u64 n = 0;
	u64 puts = 0;
	u64 deletes = 0;

	printf("%s\n", __FUNCTION__);
	init_twister(37);
	BcInit(&t, KEY_LEN);
	for (u64 j = 0; j < NUM_TRIALS; j++) {
		Key key;
		bool found;
		if (Prob(((NUM_RECS - n) * 100) / NUM_RECS)) {
			aver(n < NUM_RECS);
			key = IntKey(twister_urand(10000));
			BcGet(&t, key.s, &found);
			if (!found) {
				a[n++] = key;
				RandLump(v);
				BcPut(&t, key.s, v);
				++puts;
			}
			if (0 || Prob(2)) Audit("Put", &t, a, n, j);
		} else {
			aver(0 < n);
			u64 i = twister_urand(n);
			key = a[i];
			BcGet(&t, key.s, &found);
			if (!found) {
				BcDump("not found", &t);
				fatal("didn't find %s %llu %llu", key.s, puts, deletes);
			}
			BcDelete(&t, key.s);
			BcGet(&t, key.s, &found);
			if (found) {
				BcDump("found", &t);
				fatal("found %llu", key);
			}
			a[i] = a[--n];
			++deletes;
			if (0 || Prob(2)) Audit("Delete", &t, a, n, j);
		}
	}
	BcDoAudit(&t);
	printf("\tputs=%llu deletes=%llu\n", puts, deletes);
	BcReport(__FUNCTION__, BcDoAudit(&t));
	BcDump(__FUNCTION__, &t);
	BcFree(&t);
}
// add key of this container as attribute to all particles
// if there might be overlaps - create a different keys for each instance
void ConsecutivePairContainer::init() {
  std::ostringstream oss;
  oss << "CPC cache " << key_count;
  ++key_count;
  key_ = IntKey(oss.str());
  for (unsigned int i = 0; i < ps_.size(); ++i) {
    IMP_USAGE_CHECK(!get_model()->get_has_attribute(key_, ps_[i]),
                    "You must create containers before reading in the "
                        << "saved model: "
                        << get_model()->get_particle(ps_[i])->get_name());
    get_model()->add_attribute(key_, ps_[i], i);
  }
}
// TODO - do not use ProteinsAnchorsSamplingSpace.
// you are not going to use the paths here
ProteomicsEMAlignmentAtomic::ProteomicsEMAlignmentAtomic(
    const ProteinsAnchorsSamplingSpace &mapping_data,
    multifit::SettingsData *asmb_data, const AlignmentParams &align_param)
    : Object("ProteomicsEMAlignmentAtomic%1%"),
      mapping_data_(mapping_data),
      params_(align_param),
      order_key_(IntKey("order")),
      asmb_data_(asmb_data) {
  fast_scoring_ = false;
  IMP_LOG_TERSE("start" << std::endl);

  // initialize everything
  mdl_ = new Model();
  IMP_LOG_VERBOSE("get proteomics data\n");
  prot_data_ = mapping_data_.get_proteomics_data();
  fit_state_key_ = IntKey("fit_state_key");
  load_atomic_molecules();
  IMP_LOG_VERBOSE("set NULL \n");
  pst_ = nullptr;
  states_set_ = false;
  filters_set_ = false;
  ev_thr_ = 0.001;  // TODO make a parameter
  IMP_LOG_VERBOSE("end initialization\n");
}
示例#8
0
文件: BzTest.c 项目: taysom/tau
void
BzTest1(void)
{
	enum { NUM_RECS = 100 };
	VAR_LUMP(v, MAX_DATA);
	Bz t;

	printf("%s\n", __FUNCTION__);
	BzInit(&t, KEY_LEN);
	for (u64 i = 0; i < NUM_RECS; i++) {
		if (1) IntLump(v, i);
		else RandLump(v);
		BzPut(&t, IntKey(i+1).s, v);
	}
	BzDump(__FUNCTION__, &t);
}
示例#9
0
文件: BzTest.c 项目: taysom/tau
void
BzTest2(void)
{
	enum { NUM_RECS = 100 };
	VAR_LUMP(v, MAX_DATA);
	Bz t;

	printf("%s\n", __FUNCTION__);
	init_twister(17);
	BzInit(&t, KEY_LEN);
	for (u64 i = 0; i < NUM_RECS; i++) {
		if (1) IntLump(v, i);
		else IntLump(v, twister_urand(1000));
		if (0) BzPut(&t, RandKey().s, v);
		else BzPut(&t, IntKey(twister_urand(1000)).s, v);
	}
	BzDump(__FUNCTION__, &t);
}
示例#10
0
#include <IMP/core/GridClosePairsFinder.h>
#include <IMP/core/internal/close_pairs_helpers.h>
#include <IMP/core/pair_predicates.h>
#include <IMP/generic.h>
#include <IMP/PairModifier.h>
#include <IMP/utility.h>
#include <algorithm>


#include <IMP/core/RigidClosePairsFinder.h>
#include <IMP/core/rigid_bodies.h>


IMPCORE_BEGIN_INTERNAL_NAMESPACE

IntKey InList::key_= IntKey("in list temp");

IMP_LIST_IMPL(CoreClosePairContainer,
              PairFilter,
              pair_filter,
              PairFilter*,
              PairFilters);


CoreClosePairContainer::CoreClosePairContainer(SingletonContainer *c,
                                                 double distance,
                                                 ClosePairsFinder *cpf,
                                       double slack):
  IMP::internal::ListLikePairContainer(c->get_model(),
                                       "ClosePairContainer") {
 initialize(c, distance, slack,
示例#11
0
文件: swig.cpp 项目: apolitis/imp
void _TrivialDecorator::do_setup_particle(Model *m, ParticleIndex pi) {
  m->add_attribute(IntKey("trivial_attribute"), pi, 1);
}
示例#12
0
文件: swig.cpp 项目: apolitis/imp
void _TrivialDerivedDecorator::do_setup_particle(Model *m, ParticleIndex pi) {
  m->add_attribute(IntKey("trivial_attribute_2"), pi, 2);
  if (!_TrivialDecorator::get_is_setup(m, pi)) {
    _TrivialDecorator::setup_particle(m, pi);
  }
}
示例#13
0
//------------------------------------------------------------------------------------------------------------------------------------------------------
bool Settings::Load()
{
    nameFile = String("TVData/settings.xml");

    mapIntChild[IntKey(TV_SCREEN_WIDTH)] = SET::WINDOW::WIDTH;
    mapIntChild[IntKey(TV_SCREEN_HEIGHT)] = SET::WINDOW::HEIGHT;
    mapIntChild[IntKey(TV_LANGUAGE)] = 1;
    mapIntChild[IntKey(TV_TEXTURE_QUALITY)] = 2;
    mapIntChild[IntKey(TV_BRIGHTNESS)] = 50;
    mapIntChild[IntKey(TV_VOLUME)] = 50;
    mapIntChild[IntKey(TV_MAX_OCCLUDER_TRIANGLES)] = 5000;
    mapIntChild[IntKey(TV_TEXTURE_ANISOTROPY)] = 3;
    mapIntChild[IntKey(TV_MATERIAL_QUALITY)] = 3;
    mapIntChild[IntKey(TV_SHADOW_DRAW)] = 1;
    mapIntChild[IntKey(TV_SPECULAR_LIGHTING)] = 1;
    mapIntChild[IntKey(TV_SHADOW_MAP_SIZE)] = 4;
    mapIntChild[IntKey(TV_PANEL_BOTTOM_BUTTON_WIDTH)] = SET::PANEL::BOTTOM::BUTTON::WIDTH;
    mapIntChild[IntKey(TV_PANEL_BOTTOM_BUTTON_HEIGHT)] = SET::PANEL::BOTTOM::BUTTON::HEIGHT;
    mapIntChild[IntKey(TV_PANEL_BOTTOM_HEIGHT)] = SET::PANEL::BOTTOM::HEIGHT;
    mapIntChild[IntKey(TV_PANEL_MAP_WIDTH)] = SET::PANEL::MAP::WIDTH;
    mapIntChild[IntKey(TV_PANEL_BOTTOM_BUTTON_Y)] = 3;

    mapFloatChild[FloatKey(TV_PANEL_SPEED)] = SET::PANEL::SPEED;

    File inFile(gContext);
    if(inFile.Open(nameFile, Urho3D::FILE_READ))
    {
        file = new XMLFile(gContext);
        bool begined = file->BeginLoad(inFile);
        if(begined)
        {
            root = file->GetRoot();
            if(root != XMLElement::EMPTY)
            {
                return true;
            }
        }
    }
    if (file == nullptr)
    {
        file = new XMLFile(gContext);
    }
    root = file->CreateRoot("settings");
    return false;
}
 *  Copyright 2007-2012 IMP Inventors. All rights reserved.
 *
 */

#include <IMP/saxs/FormFactorTable.h>
#include <IMP/atom/Atom.h>
#include <IMP/constants.h>
#include <IMP/algebra/utility.h>

#include <fstream>
#include <algorithm>
#include <cmath>

IMPSAXS_BEGIN_NAMESPACE

IntKey FormFactorTable::form_factor_type_key_ = IntKey("form factor key");

std::map<atom::Element, FormFactorTable::FormFactorAtomType>
FormFactorTable::element_ff_type_map_;

std::map<atom::ResidueType, FormFactorTable::FormFactor>
FormFactorTable::residue_type_form_factor_map_;

Float FormFactorTable::zero_form_factors_[] = {
  -0.720147, -0.720228,
   //   H       He
  1.591, 2.591, 3.591, 0.50824, 6.16294, 4.94998, 7.591, 6.993,
  // Li     Be      B     C       N        O       F      Ne
  7.9864, 8.9805, 9.984, 10.984, 13.0855, 9.36656, 13.984, 16.591,
  //  Na      Mg     Al     Si      P        S       Cl     Ar
  15.984, 14.9965, 20.984, 21.984, 20.9946, 23.984,