convert fq to fa
554092
def fq2fa(fq):
    
    c = cycle([1, 2, 3, 4])
    for line in fq:
        n = next(c)
        if n == 1:
            seq = ['>%s' % (line.strip().split('@', 1)[1])]
        if n == 2:
            seq.append(line.strip())
            yield seq
1124227
def ask_float(msg="Enter a float", dft=None, vld=None, hlp=None):
    """"""
    vld = vld or [float]
    return ask(msg, dft=dft, vld=vld, fmt=partial(cast, typ=float), hlp=hlp)
574342
def _convert_fastq(srafn, outdir, single=False):
    ""
    cmd = "fastq-dump --split-files --gzip {srafn}"
    cmd = "%s %s" % (utils.local_path_export(), cmd)
    sraid = os.path.basename(utils.splitext_plus(srafn)[0])
    if not srafn:
        return None
    if not single:
        out_file = [os.path.join(outdir, "%s_1.fastq.gz" % sraid),
                    os.path.join(outdir, "%s_2.fastq.gz" % sraid)]
        if not utils.file_exists(out_file[0]):
            with utils.chdir(outdir):
                do.run(cmd.format(**locals()), "Covert to fastq %s" % sraid)
        if not utils.file_exists(out_file[0]):
            raise IOError("SRA %s didn't convert, something happened." % srafn)
        return [out for out in out_file if utils.file_exists(out)]
    else:
        raise ValueError("Not supported single-end sra samples for now.")
669373
def _get_fqn(cls, path):
        
        name_list = [path.stem]
        current_path = path
        # move to parent path until parent path is a python package
        while cls.is_pkg(current_path.parent):
            name_list.append(current_path.parent.name)
            current_path = current_path.parent
        return list(reversed(name_list))
