File: read_assignment.cpp

package info (click to toggle)
seqan2 2.5.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 228,748 kB
  • sloc: cpp: 257,602; ansic: 91,967; python: 8,326; sh: 1,056; xml: 570; makefile: 229; awk: 51; javascript: 21
file content (86 lines) | stat: -rw-r--r-- 2,432 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <iostream>
#include <seqan/basic.h>
#ifndef STDLIB_VS
#include <seqan/blast.h>

using namespace seqan2;

int main(int argc, char **argv)
{
    if (argc != 2)
    {
      std::cerr << "USAGE: FILE_IN\n";
      return 0;
    }

    typedef Gaps<String<AminoAcid>, ArrayGaps> TGaps;
    typedef BlastMatch<TGaps, TGaps> TBlastMatch;
    typedef BlastRecord<TBlastMatch> TBlastRecord;
    typedef BlastIOContext<> TContext;

    BlastTabularFileIn<TContext> file(argv[1]);

    readHeader(file);

    TBlastRecord record;

    while (onRecord(file))
    {
        // read the record
        readRecord(record, file);

        // print some diagnostics
        std::cout << "Record of query sequence \"" << record.qId << "\"\n"
                  << "==========================================\n"
                  << "Number of HSPs: " << length(record.matches) << "\n";
        if  (!empty(record.matches))
            std::cout << "BitScore of best HSP: " << front(record.matches).bitScore << "\n";

        // print column composition
        std::cout << "Columns: ";
        for (auto field : context(file).fields)
            std::cout << BlastMatchField<>::optionLabels[(int)field] << " ";
        std::cout << "\n\n";

        // if there is anything unexpected, tell the user about it
        if (!empty(context(file).conformancyErrors))
        {
            std::cout << "There were non critical errors when reading the record:\n";
            write(std::cout, context(file).conformancyErrors);
            std::cout << "\n\n";
        }

        if (!empty(context(file).otherLines))
        {
            std::cout << "There were unidentified lines in the comments:\n";
            write(std::cout, context(file).otherLines);
            std::cout << "\n\n";
        }

        std::cout << "\n\n";
    }

    readFooter(file);

    std::cout << "File Format: tabular"
              << (context(file).tabularSpec == BlastTabularSpec::COMMENTS ? " with coment lines" : "")
              << '\n'
              << "Generation: "
              << (context(file).legacyFormat ? " legacy" : " BLAST+")
              << '\n'
              << "Program and version: "
              << context(file).versionString
              << '\n'
              << "Database: "
              << context(file).dbName
              << "\n\n";

    return 0;
}
#else
int main()
{
    std::cerr << "USAGE: FILE_IN\n";
    return 0;
}
#endif