コード例 #1
0
ファイル: count_in_bins.c プロジェクト: aakrosh/CNVTk
static void count_in_bins(const char* const refName,
                          const char* const mapName,
                          const char* const bamName,
                          int binSize)
{
    // lets read the reference sequence. The reference sequence will be a
    // hashtable where the key is the name of the chromosome and the value will
    // be a char array of size equal to  the length of the chromosome sequence.
    hashtable* reference = ReadReference(refName);
    timestamp("Read the reference sequence.\n");

    // create a map of bases that are  uniquely mappable
    CreateRefMap(refName, mapName, reference);
    timestamp("Created a map of unique locations in the genome.\n");

    // create a coverage map of all locations from the BAM file
    CreateCoverageMap(refName, bamName, reference);
    timestamp("Read the coverage information from the BAM file.\n");

    // calculate a bin size that will ensure that at least 100 fragments cover a
    // bin on average
    if (binSize == 0) 
        binSize = CalculateAGoodBinSize(refName, reference);
    if (binSize < 0) return;
    fprintf(stderr, "Using a bin size of %d mappable bases.\n", binSize);

    // using that bin size, print out the information about the bins
    PrintBinInfo(refName, reference, binSize);
    timestamp("Done with the counting.\n");
}
コード例 #2
0
void StackTraceFormatter::AppendArgumentType(Thread *const thread, StringBuffer &buf, const Value *arg)
{
	Value argValue; // Copy, because arg is const

	if (IS_REFERENCE(*arg))
	{
		// If the argument is a reference, it must be dereferenced before
		// we can make use of the type information.
		buf.Append(4, "ref ");
		ReadReference(const_cast<Value*>(arg), &argValue);
	}
	else
	{
		argValue = *arg;
	}

	Type *type = argValue.type;
	if (type == nullptr)
	{
		buf.Append(4, "null");
		return;
	}

	// To make the stack trace more readable, we only append the last component
	// of the type name, so 'osprey.compiler.parser.Token' becomes just 'Token'.
	AppendShortMemberName(thread, buf, type->fullName);

	// When the argument is an aves.Method, we append some information about
	// the instance and method group, too, in the format
	//   Method(this: <instance type>, <method name>)
	//
	// Note that this is applied recursively to the instance type, which means
	// you can end up with situations like
	//   Method(this: Method(this: Method(...), ...), ...)
	//
	// It should at least be impossible for an aves.Method to be bound to iself.
	// Otherwise, well, we'll get infinite recursion!
	if (type == thread->GetVM()->types.Method)
	{
		// Append some information about the instance and method group, too.
		MethodInst *method = argValue.v.method;

		buf.Append(7, "(this: ");

		// It should be impossible for an aves.Method to be bound to iself.
		OVUM_ASSERT(method->instance.v.instance != argValue.v.instance);
		AppendArgumentType(thread, buf, &method->instance);

		buf.Append(2, ", ");

		AppendShortMethodName(thread, buf, method->method);

		buf.Append(')');
	}
}
コード例 #3
0
ファイル: XMLScanner.cpp プロジェクト: monika297/sayl
/**********************************************************************************************
 *
 * ReadLiteral
 *
 * Literal = '"' ([^<&"] | Reference)* '"' | "'" ([^<&'] | Reference)* "'" ;
 *
 *********************************************************************************************/
XMLScanner::TOKEN XMLParser::ReadLiteral () {
    char quote = '\0';
    if (current == '\"' || current == '\'') {
        quote = current;
        output.Reset ();
    }

    while (ReadCharacter ()) {
        if (current == quote) {
            ReadCharacter ();
            break;

        } else if (current == '<') {
            throw UnexpectedCharacterException ();

        } else if (current == '&') {
            ReadReference ();

        } else {
            output.Append (current);
        }
    }
    return Literal (output.toString ());
}
コード例 #4
0
ファイル: XMLScanner.cpp プロジェクト: monika297/sayl
/**********************************************************************************************
 * NextToken
 *********************************************************************************************/