553128
function _CreateSuffix($fname, &$ftype, $fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
	{
		if ($fautoinc) {
			$ftype = 'COUNTER';
			return '';
		}
		if (substr($ftype,0,7) == 'DECIMAL') $ftype = 'DECIMAL';
		$suffix = '';
		if (strlen($fdefault)) {
			//$suffix .= " DEFAULT $fdefault";
			if ($this->debug) ADOConnection::outp("Warning: Access does not supported DEFAULT values (field $fname)");
		}
		if ($fnotnull) $suffix .= ' NOT NULL';
		if ($fconstraint) $suffix .= ' '.$fconstraint;
		return $suffix;
	}
163377
private List<Token> convertFactor(final Token.Factor factor) {
        
        final String item = factor.getValue();
        final int itemLength = item.length();
        final List<Token> list = new ArrayList<>();
        
        StringBuilder sb = new StringBuilder();
        for(int i=0; i < itemLength; i++) {
            char c = item.charAt(i);
            if(c == '@') {
                // バッファから取り出し、新たにバッファを作成する
                list.add(Token.factor(sb.toString()));
                sb = new StringBuilder();
                
                list.add(Token.SYMBOL_AT_MARK);
                
            } else {
                sb.append(c);
            }
        }
        
        if(sb.length() > 0) {
            list.add(Token.factor(sb.toString()));
            sb = null;
        }
        
        return list;
    }
745625
def open_fastq(in_file):
    
    _, ext = os.path.splitext(in_file)
    if ext == ".gz":
        return gzip.open(in_file, 'rb')
    if ext in [".fastq", ".fq", ".fasta", ".fa"]:
        return open(in_file, 'r')
    return ValueError("File needs to be fastq|fasta|fq|fa [.gz]")
1223409
void cfftf(double a[], int offa, int isign) {
		int idot;
		int l1, l2;
		int na, nf, ip, iw, ido, idl1;
		final int twon = 2 * n;

		int iw1, iw2;
		double[] ch = ch2;

		iw1 = twon;
		iw2 = 4 * n;
		nac[0] = 0;
		nf = (int) wtable[1 + iw2];
		na = 0;
		l1 = 1;
		iw = iw1;
		for (int k1 = 2; k1 <= nf + 1; k1++) {
			ip = (int) wtable[k1 + iw2];
			l2 = ip * l1;
			ido = n / l2;
			idot = ido + ido;
			idl1 = idot * l1;
			switch (ip) {
				case 4:
					if (na == 0) {
						passf4(idot, l1, a, offa, ch, 0, iw, isign);
					} else {
						passf4(idot, l1, ch, 0, a, offa, iw, isign);
					}
					na = 1 - na;
					break;
				case 2:
					if (na == 0) {
						passf2(idot, l1, a, offa, ch, 0, iw, isign);
					} else {
						passf2(idot, l1, ch, 0, a, offa, iw, isign);
					}
					na = 1 - na;
					break;
				case 3:
					if (na == 0) {
						passf3(idot, l1, a, offa, ch, 0, iw, isign);
					} else {
						passf3(idot, l1, ch, 0, a, offa, iw, isign);
					}
					na = 1 - na;
					break;
				case 5:
					if (na == 0) {
						passf5(idot, l1, a, offa, ch, 0, iw, isign);
					} else {
						passf5(idot, l1, ch, 0, a, offa, iw, isign);
					}
					na = 1 - na;
					break;
				default:
					if (na == 0) {
						passfg(nac, idot, ip, l1, idl1, a, offa, ch, 0, iw, isign);
					} else {
						passfg(nac, idot, ip, l1, idl1, ch, 0, a, offa, iw, isign);
					}
					if (nac[0] != 0)
						na = 1 - na;
					break;
			}
			l1 = l2;
			iw += (ip - 1) * idot;
		}
		if (na == 0)
			return;
		System.arraycopy(ch, 0, a, offa, twon);

	}
491283
def fastq(self):
        '''
        
        '''
        if self.qual is None:
            self._fastq = None
        else:
            if self._fastq is None:
                self._fastq = '@{}\n{}\n+\n{}'.format(self.id, self.sequence, self.qual)
        return self._fastq
1247713
public static FA create(FA fa, int errorSi) {
        FA cfa; // result
        int[] sorted;
        int si;
        int idx;
        int faSize;
        State faState;
        State cfaState;
        int nextChar;
        int width;
        Range range;
        int nextSi;

        faSize = fa.size();
        cfa = new FA();
        for (si = 0; si < faSize; si++) {
            faState = fa.get(si);
            if (cfa.add(faState.getLabel()) != si) {
                throw new RuntimeException();
            }
            cfaState = cfa.get(si);
            if (fa.getStart() == si) {
                cfa.setStart(si);
            }
            if (fa.isEnd(si)) {
                cfa.setEnd(si);
            }

            sorted = faState.sortRanges();
            nextChar = 0;
            for (idx = 0; idx < sorted.length; idx += width) {
                width = countConsecutive(faState, sorted, idx);
                range = firstToLast(faState, sorted, idx, width);
                nextSi = faState.getEnd(sorted[idx]);
                if (nextChar < range.getFirst()) {
                    cfaState.add(errorSi, new Range((char) nextChar, (char) (range.getFirst() - 1)));
                }
                cfaState.add(faState.getEnd(sorted[idx]), range);
                nextChar = range.getLast() + 1;
            }
            if (nextChar <= Character.MAX_VALUE) {
                cfaState.add(errorSi, new Range((char) nextChar, Character.MAX_VALUE));
            }
        }

        return cfa;
    }
317180
def fasta(args):
    
    p = OptionParser(fasta.__doc__)
    p.add_option("--seqtk", default=False, action="store_true",
                 help="Use seqtk to convert")
    p.set_outdir()
    p.set_outfile(outfile=None)
    opts, args = p.parse_args(args)

    if len(args) < 1:
        sys.exit(not p.print_help())

    fastqfiles = args
    outdir = opts.outdir
    if outdir and outdir != ".":
        mkdir(outdir)

    fastqfile = fastqfiles[0]
    pf = op.basename(fastqfile)
    gzinput = pf.endswith(".gz")
    if gzinput:
        pf = pf.rsplit(".", 1)[0]

    pf, sf = pf.rsplit(".", 1)
    if sf not in ("fq", "fastq"):
        logging.debug("Assumed FASTA: suffix not `fq` or `fastq`")
        return fastqfile, None

    fastafile, qualfile = pf + ".fasta", pf + ".qual"
    outfile = opts.outfile or fastafile
    outfile = op.join(outdir, outfile)
    if opts.seqtk:
        if need_update(fastqfiles, outfile):
            for i, fastqfile in enumerate(fastqfiles):
                cmd = "seqtk seq -A {0} -L 30 -l 70".format(fastqfile)
                # First one creates file, following ones append to it
                sh(cmd, outfile=outfile, append=i)
        else:
            logging.debug("Outfile `{0}` already exists.".format(outfile))
        return outfile, None

    for fastqfile in fastqfiles:
        SeqIO.convert(fastqfile, "fastq", fastafile, "fasta")
        SeqIO.convert(fastqfile, "fastq", qualfile, "qual")

    return fastafile, qualfile
114851
def _f90complex(self, value):
        """"""
        return '({0:{fmt}}, {1:{fmt}})'.format(value.real, value.imag,
                                               fmt=self.float_format)
139154
def finalize_options(self):
        """"""
        assert bool(self.fa_version), 'FA version is mandatory for this command.'
        if self.zip_path:
            assert os.path.exists(self.zip_path), (
                'Local zipfile does not exist: %s' % self.zip_path)
303355
def convert_sub(sub):
    """"""

    args = sub.args
    (ref_aa, pos, new_aa) = args

    parent_fn_name = sub.parent_function.name_short
    prefix_list = {"p": "p.", "r": "r.", "g": "c."}
    prefix = prefix_list[parent_fn_name]

    new_var_arg = f'"{prefix}{spec["namespaces"]["AminoAcid"]["to_short"][ref_aa.value]}{pos.value}{spec["namespaces"]["AminoAcid"]["to_short"][new_aa.value]}"'

    new_var = bel.lang.ast.Function("var", bo.spec)

    new_var.add_argument(StrArg(new_var_arg, new_var))

    return new_var
1341887
def parse_away_fo(self):
        
        try:
            self.__set_fo_tables()
            self.face_offs['away'] = self.__parse_fo_table(self.__away_fo)
            return self
        except:
            return None
550078
def _get_fba_problem(model, tfba, solver):
    """"""
    p = FluxBalanceProblem(model, solver)
    if tfba:
        p.add_thermodynamic()
    return p
957578
@Override
    public Integer convertMQFeedbackToJS(int fb) {
        Integer result;
        switch (fb) {
            case ApiJmsConstants.MQFB_COA:
                result = SIApiConstants.REPORT_COA;
                break;
            case ApiJmsConstants.MQFB_COD:
                result = SIApiConstants.REPORT_COD;
                break;
            case ApiJmsConstants.MQFB_EXPIRATION:
                result = SIApiConstants.REPORT_EXPIRY;
                break;
            case ApiJmsConstants.MQFB_PAN:
                result = SIApiConstants.REPORT_PAN;
                break;
            case ApiJmsConstants.MQFB_NAN:
                result = SIApiConstants.REPORT_NAN;
                break;
            default:
                result = Integer.valueOf(fb); // all other values are passed unchanged.
        }
        return result;
    }