예제 #1
0
	bool _parseOptions(po::variables_map &vm) {
		bool ret = true;

		ret |= GeneralOptions::_parseOptions(vm);

		setOpt("unmapped-read-pairs", unmappedReadPairs);
		setOpt("unmapped-reads", unmappedReads);
		setOpt("keep-unmapped-paired-read", keepUnmappedPairedRead);
		setOpt("output-bam", outputBam);
		setOpt2("input-bams", inputBams);
		setOpt("num-partitions", numPartitions);

		if (outputBam.empty())
			setOptionsErrorMsg("You must specify at least the outputBam");

		if (inputBams.empty())
			setOptionsErrorMsg("You must specify at least one input bam");

		if (unmappedReads.empty() && !unmappedReadPairs.empty()) {
			unmappedReads = unmappedReadPairs;
		}
		if (unmappedReadPairs.empty() && !unmappedReads.empty()) {
			unmappedReadPairs = unmappedReads;
		}

		// Other ret &= *::_parseOptions(vm);
		return ret;
	}
/**
 * @brief Check to see if the options used by the copy number engine are valid.
 */
void CNReferenceEngine::checkOptionsImp()
{
    defineStates();

    setLibFileOpt("reference-file");
    m_pEngine->setLibFileOpt("probeset-ids");
    m_pEngine->setLibFileOpt("annotation-file");

    if (m_pEngine == this)
    {
        if (getOpt("set-analysis-name") == "") {setOpt("set-analysis-name", "CN5");}
        if (m_pEngine->getOpt("expr-summary-file") == "") {throw(Except("Must specify a expr-summary-file."));}
        if (m_pEngine->getOpt("genotype-calls-file") == "") {throw(Except("Must specify a genotype-calls-file."));}
        if (m_pEngine->getOpt("genotype-confidences-file") == "") {throw(Except("Must specify a genotype-confidences-file."));}
        if (m_pEngine->getOpt("genotype-report-file") == "") {throw(Except("Must specify a genoptype-report-file."));}
        if (m_pEngine->getOpt("reference-file") == "") {throw(Except("Must specify a reference-file."));}
    }
    if (m_pEngine->getOpt("annotation-file") == "") {throw(Except("Must specify a netaffx annotation-file."));}

    AffxString strReferenceFileName = m_pEngine->getOpt("reference-file");
    if (m_pEngine == this)
    {
        m_pEngine->setOpt("create-reference", "true");
        m_pEngine->setOpt("reference-file", strReferenceFileName);
    }
}
예제 #3
0
void OptionList::setOpt(const OptionList & options)
{
  for(mapType::const_iterator pos = options.mOptions.begin();
      pos != options.mOptions.end();
      pos++)
   {
     setOpt(pos->second->clone());
   }  
}
예제 #4
0
int DmetEngine::parseArgv( const char * const * const argv, int start ){
    vector<string> argvStrings;
    for (const char* const * arg=argv;*arg!=NULL;arg++) {
        argvStrings.push_back(*arg);
    }
    int argc = argvStrings.size();

    // Parse DmetEngine Options
    int argvPos = Options::parseArgv(argv, start);

    vector<string> celFiles;
    for(vector<const char *>::size_type i = 0; i < getArgCount(); i++)
        celFiles.push_back(getArg(i));
    setOpt("cels",celFiles);

    // Allow user to override APS defaults
    if(argc > argvPos) {
        ProbesetSummarizeEngine pse;
        int newArgvPos = pse.parseArgv(argv, argvPos+1);
        Verbose::out(1,"Parsed " + ToStr(newArgvPos - argvPos - 1) + " extra options for ProbesetSummarizeEngine!");
        m_ArgvPosAPS = argvPos + 1;
        argvPos = newArgvPos;
    } else {
        m_ArgvPosAPS = -1;
    }

    // Allow user to override CN defaults
    if(argc > argvPos) {
        DmetCopyNumberEngine cde;
        int newArgvPos = cde.parseArgv(argv,argvPos+1);
        Verbose::out(1,"Parsed " + ToStr(newArgvPos - argvPos - 1) + " extra options for DmetCopyNumberEngine!");
        m_ArgvPosCN = argvPos + 1;
        argvPos = newArgvPos;
    } else {
        m_ArgvPosCN = -1;
    }
    
    // Allow user to override APG defaults
    if(argc > argvPos) {
        ProbesetGenotypeEngine pge;
        int newArgvPos = pge.parseArgv(argv,argvPos+1);
        Verbose::out(1,"Parsed " + ToStr(newArgvPos - argvPos - 1) + " extra options for ProbesetGenotypeEngine!");
        m_ArgvPosAPG = argvPos + 1;
        argvPos = newArgvPos;
    } else {
        m_ArgvPosAPG = -1;
    }

    m_argv = argv;
    return argvPos;
}
예제 #5
0
/**
 * compute CHP files
 */
