[viewBag] snippetCode = "testfragment" snippetName = "TestFragment" == page //$_SERVER['HTTP_REFERER'] ); } ?> == mavar = {{ mavar }}


| DOSE: |
125 mg |
oral |
Methylone |
(powder / crystals) |
Preparation: one gram of '2-methylamino-3,4-methylenedioxypropiophenone HCl' was visually divided into eight equal size piles of 125mg each and each one placed into a gelcap. One cap was ingested by the researcher at 7:00 PM Friday night, and here is his report....
'Given the structural similarities, I expected the methylone to be much like MDMA, as it is an extremely close structural analog. This is not the case at all. Methylone is most definitely not a recreational party drug. On the contrary, the trip was a deep, therapeutic one which flirted with transcendence. I have in general found the quality of the insights gained on phenethylamines to be somewhat shallow and glossy, and therefore was very surprised by what I got from this material.
The onset was very similar to ecstasy, but calmer; a centered, meditative euphoria. I had taken the drug while with a close friend, who did not take any drugs herself, and for the first hour or so we just sat and talked. It was nice, I felt good, extremely happy, much the way I feel coming up on any psychedelic. We then met up with some other friends, all of whom were sober, and their incessant yapping about basically nothing began to annoy me in a most unpleasant way. This surprised me, as with most phenethylamines I am very social, and very tolerant of others. With the Methylone, I felt the urge to be either alone or having a deep meaningful conversation with one other person, not chatting it up with my stoner buddies.
Realizing that my trip would be wasted were I to remain in that environment, I decided to take a nice long half hour walk to the convenience store. As I walked, I fell into a sort of trance. I was extremely depersonalized, and it was as if I was disconnected from the world around me. Negative thoughts began to flow into my head. At first I blamed it on the material, thinking I was having a bad trip. But this was not the case. The negativity stemmed from the negative choices I have been making in my life recently. It was as if I was looking into my personality and my actions in a most raw and unforgiving way, cataloging the good, the bad, and the ugly within me.
It then came to me. I stopped in the middle of my walk. I must have appeared peculiar, standing in the middle of the sidewalk, staring straight ahead for what seemed like an eternity. I realized that for the longest time, I have blamed my difficulties and lack of success in certain areas of my life on the close-mindedness of others. Sort of like a teenage rebel who sits at home depressed while talking about how he worships Satan and hates the world :-) I have delevoped a defensiveness about me, a bristling reaction of anger to the smallest criticism of my choices or certain character traits. And I realized that I was not perfect. And that there was no need to be afraid of that. For as soon as one can accept that one has issues to work out, one may work them out (if that makes any sense at all.) It is when one blames everyone else for one's difficulties that nothing gets accomplished.
Eventually, I walked back to where my friends were chilling, and sat down on the bed and meditated. Normally I am completely incompetent at meditation, but the methylone had put me in a state of mind where I could sit in the lotus position for as long as I wished and calmly let my energy equalize itself.
The peak of the trip lasted for three hours, from 8:00 to 11:00. The comedown, however, was extremely long. Even at 2 AM that night, 7 hours after ingestion, there was definitely something there, and 5mg Imovane (zopiclone) was taken so that I could sleep. This residual stimulation became somewhat annoying, although not extremely unpleasant by any means. The next morning, I woke up, still definitely buzzing from the Methylone. I was not completely down until 2 PM that day, when the buzzing was replaced with a general tiredness similar to, but less severe than the day after MDMA. Going to the gym and working out later that afternoon restored my energy, and I slept extremely well Saturday night.
I think that a Methylone trip in the right environment and with some mental preparation could be life changing. There is a strong spiritual dimension to the experience which I will explore more fully next time, now that I know what to expect. As for dosage, 125mg was perfect for me (who is somewhat of a lightweight when it comes to phenethylamines) and I would repeat it at the same level.'
As a postscript, I shoult note that contrary to the reports of some, this compound appears to show increased potency when taken intranasally. On Saturday night, a 125mg cap was split between four individuals who had never used Methylone before, and each found 37.5mg snorted to give a fairly mild, but definite trip. However, they did not have nearly as profound experiences as I did when ingesting it orally. Personally, I will stick to oral ingestion.
Experience Reports are the writings and opinions of the individual authors who submit them.
Some of the activities described are dangerous and/or illegal and none are recommended by Erowid.


Arrange
Preview
Tools
View
Duplicate
Scale
Rotate
Delete
Help
X:
Y:
Z:
Uniform Scaling
X:
Y:
Z:
Supports
Raft
Print Quality
Advanced
▶
Advanced
Process
layer height
shell count
shell spacing
fill overlap
fill spacing
fill angle
fill ratio
solid area
solid layers
base layers
top layers
vase mode
Output
bed temp
nozzle temp
print speed
finish speed
move speed
shell factor
solid factor
infill factor
cooling
First Layer
layer height
shell speed
fill speed
print factor
skirt count
skirt offset
Supports
density
pillar size
gap layers
max bridge
min area
expand
enable
Raft
spacing
enable
Advanced
retract dist
retract rate
engage dwell
short outline
short segment
short factor
finish factor
min layer
z-hop distance
anti-backlash
GCode
k-factor
pause layers
|
|
Powered by Inksmith


Learning Objectives
Attaching CSS to HTML to set up a page structure can be confusing the first few times you're asked to do it. In order to be able to complete Assignment 1, you'll need to be able to understand how CSS hooks to HTML.
This lab should help you work out how CSS stylesheet rules bind to HTML element tags.
Collaborative or No?
This lab is intended to be completed on your own. While you can ask your classmates for help, please submit your own work for grading.
Lab Instructions
To successfully submit your labs, you will need to follow the steps laid out here:
Lab Setup
- Pull to update your version of the class repository
- Turn on your local server
- opening two terminal windows
- type npm install && npm start
- You should see a message saying something is running on Port 3000
- Check that this is happening by opening a browser and navigating to localhost:3000/lab_3/
Lab Submission
- When you are done, you should be able to see your lab at https://yourusername.github.io/public/lab_3
- Please submit your github.io link as your lab submission
Lab Instructions
Adapted from MDN: Structuring A Page of Content
- Open up public/lab_3 in your VSCode editor
- You have a page of full HTML and a CSS file at your disposal.
- Insert the correct DIV tags with appropriate class names in your code to match the screenshot provided.
- class:
.something
- id:
#something
, 1 per page
- element:
something
, no identifying marks, applies to all elements of that type on the page
- When you have completed the structural portion of your lab, please adjust your page as follows:
- Rename your page to your own name
- Replace the image of birds with four non-bird images.
- Change the page background colour to a shade of blue.
- Change the page header font from Cinzel Decorative 700 to a font of your choice from Google Fonts' Display selection
- Use two weights of one font
- Replace the main body of text with lorem ipsum display text.
- Lorem Ipsum generator
- In the footer, replace the text with a credit to yourself, using your full name - ie:
- "This website example has been written by Sam Cap, 2020"


X
{{log}}
Know wrong passwords
Password
Likeness
{{error.password}}
{{error.likeness}}
Enter the likeness of this wrong password


A website utilizing HTML, and is dedicated to a recipe for oatmeal-chocolate-chip cookies:
including a list of ingredients you'll need and instructions on how to make them.
~ Co-authored by: Andrew Lawson.
Animal Shelter is a website about a fictitous animal shelter, created with HTML and CSS.
~ Co-authored by: Andrew Lawson.
Baby Cakes, a made-up cupcake shop specializing in miniature cupcakes.
~ Co-authored by: Andrew Lawson.
A fictitous travel compasies site, displaying planets they recommend traveling to,
with comments from previous vacationers.
~ Co-authored by: Andrew Lawson.
I graduated from Tallglass Sudbury School, a democrattically run freedom-based school, in 2013. This self-motivated learning sytle has lead me to seek out new skills, and devote much of my time to developing them. Originally a regitered nurse, I sought out a new field, which would allow me to learn continously.**PLACEHOLDERTEXT: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.**


Egg allergy is one of the most common food allergies in children, second only to milk allergy. As many as 2 percent of children are allergic to eggs. Fortunately, studies show that about 70 percent of children with an egg allergy will outgrow the condition by age 16.
Egg allergies are caused by an immune system over reaction. The immune system mistakenly identifies certain egg proteins as harmful. When you or your child comes in contact with egg proteins, immune system cells [antibodies] recognize them and signal the immune system to release histamine and other chemicals that cause allergic signs and symptoms.
Both egg yolks and egg whites contain proteins that can cause allergies, but allergy to egg whites is most common. It is possible for breast-fed infants to have an allergic reaction to egg proteins in breast milk if the mother consumes eggs.
Although ovalbumin, ovomucoid, and ovotransferrin have been identified as the major allergens in egg white, 0ther unnamed allergens of lesser importance have been identified. These allergens are also present in egg yolk but in lesser quantities. This is important because components of egg may be individually used for specific actions in food preparation. For example, hen's egg lysozyme is used as a preservative in food; and in some countries, notably Japan and Switzerland,lysozyme is used in medications. Individuals sensitive to hen's egg have been shown to be allergic to lysozyme produced from hen's egg.
Although rare, avian proteins can induce egg allergy in susceptible individuals. It has been suggested that duck egg be substituted for hen's egg in egg- sensitive individuals. These individuals are able to tolerate cooked chicken.
Mild
Severe
Life threatening emergency
Certain factors may increase the risk of developing an egg allergy.
Your doctor will start with a medical history and examination. Your doctor may also recommend one or more of the following tests.
Antihistamines may help to relieve mild symptoms of egg allergy, such as itching. In addition, your allergist may prescribe adrenaline injection, to be taken in the event there are symptoms of anaphylaxis a potentially fatal reaction that includes shortness of breath, swelling of the throat and dizziness from a sudden drop in blood pressure. An injection should be kept with you at all times and used as soon as symptoms start to appear.
Some vaccines contain egg proteins. In some people,these vaccines pose a risk of triggering an allergic reaction.
Avoid foods that contain eggs or any of these ingredients
Egg is sometimes found in the following
Labels That hides eggs
Ovalbumin, Livestin, Albumin, Lysozyme E1, Globulin, Ovamucoid, Lecithin E322, Yolk, Egg white
List of products that can contain eggs
Pancakes, Cakes, Quiches, Pies, Gratins, StewsSausages, Meat Products, Candies, Fresh dough, Bread Spreads, Instant meals, Custard, Mayonnaise, Soups, Ketchup, Meat Products, Ice cream, Hamburger, Etc.
Individuals with egg allergy should also avoid eggs from Duck, Turkey, Goose, Quail, etc.,as these are known to be cross- reactive with chicken egg.


Module: ActiveSupport::JSON
| Relationships & Source Files | |
| Defined in: | activesupport/lib/active_support/json/decoding.rb, activesupport/lib/active_support/json/encoding.rb |
Constant Summary
-
DATE_REGEX =
# File 'activesupport/lib/active_support/json/decoding.rb', line 11
matches YAML-formatted dates
/^(?:\d{4}-\d{2}-\d{2}|\d{4}-\d{1,2}-\d{1,2}[T \t]+\d{1,2}:\d{2}:\d{2}(\.[0-9]*)?(([ \t]*)Z|[-+]\d{2}?(:\d{2})?))$/
Class Method Summary
-
.decode(json, options = {})
Parses a
JSON
string (JavaScript ::Object Notation) into a hash. -
.encode(value, options = nil)
Dumps objects in
JSON
(JavaScript ::Object Notation). -
.parse_error
Returns the class of the error that will be raised when there is an error in decoding
JSON
.
Class Method Details
.decode(json, options = {})
Parses a JSON
string (JavaScript ::Object Notation) into a hash. See www.json.org for more info.
ActiveSupport::JSON.decode("{\"team\":\"rails\",\"players\":\"36\"}")
#=> {"team" => "rails", "players" => "36"}
# File 'activesupport/lib/active_support/json/decoding.rb', line 19
def decode(json, = {}) if .present? raise ArgumentError, "In Rails 4.1, ActiveSupport::JSON.decode no longer " \ "accepts an options hash for MultiJSON. MultiJSON reached its end of life " \ "and has been removed." end data = ::JSON.parse(json, quirks_mode: true) if ActiveSupport.parse_json_times convert_dates_from(data) else data end end
.encode(value, options = nil)
Dumps objects in JSON
(JavaScript ::Object Notation). See www.json.org for more info.
ActiveSupport::JSON.encode({ team: 'rails', players: '36' })
# => "{\"team\":\"rails\",\"players\":\"36\"}"
# File 'activesupport/lib/active_support/json/encoding.rb', line 21
def self.encode(value, = nil) Encoding.json_encoder.new( ).encode(value) end
.parse_error
Returns the class of the error that will be raised when there is an error in decoding JSON
. Using this method means you won't directly depend on the ActiveSupport's JSON
implementation, in case it changes in the future.
begin
obj = ActiveSupport::JSON.decode(some_string)
rescue ActiveSupport::JSON.parse_error
Rails.logger.warn("Attempted to decode invalid JSON: #{some_string}")
end
# File 'activesupport/lib/active_support/json/decoding.rb', line 45
def parse_error ::JSON::ParserError end


