Ember.Ember Class
Item Index
Methods
- $
- A
- addObserver
- aliasMethod
- apply
- arrayComputed
- beginPropertyChanges
- bind
- cacheFor
- changeProperties
- compare
- computed
- computed.alias
- computed.and
- computed.any
- computed.bool
- computed.collect
- computed.defaultTo deprecated
- computed.deprecatingAlias
- computed.empty
- computed.equal
- computed.filter
- computed.gt
- computed.gte
- computed.intersect
- computed.lt
- computed.lte
- computed.match
- computed.none
- computed.not
- computed.notEmpty
- computed.oneWay
- computed.or
- computed.readOnly
- computed.reads
- computed.sort
- computed.sum
- computed.uniq
- controllerFor
- copy
- create
- create static
- deprecateProperty
- destroy
- detect
- endPropertyChanges
- generateControllerFactory
- generateGuid
- get
- getProperties
- inject.controller
- inject.service
- inspect
- isArray
- isBlank
- isEmpty
- isEqual
- isGlobalPath
- isNone
- isPresent
- K
- K
- keys
- makeArray
- merge
- meta
- mixin
- normalizeTuple
- observer
- onLoad
- propertyDidChange
- propertyWillChange
- reduceComputed
- registerASTPlugin
- reopen
- required
- set
- suspendListener
- tryCatchFinally
- tryFinally
- tryInvoke
- trySet
- typeOf
- watch
Methods
$
()
Alias for jQuery
A
()
Ember.NativeArray
Creates an Ember.NativeArray
from an Array like object.
Does not modify the original object. Ember.A is not needed if
Ember.EXTEND_PROTOTYPES
is true
(the default value). However,
it is recommended that you use Ember.A when creating addons for
ember or when you can not guarantee that Ember.EXTEND_PROTOTYPES
will be true
.
Example
var Pagination = Ember.CollectionView.extend({
tagName: 'ul',
classNames: ['pagination'],
init: function() {
this._super();
if (!this.get('content')) {
this.set('content', Ember.A());
}
}
});
Returns:
addObserver
-
obj
-
path
-
targetOrMethod
-
[method]
aliasMethod
-
methodName
Makes a method available via an additional name.
App.Person = Ember.Object.extend({
name: function() {
return 'Tomhuda Katzdale';
},
moniker: Ember.aliasMethod('name')
});
var goodGuy = App.Person.create();
goodGuy.name(); // 'Tomhuda Katzdale'
goodGuy.moniker(); // 'Tomhuda Katzdale'
Parameters:
-
methodName
Stringname of the method to alias
Returns:
arrayComputed
-
[dependentKeys*]
-
options
Creates a computed property which operates on dependent arrays and
is updated with "one at a time" semantics. When items are added or
removed from the dependent array(s) an array computed only operates
on the change instead of re-evaluating the entire array. This should
return an array, if you'd like to use "one at a time" semantics and
compute some value other then an array look at
Ember.reduceComputed
.
If there are more than one arguments the first arguments are considered to be dependent property keys. The last argument is required to be an options object. The options object can have the following three properties.
initialize
- An optional initialize function. Typically this will be used
to set up state on the instanceMeta object.
removedItem
- A function that is called each time an element is
removed from the array.
addedItem
- A function that is called each time an element is
added to the array.
The initialize
function has the following signature:
function(array, changeMeta, instanceMeta)
array
- The initial value of the arrayComputed, an empty array.
changeMeta
- An object which contains meta information about the
computed. It contains the following properties:
property
the computed propertypropertyName
the name of the property on the object
instanceMeta
- An object that can be used to store meta
information needed for calculating your computed. For example a
unique computed might use this to store the number of times a given
element is found in the dependent array.
The removedItem
and addedItem
functions both have the following signature:
function(accumulatedValue, item, changeMeta, instanceMeta)
accumulatedValue
- The value returned from the last time
removedItem
or addedItem
was called or an empty array.
item
- the element added or removed from the array
changeMeta
- An object which contains meta information about the
change. It contains the following properties:
property
the computed propertypropertyName
the name of the property on the objectindex
the index of the added or removed itemitem
the added or removed item: this is exactly the same as the second argarrayChanged
the array that triggered the change. Can be useful when depending on multiple arrays.
For property changes triggered on an item property change (when
depKey is something like<EMAIL_ADDRESS>),
changeMeta
will also contain the following property:
previousValues
an object whose keys are the properties that changed on the item, and whose values are the item's previous values.
previousValues
is important Ember coalesces item property changes via
Ember.run.once. This means that by the time removedItem gets called, item has
the new values, but you may need the previous value (eg for sorting &
filtering).
instanceMeta
- An object that can be used to store meta
information needed for calculating your computed. For example a
unique computed might use this to store the number of times a given
element is found in the dependent array.
The removedItem
and addedItem
functions should return the accumulated
value. It is acceptable to not return anything (ie return undefined)
to invalidate the computation. This is generally not a good idea for
arrayComputed but it's used in eg max and min.
Example
Ember.computed.map = function(dependentKey, callback) {
var options = {
addedItem: function(array, item, changeMeta, instanceMeta) {
var mapped = callback(item);
array.insertAt(changeMeta.index, mapped);
return array;
},
removedItem: function(array, item, changeMeta, instanceMeta) {
array.removeAt(changeMeta.index, 1);
return array;
}
};
return Ember.arrayComputed(dependentKey, options);
};
Returns:
beginPropertyChanges
()
private
chainable
bind
-
obj
-
to
-
from
Global helper method to create a new binding. Just pass the root object
along with a to
and from
path to create and connect the binding.
Parameters:
Returns:
binding instance
cacheFor
-
obj
-
key
Returns the cached value for a property, if one exists. This can be useful for peeking at the value of a computed property that is generated lazily, without accidentally causing it to be created.
Parameters:
Returns:
the cached value
changeProperties
-
callback
-
[binding]
Make a series of property changes together in an exception-safe way.
Ember.changeProperties(function() {
obj1.set('foo', mayBlowUpWhenSet);
obj2.set('bar', baz);
});
compare
-
v
-
w
This will compare two javascript values of possibly different types. It will tell you which one is greater than the other by returning:
- -1 if the first is smaller than the second,
- 0 if both are equal,
- 1 if the first is greater than the second.
The order is calculated based on Ember.ORDER_DEFINITION
, if types are different.
In case they have the same type an appropriate comparison for this type is made.
Ember.compare('hello', 'hello'); // 0
Ember.compare('abc', 'dfg'); // -1
Ember.compare(2, 1); // 1
Returns:
-1 if v < w, 0 if v = w and 1 if v > w.
computed
-
[dependentKeys*]
-
func
This helper returns a new property descriptor that wraps the passed
computed property function. You can use this helper to define properties
with mixins or via Ember.defineProperty()
.
The function you pass will be used to both get and set property values. The function should accept two parameters, key and value. If value is not undefined you should set the value first. In either case return the current value of the property.
A computed property defined in this way might look like this:
var Person = Ember.Object.extend({
firstName: 'Betty',
lastName: 'Jones',
fullName: Ember.computed('firstName', 'lastName', function(key, value) {
return this.get('firstName') + ' ' + this.get('lastName');
})
});
var client = Person.create();
client.get('fullName'); // 'Betty Jones'
client.set('lastName', 'Fuller');
client.get('fullName'); // 'Betty Fuller'
Note: This is the preferred way to define computed properties when writing third-party libraries that depend on or use Ember, since there is no guarantee that the user will have prototype extensions enabled.
You might use this method if you disabled Prototype Extensions. The alternative syntax might look like this (if prototype extensions are enabled, which is the default behavior):
fullName: function () {
return this.get('firstName') + ' ' + this.get('lastName');
}.property('firstName', 'lastName')
Parameters:
Returns:
property descriptor instance
computed.alias
-
dependentKey
Creates a new property that is an alias for another property
on an object. Calls to get
or set
this property behave as
though they were called on the original property.
var Person = Ember.Object.extend({
name: 'Alex Matchneer',
nomen: Ember.computed.alias('name')
});
var alex = Person.create();
alex.get('nomen'); // 'Alex Matchneer'
alex.get('name'); // 'Alex Matchneer'
alex.set('nomen', '@machty');
alex.get('name'); // '@machty'
Parameters:
-
dependentKey
String
Returns:
computed property which creates an alias to the original value for property.
computed.and
-
dependentKey
A computed property that performs a logical and
on the
original values for the provided dependent properties.
Example
var Hamster = Ember.Object.extend({
readyForCamp: Ember.computed.and('hasTent', 'hasBackpack')
});
var hamster = Hamster.create();
hamster.get('readyForCamp'); // false
hamster.set('hasTent', true);
hamster.get('readyForCamp'); // false
hamster.set('hasBackpack', true);
hamster.get('readyForCamp'); // true
Parameters:
-
dependentKey
String multiple
Returns:
computed property which performs
a logical and
on the values of all the original values for properties.
computed.any
-
dependentKey
A computed property that returns the first truthy value from a list of dependent properties.
Example
var Hamster = Ember.Object.extend({
hasClothes: Ember.computed.any('hat', 'shirt')
});
var hamster = Hamster.create();
hamster.get('hasClothes'); // null
hamster.set('shirt', 'Hawaiian Shirt');
hamster.get('hasClothes'); // 'Hawaiian Shirt'
Parameters:
-
dependentKey
String multiple
Returns:
computed property which returns the first truthy value of given list of properties.
computed.bool
-
dependentKey
A computed property that converts the provided dependent property into a boolean value.
var Hamster = Ember.Object.extend({
hasBananas: Ember.computed.bool('numBananas')
});
var hamster = Hamster.create();
hamster.get('hasBananas'); // false
hamster.set('numBananas', 0);
hamster.get('hasBananas'); // false
hamster.set('numBananas', 1);
hamster.get('hasBananas'); // true
hamster.set('numBananas', null);
hamster.get('hasBananas'); // false
Parameters:
-
dependentKey
String
Returns:
computed property which converts to boolean the original value for property
computed.collect
-
dependentKey
A computed property that returns the array of values for the provided dependent properties.
Example
var Hamster = Ember.Object.extend({
clothes: Ember.computed.collect('hat', 'shirt')
});
var hamster = Hamster.create();
hamster.get('clothes'); // [null, null]
hamster.set('hat', 'Camp Hat');
hamster.set('shirt', 'Camp Shirt');
hamster.get('clothes'); // ['Camp Hat', 'Camp Shirt']
Parameters:
-
dependentKey
String multiple
Returns:
computed property which maps values of all passed in properties to an array.
computed.defaultTo
-
defaultPath
A computed property that acts like a standard getter and setter,
but returns the value at the provided defaultPath
if the
property itself has not been set to a value
Example
var Hamster = Ember.Object.extend({
wishList: Ember.computed.defaultTo('favoriteFood')
});
var hamster = Hamster.create({ favoriteFood: 'Banana' });
hamster.get('wishList'); // 'Banana'
hamster.set('wishList', 'More Unit Tests');
hamster.get('wishList'); // 'More Unit Tests'
hamster.get('favoriteFood'); // 'Banana'
Parameters:
-
defaultPath
String
Returns:
computed property which acts like
a standard getter and setter, but defaults to the value from defaultPath
.
computed.deprecatingAlias
-
dependentKey
Creates a new property that is an alias for another property
on an object. Calls to get
or set
this property behave as
though they were called on the original property, but also
print a deprecation warning.
Parameters:
-
dependentKey
String
Returns:
computed property which creates an alias with a deprecation to the original value for property.
computed.empty
-
dependentKey
A computed property that returns true if the value of the dependent property is null, an empty string, empty array, or empty function.
Example
var ToDoList = Ember.Object.extend({
isDone: Ember.computed.empty('todos')
});
var todoList = ToDoList.create({
todos: ['Unit Test', 'Documentation', 'Release']
});
todoList.get('isDone'); // false
todoList.get('todos').clear();
todoList.get('isDone'); // true
Parameters:
-
dependentKey
String
Returns:
computed property which negate the original value for property
computed.equal
-
dependentKey
-
value
A computed property that returns true if the provided dependent property is equal to the given value.
Example
var Hamster = Ember.Object.extend({
napTime: Ember.computed.equal('state', 'sleepy')
});
var hamster = Hamster.create();
hamster.get('napTime'); // false
hamster.set('state', 'sleepy');
hamster.get('napTime'); // true
hamster.set('state', 'hungry');
hamster.get('napTime'); // false
Returns:
computed property which returns true if the original value for property is equal to the given value.
computed.filter
-
dependentKey
-
callback
Filters the array by the callback.
The callback method you provide should have the following signature.
item
is the current item in the iteration.
index
is the integer index of the current item in the iteration.
array
is the dependant array itself.
function(item, index, array);
var Hamster = Ember.Object.extend({
remainingChores: Ember.computed.filter('chores', function(chore, index, array) {
return !chore.done;
})
});
var hamster = Hamster.create({
chores: [
{ name: 'cook', done: true },
{ name: 'clean', done: true },
{ name: 'write more unit tests', done: false }
]
});
hamster.get('remainingChores'); // [{name: 'write more unit tests', done: false}]
Returns:
the filtered array
computed.gt
-
dependentKey
-
value
A computed property that returns true if the provided dependent property is greater than the provided value.
Example
var Hamster = Ember.Object.extend({
hasTooManyBananas: Ember.computed.gt('numBananas', 10)
});
var hamster = Hamster.create();
hamster.get('hasTooManyBananas'); // false
hamster.set('numBananas', 3);
hamster.get('hasTooManyBananas'); // false
hamster.set('numBananas', 11);
hamster.get('hasTooManyBananas'); // true
Returns:
computed property which returns true if the original value for property is greater than given value.
computed.gte
-
dependentKey
-
value
A computed property that returns true if the provided dependent property is greater than or equal to the provided value.
Example
var Hamster = Ember.Object.extend({
hasTooManyBananas: Ember.computed.gte('numBananas', 10)
});
var hamster = Hamster.create();
hamster.get('hasTooManyBananas'); // false
hamster.set('numBananas', 3);
hamster.get('hasTooManyBananas'); // false
hamster.set('numBananas', 10);
hamster.get('hasTooManyBananas'); // true
Returns:
computed property which returns true if the original value for property is greater or equal then given value.
computed.intersect
-
propertyKey
A computed property which returns a new array with all the duplicated elements from two or more dependent arrays.
Example
var obj = Ember.Object.createWithMixins({
adaFriends: ['Charles Babbage', 'John Hobhouse', 'William King', 'Mary Somerville'],
charlesFriends: ['William King', 'Mary Somerville', 'Ada Lovelace', 'George Peacock'],
friendsInCommon: Ember.computed.intersect('adaFriends', 'charlesFriends')
});
obj.get('friendsInCommon'); // ['William King', 'Mary Somerville']
Parameters:
-
propertyKey
String multiple
Returns:
computes a new array with all the duplicated elements from the dependent arrays
computed.lt
-
dependentKey
-
value
A computed property that returns true if the provided dependent property is less than the provided value.
Example
var Hamster = Ember.Object.extend({
needsMoreBananas: Ember.computed.lt('numBananas', 3)
});
var hamster = Hamster.create();
hamster.get('needsMoreBananas'); // true
hamster.set('numBananas', 3);
hamster.get('needsMoreBananas'); // false
hamster.set('numBananas', 2);
hamster.get('needsMoreBananas'); // true
Returns:
computed property which returns true if the original value for property is less then given value.
computed.lte
-
dependentKey
-
value
A computed property that returns true if the provided dependent property is less than or equal to the provided value.
Example
var Hamster = Ember.Object.extend({
needsMoreBananas: Ember.computed.lte('numBananas', 3)
});
var hamster = Hamster.create();
hamster.get('needsMoreBananas'); // true
hamster.set('numBananas', 5);
hamster.get('needsMoreBananas'); // false
hamster.set('numBananas', 3);
hamster.get('needsMoreBananas'); // true
Returns:
computed property which returns true if the original value for property is less or equal than given value.
computed.match
-
dependentKey
-
regexp
A computed property which matches the original value for the
dependent property against a given RegExp, returning true
if they values matches the RegExp and false
if it does not.
Example
var User = Ember.Object.extend({
hasValidEmail: Ember.computed.match('email'<EMAIL_ADDRESS>});
var user = User.create({loggedIn: false});
user.get('hasValidEmail'); // false
user.set('email', '');
user.get('hasValidEmail'); // false
user.set('email', 'ember_hamster@example.com');
user.get('hasValidEmail'); // true
Returns:
computed property which match the original value for property against a given RegExp
computed.none
-
dependentKey
A computed property that returns true if the value of the dependent property is null or undefined. This avoids errors from JSLint complaining about use of ==, which can be technically confusing.
Example
var Hamster = Ember.Object.extend({
isHungry: Ember.computed.none('food')
});
var hamster = Hamster.create();
hamster.get('isHungry'); // true
hamster.set('food', 'Banana');
hamster.get('isHungry'); // false
hamster.set('food', null);
hamster.get('isHungry'); // true
Parameters:
-
dependentKey
String
Returns:
computed property which returns true if original value for property is null or undefined.
computed.not
-
dependentKey
A computed property that returns the inverse boolean value of the original value for the dependent property.
Example
var User = Ember.Object.extend({
isAnonymous: Ember.computed.not('loggedIn')
});
var user = User.create({loggedIn: false});
user.get('isAnonymous'); // true
user.set('loggedIn', true);
user.get('isAnonymous'); // false
Parameters:
-
dependentKey
String
Returns:
computed property which returns inverse of the original value for property
computed.notEmpty
-
dependentKey
A computed property that returns true if the value of the dependent property is NOT null, an empty string, empty array, or empty function.
Example
var Hamster = Ember.Object.extend({
hasStuff: Ember.computed.notEmpty('backpack')
});
var hamster = Hamster.create({ backpack: ['Food', 'Sleeping Bag', 'Tent'] });
hamster.get('hasStuff'); // true
hamster.get('backpack').clear(); // []
hamster.get('hasStuff'); // false
Parameters:
-
dependentKey
String
Returns:
computed property which returns true if original value for property is not empty.
computed.oneWay
-
dependentKey
Where computed.alias
aliases get
and set
, and allows for bidirectional
data flow, computed.oneWay
only provides an aliased get
. The set
will
not mutate the upstream property, rather causes the current property to
become the value set. This causes the downstream property to permanently
diverge from the upstream property.
Example
var User = Ember.Object.extend({
firstName: null,
lastName: null,
nickName: Ember.computed.oneWay('firstName')
});
var teddy = User.create({
firstName: 'Teddy',
lastName: 'Zeenny'
});
teddy.get('nickName'); // 'Teddy'
teddy.set('nickName', 'TeddyBear'); // 'TeddyBear'
teddy.get('firstName'); // 'Teddy'
Parameters:
-
dependentKey
String
Returns:
computed property which creates a one way computed property to the original value for property.
computed.or
-
dependentKey
A computed property which performs a logical or
on the
original values for the provided dependent properties.
Example
var Hamster = Ember.Object.extend({
readyForRain: Ember.computed.or('hasJacket', 'hasUmbrella')
});
var hamster = Hamster.create();
hamster.get('readyForRain'); // false
hamster.set('hasJacket', true);
hamster.get('readyForRain'); // true
Parameters:
-
dependentKey
String multiple
Returns:
computed property which performs
a logical or
on the values of all the original values for properties.
computed.readOnly
-
dependentKey
Where computed.oneWay
provides oneWay bindings, computed.readOnly
provides
a readOnly one way binding. Very often when using computed.oneWay
one does
not also want changes to propagate back up, as they will replace the value.
This prevents the reverse flow, and also throws an exception when it occurs.
Example
var User = Ember.Object.extend({
firstName: null,
lastName: null,
nickName: Ember.computed.readOnly('firstName')
});
var teddy = User.create({
firstName: 'Teddy',
lastName: 'Zeenny'
});
teddy.get('nickName'); // 'Teddy'
teddy.set('nickName', 'TeddyBear'); // throws Exception
// throw new Ember.Error('Cannot Set: nickName on: <User:ember27288>' );`
teddy.get('firstName'); // 'Teddy'
Parameters:
-
dependentKey
String
Returns:
computed property which creates a one way computed property to the original value for property.
computed.reads
-
dependentKey
This is a more semantically meaningful alias of computed.oneWay
,
whose name is somewhat ambiguous as to which direction the data flows.
Parameters:
-
dependentKey
String
Returns:
computed property which creates a one way computed property to the original value for property.
computed.sort
-
dependentKey
-
sortDefinition
A computed property which returns a new array with all the properties from the first dependent array sorted based on a property or sort function.
The callback method you provide should have the following signature:
function(itemA, itemB);
itemA
the first item to compare.itemB
the second item to compare.
This function should return negative number (e.g. -1
) when itemA
should come before
itemB
. It should return positive number (e.g. 1
) when itemA
should come after
itemB
. If the itemA
and itemB
are equal this function should return 0
.
Therefore, if this function is comparing some numeric values, simple itemA - itemB
or
itemA.get( 'foo' ) - itemB.get( 'foo' )
can be used instead of series of if
.
Example
var ToDoList = Ember.Object.extend({
// using standard ascending sort
todosSorting: ['name'],
sortedTodos: Ember.computed.sort('todos', 'todosSorting'),
// using descending sort
todosSortingDesc: ['name:desc'],
sortedTodosDesc: Ember.computed.sort('todos', 'todosSortingDesc'),
// using a custom sort function
priorityTodos: Ember.computed.sort('todos', function(a, b){
if (a.priority > b.priority) {
return 1;
} else if (a.priority < b.priority) {
return -1;
}
return 0;
})
});
var todoList = ToDoList.create({todos: [
{ name: 'Unit Test', priority: 2 },
{ name: 'Documentation', priority: 3 },
{ name: 'Release', priority: 1 }
]});
todoList.get('sortedTodos'); // [{ name:'Documentation', priority:3 }, { name:'Release', priority:1 }, { name:'Unit Test', priority:2 }]
todoList.get('sortedTodosDesc'); // [{ name:'Unit Test', priority:2 }, { name:'Release', priority:1 }, { name:'Documentation', priority:3 }]
todoList.get('priorityTodos'); // [{ name:'Release', priority:1 }, { name:'Unit Test', priority:2 }, { name:'Documentation', priority:3 }]
Parameters:
-
dependentKey
String -
sortDefinition
String or Functiona dependent key to an array of sort properties (add
:desc
to the arrays sort properties to sort descending) or a function to use when sorting
Returns:
computes a new sorted array based on the sort property array or callback function
computed.sum
-
dependentKey
A computed property that returns the sum of the value in the dependent array.
Parameters:
-
dependentKey
String
Returns:
computes the sum of all values in the dependentKey's array
computed.uniq
-
propertyKey
A computed property which returns a new array with all the unique elements from one or more dependent arrays.
Example
var Hamster = Ember.Object.extend({
uniqueFruits: Ember.computed.uniq('fruits')
});
var hamster = Hamster.create({
fruits: [
'banana',
'grape',
'kale',
'banana'
]
});
hamster.get('uniqueFruits'); // ['banana', 'grape', 'kale']
Parameters:
-
propertyKey
String multiple
Returns:
computes a new array with all the unique elements from the dependent array
controllerFor
()
private
Finds a controller instance.
copy
-
obj
-
deep
Creates a clone of the passed object. This function can take just about any type of object and create a clone of it, including primitive values (which are not actually cloned because they are immutable).
If the passed object implements the copy()
method, then this function
will simply call that method and return the result. Please see
Ember.Copyable
for further details.
Returns:
The cloned object
create
()
Identical to Object.create()
. Implements if not available natively.
deprecateProperty
-
object
-
deprecatedKey
-
newKey
Used internally to allow changing properties in a backwards compatible way, and print a helpful deprecation warning.
destroy
-
obj
Tears down the meta on an object so that it can be garbage collected. Multiple calls will have no effect.
Parameters:
-
obj
Objectthe object to destroy
Returns:
endPropertyChanges
()
private
generateControllerFactory
()
private
Generates a controller factory
The type of the generated controller factory is derived from the context. If the context is an array an array controller is generated, if an object, an object controller otherwise, a basic controller is generated.
You can customize your generated controllers by defining
App.ObjectController
or App.ArrayController
.
generateGuid
-
[obj]
-
[prefix]
Generates a new guid, optionally saving the guid to the object that you
pass in. You will rarely need to use this method. Instead you should
call Ember.guidFor(obj)
, which return an existing guid if available.
Parameters:
-
[obj]
Object optionalObject the guid will be used for. If passed in, the guid will be saved on the object and reused whenever you pass the same object again.
If no object is passed, just generate a new guid.
-
[prefix]
String optionalPrefix to place in front of the guid. Useful when you want to separate the guid into separate namespaces.
Returns:
the guid
get
-
obj
-
keyName
Gets the value of a property on an object. If the property is computed,
the function will be invoked. If the property is not defined but the
object implements the unknownProperty
method then that will be invoked.
If you plan to run on IE8 and older browsers then you should use this method anytime you want to retrieve a property on an object that you don't know for sure is private. (Properties beginning with an underscore '_' are considered private.)
On all newer browsers, you only need to use this method to retrieve
properties if the property might not be defined on the object and you want
to respect the unknownProperty
handler. Otherwise you can ignore this
method.
Note that if the object itself is undefined
, this method will throw
an error.
Returns:
the property value or null
.
getProperties
-
obj
-
list
To get multiple properties at once, call Ember.getProperties
with an object followed by a list of strings or an array:
Ember.getProperties(record, 'firstName', 'lastName', 'zipCode');
// { firstName: 'John', lastName: 'Doe', zipCode: '10011' }
is equivalent to:
Ember.getProperties(record, ['firstName', 'lastName', 'zipCode']);
// { firstName: 'John', lastName: 'Doe', zipCode: '10011' }
Returns:
inject.controller
-
name
Creates a property that lazily looks up another controller in the container. Can only be used when defining another controller.
Example:
App.PostController = Ember.Controller.extend({
posts: Ember.inject.controller()
});
This example will create a posts
property on the post
controller that
looks up the posts
controller in the container, making it easy to
reference other controllers. This is functionally equivalent to:
App.PostController = Ember.Controller.extend({
needs: 'posts',
posts: Ember.computed.alias('controllers.posts')
});
Parameters:
-
name
String(optional) name of the controller to inject, defaults to the property's name
Returns:
injection descriptor instance
inject.service
-
name
Creates a property that lazily looks up a service in the container. There are no restrictions as to what objects a service can be injected into.
Example:
App.ApplicationRoute = Ember.Route.extend({
authManager: Ember.inject.service('auth'),
model: function() {
return this.get('authManager').findCurrentUser();
}
});
This example will create an authManager
property on the application route
that looks up the auth
service in the container, making it easily
accessible in the model
hook.
Parameters:
-
name
String(optional) name of the service to inject, defaults to the property's name
Returns:
injection descriptor instance
inspect
-
obj
Convenience method to inspect an object. This method will attempt to convert the object into a useful string description.
It is a pretty simple implementation. If you want something more robust, use something like JSDump: https://github.com/NV/jsDump
Parameters:
-
obj
ObjectThe object you want to inspect.
Returns:
A description of the object
isArray
-
obj
Returns true if the passed object is an array or Array-like.
Ember Array Protocol:
- the object has an objectAt property
- the object is a native Array
- the object is an Object, and has a length property
Unlike Ember.typeOf
this method returns true even if the passed object is
not formally array but appears to be array-like (i.e. implements Ember.Array
)
Ember.isArray(); // false
Ember.isArray([]); // true
Ember.isArray(Ember.ArrayProxy.create({ content: [] })); // true
Parameters:
-
obj
ObjectThe object to test
Returns:
true if the passed object is an array or Array-like
isBlank
-
obj
A value is blank if it is empty or a whitespace string.
Ember.isBlank(); // true
Ember.isBlank(null); // true
Ember.isBlank(undefined); // true
Ember.isBlank(''); // true
Ember.isBlank([]); // true
Ember.isBlank('\n\t'); // true
Ember.isBlank(' '); // true
Ember.isBlank({}); // false
Ember.isBlank('\n\t Hello'); // false
Ember.isBlank('Hello world'); // false
Ember.isBlank([1,2,3]); // false
Parameters:
-
obj
ObjectValue to test
Returns:
isEmpty
-
obj
Verifies that a value is null
or an empty string, empty array,
or empty function.
Constrains the rules on Ember.isNone
by returning true for empty
string and empty arrays.
Ember.isEmpty(); // true
Ember.isEmpty(null); // true
Ember.isEmpty(undefined); // true
Ember.isEmpty(''); // true
Ember.isEmpty([]); // true
Ember.isEmpty({}); // false
Ember.isEmpty('Adam Hawkins'); // false
Ember.isEmpty([0,1,2]); // false
Parameters:
-
obj
ObjectValue to test
Returns:
isEqual
-
a
-
b
Compares two objects, returning true if they are logically equal. This is
a deeper comparison than a simple triple equal. For sets it will compare the
internal objects. For any other object that implements isEqual()
it will
respect that method.
Ember.isEqual('hello', 'hello'); // true
Ember.isEqual(1, 2); // false
Ember.isEqual([4, 2], [4, 2]); // false
Returns:
isGlobalPath
-
path
Returns true if the provided path is global (e.g., MyApp.fooController.bar
)
instead of local (foo.bar.baz
).
Parameters:
-
path
String
Returns:
Boolean
-
pattern
-
callback
Expands pattern
, invoking callback
for each expansion.
The only pattern supported is brace-expansion, anything else will be passed
once to callback
directly.
Example
function echo(arg){ console.log(arg); }
Ember.expandProperties('foo.bar', echo); //=> 'foo.bar'
Ember.expandProperties('{foo,bar}', echo); //=> 'foo', 'bar'
Ember.expandProperties('foo.{bar,baz}', echo); //=> 'foo.bar', 'foo.baz'
Ember.expandProperties('{foo,bar}.baz', echo); //=> '{foo,bar}.baz'
Ember.expandProperties('foo.{bar,baz}.@each', echo) //=> 'foo.bar.@each', 'foo.baz.@each'
Ember.expandProperties('{foo,bar}.{spam,eggs}', echo) //=> 'foo.spam', 'foo.eggs', 'bar.spam', 'bar.eggs'
Ember.expandProperties('{foo}.bar.{baz}') //=> 'foo.bar.baz'
isNone
-
obj
Returns true if the passed value is null or undefined. This avoids errors from JSLint complaining about use of ==, which can be technically confusing.
Ember.isNone(); // true
Ember.isNone(null); // true
Ember.isNone(undefined); // true
Ember.isNone(''); // false
Ember.isNone([]); // false
Ember.isNone(function() {}); // false
Parameters:
-
obj
ObjectValue to test
Returns:
isPresent
-
obj
A value is present if it not isBlank
.
Ember.isPresent(); // false
Ember.isPresent(null); // false
Ember.isPresent(undefined); // false
Ember.isPresent(''); // false
Ember.isPresent([]); // false
Ember.isPresent('\n\t'); // false
Ember.isPresent(' '); // false
Ember.isPresent({}); // true
Ember.isPresent('\n\t Hello'); // true
Ember.isPresent('Hello world'); // true
Ember.isPresent([1,2,3]); // true
Parameters:
-
obj
ObjectValue to test
Returns:
keys
-
obj
Returns all of the keys defined on an object or hash. This is useful
when inspecting objects for debugging. On browsers that support it, this
uses the native Object.keys
implementation.
Parameters:
-
obj
Object
Returns:
Array containing keys of obj
makeArray
-
obj
Forces the passed object to be part of an array. If the object is already
an array or array-like, it will return the object. Otherwise, it will add the object to
an array. If obj is null
or undefined
, it will return an empty array.
Ember.makeArray(); // []
Ember.makeArray(null); // []
Ember.makeArray(undefined); // []
Ember.makeArray('lindsay'); // ['lindsay']
Ember.makeArray([1, 2, 42]); // [1, 2, 42]
var controller = Ember.ArrayProxy.create({ content: [] });
Ember.makeArray(controller) === controller; // true
Parameters:
-
obj
Objectthe object
Returns:
merge
-
original
-
updates
Merge the contents of two objects together into the first object.
Ember.merge({first: 'Tom'}, {last: 'Dale'}); // {first: 'Tom', last: 'Dale'}
var a = {first: 'Yehuda'}, b = {last: 'Katz'};
Ember.merge(a, b); // a == {first: 'Yehuda', last: 'Katz'}, b == {last: 'Katz'}
Parameters:
Returns:
meta
-
obj
-
[writable=true]
Retrieves the meta hash for an object. If writable
is true ensures the
hash is writable for this object as well.
The meta object contains information about computed property descriptors as well as any watched properties and other information. You generally will not access this information directly but instead work with higher level methods that manipulate this hash indirectly.
Parameters:
Returns:
the meta hash for an object
normalizeTuple
-
target
-
path
Normalizes a target/path pair to reflect that actual target/path that should be observed, etc. This takes into account passing in global property paths (i.e. a path beginning with a capital letter not defined on the target).
Parameters:
Returns:
a temporary array with the normalized target/path pair.
observer
-
propertyNames
-
func
Specify a method that observes property changes.
Ember.Object.extend({
valueObserver: Ember.observer('value', function() {
// Executes whenever the "value" property changes
})
});
In the future this method may become asynchronous. If you want to ensure
synchronous behavior, use immediateObserver
.
Also available as Function.prototype.observes
if prototype extensions are
enabled.
Returns:
func
onLoad
-
name
-
callback
Detects when a specific package of Ember (e.g. 'Ember.Handlebars') has fully loaded and is available for extension.
The provided callback
will be called with the name
passed
resolved from a string into the object:
Ember.onLoad('Ember.Handlebars' function(hbars) {
hbars.registerHelper(...);
});
propertyDidChange
-
obj
-
keyName
This function is called just after an object property has changed. It will notify any observers and clear caches among other things.
Normally you will not need to call this method directly but if for some
reason you can't directly watch a property you can invoke this method
manually along with Ember.propertyWillChange()
which you should call just
before the property value changes.
Parameters:
Returns:
propertyWillChange
-
obj
-
keyName
This function is called just before an object property is about to change. It will notify any before observers and prepare caches among other things.
Normally you will not need to call this method directly but if for some
reason you can't directly watch a property you can invoke this method
manually along with Ember.propertyDidChange()
which you should call just
after the property value changes.
Parameters:
Returns:
reduceComputed
-
[dependentKeys*]
-
options
Creates a computed property which operates on dependent arrays and is updated with "one at a time" semantics. When items are added or removed from the dependent array(s) a reduce computed only operates on the change instead of re-evaluating the entire array.
If there are more than one arguments the first arguments are considered to be dependent property keys. The last argument is required to be an options object. The options object can have the following four properties:
initialValue
- A value or function that will be used as the initial
value for the computed. If this property is a function the result of calling
the function will be used as the initial value. This property is required.
initialize
- An optional initialize function. Typically this will be used
to set up state on the instanceMeta object.
removedItem
- A function that is called each time an element is removed
from the array.
addedItem
- A function that is called each time an element is added to
the array.
The initialize
function has the following signature:
function(initialValue, changeMeta, instanceMeta)
initialValue
- The value of the initialValue
property from the
options object.
changeMeta
- An object which contains meta information about the
computed. It contains the following properties:
property
the computed propertypropertyName
the name of the property on the object
instanceMeta
- An object that can be used to store meta
information needed for calculating your computed. For example a
unique computed might use this to store the number of times a given
element is found in the dependent array.
The removedItem
and addedItem
functions both have the following signature:
function(accumulatedValue, item, changeMeta, instanceMeta)
accumulatedValue
- The value returned from the last time
removedItem
or addedItem
was called or initialValue
.
item
- the element added or removed from the array
changeMeta
- An object which contains meta information about the
change. It contains the following properties:
property
the computed propertypropertyName
the name of the property on the objectindex
the index of the added or removed itemitem
the added or removed item: this is exactly the same as the second argarrayChanged
the array that triggered the change. Can be useful when depending on multiple arrays.
For property changes triggered on an item property change (when
depKey is something like<EMAIL_ADDRESS>),
changeMeta
will also contain the following property:
previousValues
an object whose keys are the properties that changed on the item, and whose values are the item's previous values.
previousValues
is important Ember coalesces item property changes via
Ember.run.once. This means that by the time removedItem gets called, item has
the new values, but you may need the previous value (eg for sorting &
filtering).
instanceMeta
- An object that can be used to store meta
information needed for calculating your computed. For example a
unique computed might use this to store the number of times a given
element is found in the dependent array.
The removedItem
and addedItem
functions should return the accumulated
value. It is acceptable to not return anything (ie return undefined)
to invalidate the computation. This is generally not a good idea for
arrayComputed but it's used in eg max and min.
Note that observers will be fired if either of these functions return a value
that differs from the accumulated value. When returning an object that
mutates in response to array changes, for example an array that maps
everything from some other array (see Ember.computed.map
), it is usually
important that the same array be returned to avoid accidentally triggering observers.
Example
Ember.computed.max = function(dependentKey) {
return Ember.reduceComputed(dependentKey, {
initialValue: -Infinity,
addedItem: function(accumulatedValue, item, changeMeta, instanceMeta) {
return Math.max(accumulatedValue, item);
},
removedItem: function(accumulatedValue, item, changeMeta, instanceMeta) {
if (item < accumulatedValue) {
return accumulatedValue;
}
}
});
};
Dependent keys may refer to @this
to observe changes to the object itself,
which must be array-like, rather than a property of the object. This is
mostly useful for array proxies, to ensure objects are retrieved via
objectAtContent
. This is how you could sort items by properties defined on an item controller.
Example
App.PeopleController = Ember.ArrayController.extend({
itemController: 'person',
sortedPeople: Ember.computed.sort('<EMAIL_ADDRESS>function(personA, personB) {
// reversedName
isn't defined on Person, but we have access to it via
// the item controller App.PersonController. If we'd used
//<EMAIL_ADDRESS>above, we would be getting the objects
// directly and not have access to reversedName
.
//
var reversedNameA = get(personA, 'reversedName');
var reversedNameB = get(personB, 'reversedName');
return Ember.compare(reversedNameA, reversedNameB);
})
});
App.PersonController = Ember.ObjectController.extend({
reversedName: function() {
return reverse(get(this, 'name'));
}.property('name')
});
Dependent keys whose values are not arrays are treated as regular
dependencies: when they change, the computed property is completely
recalculated. It is sometimes useful to have dependent arrays with similar
semantics. Dependent keys which end in .[]
do not use "one at a time"
semantics. When an item is added or removed from such a dependency, the
computed property is completely recomputed.
When the computed property is completely recomputed, the accumulatedValue
is discarded, it starts with initialValue
again, and each item is passed
to addedItem
in turn.
Example
Ember.Object.extend({
// When string
is changed, computed
is completely recomputed.
string: 'a string',
// When an item is added to array
, addedItem
is called.
array: [],
// When an item is added to anotherArray
, computed
is completely
// recomputed.
anotherArray: [],
computed: Ember.reduceComputed('string', 'array', 'anotherArray.[]', {
addedItem: addedItemCallback,
removedItem: removedItemCallback
})
});
Returns:
registerASTPlugin
()
private
Adds an AST plugin to be used by Ember.HTMLBars.compile.
required
()
Denotes a required property for a mixin
set
-
obj
-
keyName
-
value
Sets the value of a property on an object, respecting computed properties
and notifying observers and other listeners of the change. If the
property is not defined but the object implements the setUnknownProperty
method then that will be invoked as well.
Parameters:
Returns:
the passed value.
suspendListener
-
obj
-
eventName
-
target
-
method
-
callback
Suspend listener during callback.
This should only be used by the target of the event listener when it is taking an action that would cause the event, e.g. an object might suspend its property change listener while it is setting that property.
tryCatchFinally
-
tryable
-
catchable
-
finalizer
-
[binding]
Provides try/catch/finally functionality, while working around Safari's double finally bug.
var tryable = function() {
for (i = 0, l = listeners.length; i < l; i++) {
listener = listeners[i];
beforeValues[i] = listener.before(name, time(), payload);
}
return callback.call(binding);
};
var catchable = function(e) {
payload = payload || {};
payload.exception = e;
};
var finalizer = function() {
for (i = 0, l = listeners.length; i < l; i++) {
listener = listeners[i];
listener.after(name, time(), payload, beforeValues[i]);
}
};
Ember.tryCatchFinally(tryable, catchable, finalizer);
Parameters:
Returns:
The return value is the that of the finalizer, unless that value is undefined, in which case it is the return value of the tryable.
tryFinally
-
tryable
-
finalizer
-
[binding]
Provides try/finally functionality, while working around Safari's double finally bug.
var tryable = function() {
someResource.lock();
runCallback(); // May throw error.
};
var finalizer = function() {
someResource.unlock();
};
Ember.tryFinally(tryable, finalizer);
Parameters:
Returns:
The return value is the that of the finalizer, unless that value is undefined, in which case it is the return value of the tryable
tryInvoke
-
obj
-
methodName
-
[args]
Checks to see if the methodName
exists on the obj
,
and if it does, invokes it with the arguments passed.
var d = new Date('03/15/2013');
Ember.tryInvoke(d, 'getTime'); //<PHONE_NUMBER>000
Ember.tryInvoke(d, 'setFullYear', [2014]); //<PHONE_NUMBER>000
Ember.tryInvoke(d, 'noSuchMethod', [2014]); // undefined
Parameters:
Returns:
the return value of the invoked method or undefined if it cannot be invoked
trySet
-
obj
-
path
-
value
Error-tolerant form of Ember.set
. Will not blow up if any part of the
chain is undefined
, null
, or destroyed.
This is primarily used when syncing bindings, which may try to update after an object has been destroyed.
typeOf
-
item
Returns a consistent type for the passed item.
Use this instead of the built-in typeof
to get the type of an item.
It will return the same result across all browsers and includes a bit
more detail. Here is what will be returned:
| Return Value | Meaning |
|---------------|------------------------------------------------------|
| 'string' | String primitive or String object. |
| 'number' | Number primitive or Number object. |
| 'boolean' | Boolean primitive or Boolean object. |
| 'null' | Null value |
| 'undefined' | Undefined value |
| 'function' | A function |
| 'array' | An instance of Array |
| 'regexp' | An instance of RegExp |
| 'date' | An instance of Date |
| 'class' | An Ember class (created using Ember.Object.extend()) |
| 'instance' | An Ember object instance |
| 'error' | An instance of the Error object |
| 'object' | A JavaScript object not inheriting from Ember.Object |
Examples:
Ember.typeOf(); // 'undefined'
Ember.typeOf(null); // 'null'
Ember.typeOf(undefined); // 'undefined'
Ember.typeOf('michael'); // 'string'
Ember.typeOf(new String('michael')); // 'string'
Ember.typeOf(101); // 'number'
Ember.typeOf(new Number(101)); // 'number'
Ember.typeOf(true); // 'boolean'
Ember.typeOf(new Boolean(true)); // 'boolean'
Ember.typeOf(Ember.makeArray); // 'function'
Ember.typeOf([1, 2, 90]); // 'array'
Ember.typeOf(/abc/); // 'regexp'
Ember.typeOf(new Date()); // 'date'
Ember.typeOf(Ember.Object.extend()); // 'class'
Ember.typeOf(Ember.Object.create()); // 'instance'
Ember.typeOf(new Error('teamocil')); // 'error'
// 'normal' JavaScript object
Ember.typeOf({ a: 'b' }); // 'object'
Parameters:
-
item
Objectthe item to check
Returns:
the type
watch
-
obj
-
keyName
Starts watching a property on an object. Whenever the property changes,
invokes Ember.propertyWillChange
and Ember.propertyDidChange
. This is the
primitive used by observers and dependent keys; usually you will never call
this method directly but instead use higher level methods like
Ember.addObserver()
Properties
EXTEND_PROTOTYPES
Boolean
Determines whether Ember should enhance some built-in object prototypes to
provide a more friendly API. If enabled, a few methods will be added to
Function
, String
, and Array
. Object.prototype
will not be enhanced,
which is the one that causes most trouble for people.
In general we recommend leaving this option set to true since it rarely
conflicts with other code. If you need to turn it off however, you can
define an EmberENV.EXTEND_PROTOTYPES
config to disable it.
Default: true
EXTEND_PROTOTYPES
Boolean
Determines whether Ember should enhance some built-in object prototypes to
provide a more friendly API. If enabled, a few methods will be added to
Function
, String
, and Array
. Object.prototype
will not be enhanced,
which is the one that causes most trouble for people.
In general we recommend leaving this option set to true since it rarely
conflicts with other code. If you need to turn it off however, you can
define an EmberENV.EXTEND_PROTOTYPES
config to disable it.
Default: true
GUID_KEY
String
private
final
A unique key used to assign guids and other private metadata to objects. If you inspect an object in your browser debugger you will often see these. They can be safely ignored.
On browsers that support it, these properties are added with enumeration disabled so they won't show up when you iterate over your properties.
helpers
Unknown
private
LOG_BINDINGS
Boolean
Debug parameter you can turn on. This will log all bindings that fire to the console. This should be disabled in production code. Note that you can also enable this from the console or temporarily.
Default: false
LOG_STACKTRACE_ON_DEPRECATION
Boolean
Determines whether Ember logs a full stack trace during deprecation warnings
Default: true
LOG_STACKTRACE_ON_DEPRECATION
Boolean
Determines whether Ember logs a full stack trace during deprecation warnings
Default: true
LOG_VERSION
Boolean
Determines whether Ember logs info about version of used libraries
Default: true
LOG_VERSION
Boolean
Determines whether Ember logs info about version of used libraries
Default: true
SHIM_ES5
Boolean
Determines whether Ember should add ECMAScript 5 Array shims to older browsers.
Default: Ember.EXTEND_PROTOTYPES
SHIM_ES5
Boolean
Determines whether Ember should add ECMAScript 5 Array shims to older browsers.
Default: Ember.EXTEND_PROTOTYPES
STRINGS
Hash
Defines the hash of localized strings for the current language. Used by
the Ember.String.loc()
helper. To localize, add string values to this
hash.
TEMPLATES
Hash
Global hash of shared templates. This will automatically be populated by the build tools so that you can store your Handlebars templates in separate files that get loaded into JavaScript at buildtime.


