File: getarraydata.cpp

package info (click to toggle)
pilercr 1.06%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 844 kB
  • sloc: cpp: 14,339; makefile: 67; sh: 36
file content (82 lines) | stat: -rwxr-xr-x 1,702 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
#include "pilercr.h"

static bool PileByPos(int PileIndex1, int PileIndex2)
	{
	return GetPile(PileIndex1).Lo < GetPile(PileIndex2).Lo;
	}

bool GetArrayData(const IntVec &ArrayPileIndexes, ArrayData &AD)
	{
	if (ArrayPileIndexes.size() == 0)
		Quit("GetArrayData, size=0");

#if	TRACE
	Log("\n");
	Log("Array\n");
	Log("=====\n");
#endif

	for_CIntVec(ArrayPileIndexes, p)
		AD.PileIndexes.push_back(*p);

// Sort by position
	std::sort(AD.PileIndexes.begin(), AD.PileIndexes.end(), PileByPos);

	SeqVect Seqs;
	int Lo = -1;
	int Hi = -1;
	for_CIntVec(ArrayPileIndexes, p)
		{
		int PileIndex = *p;
		Seq *s = new Seq;
		PileToSeq(g_Piles, PileIndex, *s, &Lo, &Hi);
		if (Seqs.size() == 0)
			AD.Lo = Lo;
		Seqs.push_back(s);
		}

	MSA Aln;
	MultipleAlign(Seqs, Aln);

	int StartCol;
	int EndCol;
	double MinCons = g_DraftMinCons;
	const int SeqCount = (int) Aln.GetSeqCount();
	if (SeqCount >= g_MinOneDiff)
		{
		double AltMinCons = ((double) (SeqCount - 1) / (double) SeqCount) - 0.1;
		if (AltMinCons < MinCons)
			MinCons = AltMinCons;
		}

	GetConsSeq(Aln, MinCons, &StartCol, &EndCol, AD.ConsSeq);
	if ((int) AD.ConsSeq.Length() < g_DraftMinRepeatLength)
		return false;

	char Label[128];
	sprintf(Label, "Cons%d", AD.Id);
	AD.ConsSeq.SetName(Label);
	AD.ConsSeq.SetId(0);
	AD.RepeatLength = AD.ConsSeq.Length();
	AD.SpacerLength = -1;

	if (g_LogAlns)
		{
		Log("\n");
		Log("Draft alignment for array %d:\n", AD.Id);
		Aln.LogMe();
		Log("\n");
		Log("Consensus: ");
		AD.ConsSeq.LogMeSeqOnly();
		Log("\n");
		Log("\n");
		}

#if	TRACE
	Aln.LogMe();
	AD.ConsSeq.LogMe();
	Log("\n");
#endif

	return true;
	}