void DmetEngine::runImp() {

    setOpt("analysis-guid", affxutil::Guid::GenerateNewGuid());

    string errMsg;

    if(!Fs::isWriteableDir(getOpt("out-dir")))
        if(Fs::mkdirPath(getOpt("out-dir"), false) != APT_OK)
            Err::errAbort("Can't make or write to directory: " + getOpt("out-dir"));
    if(getOptBool("run-cn-engine")) {
        Verbose::out(1,"");
        Verbose::out(1,"Step 1: Computing probeset summaries for copy number state calling");
        if(computeCnSummaries()) {
            Verbose::out(1,"");
            Verbose::out(1,"Step 2: Computing copy number states");
            computeCnState();
            setOpt("run-cn-engine","true");
        } else {
            Verbose::out(1,"");
            Verbose::out(1,"No CN regions to compute. Skipping step 2.");
            setOpt("run-cn-engine","false");
        }
    } else {
        Verbose::out(1,"");
        Verbose::out(1,"Not computing CN state. Skipping steps 1 and 2.");
        setOpt("run-cn-engine","false");
    }
    Verbose::out(1,"");
    Verbose::out(1,"Step 3: Computing genotypes");
    computeGenotypes();
    if(getOptBool("cc-chp-output")) {
        Verbose::out(1,"");
        Verbose::out(1,"Step 4: Generating CHP files");
        generateChpFiles();
    }
    Verbose::out(1,"");
    Verbose::out(1, "Done.");
}
예제 #6
0
int SocketImp::accept(const int fd)
{
	struct sockaddr_in client;
	socklen_t len = sizeof(struct sockaddr_in);
	int cfd = ::accept(fd, (struct sockaddr*)(&client), &len);
	if(SOCKET_ERR == cfd)
	{
		return SOCKET_ERR;
	}


	setOpt(cfd);

	return cfd;
}
예제 #7
0
int SerialCom::comInit()
{
  int i;

  if((fd_ = openPort(fd_,port_)) < 0)
  {
    ROS_INFO("failed to setup the serial!");
    return 0;
  }

  if((i = setOpt(fd_,baudrate_,8,'N',1)) < 0)
  {
    ROS_INFO("failed to setup the serial!");
    return 0;
  }

  ROS_INFO("the serial openned,setup the serial successed。the file operator=%d",fd_); 
  
  return 0;
}
예제 #8
0
int SocketImp::listen(const char *ip, const int port, int backlog)
{
	_fd = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
	if(SOCKET_ERR == _fd)
	{
		return SOCKET_ERR;
	}
	
	int nret = -1;
	struct sockaddr_in server_addr;
	memset(&server_addr, 0, sizeof(server_addr));
	socklen_t sellen = sizeof(server_addr);
	server_addr.sin_family = AF_INET;
	server_addr.sin_port = htons(port);
	server_addr.sin_addr.s_addr = inet_addr(ip);

	nret = ::bind(_fd, (sockaddr*)(&server_addr), sellen);
	if(SOCKET_ERR == nret)
	{

		return SOCKET_ERR;
	}

	if(SOCKET_ERR == setOpt(_fd))
	{
		return SOCKET_ERR;
	}

	backlog =(backlog == 0)? MAX_BACKLOG : backlog; 
	nret = ::listen(_fd, backlog);	
	if(SOCKET_ERR == nret)
	{

		return SOCKET_ERR;
	}

	return _fd;

}
int DownloadChild::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: finished(); break;
        case 1: download(); break;
        case 2: setURL((*reinterpret_cast< QString*(*)>(_a[1]))); break;
        case 3: { QString* _r = getURL();
            if (_a[0]) *reinterpret_cast< QString**>(_a[0]) = _r; }  break;
        case 4: setSaveFile((*reinterpret_cast< QString*(*)>(_a[1]))); break;
        case 5: { QString* _r = getSaveFile();
            if (_a[0]) *reinterpret_cast< QString**>(_a[0]) = _r; }  break;
        case 6: setOpt((*reinterpret_cast< QString*(*)>(_a[1]))); break;
        case 7: { QString* _r = getOpt();
            if (_a[0]) *reinterpret_cast< QString**>(_a[0]) = _r; }  break;
        default: ;
        }
        _id -= 8;
    }
    return _id;
}
예제 #10
0
파일: Easy.cpp 프로젝트: Chronodt/curlpp
void
curlpp::Easy::setOpt(const OptionBase & option)
{
	setOpt(option.clone());    
}
예제 #11
0
bool Socket::setKeepAlive(bool flag /*= true*/)
{
    int optval = flag ? 1 : 0;
    return setOpt(SOL_SOCKET, SO_KEEPALIVE, (char *)&optval, sizeof(optval));
}
예제 #12
0
bool Socket::setReuseAddr(bool flag /*= true*/)
{
    int optval = flag ? 1 : 0;
    return setOpt(SOL_SOCKET, SO_REUSEADDR, (char *)&optval, sizeof(optval));
}
예제 #13
0
bool Socket::setNoDelay(bool flag /*= true*/)
{
    int optval = flag ? 1 : 0;
    return setOpt(IPPROTO_TCP, TCP_NODELAY, (char *)&optval, sizeof(optval));
}
예제 #14
0
void OptionList::setOpt(const curlpp::OptionBase & option)
{
   setOpt(option.clone());
}
예제 #15
0
void
cURLpp::Easy::setOpt(const cURLpp::OptionBase &option)
{
    setOpt(option.clone());    
}
예제 #16
0
   // PD_TRACE_DECLARE_FUNCTION ( SDB__NETEVNHND_SYNCCONN, "_netEventHandler::syncConnect" )
   INT32 _netEventHandler::syncConnect( const CHAR *hostName,
                                        const CHAR *serviceName )
   {
      SDB_ASSERT( NULL != hostName, "hostName should not be NULL" ) ;
      SDB_ASSERT( NULL != serviceName, "serviceName should not be NULL" ) ;

      INT32 rc = SDB_OK ;
      PD_TRACE_ENTRY ( SDB__NETEVNHND_SYNCCONN );

      if ( _isConnected )
      {
         close() ;
      }

/*
      try
      {

         boost::system::error_code ec ;
         tcp::resolver::query query ( tcp::v4(), hostName, serviceName ) ;
         tcp::resolver resolver ( _frame->ioservice() ) ;
         tcp::resolver::iterator itr = resolver.resolve ( query ) ;
         ip::tcp::endpoint endpoint = *itr ;
         _sock.open( tcp::v4()) ;

         _sock.connect( endpoint, ec ) ;
         if ( ec )
         {
            if ( boost::asio::error::would_block ==
                 ec )
            {
            rc = _complete( _sock.native() ) ;
            if ( SDB_OK != rc )
            {
               _sock.close() ;
               PD_LOG ( PDWARNING,
                  "Failed to connect to %s: %s: timeout",
                  hostName, serviceName ) ;
               goto error ;
            }
            }
            else
            {
               PD_LOG ( PDWARNING,
                  "Failed to connect to %s: %s: %s", hostName, serviceName,
                  ec.message().c_str()) ;
               rc = SDB_NET_CANNOT_CONNECT ;
               _sock.close() ;
               goto error ;
            }
         }
      }
      catch ( boost::system::system_error &e )
      {
         PD_LOG ( PDWARNING,
                  "Failed to connect to %s: %s: %s", hostName, serviceName,
                  e.what() ) ;
         rc = SDB_NET_CANNOT_CONNECT ;
         _sock.close() ;
         goto error ;
      }
*/
      UINT16 port = 0 ;
      rc = ossGetPort( serviceName, port ) ;
      if ( SDB_OK != rc )
      {
         PD_LOG( PDERROR, "failed to get port :%s", serviceName ) ;
         goto error ;
      }

      {
         _ossSocket sock( hostName, port ) ;
         rc = sock.initSocket() ;
         if ( SDB_OK != rc )
         {
            PD_LOG( PDERROR, "failed to init socket:%d", rc ) ;
            goto error ;
         }
         sock.closeWhenDestruct( FALSE ) ;
         rc = sock.connect() ;
         if ( SDB_OK != rc )
         {
            PD_LOG( PDERROR, "failed to connect remote[%s:%s], rc:%d",
                    hostName, serviceName, rc ) ;
            goto error ;
         }

         try
         {
            _sock.assign( tcp::v4(), sock.native() ) ; 
         }
         catch ( std::exception &e )
         {
            PD_LOG( PDERROR, "unexpected err happened:%s", e.what() ) ;
            rc = SDB_SYS ;
            sock.close() ;
            _sock.close() ;
            goto error ;
         }
      }

      setOpt() ;
   done:
      PD_TRACE_EXITRC ( SDB__NETEVNHND_SYNCCONN, rc );
      return rc ;
   error:
      goto done ;
   }