A paragraph consists of one or more sentences that form a self-contained unit of discourse. The start of a paragraph is indicated by a new line.
Text is easier to understand when it is split up into units of text. For example, a book may have chapters. Chapters can have subheadings. Under each heading there will be one or more paragraphs.
This is to show bold
This is to show italic
CO2, E = mc2
The earth
gets hoter
Venus
Jupiter
To be or not to be
He said: To be or not to be
Prof Hawking
It was the worst best idea.
Was $995
Molly had been staring out of her window for about an hour now. On her desk, lying between the copies of Nature, New Scientist, and all the other scientific journals her work had appeared in, was a well thumbed copy of On The Road. It had been Molly's favorite book since college, and the longer she spent in these four walls the more she felt she needed to be free.
She had spent the last ten years in this room,
sitting under a poster with an Oscar Wilde quote
proclaiming that Work is the refuge of
people who have nothing better to do
. Although
many considered her pioneering work, unraveling
the secrets of the llama DNA, to be an
outstanding achievement, Molly did think
she had something better to do.


Monacoin Core integration/staging tree
What is Monacoin?
Monacoin is an experimental digital currency that enables instant payments to anyone, anywhere in the world. Monacoin uses peer-to-peer technology to operate with no central authority: managing transactions and issuing money are carried out collectively by the network. Monacoin Core is the name of open source software which enables the use of this currency.
For more information, as well as an immediately useable, binary version of the Monacoin Core software, see https://monacoin.org.
License
Monacoin Core is released under the terms of the MIT license. See COPYING for more information or see https://opensource.org/licenses/MIT.
Development Process
The master
branch is regularly built and tested, but is not guaranteed to be
completely stable. Tags are created
regularly to indicate new official, stable release versions of Monacoin Core.
The contribution workflow is described in CONTRIBUTING.md.
The developer mailing list should be used to discuss complicated or controversial changes before working on a patch set.
Developer IRC can be found on Freenode at #monacoin-dev.
Testing
Testing and code review is the bottleneck for development; we get more pull requests than we can review and test on short notice. Please be patient and help out by testing other people's pull requests, and remember this is a security-critical project where any mistake might cost people lots of money.
Automated Testing
Developers are strongly encouraged to write unit tests for new code, and to
submit new unit tests for old code. Unit tests can be compiled and run
(assuming they weren't disabled in configure) with: make check
. Further details on running
and extending unit tests can be found in /src/test/README.md.
There are also regression and integration tests of the RPC interface, written
in Python, that are run automatically on the build server.
These tests can be run (if the test dependencies are installed) with: qa/pull-tester/rpc-tests.py
The Travis CI system makes sure that every pull request is built for Windows, Linux, and OS X, and that unit/sanity tests are run automatically.
Manual Quality Assurance (QA) Testing
Changes should be tested by somebody other than the developer who wrote the code. This is especially important for large or high-risk changes. It is useful to add a test plan to the pull request description if testing the changes is not straightforward.
Translations
We only accept translation fixes that are submitted through Bitcoin Core's Transifex page. Translations are converted to Monacoin periodically.
Translations are periodically pulled from Transifex and merged into the git repository. See the translation process for details on how this works.
Important: We do not accept translation changes as GitHub pull requests because the next pull from Transifex would automatically overwrite them again.


This application takes a stream of credit card transactions and issues alerts when potential fraud anomalies are detected. These can also be generated using the buttons below.
{{action.description}}


Start
Prev
Next
Getting my list of works
My ORCID is 0000-0003-0900-6903
We’ll use
scripts/api-works.sh
./scripts/api-works.sh "0000-0003-0900-6903" | jq .
Example output


--- layout: post status: publish published: true title: Can anyone defend Soriano? author: display_name: Corey Fineran login: Corey email<EMAIL_ADDRESS>url: '' author_login: Corey author_email<EMAIL_ADDRESS>wordpress_id: 1148 wordpress_url: http://ivyenvy.com/?p=1148 date: '2009-07-28 15:51:14 +0000' date_gmt: '2009-07-28 21:51:14 +0000' categories: - Defense - General Baseball - Outfield tags: - Alfonso Soriano - Aramis Ramirez - Pete Rose - John Cena comments: - id: 329 author: Kurt author_email<EMAIL_ADDRESS>author_url: http:// date: '2009-07-28 22:16:48 +0000' date_gmt: '2009-07-29 04:16:48 +0000' content: I was pretty annoyed too. Lucha libre Soriano needs to knock off the act. I'm going to reveal his kryptonite...listen up Astros, breaking balls, low and away.  Heh "lucha libre." At least it seemed like that big show he put on after the grand slam was from excitement and not cockiness, don't you think? ---
I can't remember a time when a Cubs player hit in a game-winning run and I've disliked him at that moment as much as I disliked Soriano last night. I haven't hid the fact that do not like Soriano. I would love to see him and his streakiness off this team at the trading deadline. Of course, that's not happening.
I also disliked Aramis Ramirez for about 4 years, and although I'm not a huge Ramirez fan, Soriano makes Ramirez look like Pete Rose running the bases.
  Defend away.
If this is the future of baseball, I'm done. No Cubs blog should EVER have to mention John Cena.


--- layout: post title: "The programmer as decision maker" description: "As a programmer, your job is to make technical decisions. Make some more." date: 2019-03-18 7:44 UTC tags: [Productivity] image: "/content/binary/small-vs-big-decisions-gradient.png" image_alt: "A spectrum of decisions from small to the left to big to the right." --- {% include JB/setup %}
{{ page.description }}
When I speak at conferences, people often come and talk to me. (I welcome that, BTW.) Among all the conversations I've had over the years, there's a pattern to some of them. The attendee will start by telling me how inspired (s)he is by the talk I just gave, or something I've written. That's gratifying, and a good way to start a conversation, but is often followed up like this:
Attendee: "I just wish that we could do something like that in our organisation..."
Let's just say that here we're talking about test-driven development, or perhaps just unit testing. Nothing too controversial. I'd typically respond,
Me: "Why can't you?"
Attendee: "Our boss won't let us..."
That's unfortunate. If your boss has explicitly forbidden you to write and run unit tests, then there's not much you can do. Let me make this absolutely clear: I'm not going on record saying that you should actively disobey a direct order (unless it's unethical, that is). I do wonder, however:
Why is the boss even involved in that decision?
It seems to me that programmers often defer too much authority to their managers.
I'd like to preface the rest of this article with my own context. I've spent most of my programming career in Danish organisations. Even when I worked for Microsoft, I worked for Danish subsidiaries, with Danish managers.
The power distance in Denmark is (in)famously short. It's not unheard of for individual contributors to question their superiors' decisions; sometimes to their face, and sometimes even when other people witness this. When done respectfully (which it often is), this can be extremely efficient. Managers are as fallible as the rest of us, and often their subordinates know of details that could impact a decision that a manager is about to make. Immediately discussing such details can help ensure that good decisions are made, and bad decisions are cancelled.
This helps managers make better decisions, so enlightened managers welcome feedback.
In general, Danish employees also tend to have a fair degree of autonomy. What I'll suggest in this article is unlikely to get you fired in Denmark. Please use your own judgement if you consider transplanting the following to your own culture.
If your job is programmer, software developer, or similar, the value you add to the team is that you bring technical expertise. Maybe some of your colleagues are programmers as well, but together, you are the people with the technical expertise.
Even if the project manager or other superiors used to program, unless they're also writing code for the current code base, they only have general technical expertise, but not specific expertise related to the code base you're working with. The people with most technical expertise are you and your colleagues.
You are decision makers.
Whenever you interact with your code base, you make technical decisions.
In order to handle incoming HTTP requests to a /reservations
resource, you may first decide to create a new file called ReservationsController.cs
. You'd most likely also decide to open that file and start adding code to it.
Perhaps you add a method called Post
that takes a Reservation
argument.
At various steps along the way, you may decide to compile the code.
Once you think that you've made enough changes to address your current work item, you may decide to run the program to see if it works. For a web-based piece of software, that typically involves starting up a browser and somehow interacting with the service. If your program is a web site, you may start at the front page, log in, click around, and fill in some forms. If your program is a REST API, you may interact with it via Fiddler or Postman (I prefer curl or Furl, but most people I've met still prefer something they can click on, it seems).
What often happens is that your changes don't work the first time around, so you'll have to troubleshoot. Perhaps you decide to use a debugger.
How many decisions are that?
I just described seven or eight types of the sort of decisions you make as a programmer. You make such decisions all the time. Do you ask your managers permission before you start a debugging session? Before you create a new file? Before you name a variable?
Of course you don't. You're the technical expert. There's no-one better equipped than you or your team members to make those decisions.
If you want to add unit tests, why don't you just decide to add them? If you want to apply test-driven development, why don't you just do so?
A unit test is one or more code files. You're already authorised to make decisions about adding files.
You can run a test suite instead of launching the software every time you want to interact with it. It's likely to be faster, even.
Why should you ask permission to do that?
Another complaint I hear is that people aren't allowed to refactor.
Why are you even asking permission to refactor?
Refactoring means reorganising the code without changing the behaviour of the system. Another word for that is editing the code. It's okay. You're already permitted to edit code. It's part of your job description.
I think I know what the underlying problem is, though...
As an individual contributor, you're empowered to make small-scale technical decisions. These are decisions that are unlikely to impact schedules or allocation of programmers, including new hires. Big decisions probably should involve your manager.
I have an inkling of why people feel that they need permission to refactor. It's because the refactoring they have in mind is going to take weeks. Weeks in which nothing else can be done. Weeks where perhaps the code doesn't even compile.
Many years ago (but not as many as I'd like it to be), my colleague and I had what Eric Evans in DDD calls a breakthrough. We wanted to refactor towards deeper insight. What prompted the insight was a new feature that we had to add, and we'd been throwing design ideas back and forth for some time before the new insight arrived.
We could implement the new feature if we changed one of the core abstractions in our domain model, but it required substantial changes to the existing code base. We informed our manager of our new insight and our plan, estimating that it would take less than a week to make the changes and implement the new feature. Our manager agreed with the plan.
Two weeks later our code hadn't been in a compilable state for a week. Our manager pulled me away to tell me, quietly and equitably, that he was not happy with our lack of progress. I could only concur.
After more heroic work, we finally managed to complete the changes and implement the new feature. Nonetheless, blocking all other development for two-three weeks in order to make a change isn't acceptable.
That sort of change is a big decision because it impacts other team members, schedules, and perhaps overall business plans. Don't make those kinds of decisions without consulting with stakeholders.
This still leaves, I believe, lots of room for individual decision-making in the small. What I learned from the experience I just recounted was not to engage in big changes to a code base. Learn how to make multiple incremental changes instead. In case that's completely impossible, add the new model side-by-side with the old model, and incrementally change over. That's what I should have done those many years ago.
When I give talks about the blessings of functional programming, I sometimes get into another type of discussion.
Attendee: It's so inspiring how beautiful and simple complex domain models become in F#. How can we do the same in C#?
Me: You can't. If you're already using C#, you should strongly consider F# if you wish to do functional programming. Since it's also a .NET language, you can gradually introduce F# code and mix the compiled code with your existing C# code.
Attendee: Yes... [already getting impatient with me] But we can't do that...
Me: Why not?
Attendee: Because our manager will not allow it.
Based on the suggestions I've already made here, you may expect me to say that that's another technical decision that you should make without asking permission. Like the previous example about blocking refactorings, however, this is another large-scale decision.
Your manager may be concerned that it'd be hard to find new employees if the code base is written in some niche language. I tend to disagree with that position, but I do understand why a manager would take that position. While I think it suboptimal to restrict an entire development organisation to a single language (whether it's C#, Java, C++, Ruby, etc.), I'll readily accept that language choice is a strategic decision.
If every programmer got to choose the programming language they prefer the most that day, you'd have code bases written in dozens of different languages. While you can train bright new hires to learn a new language or two, it's unrealistic that a new employee will be able to learn thirty different languages in a short while.
I find it reasonable that a manager has the final word on the choice of language, even when I often disagree with the decisions.
The outcome usually is that people are stuck with C# (or Java, or...). Hence the question: How can we do functional programming in C#?
I'll give the answer that I often give here on the blog: mu (unask the question). You can, in fact, translate functional concepts to C#, but the result is so non-idiomatic that only the syntax remains of C#:
public static IReservationsInstruction<TResult> Select<T, TResult>( this IReservationsInstruction<T> source, Func<T, TResult> selector) { return source.Match<IReservationsInstruction<TResult>>( isReservationInFuture: t => new IsReservationInFuture<TResult>( new Tuple<Reservation, Func<bool, TResult>>( t.Item1, b => selector(t.Item2(b)))), readReservations: t => new ReadReservations<TResult>( new Tuple<DateTimeOffset, Func<IReadOnlyCollection<Reservation>, TResult>>( t.Item1, d => selector(t.Item2(d)))), create: t => new Create<TResult>( new Tuple<Reservation, Func<int, TResult>>( t.Item1, r => selector(t.Item2(r))))); }
Keep in mind the manager's motivation for standardising on C#. It's often related to concerns about being able to hire new employees, or move employees from project to project.
If you write 'functional' C#, you'll end up with code like the above, or the following real-life example:
return await sendRequest( ApiMethodNames.InitRegistration, new GSObject()) .Map(r => ValidateResponse.Validate(r) .MapFailure(_ => ErrorResponse.RegisterErrorResponse())) .Bind(r => r.RetrieveField("regToken")) .BindAsync(token => sendRequest( ApiMethodNames.RegisterAccount, CreateRegisterRequest( mailAddress, password, token)) .Map(ValidateResponse.Validate) .Bind(response => getIdentity(response) .ToResult(ErrorResponse.ExternalServiceResponseInvalid))) .Map(id => GigyaIdentity.CreateNewSiteUser(id.UserId, mailAddress));
(I'm indebted to Rune Ibsen for this example.)
A new hire can have ten years of C# experience and still have no chance in a code base like that. You'll first have to teach him or her functional programming. If you can do that, you might as well also teach a new language, like F#.
It's my experience that learning the syntax of a new language is easy, and usually doesn't take much time. The hard part is learning a new way to think.
Writing 'functional' C# makes it doubly hard on new team members. Not only do they have to learn a new paradigm (functional programming), but they have to learn it in a language unsuited for that paradigm.
That's why I think you should unask the question. If your manager doesn't want to allow F#, then writing 'functional' C# is just being sneaky. That'd be obeying the letter of the law while breaking the spirit of it. That is, in my opinion, immoral. Don't be sneaky.
As a professional programmer, your job is to be a technical expert. In normal circumstances (at least the ones I know from my own career), you have agency. In order to get anything done, you make small decisions all the time, such as editing code. That's not only okay, but expected of you.
Some decision, on the other hand, can have substantial ramifications. Choosing to write code in an unsanctioned language tends to fall on the side where a manager should be involved in the decision.
In between is a grey area.
I don't even consider adding unit tests to be in the grey area, but some refactorings may be.
"It's easier to ask forgiveness than it is to get permission."
To navigate grey areas you need a moral compass.
I'll let you be the final judge of what you can get away with, but I consider it both appropriate and ethical to make the decision to add unit tests, and to continually improve code bases. You shouldn't have to ask permission to do that.
Comments
Before all, I'd just like to thank all the content you share, they all make me think in a good way!
Now regarding to this post, while I tend to agree that a developer can take the decision to add (or not) unit tests by himself, there is no great value comming out of it, if that's not an approach of the whole development team, right? I believe we need the entire team on board to maximize the values of unit tests. There are changes we need to consider, from changes in the mindset of how you develop to actually running them on continuour integration pipelines. Doesn't all of that push simple decisions like "add unit test" from green area towards orange area?
Francisco, thank you for writing. If you have a team of developers, then I agree that unit tests are going to be most valuable if the team decides to use them.
This is still something that you ought to be competent to decide as a self-organising team of developers. Do you need to ask a manager's permission?
I'm not trying to pretend that this is easy. I realise that it can be difficult.
I've heard about teams where other developers are hostile to the idea of unit testing. In that situation, I can offer no easy fixes. What a lone developer can try to do in that situation is to add and run unit tests locally, on his or her own machine. This will incur some friction, because other team members will be oblivious to the tests, so they'll change code that will cause those unit tests to break.
This might teach the lone developer to write tests so that they're as robust to trivial changes as possible. That's a valuable skill in any case. There's still going to be some overhead of maintaining the unit tests in a scenario like that, but if that overhead is smaller than the productivity gained, then in might still be worthwhile.
What might then happen could be that other developers who are on the fence see that the lone unit tester is more effective than they are. Perhaps they'll get curious about unit tests after all, once they can see the contours of advantages.
The next scenario, then, is a team with a few developers writing unit tests, and other who don't. At some number, you'll have achieved enough critical mass that, at least, you get to check in the unit tests together with the source code. Soon after, you may be able to institute a policy that while not everyone writes unit tests, it's not okay to break existing tests.
The next thing you can do, then, is to set up a test run as part of continuous integration and declare that a failing test run means that the build broke. You still have team members who don't write tests, but at least you get to do it, and the tests add value to the whole team.
Perhaps the sceptics will slowly start to write unit tests over time. Some die-hards probably never will.
You may be able to progress through such stages without asking a manager, but I do understand that there's much variation in organisation and team dynamics. If you can use any of the above sketches as inspiration, then that's great. If you (or other readers) have other success stories to tell, then please share them.
The point I was trying to make with this article is that programmers have agency. This isn't a licence to do whatever you please. You still have to navigate the dynamics of whatever organisation you're in. You may not, however, need to ask your manager about every little thing that you're competent to decide yourselves.
Thank you A LOT for putting words on all these thought. You'll be my reference whenever I want to introduce unit test.
My usual example is "a surgeon doesn't need to ask to the manager if he can wash his hand. Whashing his hand is part of his job". (Not mine, but I can't remember where it comes from)


Toggle navigation
disconnected
Log Out
Current User
Users
Session
Meteor DevTools v
No app detected.
Reloading...
Is
meteor-devtools
running?


importance: 5
Compare the two code fragments.
The first one uses finally
to execute the code after try..catch
:
The second fragment puts the cleaning right after try..catch
:
We definitely need the cleanup after the work, doesn’t matter if there was an error or not.
Is there an advantage here in using finally
or both code fragments are equal? If there is such an advantage, then give an example when it matters.


Cost-reimbursement types of contracts provide for payment of allowable incurred costs, to the extent prescribed in the contract. These contracts establish an estimate of total cost for the purpose of obligating funds and establishing a ceiling that the contractor may not exceed (except at its own risk) without the approval of the contracting officer.
(a) The contracting officer shall use cost-reimbursement contracts only when—
(1) Circumstances do not allow the agency to define its requirements sufficiently to allow for a fixed-price type contract (see 7.105); or
(2) Uncertainties involved in contract performance do not permit costs to be estimated with sufficient accuracy to use any type of fixed-price contract.
(b) The contracting officer shall document the rationale for selecting the contract type in the written acquisition plan and ensure that the plan is approved and signed at least one level above the contracting officer (see 7.103(j) and 7.105).
(a) A cost-reimbursement contract may be used only when
(1) The factors in 16.104 have been considered;
(2) A written acquisition plan has been approved and signed at least one level above the contracting officer;
(3) The contractor’s accounting system is adequate for determining costs applicable to the contract or order; and
(4) Prior to award of the contract or order, adequate Government resources are available to award and manage a contract other than firm-fixed-priced (see 7.104(e)). This includes appropriate Government surveillance during performance in accordance with 1.602-2, to provide reasonable assurance that efficient methods and effective cost controls are used.
(i) Designation of at least one contracting officer’s representative (COR) qualified in accordance with 1.602-2 has been made prior to award of the contract or order; and
(ii) Appropriate Government surveillance during performance to provide reasonable assurance that efficient methods and effective cost controls are used.
(b) The use of cost-reimbursement contracts is prohibited for the acquisition of commercial items (see Parts 2 and 12).
(a) Description. A cost contract is a cost-reimbursement contract in which the contractor receives no fee.
(b) Application. A cost contract may be appropriate for research and development work, particularly with nonprofit educational institutions or other nonprofit organizations.
(c) Limitations. See 16.301-3.
(a) Description. A cost-sharing contract is a cost-reimbursement contract in which the contractor receives no fee and is reimbursed only for an agreed-upon portion of its allowable costs.
(b) Application. A cost-sharing contract may be used when the contractor agrees to absorb a portion of the costs, in the expectation of substantial compensating benefits.
(c) Limitations. See 16.301-3.
A cost-plus-incentive-fee contract is a cost-reimbursement contract that provides for an initially negotiated fee to be adjusted later by a formula based on the relationship of total allowable costs to total target costs. Cost-plus-incentive-fee contracts are covered in Subpart 16.4, Incentive Contracts. See 16.405-1 for a more complete description and discussion of application of these contracts. See 16.301-3 for limitations.
A cost-plus-award-fee contract is a cost-reimbursement contract that provides for a fee consisting of (a) a base amount (which may be zero) fixed at inception of the contract and (b) an award amount, based upon a judgmental evaluation by the Government, sufficient to provide motivation for excellence in contract performance. Cost-plus-award-fee contracts are covered in Subpart 16.4, Incentive Contracts. See 16.401(e) for a more complete description and discussion of the application of these contracts. See 16.301-3 and 16.401(e)(5) for limitations.
(a) Description. A cost-plus-fixed-fee contract is a cost-reimbursement contract that provides for payment to the contractor of a negotiated fee that is fixed at the inception of the contract. The fixed fee does not vary with actual cost, but may be adjusted as a result of changes in the work to be performed under the contract. This contract type permits contracting for efforts that might otherwise present too great a risk to contractors, but it provides the contractor only a minimum incentive to control costs.
(b) Application.
(1) A cost-plus-fixed-fee contract is suitable for use when the conditions of 16.301-2 are present and, for example—
(i) The contract is for the performance of research or preliminary exploration or study, and the level of effort required is unknown; or
(ii) The contract is for development and test, and using a cost-plus-incentive-fee contract is not practical.
(2) A cost-plus-fixed-fee contract normally should not be used in development of major systems (see Part 34) once preliminary exploration, studies, and risk reduction have indicated a high degree of probability that the development is achievable and the Government has established reasonably firm performance objectives and schedules.
(c) Limitations. No cost-plus-fixed-fee contract shall be awarded unless the contracting officer complies with all limitations in 15.404-4(c)(4)(i) and 16.301-3.
(d) Completion and term forms. A cost-plus-fixed-fee contract may take one of two basic forms—completion or term.
(1) The completion form describes the scope of work by stating a definite goal or target and specifying an end product. This form of contract normally requires the contractor to complete and deliver the specified end product (e.g., a final report of research accomplishing the goal or target) within the estimated cost, if possible, as a condition for payment of the entire fixed fee. However, in the event the work cannot be completed within the estimated cost, the Government may require more effort without increase in fee, provided the Government increases the estimated cost.
(2) The term form describes the scope of work in general terms and obligates the contractor to devote a specified level of effort for a stated time period. Under this form, if the performance is considered satisfactory by the Government, the fixed fee is payable at the expiration of the agreed-upon period, upon contractor statement that the level of effort specified in the contract has been expended in performing the contract work. Renewal for further periods of performance is a new acquisition that involves new cost and fee arrangements.
(3) Because of the differences in obligation assumed by the contractor, the completion form is preferred over the term form whenever the work, or specific milestones for the work, can be defined well enough to permit development of estimates within which the contractor can be expected to complete the work.
(4) The term form shall not be used unless the contractor is obligated by the contract to provide a specific level of effort within a definite time period.
(a)(1) The contracting officer shall insert the clause at 52.216-7, Allowable Cost and Payment, in solicitations and contracts when a cost-reimbursement contract or a time-and-materials contract (other than a contract for a commercial item) is contemplated. If the contract is a time-and-materials contract , the clause at 52.216-7 applies in conjunction with the clause at 52.232-7), but only to the portion of the contract that provides for reimbursement of materials (as defined in the clause at 52.232-7) at actual cost. Further, the clause at 52.216-7 does not apply to labor-hour contracts.
(2) If the contract is a construction contract and contains the clause at 52.232-27, Prompt Payment for Construction Contracts, the contracting officer shall use the clause at 52.216-7 with its Alternate I.
(3) If the contract is with an educational institution, the contracting officer shall use the clause at 52.216-7 with its Alternate II.
(4) If the contract is with a State or local government, the contracting officer shall use the clause at 52.216-7 with its Alternate III.
(5) If the contract is with a nonprofit organization other than an educational institution, a State or local government, or a nonprofit organization exempted under the OMB Uniform Guidance at 2 CFR part 200, appendix VIII, the contracting officer shall use the clause at 52.216-7 with its Alternate IV.
(b) The contracting officer shall insert the clause at 52.216-8, Fixed Fee, in solicitations and contracts when a cost-plus-fixed-fee contract (other than a construction contract) is contemplated.
(c) The contracting officer shall insert the clause at 52.216-9, Fixed-Fee—Construction, in solicitations and contracts when a cost-plus-fixed-fee construction contract is contemplated.
(d) The contracting officer shall insert the clause at 52.216-10, Incentive Fee, in solicitations and contracts when a cost-plus-incentive-fee contract is contemplated.
(e)(1) The contracting officer shall insert the clause at 52.216-11, Cost Contract—No Fee, in solicitations and contracts when a cost-reimbursement contract is contemplated that provides no fee and is not a cost-sharing contract.
(2) If a cost-reimbursement research and development contract with an educational institution or a nonprofit organization that provides no fee or other payment above cost and is not a cost-sharing contract is contemplated, and if the contracting officer determines that withholding of a portion of allowable costs is not required, the contracting officer shall use the clause with its Alternate I.
(f)(1) The contracting officer shall insert the clause at 52.216-12, Cost-Sharing Contract—No Fee, in solicitations and contracts when a cost-sharing contract is contemplated.
(2) If a cost-sharing research and development contract with an educational institution or a nonprofit organization is contemplated, and if the contracting officer determines that withholding of a portion of allowable costs is not required, the contracting officer shall use the clause with its Alternate I.
(g) The contracting officer shall insert the clause at 52.216-15, Predetermined Indirect Cost Rates, in solicitations and contracts when a cost-reimbursement research and development contract with an educational institution (see 42.705-3(b)) is contemplated and predetermined indirect cost rates are to be used.


With the following tools, SAM files can be parsed to gain information of read names, where they were mapped, which quality score the mapping was assigned and so on.
The procedures in this chapter may vary more than the previous ones, depending on the research question.
In the setting this package was originally designed for, the names of the reads carry the information where the reads actually belong to. This information can subsequently be compared to the actual mapping information obtained from the SAM file.
To use the information of the SAM file, convert it to a tabular form using the tool sam2table
. This generates a table with column names adhering to the names defined in the SAM Specification, which are, amongst others:
*
if not mapped.
Show beginning and end of the generated file:
qname flag rname pos mapq cigar rnext pnext tlen
volpertinger_1 4 * 0 0 * * 0 0
volpertinger_2 0 MT 3402 37 20M * 0 0
volpertinger_3 4 * 0 0 * * 0 0
volpertinger_4 0 A3 5689 37 21M * 0 0
volpertinger_5 0 MT 3280 37 25M * 0 0
volpertinger_6 0 A3 4936 25 27M * 0 0
volpertinger_7 0 A1 1320 25 22M * 0 0
volpertinger_8 4 * 0 0 * * 0 0
volpertinger_9 0 X 2381 25 20M * 0 0
retli_41 0 A1 961 25 20M * 0 0
retli_42 4 * 0 0 * * 0 0
retli_43 4 * 0 0 * * 0 0
retli_44 4 * 0 0 * * 0 0
retli_45 4 * 0 0 * * 0 0
retli_46 4 * 0 0 * * 0 0
retli_47 4 * 0 0 * * 0 0
retli_48 4 * 0 0 * * 0 0
retli_49 4 * 0 0 * * 0 0
retli_50 4 * 0 0 * * 0 0
To determine whether a read was mapped correctly, the mapping information like mapped position of the read in the target reference as well as the true read position must be known. The true read information was generated along with the read FASTQ files and was stored in .coord
files.
The script add_mapped_organisms
reads the mapping information stored in the SAM file (converted to a table) and the true read information and merges the information into one table.
Thereby, all information about one read is stored in the same line.
In this example, the organism volpertinger
provides the endogenous reads as all reads were mapped only to the volpertinger
genome. The retli
reads are therefore exogenous reads, as these are not supposed to map to that reference genome.
To assign the correct organism names to the reads, the script must be provided with
The call is shown below. The script write_later
at the end of the pipe is to prevent merge
from overwriting its own input file too soon, as the output is meant to replace the input file.
scripts/add_mapped_organisms \
--endogenous volpertinger \
input/genome/volpertinger.fasta.fai \
data/2/volpertinger.coord \
--exogenous retli \
input/retli/retli.fasta.fai \
data/2/retli.coord \
data/5/1.tab \
| scripts/write_later data/5/1.tab
head data/5/1.tab | column -t
qname mapped_flag mapped_rname mapped_pos mapped_mapq mapped_cigar mapped_rnext mapped_pnext mapped_tlen mapped_organism true_record true_start true_end true_organism
volpertinger_1 4 * 0 0 * * 0 0 * B1 2143 2171 volpertinger
volpertinger_2 0 MT 3402 37 20M * 0 0 volpertinger MT 3402 3421 volpertinger
volpertinger_3 4 * 0 0 * * 0 0 * A3 1413 1438 volpertinger
volpertinger_4 0 A3 5689 37 21M * 0 0 volpertinger A3 5689 5709 volpertinger
volpertinger_5 0 MT 3280 37 25M * 0 0 volpertinger MT 3280 3304 volpertinger
volpertinger_6 0 A3 4936 25 27M * 0 0 volpertinger A3 4936 4962 volpertinger
volpertinger_7 0 A1 1320 25 22M * 0 0 volpertinger A1 1320 1341 volpertinger
volpertinger_8 4 * 0 0 * * 0 0 * A3 4480 4506 volpertinger
volpertinger_9 0 X 2381 25 20M * 0 0 volpertinger X 2381 2400 volpertinger
Now all the information is present to determine whether a read has been mapped correctly. The last step is writing in a new column whether a read was mapped correctly. This can be archieved using any means you can imagine, for this example we will use R. The pocketR
tool is a thin wrapper which handles reading and writing of data for us. The input data will be available as a data.frame
called input
. The R calls must return a data.frame
, which will be printed as a table.
This step is exposed to the user, because this enables great flexibility in what exactly is considered a “correct” read mapping.
The following command adds a new column to the input data which indicates whether a read was mapped correctly. In this tutorial, “correct” is defined as “the read has been mapped exactly to the position from which it originated”.
scripts/pocketR '
within(input, {
correct =
mapped_pos == true_start &
mapped_rname == true_record &
mapped_organism == true_organism })
' data/5/1.tab \
| scripts/write_later data/5/1.tab
head data/5/1.tab | column -t
qname mapped_flag mapped_rname mapped_pos mapped_mapq mapped_cigar mapped_rnext mapped_pnext mapped_tlen mapped_organism true_record true_start true_end true_organism correct
volpertinger_1 4 * 0 0 * * 0 0 * B1 2143 2171 volpertinger FALSE
volpertinger_2 0 MT 3402 37 20M * 0 0 volpertinger MT 3402 3421 volpertinger TRUE
volpertinger_3 4 * 0 0 * * 0 0 * A3 1413 1438 volpertinger FALSE
volpertinger_4 0 A3 5689 37 21M * 0 0 volpertinger A3 5689 5709 volpertinger TRUE
volpertinger_5 0 MT 3280 37 25M * 0 0 volpertinger MT 3280 3304 volpertinger TRUE
volpertinger_6 0 A3 4936 25 27M * 0 0 volpertinger A3 4936 4962 volpertinger TRUE
volpertinger_7 0 A1 1320 25 22M * 0 0 volpertinger A1 1320 1341 volpertinger TRUE
volpertinger_8 4 * 0 0 * * 0 0 * A3 4480 4506 volpertinger FALSE
volpertinger_9 0 X 2381 25 20M * 0 0 volpertinger X 2381 2400 volpertinger TRUE
As another example to perform the same step, below is shown how to allow for 5 bp of tolerance when determining whether the read was mapped correctly:
scripts/pocketR '
within(input, {
correct =
abs(mapped_pos - true_start) < 5 &
mapped_rname == true_record &
mapped_organism == true_organism })
' data/5/1.tab \
| scripts/write_later data/5/1.tab
As next step, the number of reads are counted which belong to certain categories. Here, the categories are:
Again, the R language can be used to express our wishes concisely: Group the reads by all combinations of:
true_organism
mapped_organism
… and count the reads belonging to each category:
the cbind
function is needed in order to rename the column containing the read count. qname
can be substituted here by any valid input column name, as its only used for counting (each column is equal in length).
scripts/pocketR '
aggregate( cbind(count=qname) ~ true_organism + mapped_organism + correct,
FUN=length, data=input)
' data/5/1.tab \
> data/5/1.agg
cat data/5/1.agg | column -t
true_organism mapped_organism correct count
retli * FALSE 49
volpertinger * FALSE 9
retli volpertinger FALSE 1
volpertinger volpertinger TRUE 16
This format may be used to plot the read fate of a single mapper run and to derive the measures sensitivity and specificity:
scripts/plot_read_fate --exogenous retli \
--format png \
true_organism mapped_organism \
correct count \
fig/fate1.png data/5/1.agg
The script produces the following plot:
The plot shows, which fractions of the input species (endogenous: volpertinger, contaminant: R. etli) are mapped and whether the mapping was correct. It can be seen that in this case, almost no contaminant reads were mapped, indicating high mapper specificity. However, only 75% of the endogenous reads were mapped.
If non-endogenous reads were included in the reads, like we did by including the R. etli reads, both measures can be calculated.
The following script needs the same kind of input as the plot-read-fate
script. Additionally, a list of organisms must be specified, whose genomes the mapper used as a reference.
If you specify multiple organisms, separate them by commas and don’t include any spaces.
scripts/sensspec --c-morg mapped_organism \
--c-torg true_organism \
data/5/1.agg volpertinger \
> data/5/1.performance
column -t data/5/1.performance
map.true map.actl sensitivity nomap.true nomap.actl specificity bcr
25 16 0.64 50 49 0.98 0.81
The code needed to evaluate the data generated by the mapper might as well be included in the mapping template script introduced in the last section. If this is done, the data evaluation can be as well parallelized as the mapping process.
All scripts used here were already introduced in this section.
The files data/5/all.tab
and data/5/all.recids
must be calculated prior to execution of this script. This has been done in this section as well.
Browse the directory data/5
to see the results.
for sam in data/4/*.sam; do
# Generate output prefix p from input name: `4.sam` -> `4`
bn=$(basename $sam)
p=${bn%.sam}
# Convert SAM to table
scripts/sam2table data/4/${p}.sam > data/5/${p}.tab
# Mark correctly/incorrectly mapped reads
scripts/add_mapped_organisms \
--endogenous volpertinger \
input/genome/volpertinger.fasta.fai \
data/2/volpertinger.coord \
--exogenous retli \
input/retli/retli.fasta.fai \
data/2/retli.coord \
data/5/${p}.tab \
| scripts/write_later data/5/${p}.tab
# Determine whether each read was correctly mapped
scripts/pocketR '
within(input, {
correct =
mapped_pos == true_start &
mapped_rname == true_record &
mapped_organism == true_organism })
' data/5/${p}.tab \
| scripts/write_later data/5/${p}.tab
# Count reads per origin/target organism and mapping status
scripts/pocketR '
aggregate( cbind(count=qname) ~ true_organism + mapped_organism + correct,
FUN=length, data=input) ' \
data/5/${p}.tab \
> data/5/${p}.agg
# Plot mapping targets per origin organism
scripts/plot_read_fate --exogenous retli \
--format png \
true_organism mapped_organism \
correct count \
fig/fate${p}.png data/5/${p}.agg
# Calculate sensitivity, specificity and balanced accuracy
scripts/sensspec --c-morg mapped_organism \
--c-torg true_organism \
data/5/${p}.agg volpertinger \
> data/5/${p}.performance
echo "$sam done. -> Generated data/5/${p}.{tab,agg,pdf,performance}"
done
data/4/0.sam done. -> Generated data/5/0.{tab,agg,pdf,performance}
data/4/1.sam done. -> Generated data/5/1.{tab,agg,pdf,performance}
data/4/2.sam done. -> Generated data/5/2.{tab,agg,pdf,performance}
data/4/3.sam done. -> Generated data/5/3.{tab,agg,pdf,performance}
data/4/4.sam done. -> Generated data/5/4.{tab,agg,pdf,performance}
data/4/5.sam done. -> Generated data/5/5.{tab,agg,pdf,performance}
All generated images:
1.png:
2.png:
3.png:
4.png:
5.png:


You need to reload the Twitter home page while logged in, to make use of this tool. The below steps will help you properly start the tool:


remote_ssl_no_validateedit
This should be True
, False
or left empty.
actions: 1: description: "Reindex index1 into index2" action: reindex options: wait_interval: 9 max_wait: -1 remote_ssl_no_validate: True request_body: source: remote: host: https://otherhost:9200 index: index1 dest: index: index2 filters: - filtertype: none
If access to your Elasticsearch instance is protected by SSL encryption, you may
set ssl_no_validate
to True
to disable SSL certificate verification.
Valid use cases for doing so include the use of self-signed certificates that cannot be otherwise verified and would generate error messages.
Setting ssl_no_validate
to True
will likely result in a warning
message that your SSL certificates are not trusted. This is expected
behavior.
The default value is False
.


#include <pthread.h> int pthread_setconcurrency(int new_level); int pthread_getconcurrency(void); Compile and link with -pthread.
Specifying new_level as 0 instructs the implementation to manage the concurrency level as it deems appropriate.
pthread_getconcurrency() returns the current value of the concurrency level for this process.
pthread_getconcurrency() always succeeds, returning the concurrency level set by a previous call to pthread_setconcurrency(), or 0, if pthread_setconcurrency() has not previously been called.
POSIX.1-2001 also documents an EAGAIN error ("the value specified by new_level would cause a system resource to be exceeded").
Concurrency levels are meaningful only for M:N threading implementations, where at any moment a subset of a process's set of user-level threads may be bound to a smaller number of kernel-scheduling entities. Setting the concurrency level allows the application to give the system a hint as to the number of kernel-scheduling entities that should be provided for efficient execution of the application.
Both LinuxThreads and NPTL are 1:1 threading implementations, so setting the concurrency level has no meaning. In other words, on Linux these functions merely exist for compatibility with other systems, and they have no effect on the execution of a program.


contact us phone number: 0511-3859066 address:between 15th and 17th saba blv, saba blv,shahrake abouzar


Dashboard
Employees
Add Employee
View Employees
View Employees (Img)
Update Employee
Employee Attendance
Checklists
View Checklists' Status
Update Checklists
₹
Payroll
View Payroll


Demo page for mobile
Creation, Deletion, Event
Download Json
Create form
work_start
work_end
unpaid_minutes
job_name
job_id
timecard_id
Create
Edit form
work_start
work_end
unpaid_minutes
job_name
job_id
timecard_id
delete


Super Galactic Age Calculator
Enter your age to check how old you would be on another planet:
Find out!
Your age is...


Let the brewing night commence! Um, after we get stuff from the store... and more propane... and dinner...
10/9/2009, 7:30:32 PM
Favs: 0
Retweets: 0
link--- layout: tweet ---
Let the brewing night commence! Um, after we get stuff from the store... and more propane... and dinner...
10/9/2009, 7:30:32 PM
Favs: 0
Retweets: 0
link


×
Login
RWTH Administration
Account Address
Balance
Register new Semester
Semester Term
Year
Tuition Fee
Abbreviation
Register
Abbreviation
Term
Year
Tuition Fee
Abbreviation
Term
Year
Tuition Fee
Status
Registration Form:
Name*
Matriculation Number*
Register