ERASEthemasterswordsman
on 2012-06-07 13:11:02
Please note that hashing a has is not completely secure, but can be used as an extra precaution (but not recommended):
<?php
sha1(md5($string));
?>
G
on 2009-01-17 00:26:39
fuckin wicked code. nice, neat, small, clean, and very useful :)
Kevin van Zonneveld
on 2008-11-25 17:10:59
@ Patrick Schlicher: Thanks for the info!
Onno Marsman
on 2008-11-19 19:22:27
Mainda: Unfortunately I don't know anything about any sha1 algorithm. I just posted some code I found somewhere in the past. I've been using this code successfully for a long time, also in IE7. So I don't know where your error could have come from.
Looking at the code from this library: I've been wondering in the past about the following line of code:
str = utf8_encode(str);
I know this is not part of the sha1 algorithm and is probably necessary because of the way browsers handle character encoding, although I don't really understand it.
You could try removing this line. Let me know whether it worked.
Mainda Siriwardana
on 2008-11-19 14:42:18
hi! Onno Marsman,
I would like to know whether its working on IE(7) and if possible let me know more details about it. sha1 originally mentionaed is not working properly for binary file. this code is working fine on FF but not on IE saying "this method is not supported"
thanks!
Patrick Schlicher
on 2008-11-19 09:07:58
I was searching for an encryption like blowfish that works with PHP and JS for long time.
Finally I found a working AES implementation:
JS:
http://www.movable-type.co.uk/scripts/aes.html
PHP:
http://www.movable-type.co.uk/scripts/aes-php.html
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* AES implementation in JavaScript (c) Chris Veness 2005-2008 */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*
* AES Cipher function: encrypt 'input' with Rijndael algorithm
*
* takes byte-array 'input' (16 bytes)
* 2D byte-array key schedule 'w' (Nr+1 x Nb bytes)
*
* applies Nr rounds (10/12/14) using key schedule w for 'add round key' stage
*
* returns byte-array encrypted value (16 bytes)
*/
function Cipher(input, w) { // main Cipher function [Â§5.1]
var Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES)
var Nr = w.length/Nb - 1; // no of rounds: 10/12/14 for 128/192/256-bit keys
var state = [[],[],[],[]]; // initialise 4xNb byte-array 'state' with input [Â§3.4]
for (var i=0; i<4*Nb; i++) state[i%4][Math.floor(i/4)] = input[i];
state = AddRoundKey(state, w, 0, Nb);
for (var round=1; round<Nr; round++) {
state = SubBytes(state, Nb);
state = ShiftRows(state, Nb);
state = MixColumns(state, Nb);
state = AddRoundKey(state, w, round, Nb);
}
state = SubBytes(state, Nb);
state = ShiftRows(state, Nb);
state = AddRoundKey(state, w, Nr, Nb);
var output = new Array(4*Nb); // convert state to 1-d array before returning [Â§3.4]
for (var i=0; i<4*Nb; i++) output[i] = state[i%4][Math.floor(i/4)];
return output;
}
function SubBytes(s, Nb) { // apply SBox to state S [Â§5.1.1]
for (var r=0; r<4; r++) {
for (var c=0; c<Nb; c++) s[r][c] = Sbox[s[r][c]];
}
return s;
}
function ShiftRows(s, Nb) { // shift row r of state S left by r bytes [Â§5.1.2]
var t = new Array(4);
for (var r=1; r<4; r++) {
for (var c=0; c<4; c++) t[c] = s[r][(c+r)%Nb]; // shift into temp copy
for (var c=0; c<4; c++) s[r][c] = t[c]; // and copy back
} // note that this will work for Nb=4,5,6, but not 7,8 (always 4 for AES):
return s; // see fp.gladman.plus.com/cryptography_technology/rijndael/aes.spec.311.pdf
}
function MixColumns(s, Nb) { // combine bytes of each col of state S [Â§5.1.3]
for (var c=0; c<4; c++) {
var a = new Array(4); // 'a' is a copy of the current column from 's'
var b = new Array(4); // 'b' is aâ€¢{02} in GF(2^8)
for (var i=0; i<4; i++) {
a[i] = s[i][c];
b[i] = s[i][c]&0x80 ? s[i][c]<<1 ^ 0x011b : s[i][c]<<1;
}
// a[n] ^ b[n] is aâ€¢{03} in GF(2^8)
s[0][c] = b[0] ^ a[1] ^ b[1] ^ a[2] ^ a[3]; // 2*a0 + 3*a1 + a2 + a3
s[1][c] = a[0] ^ b[1] ^ a[2] ^ b[2] ^ a[3]; // a0 * 2*a1 + 3*a2 + a3
s[2][c] = a[0] ^ a[1] ^ b[2] ^ a[3] ^ b[3]; // a0 + a1 + 2*a2 + 3*a3
s[3][c] = a[0] ^ b[0] ^ a[1] ^ a[2] ^ b[3]; // 3*a0 + a1 + a2 + 2*a3
}
return s;
}
function AddRoundKey(state, w, rnd, Nb) { // xor Round Key into state S [Â§5.1.4]
for (var r=0; r<4; r++) {
for (var c=0; c<Nb; c++) state[r][c] ^= w[rnd*4+c][r];
}
return state;
}
function KeyExpansion(key) { // generate Key Schedule (byte-array Nr+1 x Nb) from Key [Â§5.2]
var Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES)
var Nk = key.length/4 // key length (in words): 4/6/8 for 128/192/256-bit keys
var Nr = Nk + 6; // no of rounds: 10/12/14 for 128/192/256-bit keys
var w = new Array(Nb*(Nr+1));
var temp = new Array(4);
for (var i=0; i<Nk; i++) {
var r = [key[4*i], key[4*i+1], key[4*i+2], key[4*i+3]];
w[i] = r;
}
for (var i=Nk; i<(Nb*(Nr+1)); i++) {
w[i] = new Array(4);
for (var t=0; t<4; t++) temp[t] = w[i-1][t];
if (i % Nk == 0) {
temp = SubWord(RotWord(temp));
for (var t=0; t<4; t++) temp[t] ^= Rcon[i/Nk][t];
} else if (Nk > 6 && i%Nk == 4) {
temp = SubWord(temp);
}
for (var t=0; t<4; t++) w[i][t] = w[i-Nk][t] ^ temp[t];
}
return w;
}
function SubWord(w) { // apply SBox to 4-byte word w
for (var i=0; i<4; i++) w[i] = Sbox[w[i]];
return w;
}
function RotWord(w) { // rotate 4-byte word w left by one byte
var tmp = w[0];
for (var i=0; i<3; i++) w[i] = w[i+1];
w[3] = tmp;
return w;
}
// Sbox is pre-computed multiplicative inverse in GF(2^8) used in SubBytes and KeyExpansion [Â§5.1.1]
var Sbox = [0x63,0x7c,0x77,0x7b,0xf2,0x6b,0x6f,0xc5,0x30,0x01,0x67,0x2b,0xfe,0xd7,0xab,0x76,
0xca,0x82,0xc9,0x7d,0xfa,0x59,0x47,0xf0,0xad,0xd4,0xa2,0xaf,0x9c,0xa4,0x72,0xc0,
0xb7,0xfd,0x93,0x26,0x36,0x3f,0xf7,0xcc,0x34,0xa5,0xe5,0xf1,0x71,0xd8,0x31,0x15,
0x04,0xc7,0x23,0xc3,0x18,0x96,0x05,0x9a,0x07,0x12,0x80,0xe2,0xeb,0x27,0xb2,0x75,
0x09,0x83,0x2c,0x1a,0x1b,0x6e,0x5a,0xa0,0x52,0x3b,0xd6,0xb3,0x29,0xe3,0x2f,0x84,
0x53,0xd1,0x00,0xed,0x20,0xfc,0xb1,0x5b,0x6a,0xcb,0xbe,0x39,0x4a,0x4c,0x58,0xcf,
0xd0,0xef,0xaa,0xfb,0x43,0x4d,0x33,0x85,0x45,0xf9,0x02,0x7f,0x50,0x3c,0x9f,0xa8,
0x51,0xa3,0x40,0x8f,0x92,0x9d,0x38,0xf5,0xbc,0xb6,0xda,0x21,0x10,0xff,0xf3,0xd2,
0xcd,0x0c,0x13,0xec,0x5f,0x97,0x44,0x17,0xc4,0xa7,0x7e,0x3d,0x64,0x5d,0x19,0x73,
0x60,0x81,0x4f,0xdc,0x22,0x2a,0x90,0x88,0x46,0xee,0xb8,0x14,0xde,0x5e,0x0b,0xdb,
0xe0,0x32,0x3a,0x0a,0x49,0x06,0x24,0x5c,0xc2,0xd3,0xac,0x62,0x91,0x95,0xe4,0x79,
0xe7,0xc8,0x37,0x6d,0x8d,0xd5,0x4e,0xa9,0x6c,0x56,0xf4,0xea,0x65,0x7a,0xae,0x08,
0xba,0x78,0x25,0x2e,0x1c,0xa6,0xb4,0xc6,0xe8,0xdd,0x74,0x1f,0x4b,0xbd,0x8b,0x8a,
0x70,0x3e,0xb5,0x66,0x48,0x03,0xf6,0x0e,0x61,0x35,0x57,0xb9,0x86,0xc1,0x1d,0x9e,
0xe1,0xf8,0x98,0x11,0x69,0xd9,0x8e,0x94,0x9b,0x1e,0x87,0xe9,0xce,0x55,0x28,0xdf,
0x8c,0xa1,0x89,0x0d,0xbf,0xe6,0x42,0x68,0x41,0x99,0x2d,0x0f,0xb0,0x54,0xbb,0x16];
// Rcon is Round Constant used for the Key Expansion [1st col is 2^(r-1) in GF(2^8)] [Â§5.2]
var Rcon = [ [0x00, 0x00, 0x00, 0x00],
[0x01, 0x00, 0x00, 0x00],
[0x02, 0x00, 0x00, 0x00],
[0x04, 0x00, 0x00, 0x00],
[0x08, 0x00, 0x00, 0x00],
[0x10, 0x00, 0x00, 0x00],
[0x20, 0x00, 0x00, 0x00],
[0x40, 0x00, 0x00, 0x00],
[0x80, 0x00, 0x00, 0x00],
[0x1b, 0x00, 0x00, 0x00],
[0x36, 0x00, 0x00, 0x00] ];
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/**
* Encrypt a text using AES encryption in Counter mode of operation
* - see http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
*
* Unicode multi-byte character safe
*
* @param plaintext source text to be encrypted
* @param password the password to use to generate a key
* @param nBits number of bits to be used in the key (128, 192, or 256)
* @return encrypted text
*/
function AESEncryptCtr(plaintext, password, nBits) {
var blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
if (!(nBits==128 || nBits==192 || nBits==256)) return ''; // standard allows 128/192/256 bit keys
plaintext = plaintext.encodeUTF8();
password = password.encodeUTF8();
//var t = new Date(); // timer
// use AES itself to encrypt password to get cipher key (using plain password as source for key
// expansion) - gives us well encrypted key
var nBytes = nBits/8; // no bytes in key
var pwBytes = new Array(nBytes);
for (var i=0; i<nBytes; i++) {
pwBytes[i] = isNaN(password.charCodeAt(i)) ? 0 : password.charCodeAt(i);
}
var key = Cipher(pwBytes, KeyExpansion(pwBytes)); // gives us 16-byte key
key = key.concat(key.slice(0, nBytes-16)); // expand key to 16/24/32 bytes long
// initialise counter block (NIST SP800-38A Â§B.2): millisecond time-stamp for nonce in 1st 8 bytes,
// block counter in 2nd 8 bytes
var counterBlock = new Array(blockSize);
var nonce = (new Date()).getTime(); // timestamp: milliseconds since 1-Jan-1970
var nonceSec = Math.floor(nonce/1000);
var nonceMs = nonce%1000;
// encode nonce with seconds in 1st 4 bytes, and (repeated) ms part filling 2nd 4 bytes
for (var i=0; i<4; i++) counterBlock[i] = (nonceSec >>> i*8) & 0xff;
for (var i=0; i<4; i++) counterBlock[i+4] = nonceMs & 0xff;
// and convert it to a string to go on the front of the ciphertext
var ctrTxt = '';
for (var i=0; i<8; i++) ctrTxt += String.fromCharCode(counterBlock[i]);
// generate key schedule - an expansion of the key into distinct Key Rounds for each round
var keySchedule = KeyExpansion(key);
var blockCount = Math.ceil(plaintext.length/blockSize);
var ciphertxt = new Array(blockCount); // ciphertext as array of strings
for (var b=0; b<blockCount; b++) {
// set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes)
// done in two stages for 32-bit ops: using two words allows us to go past 2^32 blocks (68GB)
for (var c=0; c<4; c++) counterBlock[15-c] = (b >>> c*8) & 0xff;
for (var c=0; c<4; c++) counterBlock[15-c-4] = (b/0x100000000 >>> c*8)
var cipherCntr = Cipher(counterBlock, keySchedule); // -- encrypt counter block --
// block size is reduced on final block
var blockLength = b<blockCount-1 ? blockSize : (plaintext.length-1)%blockSize+1;
var cipherChar = new Array(blockLength);
for (var i=0; i<blockLength; i++) { // -- xor plaintext with ciphered counter char-by-char --
cipherChar[i] = cipherCntr[i] ^ plaintext.charCodeAt(b*blockSize+i);
cipherChar[i] = String.fromCharCode(cipherChar[i]);
}
ciphertxt[b] = cipherChar.join('');
}
// Array.join is more efficient than repeated string concatenation
var ciphertext = ctrTxt + ciphertxt.join('');
ciphertext = ciphertext.encodeBase64(); // encode in base64
//alert((new Date()) - t);
return ciphertext;
}
/**
* Decrypt a text encrypted by AES in counter mode of operation
*
* @param ciphertext source text to be encrypted
* @param password the password to use to generate a key
* @param nBits number of bits to be used in the key (128, 192, or 256)
* @return decrypted text
*/
function AESDecryptCtr(ciphertext, password, nBits) {
var blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
if (!(nBits==128 || nBits==192 || nBits==256)) return ''; // standard allows 128/192/256 bit keys
ciphertext = ciphertext.decodeBase64();
password = password.encodeUTF8();
//var t = new Date(); // timer
// use AES to encrypt password (mirroring encrypt routine)
var nBytes = nBits/8; // no bytes in key
var pwBytes = new Array(nBytes);
for (var i=0; i<nBytes; i++) {
pwBytes[i] = isNaN(password.charCodeAt(i)) ? 0 : password.charCodeAt(i);
}
var key = Cipher(pwBytes, KeyExpansion(pwBytes));
key = key.concat(key.slice(0, nBytes-16)); // expand key to 16/24/32 bytes long
// recover nonce from 1st 8 bytes of ciphertext
var counterBlock = new Array(8);
ctrTxt = ciphertext.slice(0, 8);
for (var i=0; i<8; i++) counterBlock[i] = ctrTxt.charCodeAt(i);
// generate key schedule
var keySchedule = KeyExpansion(key);
// separate ciphertext into blocks (skipping past initial 8 bytes)
var nBlocks = Math.ceil((ciphertext.length-8) / blockSize);
var ct = new Array(nBlocks);
for (var b=0; b<nBlocks; b++) ct[b] = ciphertext.slice(8+b*blockSize, 8+b*blockSize+blockSize);
ciphertext = ct; // ciphertext is now array of block-length strings
// plaintext will get generated block-by-block into array of block-length strings
var plaintxt = new Array(ciphertext.length);
for (var b=0; b<nBlocks; b++) {
// set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes)
for (var c=0; c<4; c++) counterBlock[15-c] = ((b) >>> c*8) & 0xff;
for (var c=0; c<4; c++) counterBlock[15-c-4] = (((b+1)/0x100000000-1) >>> c*8) & 0xff;
var cipherCntr = Cipher(counterBlock, keySchedule); // encrypt counter block
var plaintxtByte = new Array(ciphertext[b].length);
for (var i=0; i<ciphertext[b].length; i++) {
// -- xor plaintxt with ciphered counter byte-by-byte --
plaintxtByte[i] = cipherCntr[i] ^ ciphertext[b].charCodeAt(i);
plaintxtByte[i] = String.fromCharCode(plaintxtByte[i]);
}
plaintxt[b] = plaintxtByte.join('');
}
// join array of blocks into single plaintext string
var plaintext = plaintxt.join('');
plaintext = plaintext.decodeUTF8(); // decode from UTF8 back to Unicode multi-byte chars
//alert((new Date()) - t);
return plaintext;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/**
* Encode string into Base64, as defined by RFC 4648 [http://tools.ietf.org/html/rfc4648]
* (instance method extending String object). As per RFC 4648, no newlines are added.
*
* @param utf8encode optional parameter, if set to true Unicode string is encoded to UTF8 before
* conversion to base64; otherwise string is assumed to be 8-bit characters
* @return base64-encoded string
*/
var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
String.prototype.encodeBase64 = function(utf8encode) { // http://tools.ietf.org/html/rfc4648
utf8encode = (typeof utf8encode == 'undefined') ? false : utf8encode;
var o1, o2, o3, bits, h1, h2, h3, h4, e=[], pad = '', c, plain, coded;
plain = utf8encode ? this.encodeUTF8() : this;
c = plain.length % 3; // pad string to length of multiple of 3
if (c > 0) { while (c++ < 3) { pad += '='; plain += '\0'; } }
// note: doing padding here saves us doing special-case packing for trailing 1 or 2 chars
for (c=0; c<plain.length; c+=3) { // pack three octets into four hexets
o1 = plain.charCodeAt(c);
o2 = plain.charCodeAt(c+1);
o3 = plain.charCodeAt(c+2);
bits = o1<<16 | o2<<8 | o3;
h1 = bits>>18 & 0x3f;
h2 = bits>>12 & 0x3f;
h3 = bits>>6 & 0x3f;
h4 = bits & 0x3f;
// use hextets to index into b64 string
e[c/3] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
}
coded = e.join(''); // join() is far faster than repeated string concatenation
// replace 'A's from padded nulls with '='s
coded = coded.slice(0, coded.length-pad.length) + pad;
return coded;
}
/**
* Decode string from Base64, as defined by RFC 4648 [http://tools.ietf.org/html/rfc4648]
* (instance method extending String object). As per RFC 4648, newlines are not catered for.
*
* @param utf8decode optional parameter, if set to true UTF8 string is decoded back to Unicode
* after conversion from base64
* @return decoded string
*/
String.prototype.decodeBase64 = function(utf8decode) {
utf8decode = (typeof utf8decode == 'undefined') ? false : utf8decode;
var o1, o2, o3, h1, h2, h3, h4, bits, d=[], plain, coded;
coded = utf8decode ? this.decodeUTF8() : this;
for (var c=0; c<coded.length; c+=4) { // unpack four hexets into three octets
h1 = b64.indexOf(coded.charAt(c));
h2 = b64.indexOf(coded.charAt(c+1));
h3 = b64.indexOf(coded.charAt(c+2));
h4 = b64.indexOf(coded.charAt(c+3));
bits = h1<<18 | h2<<12 | h3<<6 | h4;
o1 = bits>>>16 & 0xff;
o2 = bits>>>8 & 0xff;
o3 = bits & 0xff;
d[c/4] = String.fromCharCode(o1, o2, o3);
// check for padding
if (h4 == 0x40) d[c/4] = String.fromCharCode(o1, o2);
if (h3 == 0x40) d[c/4] = String.fromCharCode(o1);
}
plain = d.join(''); // join() is far faster than repeated string concatenation
return utf8decode ? plain.decodeUTF8() : plain;
}
/**
* Encode multi-byte Unicode string into utf-8 multiple single-byte characters
* (BMP / basic multilingual plane only) (instance method extending String object).
 Right of free use is granted for all
* commercial or non-commercial use. No warranty of any form is offered.
*/
/**
* AES Cipher function: encrypt 'input' with Rijndael algorithm
*
* @param input message as byte-array (16 bytes)
* @param w key schedule as 2D byte-array (Nr+1 x Nb bytes) -
* generated from the cipher key by KeyExpansion()
* @return ciphertext as byte-array (16 bytes)
*/
function Cipher($input, $w) { // main Cipher function [Â§5.1]
$Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES)
$Nr = count($w)/$Nb - 1; // no of rounds: 10/12/14 for 128/192/256-bit keys
$state = array(); // initialise 4xNb byte-array 'state' with input [Â§3.4]
for ($i=0; $i<4*$Nb; $i++) $state[$i%4][floor($i/4)] = $input[$i];
$state = AddRoundKey($state, $w, 0, $Nb);
for ($round=1; $round<$Nr; $round++) { // apply Nr rounds
$state = SubBytes($state, $Nb);
$state = ShiftRows($state, $Nb);
$state = MixColumns($state, $Nb);
$state = AddRoundKey($state, $w, $round, $Nb);
}
$state = SubBytes($state, $Nb);
$state = ShiftRows($state, $Nb);
$state = AddRoundKey($state, $w, $Nr, $Nb);
$output = array(4*$Nb); // convert state to 1-d array before returning [Â§3.4]
for ($i=0; $i<4*$Nb; $i++) $output[$i] = $state[$i%4][floor($i/4)];
return $output;
}
function AddRoundKey($state, $w, $rnd, $Nb) { // xor Round Key into state S [Â§5.1.4]
for ($r=0; $r<4; $r++) {
for ($c=0; $c<$Nb; $c++) $state[$r][$c] ^= $w[$rnd*4+$c][$r];
}
return $state;
}
function SubBytes($s, $Nb) { // apply SBox to state S [Â§5.1.1]
global $Sbox; // PHP needs explicit declaration to access global variables!
for ($r=0; $r<4; $r++) {
for ($c=0; $c<$Nb; $c++) $s[$r][$c] = $Sbox[$s[$r][$c]];
}
return $s;
}
function ShiftRows($s, $Nb) { // shift row r of state S left by r bytes [Â§5.1.2]
$t = array(4);
for ($r=1; $r<4; $r++) {
for ($c=0; $c<4; $c++) $t[$c] = $s[$r][($c+$r)%$Nb]; // shift into temp copy
for ($c=0; $c<4; $c++) $s[$r][$c] = $t[$c]; // and copy back
} // note that this will work for Nb=4,5,6, but not 7,8 (always 4 for AES):
return $s; // see fp.gladman.plus.com/cryptography_technology/rijndael/aes.spec.311.pdf
}
function MixColumns($s, $Nb) { // combine bytes of each col of state S [Â§5.1.3]
for ($c=0; $c<4; $c++) {
$a = array(4); // 'a' is a copy of the current column from 's'
$b = array(4); // 'b' is aâ€¢{02} in GF(2^8)
for ($i=0; $i<4; $i++) {
$a[$i] = $s[$i][$c];
$b[$i] = $s[$i][$c]&0x80 ? $s[$i][$c]<<1 ^ 0x011b : $s[$i][$c]<<1;
}
// a[n] ^ b[n] is aâ€¢{03} in GF(2^8)
$s[0][$c] = $b[0] ^ $a[1] ^ $b[1] ^ $a[2] ^ $a[3]; // 2*a0 + 3*a1 + a2 + a3
$s[1][$c] = $a[0] ^ $b[1] ^ $a[2] ^ $b[2] ^ $a[3]; // a0 * 2*a1 + 3*a2 + a3
$s[2][$c] = $a[0] ^ $a[1] ^ $b[2] ^ $a[3] ^ $b[3]; // a0 + a1 + 2*a2 + 3*a3
$s[3][$c] = $a[0] ^ $b[0] ^ $a[1] ^ $a[2] ^ $b[3]; // 3*a0 + a1 + a2 + 2*a3
}
return $s;
}
/**
* Key expansion for Rijndael Cipher(): performs key expansion on cipher key
* to generate a key schedule
*
* @param key cipher key byte-array (16 bytes)
* @return key schedule as 2D byte-array (Nr+1 x Nb bytes)
*/
function KeyExpansion($key) { // generate Key Schedule from Cipher Key [Â§5.2]
global $Rcon; // PHP needs explicit declaration to access global variables!
$Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES)
$Nk = count($key)/4; // key length (in words): 4/6/8 for 128/192/256-bit keys
$Nr = $Nk + 6; // no of rounds: 10/12/14 for 128/192/256-bit keys
$w = array();
$temp = array();
for ($i=0; $i<$Nk; $i++) {
$r = array($key[4*$i], $key[4*$i+1], $key[4*$i+2], $key[4*$i+3]);
$w[$i] = $r;
}
for ($i=$Nk; $i<($Nb*($Nr+1)); $i++) {
$w[$i] = array();
for ($t=0; $t<4; $t++) $temp[$t] = $w[$i-1][$t];
if ($i % $Nk == 0) {
$temp = SubWord(RotWord($temp));
for ($t=0; $t<4; $t++) $temp[$t] ^= $Rcon[$i/$Nk][$t];
} else if ($Nk > 6 && $i%$Nk == 4) {
$temp = SubWord($temp);
}
for ($t=0; $t<4; $t++) $w[$i][$t] = $w[$i-$Nk][$t] ^ $temp[$t];
}
return $w;
}
function SubWord($w) { // apply SBox to 4-byte word w
global $Sbox; // PHP needs explicit declaration to access global variables!
for ($i=0; $i<4; $i++) $w[$i] = $Sbox[$w[$i]];
return $w;
}
function RotWord($w) { // rotate 4-byte word w left by one byte
$w[4] = $w[0];
for ($i=0; $i<4; $i++) $w[$i] = $w[$i+1];
return $w;
}
// Sbox is pre-computed multiplicative inverse in GF(2^8) used in SubBytes and KeyExpansion [Â§5.1.1]
$Sbox = array(0x63,0x7c,0x77,0x7b,0xf2,0x6b,0x6f,0xc5,0x30,0x01,0x67,0x2b,0xfe,0xd7,0xab,0x76,
0xca,0x82,0xc9,0x7d,0xfa,0x59,0x47,0xf0,0xad,0xd4,0xa2,0xaf,0x9c,0xa4,0x72,0xc0,
0xb7,0xfd,0x93,0x26,0x36,0x3f,0xf7,0xcc,0x34,0xa5,0xe5,0xf1,0x71,0xd8,0x31,0x15,
0x04,0xc7,0x23,0xc3,0x18,0x96,0x05,0x9a,0x07,0x12,0x80,0xe2,0xeb,0x27,0xb2,0x75,
0x09,0x83,0x2c,0x1a,0x1b,0x6e,0x5a,0xa0,0x52,0x3b,0xd6,0xb3,0x29,0xe3,0x2f,0x84,
0x53,0xd1,0x00,0xed,0x20,0xfc,0xb1,0x5b,0x6a,0xcb,0xbe,0x39,0x4a,0x4c,0x58,0xcf,
0xd0,0xef,0xaa,0xfb,0x43,0x4d,0x33,0x85,0x45,0xf9,0x02,0x7f,0x50,0x3c,0x9f,0xa8,
0x51,0xa3,0x40,0x8f,0x92,0x9d,0x38,0xf5,0xbc,0xb6,0xda,0x21,0x10,0xff,0xf3,0xd2,
0xcd,0x0c,0x13,0xec,0x5f,0x97,0x44,0x17,0xc4,0xa7,0x7e,0x3d,0x64,0x5d,0x19,0x73,
0x60,0x81,0x4f,0xdc,0x22,0x2a,0x90,0x88,0x46,0xee,0xb8,0x14,0xde,0x5e,0x0b,0xdb,
0xe0,0x32,0x3a,0x0a,0x49,0x06,0x24,0x5c,0xc2,0xd3,0xac,0x62,0x91,0x95,0xe4,0x79,
0xe7,0xc8,0x37,0x6d,0x8d,0xd5,0x4e,0xa9,0x6c,0x56,0xf4,0xea,0x65,0x7a,0xae,0x08,
0xba,0x78,0x25,0x2e,0x1c,0xa6,0xb4,0xc6,0xe8,0xdd,0x74,0x1f,0x4b,0xbd,0x8b,0x8a,
0x70,0x3e,0xb5,0x66,0x48,0x03,0xf6,0x0e,0x61,0x35,0x57,0xb9,0x86,0xc1,0x1d,0x9e,
0xe1,0xf8,0x98,0x11,0x69,0xd9,0x8e,0x94,0x9b,0x1e,0x87,0xe9,0xce,0x55,0x28,0xdf,
0x8c,0xa1,0x89,0x0d,0xbf,0xe6,0x42,0x68,0x41,0x99,0x2d,0x0f,0xb0,0x54,0xbb,0x16);
// Rcon is Round Constant used for the Key Expansion [1st col is 2^(r-1) in GF(2^8)] [Â§5.2]
$Rcon = array( array(0x00, 0x00, 0x00, 0x00),
array(0x01, 0x00, 0x00, 0x00),
array(0x02, 0x00, 0x00, 0x00),
array(0x04, 0x00, 0x00, 0x00),
array(0x08, 0x00, 0x00, 0x00),
array(0x10, 0x00, 0x00, 0x00),
array(0x20, 0x00, 0x00, 0x00),
array(0x40, 0x00, 0x00, 0x00),
array(0x80, 0x00, 0x00, 0x00),
array(0x1b, 0x00, 0x00, 0x00),
array(0x36, 0x00, 0x00, 0x00) );
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/**
* Encrypt a text using AES encryption in Counter mode of operation
* - see http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
*
* Unicode multi-byte character safe
*
* @param plaintext source text to be encrypted
* @param password the password to use to generate a key
* @param nBits number of bits to be used in the key (128, 192, or 256)
* @return encrypted text
*/
function AESEncryptCtr($plaintext, $password, $nBits) {
$blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
if (!($nBits==128 || $nBits==192 || $nBits==256)) return ''; // standard allows 128/192/256 bit keys
// note PHP (5) gives us plaintext and password in UTF8 encoding!
// use AES itself to encrypt password to get cipher key (using plain password as source for key
// expansion) - gives us well encrypted key
$nBytes = $nBits/8; // no bytes in key
$pwBytes = array();
for ($i=0; $i<$nBytes; $i++) $pwBytes[$i] = ord(substr($password,$i,1)) & 0xff;
$key = Cipher($pwBytes, KeyExpansion($pwBytes));
$key = array_merge($key, array_slice($key, 0, $nBytes-16)); // expand key to 16/24/32 bytes long
// initialise counter block (NIST SP800-38A Â§B.2): millisecond time-stamp for nonce in
// 1st 8 bytes, block counter in 2nd 8 bytes
$counterBlock = array();
$nonce = floor(microtime(true)*1000); // timestamp: milliseconds since 1-Jan-1970
$nonceSec = floor($nonce/1000);
$nonceMs = $nonce%1000;
// encode nonce with seconds in 1st 4 bytes, and (repeated) ms part filling 2nd 4 bytes
for ($i=0; $i<4; $i++) $counterBlock[$i] = urs($nonceSec, $i*8) & 0xff;
for ($i=0; $i<4; $i++) $counterBlock[$i+4] = $nonceMs & 0xff;
// and convert it to a string to go on the front of the ciphertext
$ctrTxt = '';
for ($i=0; $i<8; $i++) $ctrTxt .= chr($counterBlock[$i]);
// generate key schedule - an expansion of the key into distinct Key Rounds for each round
$keySchedule = KeyExpansion($key);
$blockCount = ceil(strlen($plaintext)/$blockSize);
$ciphertxt = array(); // ciphertext as array of strings
for ($b=0; $b<$blockCount; $b++) {
// set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes)
// done in two stages for 32-bit ops: using two words allows us to go past 2^32 blocks (68GB)
for ($c=0; $c<4; $c++) $counterBlock[15-$c] = urs($b, $c*8) & 0xff;
for ($c=0; $c<4; $c++) $counterBlock[15-$c-4] = urs($b/0x100000000, $c*8);
$cipherCntr = Cipher($counterBlock, $keySchedule); // -- encrypt counter block --
// block size is reduced on final block
$blockLength = $b<$blockCount-1 ? $blockSize : (strlen($plaintext)-1)%$blockSize+1;
$cipherByte = array();
for ($i=0; $i<$blockLength; $i++) { // -- xor plaintext with ciphered counter byte-by-byte --
$cipherByte[$i] = $cipherCntr[$i] ^ ord(substr($plaintext, $b*$blockSize+$i, 1));
$cipherByte[$i] = chr($cipherByte[$i]);
}
$ciphertxt[$b] = implode('', $cipherByte); // escape troublesome characters in ciphertext
}
// implode is more efficient than repeated string concatenation
$ciphertext = $ctrTxt . implode('', $ciphertxt);
$ciphertext = base64_encode($ciphertext);
return $ciphertext;
}
/**
* Decrypt a text encrypted by AES in counter mode of operation
*
* @param ciphertext source text to be decrypted
* @param password the password to use to generate a key
* @param nBits number of bits to be used in the key (128, 192, or 256)
* @return decrypted text
*/
function AESDecryptCtr($ciphertext, $password, $nBits) {
$blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
if (!($nBits==128 || $nBits==192 || $nBits==256)) return ''; // standard allows 128/192/256 bit keys
$ciphertext = base64_decode($ciphertext);
// use AES to encrypt password (mirroring encrypt routine)
$nBytes = $nBits/8; // no bytes in key
$pwBytes = array();
for ($i=0; $i<$nBytes; $i++) $pwBytes[$i] = ord(substr($password,$i,1)) & 0xff;
$key = Cipher($pwBytes, KeyExpansion($pwBytes));
$key = array_merge($key, array_slice($key, 0, $nBytes-16)); // expand key to 16/24/32 bytes long
// recover nonce from 1st element of ciphertext
$counterBlock = array();
$ctrTxt = substr($ciphertext, 0, 8);
for ($i=0; $i<8; $i++) $counterBlock[$i] = ord(substr($ctrTxt,$i,1));
// generate key schedule
$keySchedule = KeyExpansion($key);
// separate ciphertext into blocks (skipping past initial 8 bytes)
$nBlocks = ceil((strlen($ciphertext)-8) / $blockSize);
$ct = array();
for ($b=0; $b<$nBlocks; $b++) $ct[$b] = substr($ciphertext, 8+$b*$blockSize, 16);
$ciphertext = $ct; // ciphertext is now array of block-length strings
// plaintext will get generated block-by-block into array of block-length strings
$plaintxt = array();
for ($b=0; $b<$nBlocks; $b++) {
// set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes)
for ($c=0; $c<4; $c++) $counterBlock[15-$c] = urs($b, $c*8) & 0xff;
for ($c=0; $c<4; $c++) $counterBlock[15-$c-4] = urs(($b+1)/0x100000000-1, $c*8) & 0xff;
$cipherCntr = Cipher($counterBlock, $keySchedule); // encrypt counter block
$plaintxtByte = array();
for ($i=0; $i<strlen($ciphertext[$b]); $i++) {
// -- xor plaintext with ciphered counter byte-by-byte --
$plaintxtByte[$i] = $cipherCntr[$i] ^ ord(substr($ciphertext[$b],$i,1));
$plaintxtByte[$i] = chr($plaintxtByte[$i]);
}
$plaintxt[$b] = implode('', $plaintxtByte);
}
// join array of blocks into single plaintext string
$plaintext = implode('',$plaintxt);
return $plaintext;
}
/*
* Unsigned right shift function, since PHP has neither >>> operator nor unsigned ints
*
* @param a number to be shifted (32-bit integer)
* @param b number of bits to shift a to the right (0..31)
* @return a right-shifted and zero-filled by b bits
*/
function urs($a, $b) {
$a &= 0xffffffff; $b &= 0x1f; // (bounds check)
if ($a&0x80000000 && $b>0) { // if left-most bit set
$a = ($a>>1) & 0x7fffffff; // right-shift one bit & clear left-most bit
$a = $a >> ($b-1); // remaining right-shifts
} else { // otherwise
$a = ($a>>$b); // use normal right-shift
}
return $a;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
Kevin van Zonneveld
on 2008-09-05 21:28:49
@ Onno Marsman: It's also less readable (we have compressors for short code ;) and maintainable, have you benchmarked it against the current version? Cause if it's actually a lot faster, that would convince me to use this version. And what about copyrights? Thank you for time & effort Onno!
Onno Marsman
on 2008-09-04 16:34:13
Found the code below somewhere. Is similar but shorter and probably a bit faster. I've worked with it for quite some time and it seems to work fine in combination with sha1 from php. Why is utf8_encode necessary by the way? Also noticed this in base64_encode.
function sha1(s){
function X(x,y){var l=(x&0xFFFF)+(y&0xFFFF),m=(x>>16)+(y>>16)+(l>>16);return(m<<16)|(l&0xFFFF)}
function Y(x,y){return(x<<y)|(x>>>(32-y))}
var len=s.length*8,i,L=((len+64>>9)<<4)+16,x=Array(L+79),w=Array(80),a=1732584193,b=-271733879,c=-1732584194,d=271733878,e=-1009589776;
for(i=0;i<x.length;++i)x[i]=0;
for(i=0;i<len;i+=8)x[i>>5]|=(s.charCodeAt(i/8)&255)<<(24-i%32);
x[len>>5]|=0x80<<(24-len%32);
x[L-1]=len;
for(i=0;i<L;i+=16){
var oa=a,ob=b,oc=c,od=d,oe=e;
for(var j=0;j<80;j++){
w[j]=(j<16)?x[i+j]:Y(w[j-3]^w[j-8]^w[j-14]^w[j-16],1);
var t=X(X(Y(a,5),((j<20)?((b&c)|((~b)&d)):((j<40||j>=60)?(b^c^d):((b&c)|(b&d)|(c&d))))),X(X(e,w[j]),((j<20)?1518500249:(j<40)?1859775393:(j<60)?-1894007588:-899497514)));
e=d;
d=c;
c=Y(b,30);
b=a;
a=t;
}
a=X(a,oa);
b=X(b,ob);
c=X(c,oc);
d=X(d,od);
e=X(e,oe);
}
x=[a,b,c,d,e];
a="0123456789abcdef";
b="";
for(i=0;i<20;i++)b+=a.charAt((x[i>>2]>>((3-i%4)*8+4))&0xF)+a.charAt((x[i>>2]>>((3-i%4)*8))&0xF);
return b
}


Wilbert:
I drew . The cards on the table are:
What luck! Looks like I win. Still, it was a pretty exciting practice run, eh? If you want to play again, feel free to challenge me.
"I'd like to keep practicing."

"I want to quit."


Call somatic SNVs and indels via local assembly of haplotypes
Call somatic short mutations via local assembly of haplotypes. Short mutations include single nucleotide (SNA) and insertion and deletion (indel) alterations. The caller uses a Bayesian somatic genotyping model that differs from the original MuTect by Cibulskis et al., 2013 and uses the assembly-based machinery of HaplotypeCaller. Of note, Mutect2 v<IP_ADDRESS> onwards enables joint analysis of multiple samples.
This tool is featured in the Somatic Short Mutation calling Best Practice Workflow. See Tutorial#11136 for a step-by-step description of the workflow and Article#11127 for an overview of what traditional somatic calling entails. For the latest pipeline scripts, see the Mutect2 WDL scripts directory. For pipelines with example data, see the gatk-workflows repository. Although we present the tool for somatic calling, it may apply to other contexts, such as mitochondrial variant calling and detection of somatic mosaicism.
Starting with v<IP_ADDRESS> Mutect2 accomodates extreme high depths, e.g. 20,000X. See the following articles for details on this and additional applications.
Example commands show how to run Mutect2 for typical scenarios. The three modes are (i) tumor-normal mode where a tumor sample is matched with a normal sample in analysis, (ii) tumor-only mode where a single sample's alignment data undergoes analysis, and (iii) mitochondrial mode where sensitive calling at high depths is desirable.
Given a matched normal, Mutect2 is designed to call somatic variants only. The tool includes logic to skip emitting variants that are clearly present in the germline based on provided evidence, e.g. in the matched normal. This is done at an early stage to avoid spending computational resources on germline events. If the variant's germline status is borderline, then Mutect2 will emit the variant to the callset for subsequent filtering by FilterMutectCalls and review.
gatk Mutect2 \ -R reference.fa \ -I tumor.bam \ -I normal.bam \ -normal normal_sample_name \ --germline-resource af-only-gnomad.vcf.gz \ --panel-of-normals pon.vcf.gz \ -O somatic.vcf.gz
Mutect2 also generates a stats file names [output vcf].stats. That is, in the above example the stats file would be named somatic.vcf.gz.stats and would be in the same folder as somatic.vcf.gz. As of GATK 4.1.1 this file is a required input to FilterMutectCalls.
As of v4.1 Mutect2 supports joint calling of multiple tumor and normal samples from the same individual. The
only difference is that -I and
gatk Mutect2 \ -R reference.fa \ -I tumor1.bam \ -I tumor2.bam \ -I normal1.bam \ -I normal2.bam \ -normal normal1_sample_name \ -normal normal2_sample_name \ --germline-resource af-only-gnomad.vcf.gz \ --panel-of-normals pon.vcf.gz \ -O somatic.vcf.gz
This mode runs on a single type of sample, e.g. the tumor or the normal. To create a PoN, call on each normal sample in this mode, then use CreateSomaticPanelOfNormals to generate the PoN.
gatk Mutect2 \ -R reference.fa \ -I sample.bam \ -O single_sample.vcf.gz
To call mutations on a tumor sample, call in this mode using a PoN and germline resource. After FilterMutectCalls filtering, consider additional filtering by functional significance with Funcotator.
gatk Mutect2 \ -R reference.fa \ -I sample.bam \ --germline-resource af-only-gnomad.vcf.gz \ --panel-of-normals pon.vcf.gz \ -O single_sample.vcf.gz
Mutect2 automatically sets parameters appropriately for calling on mitochondria with the
gatk Mutect2 \ -R reference.fa \ -L chrM \ --mitochondria-mode \ -I mitochondria.bam \ -O mitochondria.vcf.gz
The mode accepts only a single sample, which can be provided in multiple files.
This mode force-calls all alleles in force-call-alleles.vcf in addition to any other variants Mutect2 discovers.
gatk Mutect2 \ -R reference.fa \ -I sample.bam \ -alleles force-call-alleles.vcf -O single_sample.vcf.gz
If the sample is suspected to exhibit orientation bias artifacts (such as in the case of FFPE tumor samples) one should also collect F1R2 metrics by adding an --f1r2-tar-gz argument as shown below. This file contains information that can then be passed to LearnReadOrientationModel, which generate an artifact prior table for each tumor sample for FilterMutectCalls to use.
gatk Mutect2 \ -R reference.fa \ -I sample.bam \ --f1r2-tar-gz f1r2.tar.gz \ -O single_sample.vcf.gz
#CHROM POS ID REF ALT QUAL FILTER INFO 1 10067 . T TAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCC 30.35 PASS AC=3;AF=7.384E-5 1 10108 . CAACCCT C 46514.32 PASS AC=6;AF=1.525E-4 1 10109 . AACCCTAACCCT AAACCCT,* 89837.27 PASS AC=48,5;AF=0.001223,1.273E-4 1 10114 . TAACCCTAACCCTAACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAACCCTAACCCTAACCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAAACCCTA *,CAACCCTAACCCTAACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAACCCTAACCCTAACCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCCTAACCCTAACCCTAAACCCTA,T 36728.97 PASS AC=55,9,1;AF=0.001373,2.246E-4,2.496E-5 1 10119 . CT C,* 251.23 PASS AC=5,1;AF=1.249E-4,2.498E-5 1 10120 . TA CA,* 14928.74 PASS AC=10,6;AF=2.5E-4,1.5E-4 1 10128 . ACCCTAACCCTAACCCTAAC A,* 285.71 PASS AC=3,1;AF=7.58E-5,2.527E-5 1 10131 . CT C,* 378.93 PASS AC=7,5;AF=1.765E-4,1.261E-4 1 10132 . TAACCC *,T 18025.11 PASS AC=12,2;AF=3.03E-4,5.049E-5
These Read Filters are automatically applied to the data by the Engine before processing by Mutect2.
This table summarizes the command-line arguments that are specific to this tool. For more details on each argument, see the list further down below the table or click on an argument name to jump directly to that entry in the list.
| Argument name(s) | Default value | Summary | |
|---|---|---|---|
| Required Arguments | |||
| --input -I |
BAM/SAM/CRAM file containing reads | ||
| --output -O |
File to which variants should be written | ||
| --reference -R |
Reference sequence file | ||
| Optional Tool Arguments | |||
| --af-of-alleles-not-in-resource -default-af |
-1.0 | Population allele fraction assigned to alleles not found in germline resource. Please see docs/mutect/mutect2.pdf fora derivation of the default value. | |
| --alleles |
The set of alleles to force-call regardless of evidence | ||
| --annotation -A |
One or more specific annotations to add to variant calls | ||
| --annotation-group -G |
One or more groups of annotations to apply to variant calls | ||
| --annotations-to-exclude -AX |
One or more specific annotations to exclude from variant calls | ||
| --arguments_file |
read one or more arguments files and add them to the command line | ||
| --assembly-region-out |
Output the assembly region to this IGV formatted file | ||
| --assembly-region-padding |
100 | Number of additional bases of context to include around each assembly region | |
| --base-quality-score-threshold |
18 | Base qualities below this threshold will be reduced to the minimum (6) | |
| --callable-depth |
10 | Minimum depth to be considered callable for Mutect stats. Does not affect genotyping. | |
| --cloud-index-prefetch-buffer -CIPB |
-1 | Size of the cloud-only prefetch buffer (in MB; 0 to disable). Defaults to cloudPrefetchBuffer if unset. | |
| --cloud-prefetch-buffer -CPB |
40 | Size of the cloud-only prefetch buffer (in MB; 0 to disable). | |
| --disable-bam-index-caching -DBIC |
false | If true, don't cache bam indexes, this will reduce memory requirements but may harm performance if many intervals are specified. Caching is automatically disabled if there are no intervals specified. | |
| --disable-sequence-dictionary-validation |
false | If specified, do not check the sequence dictionaries from our inputs for compatibility. Use at your own risk! | |
| --dont-use-dragstr-pair-hmm-scores |
false | disable DRAGstr pair-hmm score even when dragstr-params-path was provided | |
| --downsampling-stride -stride |
1 | Downsample a pool of reads starting within a range of one or more bases. | |
| --dragstr-het-hom-ratio |
2 | het to hom prior ratio use with DRAGstr on | |
| --dragstr-params-path |
location of the DRAGstr model parameters for STR error correction used in the Pair HMM. When provided, it overrides other PCR error correcting mechanisms | ||
| --enable-dynamic-read-disqualification-for-genotyping |
false | Will enable less strict read disqualification low base quality reads | |
| --f1r2-max-depth |
200 | sites with depth higher than this value will be grouped | |
| --f1r2-median-mq |
50 | skip sites with median mapping quality below this value | |
| --f1r2-min-bq |
20 | exclude bases below this quality from pileup | |
| --f1r2-tar-gz |
If specified, collect F1R2 counts and output files into this tar.gz file | ||
| --founder-id |
Samples representing the population "founders" | ||
| --gcs-max-retries -gcs-retries |
20 | If the GCS bucket channel errors out, how many times it will attempt to re-initiate the connection | |
| --gcs-project-for-requester-pays |
Project to bill when accessing "requester pays" buckets. If unset, these buckets cannot be accessed. User must have storage.buckets.get permission on the bucket being accessed. | ||
| --genotype-germline-sites |
false | (EXPERIMENTAL) Call all apparent germline site even though they will ultimately be filtered. | |
| --genotype-pon-sites |
false | Call sites in the PoN even though they will ultimately be filtered. | |
| --germline-resource |
Population vcf of germline sequencing containing allele fractions. | ||
| --graph-output -graph |
Write debug assembly graph information to this file | ||
| --help -h |
false | display the help message | |
| --ignore-itr-artifacts |
false | Turn off read transformer that clips artifacts associated with end repair insertions near inverted tandem repeats. | |
| --initial-tumor-lod -init-lod |
2.0 | Log 10 odds threshold to consider pileup active. | |
| --interval-merging-rule -imr |
ALL | Interval merging rule for abutting intervals | |
| --intervals -L |
One or more genomic intervals over which to operate | ||
| --max-assembly-region-size |
300 | Maximum size of an assembly region | |
| --max-population-af -max-af |
0.01 | Maximum population allele frequency in tumor-only mode. | |
| --max-reads-per-alignment-start |
50 | Maximum number of reads to retain per alignment start position. Reads above this threshold will be downsampled. Set to 0 to disable. | |
| --min-assembly-region-size |
50 | Minimum size of an assembly region | |
| --min-base-quality-score -mbq |
10 | Minimum base quality required to consider a base for calling | |
| --mitochondria-mode |
false | Mitochondria mode sets emission and initial LODs to 0. | |
| --native-pair-hmm-threads |
4 | How many threads should a native pairHMM implementation use | |
| --native-pair-hmm-use-double-precision |
false | use double precision in the native pairHmm. This is slower but matches the java implementation better | |
| --normal-lod |
2.2 | Log 10 odds threshold for calling normal variant non-germline. | |
| --normal-sample -normal |
BAM sample name of normal(s), if any. May be URL-encoded as output by GetSampleName with -encode argument. | ||
| --panel-of-normals -pon |
VCF file of sites observed in normal. | ||
| --pcr-indel-qual |
40 | Phred-scaled PCR indel qual for overlapping fragments | |
| --pcr-snv-qual |
40 | Phred-scaled PCR SNV qual for overlapping fragments | |
| --pedigree -ped |
Pedigree file for determining the population "founders" | ||
| --sites-only-vcf-output |
false | If true, don't emit genotype fields when writing vcf file output. | |
| --training-data-mode |
false | Output VCF contains featurized sets of reads for training a deep variant filter. | |
| --training-data-mode-ref-downsample |
2147483647 | Downsample ref reads to this count in training data mode. | |
| --tumor-lod-to-emit -emit-lod |
3.0 | Log 10 odds threshold to emit variant to VCF. | |
| --version |
false | display the version number for this tool | |
| Optional Common Arguments | |||
| --add-output-sam-program-record |
true | If true, adds a PG tag to created SAM/BAM/CRAM files. | |
| --add-output-vcf-command-line |
true | If true, adds a command line header line to created VCF files. | |
| --create-output-bam-index -OBI |
true | If true, create a BAM/CRAM index when writing a coordinate-sorted BAM/CRAM file. | |
| --create-output-bam-md5 -OBM |
false | If true, create a MD5 digest for any BAM/SAM/CRAM file created | |
| --create-output-variant-index -OVI |
true | If true, create a VCF index when writing a coordinate-sorted VCF file. | |
| --create-output-variant-md5 -OVM |
false | If true, create a a MD5 digest any VCF file created. | |
| --disable-read-filter -DF |
Read filters to be disabled before analysis | ||
| --disable-tool-default-read-filters |
false | Disable all tool default read filters (WARNING: many tools will not function correctly without their default read filters on) | |
| --exclude-intervals -XL |
One or more genomic intervals to exclude from processing | ||
| --gatk-config-file |
A configuration file to use with the GATK. | ||
| --interval-exclusion-padding -ixp |
0 | Amount of padding (in bp) to add to each interval you are excluding. | |
| --interval-padding -ip |
0 | Amount of padding (in bp) to add to each interval you are including. | |
| --interval-set-rule -isr |
UNION | Set merging approach to use for combining interval inputs | |
| --lenient -LE |
false | Lenient processing of VCF files | |
| --max-variants-per-shard |
0 | If non-zero, partitions VCF output into shards, each containing up to the given number of records. | |
| --QUIET |
false | Whether to suppress job-summary info on System.err. | |
| --read-filter -RF |
Read filters to be applied before analysis | ||
| --read-index |
Indices to use for the read inputs. If specified, an index must be provided for every read input and in the same order as the read inputs. If this argument is not specified, the path to the index for each input will be inferred automatically. | ||
| --read-validation-stringency -VS |
SILENT | Validation stringency for all SAM/BAM/CRAM/SRA files read by this program. The default stringency value SILENT can improve performance when processing a BAM file in which variable-length data (read, qualities, tags) do not otherwise need to be decoded. | |
| --seconds-between-progress-updates |
10.0 | Output traversal statistics every time this many seconds elapse | |
| --sequence-dictionary |
Use the given sequence dictionary as the master/canonical sequence dictionary. Must be a .dict file. | ||
| --tmp-dir |
Temp directory to use. | ||
| --use-jdk-deflater -jdk-deflater |
false | Whether to use the JdkDeflater (as opposed to IntelDeflater) | |
| --use-jdk-inflater -jdk-inflater |
false | Whether to use the JdkInflater (as opposed to IntelInflater) | |
| --verbosity |
INFO | Control verbosity of logging. | |
| Advanced Arguments | |||
| --active-probability-threshold |
0.002 | Minimum probability for a locus to be considered active. | |
| --adaptive-pruning-initial-error-rate |
0.001 | Initial base error rate estimate for adaptive pruning | |
| --allele-informative-reads-overlap-margin |
2 | Likelihood and read-based annotations will only take into consideration reads that overlap the variant or any base no further than this distance expressed in base pairs | |
| --allow-non-unique-kmers-in-ref |
false | Allow graphs that have non-unique kmers in the reference | |
| --bam-output -bamout |
File to which assembled haplotypes should be written | ||
| --bam-writer-type |
CALLED_HAPLOTYPES | Which haplotypes should be written to the BAM | |
| --debug-assembly -debug |
false | Print out verbose debug information about each assembly region | |
| --disable-adaptive-pruning |
false | Disable the adaptive algorithm for pruning paths in the graph | |
| --disable-cap-base-qualities-to-map-quality |
false | If false this disables capping of base qualities in the HMM to the mapping quality of the read | |
| --disable-symmetric-hmm-normalizing |
false | Toggle to revive legacy behavior of asymmetrically normalizing the arguments to the reference haplotype | |
| --disable-tool-default-annotations |
false | Disable all tool default annotations | |
| --dont-increase-kmer-sizes-for-cycles |
false | Disable iterating over kmer sizes when graph cycles are detected | |
| --dont-use-soft-clipped-bases |
false | Do not analyze soft clipped bases in the reads | |
| --emit-ref-confidence -ERC |
NONE | Mode for emitting reference confidence scores (For Mutect2, this is a BETA feature) | |
| --enable-all-annotations |
false | Use all possible annotations (not for the faint of heart) | |
| --expected-mismatch-rate-for-read-disqualification |
0.02 | Error rate used to set expectation for post HMM read disqualification based on mismatches | |
| --force-active |
false | If provided, all regions will be marked as active | |
| --force-call-filtered-alleles -genotype-filtered-alleles |
false | Force-call filtered alleles included in the resource specified by --alleles | |
| --gvcf-lod-band -LODB |
[-2.5, -2.0, -1.5, -1.0, -0.5, 0.0, 0.5, 1.0] | Exclusive upper bounds for reference confidence LOD bands (must be specified in increasing order) | |
| --independent-mates |
false | Allow paired reads to independently support different haplotypes. Useful for validations with ill-designed synthetic data. | |
| --kmer-size |
[10, 25] | Kmer size to use in the read threading assembler | |
| --linked-de-bruijn-graph |
false | If enabled, the Assembly Engine will construct a Linked De Bruijn graph to recover better haplotypes | |
| --max-mnp-distance -mnp-dist |
1 | Two or more phased substitutions separated by this distance or less are merged into MNPs. | |
| --max-num-haplotypes-in-population |
128 | Maximum number of haplotypes to consider for your population | |
| --max-prob-propagation-distance |
50 | Upper limit on how many bases away probability mass can be moved around when calculating the boundaries between active and inactive assembly regions | |
| --max-suspicious-reads-per-alignment-start |
0 | Maximum number of suspicious reads (mediocre mapping quality or too many substitutions) allowed in a downsampling stride. Set to 0 to disable. | |
| --max-unpruned-variants |
100 | Maximum number of variants in graph the adaptive pruner will allow | |
| --min-dangling-branch-length |
4 | Minimum length of a dangling branch to attempt recovery | |
| --min-pruning |
2 | Minimum support to not prune paths in the graph | |
| --minimum-allele-fraction -min-AF |
0.0 | Lower bound of variant allele fractions to consider when calculating variant LOD | |
| --num-pruning-samples |
1 | Number of samples that must pass the minPruning threshold | |
| --pair-hmm-gap-continuation-penalty |
10 | Flat gap continuation penalty for use in the Pair HMM | |
| --pair-hmm-implementation -pairHMM |
FASTEST_AVAILABLE | The PairHMM implementation to use for genotype likelihood calculations | |
| --pcr-indel-model |
CONSERVATIVE | The PCR indel model to use | |
| --phred-scaled-global-read-mismapping-rate |
45 | The global assumed mismapping rate for reads | |
| --pruning-lod-threshold |
2.302585092994046 | Ln likelihood ratio threshold for adaptive pruning algorithm | |
| --pruning-seeding-lod-threshold |
9.210340371976184 | Ln likelihood ratio threshold for seeding subgraph of good variation in adaptive pruning algorithm | |
| --recover-all-dangling-branches |
false | Recover all dangling branches | |
| --showHidden |
false | display hidden arguments | |
| --smith-waterman |
JAVA | Which Smith-Waterman implementation to use, generally FASTEST_AVAILABLE is the right choice | |
| --soft-clip-low-quality-ends |
false | If enabled will preserve low-quality read ends as softclips (used for DRAGEN-GATK BQD genotyper model) | |
| Deprecated Arguments | |||
| --tumor-sample -tumor |
BAM sample name of tumor. May be URL-encoded as output by GetSampleName with -encode argument. |
Arguments in this list are specific to this tool. Keep in mind that other arguments are available that are shared with other tools (e.g. command-line GATK arguments); see Inherited arguments above.
Minimum probability for a locus to be considered active.
double 0.002 [ [ -∞ ∞ ] ]
Initial base error rate estimate for adaptive pruning
Initial base error rate guess for the probabilistic adaptive pruning model. Results are not very sensitive to this
parameter because it is only a starting point from which the algorithm discovers the true error rate.
double 0.001 [ [ -∞ ∞ ] ]
If true, adds a PG tag to created SAM/BAM/CRAM files.
boolean true
If true, adds a command line header line to created VCF files.
boolean true
Population allele fraction assigned to alleles not found in germline resource. Please see docs/mutect/mutect2.pdf fora derivation of the default value.
Population allele fraction assigned to alleles not found in germline resource.
double -1.0 [ [ -∞ ∞ ] ]
Likelihood and read-based annotations will only take into consideration reads that overlap the variant or any base no further than this distance expressed in base pairs
int 2 [ [ -∞ ∞ ] ]
The set of alleles to force-call regardless of evidence
FeatureInput[VariantContext] null
Allow graphs that have non-unique kmers in the reference
By default, the program does not allow processing of reference sections that contain non-unique kmers. Disabling
this check may cause problems in the assembly graph.
boolean false
One or more specific annotations to add to variant calls
Which annotations to include in variant calls in the output. These supplement annotations provided by annotation groups.
List[String] []
One or more groups of annotations to apply to variant calls
Which groups of annotations to add to the output variant calls.
Any requirements that are not met (e.g. failing to provide a pedigree file for a pedigree-based annotation) may cause the run to fail.
List[String] []
One or more specific annotations to exclude from variant calls
Which annotations to exclude from output in the variant calls. Note that this argument has higher priority than the
-A or -G arguments, so these annotations will be excluded even if they are explicitly included with the other
options.
List[String] []
read one or more arguments files and add them to the command line
List[File] []
Output the assembly region to this IGV formatted file
If provided, this walker will write out its assembly regions
to this file in the IGV formatted TAB-delimited output:
http://www.broadinstitute.org/software/igv/IGV
Intended to make debugging the active region calculations easier
String null
Number of additional bases of context to include around each assembly region
Parameters that control assembly regions
int 100 [ [ -∞ ∞ ] ]
File to which assembled haplotypes should be written
The assembled haplotypes and locally realigned reads will be written as BAM to this file if requested. Really
for debugging purposes only. Note that the output here does not include uninformative reads so that not every
input read is emitted to the bam.
Turning on this mode may result in serious performance cost for the caller. It's really only appropriate to
use in specific areas where you want to better understand why the caller is making specific calls.
The reads are written out containing an "HC" tag (integer) that encodes which haplotype each read best matches
according to the haplotype caller's likelihood calculation. The use of this tag is primarily intended
to allow good coloring of reads in IGV. Simply go to "Color Alignments By > Tag" and enter "HC" to more
easily see which reads go with these haplotype.
Note that the haplotypes (called or all, depending on mode) are emitted as single reads covering the entire
active region, coming from sample "HC" and a special read group called "ArtificialHaplotype". This will increase the
pileup depth compared to what would be expected from the reads only, especially in complex regions.
Note also that only reads that are actually informative about the haplotypes are emitted. By informative we mean
that there's a meaningful difference in the likelihood of the read coming from one haplotype compared to
its next best haplotype.
If multiple BAMs are passed as input to the tool (as is common for M2), then they will be combined in the bamout
output and tagged with the appropriate sample names.
The best way to visualize the output of this mode is with IGV. Tell IGV to color the alignments by tag,
and give it the "HC" tag, so you can see which reads support each haplotype. Finally, you can tell IGV
to group by sample, which will separate the potential haplotypes from the reads. All of this can be seen in
this screenshot
String null
Which haplotypes should be written to the BAM
The type of BAM output we want to see. This determines whether HC will write out all of the haplotypes it
considered (top 128 max) or just the ones that were selected as alleles and assigned to samples.
The --bam-writer-type argument is an enumerated type (WriterType), which can have one of the following values:
WriterType CALLED_HAPLOTYPES
Base qualities below this threshold will be reduced to the minimum (6)
Bases with a quality below this threshold will reduced to the minimum usable qualiy score (6).
byte 18 [ [ -∞ ∞ ] ]
Minimum depth to be considered callable for Mutect stats. Does not affect genotyping.
int 10 [ [ -∞ ∞ ] ]
Size of the cloud-only prefetch buffer (in MB; 0 to disable). Defaults to cloudPrefetchBuffer if unset.
int -1 [ [ -∞ ∞ ] ]
Size of the cloud-only prefetch buffer (in MB; 0 to disable).
int 40 [ [ -∞ ∞ ] ]
If true, create a BAM/CRAM index when writing a coordinate-sorted BAM/CRAM file.
boolean true
If true, create a MD5 digest for any BAM/SAM/CRAM file created
boolean false
If true, create a VCF index when writing a coordinate-sorted VCF file.
boolean true
If true, create a a MD5 digest any VCF file created.
boolean false
Print out verbose debug information about each assembly region
boolean false
Disable the adaptive algorithm for pruning paths in the graph
A single edge multiplicity cutoff for pruning doesn't work in samples with variable depths, for example exomes
and RNA. This parameter disables the probabilistic algorithm for pruning the assembly graph that considers the
likelihood that each chain in the graph comes from real variation, and instead uses a simple multiplicity cutoff.
boolean false
If true, don't cache bam indexes, this will reduce memory requirements but may harm performance if many intervals are specified. Caching is automatically disabled if there are no intervals specified.
boolean false
If false this disables capping of base qualities in the HMM to the mapping quality of the read
boolean false
Read filters to be disabled before analysis
List[String] []
If specified, do not check the sequence dictionaries from our inputs for compatibility. Use at your own risk!
boolean false
Toggle to revive legacy behavior of asymmetrically normalizing the arguments to the reference haplotype
boolean false
Disable all tool default annotations
Hook allowing for the user to remove default annotations from the tool
boolean false
Disable all tool default read filters (WARNING: many tools will not function correctly without their default read filters on)
boolean false
Disable iterating over kmer sizes when graph cycles are detected
When graph cycles are detected, the normal behavior is to increase kmer sizes iteratively until the cycles are
resolved. Disabling this behavior may cause the program to give up on assembling the ActiveRegion.
boolean false
disable DRAGstr pair-hmm score even when dragstr-params-path was provided
boolean false
Do not analyze soft clipped bases in the reads
boolean false
Downsample a pool of reads starting within a range of one or more bases.
Downsample a pool of reads starting within a range of one or more bases.
int 1 [ [ -∞ ∞ ] ]
het to hom prior ratio use with DRAGstr on
int 2 [ [ -∞ ∞ ] ]
location of the DRAGstr model parameters for STR error correction used in the Pair HMM. When provided, it overrides other PCR error correcting mechanisms
GATKPath null
Mode for emitting reference confidence scores (For Mutect2, this is a BETA feature)
The reference confidence mode makes it possible to emit a per-bp or summarized confidence estimate for a site being strictly homozygous-reference.
See https://software.broadinstitute.org/gatk/documentation/article.php?id=4017 for information about GVCFs.
For Mutect2, this is a BETA feature that functions similarly to the HaplotypeCaller reference confidence/GVCF mode.
The --emit-ref-confidence argument is an enumerated type (ReferenceConfidenceMode), which can have one of the following values:
ReferenceConfidenceMode NONE
Use all possible annotations (not for the faint of heart)
You can use the -AX argument in combination with this one to exclude specific annotations. Note that some
annotations may not be actually applied if they are not applicable to the data provided or if they are
unavailable to the tool (e.g. there are several annotations that are currently not hooked up to
HaplotypeCaller). At present no error or warning message will be provided, the annotation will simply be
skipped silently. You can check the output VCF header to see which annotations were activated and thus might be applied (although
this does not guarantee that the annotation was applied to all records in the VCF, since some annotations have
additional requirements, e.g. minimum number of samples or heterozygous sites only -- see the documentation
for individual annotations' requirements).
boolean false
Will enable less strict read disqualification low base quality reads
If enabled, rather than disqualifying all reads over a threshold of minimum hmm scores we will instead choose a less strict
and less aggressive cap for disqualification based on the read length and base qualities.
boolean false
One or more genomic intervals to exclude from processing
Use this argument to exclude certain parts of the genome from the analysis (like -L, but the opposite).
This argument can be specified multiple times. You can use samtools-style intervals either explicitly on the
command line (e.g. -XL 1 or -XL 1:100-200) or by loading in a file containing a list of intervals
(e.g. -XL myFile.intervals).
List[String] []
Error rate used to set expectation for post HMM read disqualification based on mismatches
double 0.02 [ [ -∞ ∞ ] ]
sites with depth higher than this value will be grouped
int 200 [ [ -∞ ∞ ] ]
skip sites with median mapping quality below this value
int 50 [ [ -∞ ∞ ] ]
exclude bases below this quality from pileup
int 20 [ [ -∞ ∞ ] ]
If specified, collect F1R2 counts and output files into this tar.gz file
File null
If provided, all regions will be marked as active
boolean false
Force-call filtered alleles included in the resource specified by --alleles
boolean false
Samples representing the population "founders"
List[String] []
A configuration file to use with the GATK.
String null
If the GCS bucket channel errors out, how many times it will attempt to re-initiate the connection
int 20 [ [ -∞ ∞ ] ]
Project to bill when accessing "requester pays" buckets. If unset, these buckets cannot be accessed. User must have storage.buckets.get permission on the bucket being accessed.
String ""
(EXPERIMENTAL) Call all apparent germline site even though they will ultimately be filtered.
Usually we exclude sites in the panel of normals from active region determination, which saves time. Setting this to true
causes Mutect to produce a variant call at these sites. This call will still be filtered, but it shows up in the vcf.
boolean false
Call sites in the PoN even though they will ultimately be filtered.
Usually we exclude sites in the panel of normals from active region determination, which saves time. Setting this to true
causes Mutect to produce a variant call at these sites. This call will still be filtered, but it shows up in the vcf.
boolean false
Population vcf of germline sequencing containing allele fractions.
A resource, such as gnomAD, containing population allele frequencies of common and rare variants.
FeatureInput[VariantContext] null
Write debug assembly graph information to this file
This argument is meant for debugging and is not immediately useful for normal analysis use.
String null
Exclusive upper bounds for reference confidence LOD bands (must be specified in increasing order)
When Mutect2 is run in reference confidence mode with banding compression enabled (-ERC GVCF), homozygous-reference
sites are compressed into bands of similar tumor LOD (TLOD) that are emitted as a single VCF record. See
the FAQ documentation for more details about the GVCF format.
This argument allows you to set the TLOD bands. Mutect2 expects a list of strictly increasing TLOD values that will act as exclusive upper bounds for the TLOD bands. To pass multiple values, you provide them one by one with the argument, as in `-LODB -3.0 -LODB -2.0 -LODB -1.0` (this would set the TLOD bands to be `[-Inf, -3.0), [-3.0, -2.0), [-2.0, -1.0), [-1.0, Inf]`, for example).
Note that, unlike the GQ used by HaplotypeCaller GVCFs, here the reference calls with the highest confidence are the most negative.
List[Double] [-2.5, -2.0, -1.5, -1.0, -0.5, 0.0, 0.5, 1.0]
display the help message
boolean false
Turn off read transformer that clips artifacts associated with end repair insertions near inverted tandem repeats.
When opposite ends of a fragment are inverted tandem repeats of each other, the sequence past one end may be copied onto the other
during library prep. By default, Mutect2 identifies and clips these artifacts, which are especially prevalent when
DNA is damaged as in the case of FFPE samples and ancient DNA.
boolean false
Allow paired reads to independently support different haplotypes. Useful for validations with ill-designed synthetic data.
boolean false
Log 10 odds threshold to consider pileup active.
Only variants with estimated tumor LODs exceeding this threshold will be considered active.
double 2.0 [ [ -∞ ∞ ] ]
BAM/SAM/CRAM file containing reads
R List[GATKPath] []
Amount of padding (in bp) to add to each interval you are excluding.
Use this to add padding to the intervals specified using -XL. For example, '-XL 1:100' with a
padding value of 20 would turn into '-XL 1:80-120'. This is typically used to add padding around targets when
analyzing exomes.
int 0 [ [ -∞ ∞ ] ]
Interval merging rule for abutting intervals
By default, the program merges abutting intervals (i.e. intervals that are directly side-by-side but do not
actually overlap) into a single continuous interval. However you can change this behavior if you want them to be
treated as separate intervals instead.
The --interval-merging-rule argument is an enumerated type (IntervalMergingRule), which can have one of the following values:
IntervalMergingRule ALL
Amount of padding (in bp) to add to each interval you are including.
Use this to add padding to the intervals specified using -L. For example, '-L 1:100' with a
padding value of 20 would turn into '-L 1:80-120'. This is typically used to add padding around targets when
analyzing exomes.
int 0 [ [ -∞ ∞ ] ]
Set merging approach to use for combining interval inputs
By default, the program will take the UNION of all intervals specified using -L and/or -XL. However, you can
change this setting for -L, for example if you want to take the INTERSECTION of the sets instead. E.g. to
perform the analysis only on chromosome 1 exomes, you could specify -L exomes.intervals -L 1 --interval-set-rule
INTERSECTION. However, it is not possible to modify the merging approach for intervals passed using -XL (they will
always be merged using UNION).
Note that if you specify both -L and -XL, the -XL interval set will be subtracted from the -L interval set.
The --interval-set-rule argument is an enumerated type (IntervalSetRule), which can have one of the following values:
IntervalSetRule UNION
One or more genomic intervals over which to operate
List[String] []
Kmer size to use in the read threading assembler
Multiple kmer sizes can be specified, using e.g. `--kmer-size 10 --kmer-size 25`.
List[Integer] [10, 25]
Lenient processing of VCF files
boolean false
If enabled, the Assembly Engine will construct a Linked De Bruijn graph to recover better haplotypes
Disables graph simplification into a seq graph, opts to construct a proper De Bruijn graph with potential loops
NOTE: --linked-de-bruijn-graph is currently an experimental feature that does not directly match with
the regular HaplotypeCaller. Specifically the haplotype finding code does not perform correctly at complicated
sites. Use this mode at your own risk.
boolean false
Maximum size of an assembly region
int 300 [ [ -∞ ∞ ] ]
Two or more phased substitutions separated by this distance or less are merged into MNPs.
Two or more phased substitutions separated by this distance or less are merged into MNPs.
int 1 [ [ -∞ ∞ ] ]
Maximum number of haplotypes to consider for your population
The assembly graph can be quite complex, and could imply a very large number of possible haplotypes. Each haplotype
considered requires N PairHMM evaluations if there are N reads across all samples. In order to control the
run of the haplotype caller we only take maxNumHaplotypesInPopulation paths from the graph, in order of their
weights, no matter how many paths are possible to generate from the graph. Putting this number too low
will result in dropping true variation because paths that include the real variant are not even considered.
You can consider increasing this number when calling organisms with high heterozygosity.
int 128 [ [ -∞ ∞ ] ]
Maximum population allele frequency in tumor-only mode.
In tumor-only mode, we discard variants with population allele frequencies greater than this threshold.
double 0.01 [ [ -∞ ∞ ] ]
Upper limit on how many bases away probability mass can be moved around when calculating the boundaries between active and inactive assembly regions
int 50 [ [ -∞ ∞ ] ]
Maximum number of reads to retain per alignment start position. Reads above this threshold will be downsampled. Set to 0 to disable.
Other parameters
int 50 [ [ -∞ ∞ ] ]
Maximum number of suspicious reads (mediocre mapping quality or too many substitutions) allowed in a downsampling stride. Set to 0 to disable.
Maximum number of suspicious reads (mediocre mapping quality or too many substitutions) allowed in a downsampling stride.
int 0 [ [ -∞ ∞ ] ]
Maximum number of variants in graph the adaptive pruner will allow
The maximum number of variants in graph the adaptive pruner will allow
int 100 [ [ -∞ ∞ ] ]
If non-zero, partitions VCF output into shards, each containing up to the given number of records.
int 0 [ [ 0 ∞ ] ]
Minimum size of an assembly region
Parameters that control active regions
int 50 [ [ -∞ ∞ ] ]
Minimum base quality required to consider a base for calling
Bases with a quality below this threshold will not be used for calling.
byte 10 [ [ -∞ ∞ ] ]
Minimum length of a dangling branch to attempt recovery
When constructing the assembly graph we are often left with "dangling" branches. The assembly engine attempts to rescue these branches
by merging them back into the main graph. This argument describes the minimum length of a dangling branch needed for the engine to
try to rescue it. A smaller number here will lead to higher sensitivity to real variation but also to a higher number of false positives.
int 4 [ [ -∞ ∞ ] ]
Minimum support to not prune paths in the graph
Paths with fewer supporting kmers than the specified threshold will be pruned from the graph.
Be aware that this argument can dramatically affect the results of variant calling and should only be used with great caution.
Using a prune factor of 1 (or below) will prevent any pruning from the graph, which is generally not ideal; it can make the
calling much slower and even less accurate (because it can prevent effective merging of "tails" in the graph). Higher values
tend to make the calling much faster, but also lowers the sensitivity of the results (because it ultimately requires higher
depth to produce calls).
int 2 [ [ -∞ ∞ ] ]
Lower bound of variant allele fractions to consider when calculating variant LOD
double 0.0 [ [ -∞ ∞ ] ]
Mitochondria mode sets emission and initial LODs to 0.
Mitochondria mode changes default values for --tumor-lod-to-emit and --initial-tumor-lod to 0 to increase sensitivity.
--tumor-sample is also not explicitly required in mitochondria mode since a single sample bam is expected as input.
Mitochondria mode is also required in FilterMutectCalls if used here.
Boolean false
How many threads should a native pairHMM implementation use
int 4 [ [ -∞ ∞ ] ]
use double precision in the native pairHmm. This is slower but matches the java implementation better
boolean false
Log 10 odds threshold for calling normal variant non-germline.
This is a measure of the minimum evidence to support that a variant observed in the tumor is not also present in the normal.
Applies to normal data in a tumor with matched normal analysis. The default has been tuned for diploid somatic analyses.
It is unlikely such analyses will require changing the default value. Increasing the parameter may increase the sensitivity of somatic calling,
but may also increase calling false positive, i.e. germline, variants.
double 2.2 [ [ -∞ ∞ ] ]
BAM sample name of normal(s), if any. May be URL-encoded as output by GetSampleName with -encode argument.
List[String] []
Number of samples that must pass the minPruning threshold
If fewer samples than the specified number pass the minPruning threshold for a given path, that path will be eliminated from the graph.
int 1 [ [ -∞ ∞ ] ]
File to which variants should be written
R GATKPath null
Flat gap continuation penalty for use in the Pair HMM
int 10 [ [ -∞ ∞ ] ]
The PairHMM implementation to use for genotype likelihood calculations
The PairHMM implementation to use for genotype likelihood calculations. The various implementations balance a tradeoff of accuracy and runtime.
The --pair-hmm-implementation argument is an enumerated type (Implementation), which can have one of the following values:
Implementation FASTEST_AVAILABLE
VCF file of sites observed in normal.
A panel of normals can be a useful (optional) input to help filter out commonly seen sequencing noise that may appear as low allele-fraction somatic variants.
FeatureInput[VariantContext] null
The PCR indel model to use
When calculating the likelihood of variants, we can try to correct for PCR errors that cause indel artifacts.
The correction is based on the reference context, and acts specifically around repetitive sequences that tend
to cause PCR errors). The variant likelihoods are penalized in increasing scale as the context around a
putative indel is more repetitive (e.g. long homopolymer). The correction can be disabling by specifying
'-pcrModel NONE'; in that case the default base insertion/deletion qualities will be used (or taken from the
read if generated through the BaseRecalibrator). VERY IMPORTANT: when using PCR-free sequencing data we
definitely recommend setting this argument to NONE.
The --pcr-indel-model argument is an enumerated type (PCRErrorModel), which can have one of the following values:
PCRErrorModel CONSERVATIVE
Phred-scaled PCR indel qual for overlapping fragments
int 40 [ [ -∞ ∞ ] ]
Phred-scaled PCR SNV qual for overlapping fragments
int 40 [ [ -∞ ∞ ] ]
Pedigree file for determining the population "founders"
GATKPath null
The global assumed mismapping rate for reads
The phredScaledGlobalReadMismappingRate reflects the average global mismapping rate of all reads, regardless of their
mapping quality. This term effects the probability that a read originated from the reference haplotype, regardless of
its edit distance from the reference, in that the read could have originated from the reference haplotype but
from another location in the genome. Suppose a read has many mismatches from the reference, say like 5, but
has a very high mapping quality of 60. Without this parameter, the read would contribute 5 * Q30 evidence
in favor of its 5 mismatch haplotype compared to reference, potentially enough to make a call off that single
read for all of these events. With this parameter set to Q30, though, the maximum evidence against any haplotype
that this (and any) read could contribute is Q30.
Set this term to any negative number to turn off the global mapping rate.
int 45 [ [ -∞ ∞ ] ]
Ln likelihood ratio threshold for adaptive pruning algorithm
Log-10 likelihood ratio threshold for adaptive pruning algorithm.
double 2.302585092994046 [ [ -∞ ∞ ] ]
Ln likelihood ratio threshold for seeding subgraph of good variation in adaptive pruning algorithm
Log-10 likelihood ratio threshold for adaptive pruning algorithm.
double 9.210340371976184 [ [ -∞ ∞ ] ]
Whether to suppress job-summary info on System.err.
Boolean false
Read filters to be applied before analysis
List[String] []
Indices to use for the read inputs. If specified, an index must be provided for every read input and in the same order as the read inputs. If this argument is not specified, the path to the index for each input will be inferred automatically.
List[GATKPath] []
Validation stringency for all SAM/BAM/CRAM/SRA files read by this program. The default stringency value SILENT can improve performance when processing a BAM file in which variable-length data (read, qualities, tags) do not otherwise need to be decoded.
The --read-validation-stringency argument is an enumerated type (ValidationStringency), which can have one of the following values:
ValidationStringency SILENT
Recover all dangling branches
By default, the read threading assembler does not recover dangling branches that fork after splitting from the reference. This argument
tells the assembly engine to recover all dangling branches.
boolean false
Reference sequence file
R GATKPath null
Output traversal statistics every time this many seconds elapse
double 10.0 [ [ -∞ ∞ ] ]
Use the given sequence dictionary as the master/canonical sequence dictionary. Must be a .dict file.
GATKPath null
display hidden arguments
boolean false
If true, don't emit genotype fields when writing vcf file output.
boolean false
Which Smith-Waterman implementation to use, generally FASTEST_AVAILABLE is the right choice
The --smith-waterman argument is an enumerated type (Implementation), which can have one of the following values:
Implementation JAVA
If enabled will preserve low-quality read ends as softclips (used for DRAGEN-GATK BQD genotyper model)
boolean false
Temp directory to use.
GATKPath null
Output VCF contains featurized sets of reads for training a deep variant filter.
Training data mode collects data on variant- and artifact-supporting read sets for fitting a deep learning filtering model
Boolean false
Downsample ref reads to this count in training data mode.
Downsample ref reads in training data mode
int<PHONE_NUMBER> [ [ -∞ ∞ ] ]
Log 10 odds threshold to emit variant to VCF.
Only variants with tumor LODs exceeding this threshold will be written to the VCF, regardless of filter status.
Set to less than or equal to tumor_lod. Increase argument value to reduce false positives in the callset.
Default setting of 3 is permissive and will emit some amount of negative training data that
{@link FilterMutectCalls} should then filter.
double 3.0 [ [ -∞ ∞ ] ]
BAM sample name of tumor. May be URL-encoded as output by GetSampleName with -encode argument.
String null
Whether to use the JdkDeflater (as opposed to IntelDeflater)
boolean false
Whether to use the JdkInflater (as opposed to IntelInflater)
boolean false
Control verbosity of logging.
The --verbosity argument is an enumerated type (LogLevel), which can have one of the following values:
LogLevel INFO
display the version number for this tool
boolean false
See also General Documentation | Tool Docs Index Tool Documentation Index | Support Forum
GATK version <IP_ADDRESS> built at Wed, 18 Aug 2021 19:58:25 -0400.


Item 3.9.1.h. Have each group identify the possible sources of error in the exercise and how they propagate.


facebook
Facebook helps you connect and share
with the people in your life.
Log In
Forgot Password?
Create New Account
Create a Page
for a celebrity, band or business