XMLScanner::TOKEN XMLScanner::NextToken () {
    if (state == STATE_STREAM_END)
        return TOKEN_STREAM_END;

    do {
        switch (state) {
        /* Content */
        case STATE_CONTENT:
            switch (current) {
            /* Element tag */
            case '<' :
                state = STATE_ELEMENT_TAG;
                if (! output.isEmpty ()) {
                    // TODO : check for whitespace only elements ...
                    return TOKEN_CHARACTER_DATA;
                }
                break;

            case '&' :
                ReadReference ();
                break;

            case ']' :
                /* checks for invalid CDATA section end */
                ReadCharacter ();
                if (current == ']') {
                    ReadCharacter ();
                    if (current == '>') {
                        ReadCharacter ();
                        throw IllegalCharacterException ();
                    } else {
                        output.Append (']');
                        output.Append (']');
                        output.Append (current);
                    }
                } else {
                    output.Append (']');
                    output.Append (current);
                }
                break;

            default :
                output.Append (current);
                break;
            }
            break;

        /* Element Tag */
        case STATE_ELEMENT_START_OPENING:
            if (current == '!') {
                ReadCharacter ();
                state = STATE_SPECIAL_ELEMENT;

            } else if (current == '?') {
                ReadCharacter ();
                state = STATE_CONTENT;
                return ReadProcessingInstruction ();

            } else if (current == '/') {
                ReadCharacter ();
                state = STATE_ELEMENT_END_NAME;
                return TOKEN_ELEMENT_END_TAG;

            } else if (isNameFirst (current)) {
                state = STATE_ELEMENT_START_NAME;
                return TOKEN_ELEMENT_START_OPENING;

            } else {
                throw UnexpectedCharacterException (previous);
            }
            break;

        /* Special elements (comments and CDATA sections etc ...) */
        /* '<!' ... */
        case STATE_SPECIAL_ELEMENT:
            if (current == '-') {
                ReadComment ();
            } else if (current == '[') {
                ReadCDATASection ();
            } else {
                throw UnsupportedFeatureException (position);
            }
            state = STATE_CONTENT;
            break;

        /* Element start name target */
        /* '<' ... */
        case STATE_ELEMENT_START_NAME:
            if (isNameFirst (current)) {
                state = STATE_ELEMENT_ATTRIBUTES_START;
                return ReadQualifiedName ();
            } else {
                throw UnexpectedCharacterException (previous);
            }
            break;

        /* Element start name target */
        /* '</' ... */
        case STATE_ELEMENT_END_NAME:
            if (isNameFirst (current)) {
                state = STATE_ELEMENT_END_TAG;
                return ReadQualifiedName ();
            } else {
                throw UnexpectedCharacterException (previous);
            }
            break;

        /* Attributes */
        case STATE_ATTRIBUTES_START:
            if (isWhitespace (current)) {
                state = STATE_ATTRIBUTES;

            } else if (current == '/') {
                state = STATE_ELEMENT_END_CLOSING;

            } else if (current == '>') {
                state = STATE_CONTENT;
                return TOKEN_ELEMENT_START_CLOSING;

            } else {
                throw UnexpectedCharacterException (previous);
            }
            break;

        /* '<' QualifiedName ... */
        case STATE_ATTRIBUTES :
            if (isWhitespace (current)) {
                break;

            } else if (isNameFirst (current)) {
                state = STATE_ATTRIBUTE_EQUAL;
                return ReadQualifiedName ();

            } else {
                throw UnexpectedCharacterException (previous);
            }
            break;

        case STATE_ELEMENT_END_CLOSING:
            if (current == '>') {
                state = STATE_CONTENT;
                return TOKEN_ELEMENT_END_CLOSING;

            } else {
                throw UnexpectedCharacterException (previous);
            }
            break;


        case STATE_ATTRIBUTE_EQUAL:
            if (current == '\'' || current == '\"') {
                state = STATE_ATTRIBUTES_START;
                return ReadLiteral ();
            }
            break;

        case STATE_ELEMENT_END_TAG:
            if (current == '>') {
                state = STATE_CONTENT;
                return TOKEN_ELEMENT_END_TAG_CLOSING;
            }
            break;
        }

    } while (ReadCharacter ());

    /* Stream end */
    return TOKEN_STREAM_END;
}