예제 #17
0
/**
 * Make sure that our options are sane. Call Err::errAbort if not.
 */
void DmetEngine::checkOptionsImp() {

    defineStates();

    setLibFileOpt("cdf-file");
    setLibFileOpt("spf-file");
    setLibFileOpt("special-snps");
    setLibFileOpt("chrX-probes");
    setLibFileOpt("chrY-probes");
    setLibFileOpt("reference-input");
    setLibFileOpt("probeset-ids");
    setLibFileOpt("probeset-ids-reported");
    setLibFileOpt("region-model");
    setLibFileOpt("probeset-model");
	setLibFileOpt("cn-region-gt-probeset-file");

    if (getOpt("out-dir") == "") {Err::errAbort("Must specify an output directory.");}
    if (getOpt("temp-dir") == "") { 
      setOpt("temp-dir", Fs::join(getOpt("out-dir"),"temp"));
    }

    string cdfFile = getOpt("cdf-file");
    string spfFile = getOpt("spf-file");
    string specialSnps = getOpt("special-snps");
    string chrXProbes = getOpt("chrX-probes");
    string chrYProbes = getOpt("chrY-probes");

	if(getOpt("sample-type") == "plasmid") { 
		setOpt("run-cn-engine","false"); 
	} else { 
		setOpt("run-cn-engine",getOpt("run-cn-engine"));
	}

    string refOut = getOpt("reference-output");
	string batchName = getOpt("batch-name");
    if(refOut == "") {
		if (batchName.empty() != true)
			Err::errAbort("You cannot provide a batch-name when running in single sample mode. batch-name is only valid when output-reference is specified.");
    } else {
		if (batchName.empty() == true)
			Err::errAbort("You must define the batch-name parameter");
        if(Fs::isReadable(refOut))
            if(Fs::rm(refOut, false) != APT_OK)
                Err::errAbort("Unable to remove existing reference-output file '" + refOut + "'");
	}

    ///@todo check chip type in reference file
    ///@todo check reference file version

    /* Read in cel file list from other file if specified. */
    vector<string> celFiles;
    EngineUtil::getCelFiles(celFiles, this);
    if(celFiles.size() == 0)
        Err::errAbort("No cel files specified.");
    setOpt("cels",celFiles);

    // Build a consent file if vector of markers was passed in
    vector<string> consented = getOptVector("report");
    if(consented.size() > 0) {
      FsPath probeset_path;
      probeset_path.setPath(getOpt("out-dir"),"probesets-reported","txt");
      //probeset_path.ensureWriteableDirPath();
	  Fs::ensureWriteableDirPath(getOpt("out-dir", false));
      writeProbesetList(probeset_path.asUnixPath(), consented);
      setOpt("probeset-ids-reported", probeset_path.asUnixPath());
    } else {
      setOpt("probeset-ids-reported", getOpt("probeset-ids-reported"));
    }

    if(cdfFile == "" && spfFile == "")
        Err::errAbort("Must specify either a cdf file or spf (simple probe format) file.");
    if (chrXProbes != "" && chrYProbes == "")
        Err::errAbort("Must provide a chrY Probe File when providing a chrX Probe File.");
    if (chrXProbes == "" && chrYProbes != "")
        Err::errAbort("Must provide a chrX Probe File when providing a chrY Probe File.");

    // Check chip types
    vector<string> chipTypesInLayout;

    /* Get the intial info about the chip and check cel files to make sure
       they match. */
    colrow_t numRows = 0, numCols = 0;
    int probeCount=0, probeSetCount=0;

    if(cdfFile != "")
        EngineUtil::getCdfChipType(chipTypesInLayout, numRows, numCols, probeCount, probeSetCount, cdfFile);
    else if(spfFile != "")
        EngineUtil::getSpfChipType(chipTypesInLayout, numRows, numCols, probeCount, probeSetCount, spfFile);
    else
        Err::errAbort("Must specify either a cdf file or spf (simple probe format) file.");

    setOpt("num-rows", ToStr(numRows));
    setOpt("num-cols", ToStr(numCols));
    setOpt("probe-count", ToStr(probeCount));

    if(chipTypesInLayout.empty() || chipTypesInLayout[0] == "" || probeCount == 0) 
        Err::errAbort("Problem determining ChipType in file: " + 
              ( cdfFile != "" ? cdfFile : spfFile));

    /* Did the user "force" a set of chip types via options? */
    vector<string> chipTypesSupplied = getOptVector("chip-type");

    /* Figure out what chip type to report */
    if(chipTypesSupplied.size() > 0) {
        setOpt("chip-type", chipTypesSupplied);
    } else if(chipTypesInLayout.size() > 0) {
        setOpt("chip-type", chipTypesInLayout);
    } else {
        Err::errAbort("Unable to figure out a chip type.");
    }

    /* Do Chip Type Check */
    if(!getOptBool("force")) {
        vector<string> chipTypeJustPrimary;
        vector<string> chipTypesToCheck;

        if(chipTypesSupplied.size() > 0) {
            chipTypesToCheck = chipTypesSupplied;
            EngineUtil::checkChipTypeVectors(chipTypesSupplied, chipTypesInLayout);
        } else {
            chipTypesToCheck = chipTypesInLayout;
        }

        chipTypeJustPrimary.push_back(chipTypesToCheck[0]);
        EngineUtil::checkCelChipTypes(chipTypesToCheck, probeCount, celFiles, numRows, numCols);

        // Check special SNPs files
        if (specialSnps != "") {
            EngineUtil::checkTsvFileChipType(specialSnps, chipTypeJustPrimary);
        }
        
        // And other files
        if (chrXProbes != "") {
            EngineUtil::checkTsvFileChipType(chrXProbes, chipTypesToCheck);
        }
        if (chrYProbes != "") {
            EngineUtil::checkTsvFileChipType(chrYProbes, chipTypesToCheck);
        }
    } // end if(!force)
}