Beispiel #1
0
Window FindWindow(char* szWindowToFind)
{
    Display *display = XOpenDisplay (NULL);
    int screen = DefaultScreen (display);
    XSetErrorHandler(ErrorHandler);
    Window rootWindow = RootWindow (display, screen);   
    Window wSearchedWindow = SearchWindow(szWindowToFind, 0, display, 
					  rootWindow, 0, 0);
    char* win_name;
    if (XFetchName(display, wSearchedWindow, &win_name))
    {
        printf("Found: %s\n", win_name);
    }
    XCloseDisplay (display);
    return wSearchedWindow;
}
Beispiel #2
0
BOOL CALLBACK SearchWindowDialogProc
(
	HWND hwndDlg, // handle to dialog box 
	UINT uMsg, // message 
	WPARAM wParam, // first message parameter 
	LPARAM lParam // second message parameter 
	)
{
	BOOL bRet = FALSE;  // Default return value.

	switch (uMsg)
	{
	case WM_INITDIALOG:
	{
		if (isParentKill) CheckDlgButton(hwndDlg, IDC_CHECK1, 1);
		bRet = TRUE;
		break;
	}

	case WM_MOUSEMOVE:
	{
		bRet = TRUE;

		if (g_bStartSearchWindow)
		{
			// Only when we have started the Window Searching operation will we 
			// track mouse movement.
			DoMouseMove(hwndDlg, uMsg, wParam, lParam);
		}

		break;
	}

	case WM_LBUTTONUP:
	{
		bRet = TRUE;

		if (g_bStartSearchWindow)
		{
			// Only when we have started the window searching operation will we
			// be interested when the user lifts up the left mouse button.
			DoMouseUp(hwndDlg, uMsg, wParam, lParam);
		}

		break;
	}

	case WM_COMMAND:
	{
		WORD wNotifyCode = HIWORD(wParam); // notification code 
		WORD wID = LOWORD(wParam);         // item, control, or accelerator identifier 
		HWND hwndCtl = (HWND)lParam;      // handle of control 

		if ((wID == IDOK))
		{
			if (hStoreWnd != hwndDlg)
			{
				HWND hTargetWnd = hStoreWnd;
				if (IsDlgButtonChecked(hwndDlg, IDC_CHECK1))
				{
					while (GetParent(hTargetWnd))
					{
						hTargetWnd = GetParent(hTargetWnd);
					}
					isParentKill = true;
				}
				else
					isParentKill = false;
				SetParent(hTargetWnd, hwndDlg);
			}
			bRet = TRUE;
			EndDialog(hwndDlg, wID);
		}
		else if (wID == IDCANCEL)
		{
			ExitProcess(0);
		}

		if (wID == IDC_STATIC_ICON_FINDER_TOOL)
		{
			// Because the IDC_STATIC_ICON_FINDER_TOOL static control is set with the SS_NOTIFY
			// flag, the Search Window's dialog box will be sent a WM_COMMAND message when this 
			// static control is clicked.
			bRet = TRUE;
			// We start the window search operation by calling the DoSearchWindow() function.
			SearchWindow(hwndDlg);
			break;
		}

		break;
	}

	default:
	{
		bRet = FALSE;
		break;
	}
	}

	return bRet;
}
Beispiel #3
0
short AssembleOneSV(std::map<std::string,int> &ChrName2Index, ControlState & CurrentState, const Assembly & OneSV, std::ofstream & ASM_Output) {
    //std::cout << "AssembleOneSV 1" << std::endl;
    //short Max_NT_Size = 30;
    bool WhetherFirstBP = true;
    std::vector <SPLIT_READ> First, Second;
    unsigned SearchCenter;
    unsigned SearchRange;
    std::cout << "Current SV: " << OneSV.Index << " " << OneSV.Type << " " << OneSV.ChrA << " " << OneSV.PosA << " " << OneSV.CI_A 
              << "\t" << OneSV.ChrB << " " << OneSV.PosB << " " << OneSV.CI_B << std::endl;
    // get first BP
    CurrentState.Reads_SR.clear();
    CurrentState.OneEndMappedReads.clear();
    //std::cout << "AssembleOneSV 2" << std::endl;
    const Chromosome* currentChromosomeFirst = g_genome.getChr(OneSV.ChrA);
    const Chromosome* currentChromosomeSecond = g_genome.getChr(OneSV.ChrB);
    std::string FirstChrSeq = currentChromosomeFirst->getSeq();
    std::string SecondChrSeq = currentChromosomeSecond->getSeq();
    
    if (CurrentState.CurrentChrName != OneSV.ChrA) {
        CurrentState.CurrentChrName = OneSV.ChrA;
        CurrentState.CurrentChrSeq = FirstChrSeq;
        //CurrentState.CurrentChrSeq = AllChromosomes[ChrName2Index.find(OneSV.ChrA)->second].ChrSeq; // change later, copying one chrseq for each SV is expensive.
    }

    //const unsigned CONS_Chr_Size = currentChromosome->getBiolSize(); // #################
    //std::cout << "CONS_Chr_Size " << CONS_Chr_Size << std::endl;
    g_maxPos = 0; // #################
    unsigned Left, Right;
	unsigned int lowerBinBorder = 1;
    if (OneSV.PosA > OneSV.CI_A + 1000)  
        lowerBinBorder = OneSV.PosA - OneSV.CI_A - 1000; //CurrentState.
    unsigned int upperBinBorder = OneSV.PosA + OneSV.CI_A + 1000;
	SearchWindow window( currentChromosomeFirst, lowerBinBorder, upperBinBorder );
    Left = OneSV.PosA + g_SpacerBeforeAfter - OneSV.CI_A;
    Right = OneSV.PosA + g_SpacerBeforeAfter + OneSV.CI_A;

    std::cout << "\nFirst BP\tChrName " << CurrentState.CurrentChrName << "\tRange " <<  lowerBinBorder << " " << upperBinBorder << std::endl;
    get_SR_Reads(CurrentState, window );

    //std::cout << "First size: " << CurrentState.Reads_SR.size() << std::endl;
    CombineAndSort(ChrName2Index, CurrentState, OneSV, First, lowerBinBorder, upperBinBorder, WhetherFirstBP);

    CleanUpCloseEnd(First, Left, Right); // vector of reads

    std::cout << "\nFirst size " << First.size() << std::endl;
    SearchRange = OneSV.CI_B + 1000;
    SearchCenter = OneSV.PosB + g_SpacerBeforeAfter;
	std::vector< SearchWindow > searchCluster;
	searchCluster.push_back( SearchWindow( currentChromosomeSecond, SearchCenter-SearchRange, SearchCenter+SearchRange ) );
    Left = OneSV.PosB + g_SpacerBeforeAfter - OneSV.CI_B;
    Right = OneSV.PosB + g_SpacerBeforeAfter + OneSV.CI_B;
    
	for (unsigned ReadIndex = 0; ReadIndex < First.size(); ReadIndex++) {
      First[ReadIndex].FarFragName = OneSV.ChrB;
      //SearchFarEndAtPos(AllChromosomes[ChrName2Index.find(OneSV.ChrB)->second].ChrSeq, First[ReadIndex], SearchCenter, SearchRange);
		SearchFarEndAtPos(SecondChrSeq, First[ReadIndex], searchCluster);
    }
    //std::cout << "AssembleOneSV 7" << std::endl;

    CleanUpFarEnd(First, Left, Right);
    //std::cout << "AssembleOneSV 8" << std::endl;


	for (unsigned ReadIndex = 0; ReadIndex < First.size(); ReadIndex++) {
        if (First[ReadIndex].UP_Close.size()) {
			if (First[ReadIndex].UP_Far.size()) {
				OutputCurrentRead(ChrName2Index, CurrentState, OneSV, First[ReadIndex], ASM_Output);
            }
        }
    }
    
    
    // get second BP
    CurrentState.Reads_SR.clear();
    WhetherFirstBP = false;
    CurrentState.CurrentChrName = OneSV.ChrB;
    
    CurrentState.CurrentChrSeq = SecondChrSeq;
    //CONS_Chr_Size = CurrentState.CurrentChrSeq.size() - 2 * g_SpacerBeforeAfter; // #################
    g_maxPos = 0; // #################
	lowerBinBorder = 1;
    if (OneSV.PosB > OneSV.CI_B + 1000)  
        lowerBinBorder = OneSV.PosB - OneSV.CI_B - 1000;
    upperBinBorder = OneSV.PosB + OneSV.CI_B + 1000;
	SearchWindow window2( currentChromosomeSecond, lowerBinBorder, upperBinBorder );
    Left = OneSV.PosB + g_SpacerBeforeAfter - OneSV.CI_B;
    Right = OneSV.PosB + g_SpacerBeforeAfter + OneSV.CI_B;

    std::cout << "\nSecond BP\tChrName " << CurrentState.CurrentChrName << "\tRange " << lowerBinBorder << " " << upperBinBorder << std::endl;    
    get_SR_Reads(CurrentState, window2 );

    CombineAndSort(ChrName2Index, CurrentState, OneSV, Second, lowerBinBorder, upperBinBorder, WhetherFirstBP);

    CleanUpCloseEnd(Second, Left, Right);

    std::cout << "\nSecond size " << Second.size() << std::endl;
    SearchRange = OneSV.CI_A + 1000;
    SearchCenter = OneSV.PosA + g_SpacerBeforeAfter;
    Left = OneSV.PosA + g_SpacerBeforeAfter - OneSV.CI_A;
    Right = OneSV.PosA + g_SpacerBeforeAfter + OneSV.CI_A;
	searchCluster.clear();
	searchCluster.push_back( SearchWindow( currentChromosomeFirst, SearchCenter-SearchRange, SearchCenter+SearchRange ) );
  
   for (unsigned ReadIndex = 0; ReadIndex < Second.size(); ReadIndex++) {
      Second[ReadIndex].FarFragName = OneSV.ChrA;
      //SearchFarEndAtPos(AllChromosomes[ChrName2Index.find(OneSV.ChrA)->second].ChrSeq, Second[ReadIndex], SearchCenter, SearchRange);
		SearchFarEndAtPos(FirstChrSeq, Second[ReadIndex], searchCluster);
   }

    CleanUpFarEnd(Second, Left, Right);

   for (unsigned ReadIndex = 0; ReadIndex < Second.size(); ReadIndex++) {
      if (Second[ReadIndex].UP_Close.size()) {
         if (Second[ReadIndex].UP_Far.size()) {
            OutputCurrentRead(ChrName2Index, CurrentState, OneSV, Second[ReadIndex], ASM_Output);
         }
      }
   }

    unsigned SumSize = 0;
    for (unsigned ReadIndex = 0; ReadIndex < First.size(); ReadIndex++) {
        SumSize += First[ReadIndex].UP_Far.size(); 
    }
    for (unsigned ReadIndex = 0; ReadIndex < Second.size(); ReadIndex++) {
        SumSize += Second[ReadIndex].UP_Far.size(); 
    }
    if (SumSize == 0 && OneSV.ChrA == OneSV.ChrB) {
        TryLI(ChrName2Index, CurrentState, OneSV, First, Second, ASM_Output);
    }
    return 0;
}
Beispiel #4
0
// Recursively search through all windows on display
Window SearchWindow(char* szWindowToFind, int level, Display *display, 
		    Window rootWindow, int iMatchMode, int showErrors)
{
    Window parent;
    Window *children;
    unsigned int noOfChildren;
    int status;
    unsigned int i;
    Window wSearchedWindow = 0;
    char* win_name;
    if (XFetchName(display, rootWindow, &win_name))
    {
            //printf("WinName (Level %d): %s\n", level, win_name);
            if(iMatchMode == 0)
            {
                if( strstr(win_name, szWindowToFind) )
                {
                    return rootWindow;
                }
            }
            else if(iMatchMode == 1)
            {
                if( !strcmp(win_name, szWindowToFind) )
                {
                    return rootWindow;
                }
            }
            else if(iMatchMode == 2)
            {
                if( strcasestr(win_name, szWindowToFind) )
                {
                    return rootWindow;
                }
            }
            else if(iMatchMode == 3)
            {
                if( !strcasecmp(win_name, szWindowToFind) )
                {
                    return rootWindow;
                }
            }
            else 
            {
                if( strstr(win_name, szWindowToFind) )
                {
                    return rootWindow;
                }
            }

    } // End if XFetchName
    status = XQueryTree (display, rootWindow, &rootWindow, 
			 &parent, &children, &noOfChildren);
    if (status == 0)
    {
        if (showErrors)
            printf ("ERROR - Could not query the window tree. Aborting.\r\n");
        return rootWindow;
    }
    if (noOfChildren > 0)
    {
        for (i=0; i < noOfChildren; i++)
        {
            wSearchedWindow = SearchWindow(szWindowToFind, level+1, display, children[i], iMatchMode, showErrors);
            if(wSearchedWindow)
            {
                break;
            }
        }
    } 
    XFree ((char*) children);
    return wSearchedWindow;
} // End Sub EnumerateWindows